Sublime Forum

Auto Suggestion / Auto Complete Sublime Text 3

#1

For my project I have multiple files having different structures across the files.

For example I have this structure in main.h file.

typedef struct 
{
	unsigned char uDevStat;
	unsigned char uCOM;
}DeviceInfo_t;

now in main file when I try to this structure I am not able to get these variables as auto suggestion.

which is best suitable package for the same? I have tried EasyClangComplete but that also not giving those variables as suggestion.

Regards,

0 Likes

#2

Sublime Text’s completions are based on statically defined JSON files (*.sublime-completions) or XML based snippets. Plugins can provide auto completions using the ST API.

Your best chance to get IntelliSense like auto-completions might be using the LSP which provides an interface for Microsoft’s LANGUAGE SERVER PROTOCOL. This package enables you to setup language servers like the clangd to help you with auto-completions based on your code.

But all the language-server stuff is still quite beta. Not sure whether it helps.

I use it with python with more or less luck.

1 Like

#3

I tried installing LSP package. But still same So I think the way I want looks not possible with Sublime.

0 Likes

#4

What syntax file are you using? Because the word “Serial” does not highlight in any special way for the standard C language shipped with Sublime. Also, that “!” exclamation mark should have a keyword.operator scope, so either your color scheme is not highlighting the keyword.operator scope, which I find unlikely because it looks like you’re using Monokai, or the syntax doesn’t supply that scope. You can see the syntax you’re using in the bottom-right corner of Sublime. It should say “C”.

Both the EasyClangComplete and LSP plugins need an external program/library to function. For EasyClangComplete, you’ll need either clang or libclang. For LSP, you’ll need clangd. All of this software is provided in LLVM. Since you’re using Windows, you can download an installer for version 7 from here. It should install various files in your C:\Program Files\LLVM folder. Once you did that, you should add C:\Program Files\LLVM\bin and C:\Program Files\LLVM\lib to your %PATH%, because otherwise neither EasyClangComplete nor LSP can find the executables/libraries living in C:\Program Files\LLVM\bin and C:\Program Files\LLVM\lib.

Finally, both plugins benefit from a compile_commands.json file that describes the compilation commands for each source file in your project. From the screenshot it looks like you’re using some sort of Arduino plugin. I do not know how that build system works, so I cannot help you further in that direction.

0 Likes

#5

Hi @rwols,
Thank you for detailed answer. About the questions you asked - I have installed Arduino Package from here:- Stino that is why may be that Serial is not highlight.

So my ultimate goal was when I type xDeviceInfo. then it should auto suggest me variables from that structure which are uCOM and uDevStat but that was not coming automatically in suggestion.

Just now I have downloaded LLVM, Installed and added both bin and lib to PATH. Restarted Sublime text 3 still it is not showing those two structure variable after I hit '.'

This is what it shows in package I installed.

Anything else I am still missing?

0 Likes