Show HN: Yet another Sublime Text plugin for C++ completion
github.comHello HN, I couldn't find any plugin for Sublime Text that would autocomplete C++ code and would be easy to setup, so I have written one. It is not fully polished, but works for me and a bunch of people, so I thought it was a good idea to expose it here.
The reason I post it here is two-fold.
First, I wrote it to make it useful, so I wanted to test it in real world,
Second, I tried to use libclang for autocompletion, but it works only for Linux currently. OSX and Windows for now resort to parsing the output from `clang -code-complete-at` command envoked in a subprocess. I would really love to make the plugin use libclang everywhere. So I would really like to get some help from people who are more familiar with OSX or Windows than I am and to generally spawn discussions on design desicions taken by me in this plugin.
Hope you guys like it. I am open to discussions and to your suggestions!
I very much want something like this. I'm skeptical as to how useful it will be on large projects. Every project I've ever worked in Visual Studio intelligence has eventually died. I have no hope this would work. But oh how I wish it to be true! :)
I wonder if a Sublime plugin could piggyback Visual Studio generated data. I believe VS now has the ability to compile via clang. Could you let VS manage all compilation and projects and dependencies? Use PDBs or some such to generate sublime intellisense? I've no idea. But something along those lines seems like it would be most likely to work.
We've got some pretty hairy legacy C++ and all versions of VS prior to 2015 fell over it. 2015 handles it just fine, it's worth trying again.
Regardless, clang just uses the headers - at least that's the story with clang-autocomplete. It seems to parse them much faster than VS does, so reusing the VS cache me might cause perf impediments.
I can confirm that clang just uses headers, no linking involved. No project either. Only the headers you include in your file. So it should not compile a lot unless you have a file that includes the whole project, which is probably not the case.
I'm currently on a unity project but I'm sure at some point I'll work with UE4. I very much look forward to seeing how it performs.
Please let me know when you know more. I am also interested.
It is hard for me to compare. Last time I opened Visual Studio was like 5 years ago. This plugin would actually not try to compete with VS, as this thing is a monster and this plugin is a hobby project. :)
Originally I wanted to have some lightweight autocompletion for Linux and have added Windows and OSX support because people were trying to use it.
What you say about using VS to manage all compilation and project dependencies sounds really nice and logical, but unfortunately I have no knowledge whatsoever about how VS does this, so I'm not sure I can do this alone. However, I would love to discuss it should anyone have any nice ideas.
I definitely intend to give your plugin s shot. My fear is that C++ is to hairy fora hobby project. But my fingers are crossed!
Yes, do it! Shoot me an issue should something go wrong! :) I hope with the help of clang this will be manageable :)
There's also SublimeClang for SublimeText2. The most active fork as of late is https://github.com/ensisoft/SublimeClang
There is a bunch of plugins that do essentially the same, but are all subtly different. the one you reference uses python bindings, but only works for Linux.
I will do a brief list of all that I know of: https://github.com/quarnster/SublimeClang - discontinued
This one is pretty close to what I want: https://github.com/lvzixun/Clang-Complete It uses libclang and should work on all systems. It didn't work properly for me under Linux, but feel free to use it if it does.
There is also a plugin https://github.com/griebd/clangHelper which shares the purpose with what I have written, but was never updated after the initial commit, which is a pity. I probably wouldn't have written mine if it would be alive.
Then there are https://github.com/LuckyGeck/YcmdCompletion, https://github.com/glymehrvrd/CppYCM and https://github.com/ivankoster/SublimeYouCompleteMe that use ycmd server to complete code. Ycmd is well-known to those who are vim users under the name YouCompleteMe. Unfortunately all these plugins are not fully in line with Ycmd server developments, e.g. the HMAC auth often mismatch and sometimes there is even no setting for that. These all are really great! And I do like the server-client architecture of this, but I could not make any of these work reliably for me. Believe me, I have tried. Also, again, it is harder for the user to separately setup a server and then register a client to it with multiple settings. Also there is a need for a .ycm_extra_conf.py file that has non-trivial syntax (as a python file)
And then there is https://github.com/pl-ca/ClangAutoComplete which is a really nice plugin and I started off my forking it. It uses only clang binary and is written in a simple, easy to grasp way, so it was perfect to hack around. However, I wanted to have a more modular structure and to make is unit tested and to use libclang when possible, so we have diverged.
Correct me if I did any wrong statement please and point me to the ones I may have forgotten.
Have you seen this for indexing ? https://github.com/Andersbakken/rtags
Yep, but I have unfortunately not managed to make it work for me. Also, I wanted to achieve really low-effort setup. I believe that my plugin, while maybe has less features is easier to setup. The user doesn't need to compile anything and generally can avoid opening a command line completely.
I would say these two plugins serve different purposes. rtags seems to be a machine that requires some setup and knowing what you want, but can do a whole lot of different things, while mine is simpler both in setup and architecture, but is of course less functional.
I've used rtags and it's very heavyweight because it strives to be correct. It literally runs a compilation every time.