Sublime Forum

Visual Studio-style function popups - possible?



I’m wondering if it’s possible to develop a simple function tooltip plugin for Sublime Text. Random example I pulled from the internet:

The reason I’m asking is because although Sublime indexes symbol definitions by file and location, it does not seem to store the definitions themselves. The standard goto definition/reference functionality and popups as defined in similarly work by generating links to the files from the locations, which are followed when the user executes the command. The plugin I am considering would (like VS) display the pop-ups as I type in the symbols; obviously, I wouldn’t want Sublime to rapidly open the file(s), get the definition(s) – keep in mind function overloading – and then close, as that sounds like it would be a terrible user experience.

Am I missing something? Any ideas on how I should proceed?

EDIT: One thing I should clear up, because it’s not obvious from the original post: I’m only interested in doing this using the definitions Sublime already generates by default.



Yes, you missed a plugin: LSP.



I want to be clear for others who may be visiting this thread: This kind of reply is not helpful, and I’m not sure why you thought it would be helpful, or whether you even intended to help. I know what LSP is, and if I wanted to use it, I would (actually, I would have gone for EasyClangComplete first, but anyway…).

My question is specifically about developing something using Sublime’s existing capabilities, without relying on LSP or compiler-generated flags.



i dont think so then. you can get index info by api but there is no signature.



You can’t expect Sublime to provide you with accurate signature help when it doesn’t know the compilation flags.



Overall your problem is kind of solved by LSP (and by EasyClangComplete if you want to go that route). If you want to go the LSP route, there’s instructions on how to get it working with clangd, LLVM’s language server:



Very well, thanks for your responses. One thing I should clear up, because it’s not obvious from the original post: I am not expecting Sublime to act as a compiler. Keep in mind, when I asked my question, I specifically mentioned the definitions generated by Sublime. So I am only interested in doing this for the definitions Sublime already generates for my own codebase, not necessarily for third party APIs.



It should be possible to do what you’re envisioning but I would reckon it’s a lot of work. Once the function is written out and the opening parenthesis is typed you would need to find information about all declarations. Because of how ST indexes its symbols, it doesn’t associate methods with class names. So you might end up with overloads that aren’t applicable. Or you might miss overloads, either due to incorrect parsing or particularly due to third-party libraries that aren’t indexed. All of this is only applicable to C/C++ as well, and only applicable to this editor.