Getting LanguageServer and autocompletion up and running with oF/nvim/linux

Hi all,

Returning to oF after a long break…

Has anybody been able to get something like ccls up and running in a meaningful way with openFrameworks on linux and (neo)vim? It seems the generic c++ stuff should be fine, but when I run it in nvim I am getting an awful lot of ccls: 'ofMain.h' file not found type of errors, which is obviously not very helpful.

Additionally, I would love to get my autocompletion working within openFrameworks. I was able to do something like this with gutentags back in the days, by creating a .gutentags file in the openFrameworks root directory, but it generated a loooot of noise and included all my past typos as well, so not a great way to handle this. I would basically like to expose all the oF classes to my completion engine (deoplete in nvim).

OK, replying to myself here: a key component in the process is to generate a compile_commands.json file at the root of my app (NOT the oF root) using a tool like compiledb -n make, which is available through pip or AUR in Arch Linux world. I’m still getting ofMain.h file not found, but I am now able to get the documentation up as a floating window when I hit K. Nice! Will keep filling into this thread as I figure out more stuff, as well as adding to my previous blog post with new info about language server and deoplete…

Thanks for the tip, @kflak1 ! I too am trying to set up openframeworks with LSP. The only difference is I’m doing it with Emacs and clangd – but I’ve heard awesome things about neovim and ccls too. After generating the compile_commands.json file I’m able to get auto-completion, go-to-definition etc, which is exactly what I needed. You saved the day with the “compiledb” tip!

Awesome blog, btw.

Thanks, @ianyepan! Lots of things have happened since that blog post, all kinds of interesting things in the world of neovim/lsp/autocompletion, all of it written in lua. One of these days I should really get my sh*t together and write an update to that blog post.

Oh, and if it’s possible to get treesitter syntax highlighting working in emacs, do yourself a favor and use it! It’s amazing on so many levels: intelligent highlighting, smart rename of variables, all kinds of goodies for the discerning terminal person.

+1 for the power of treesitter – I still remember the day I discovered the Emacs package for it! I’m only using treesitter for richer syntax highlighting though. All other intelligent actions I’m relying on clangd LSP. What are you using treesitter for, besides, syntax highlighting, that LSP can’t achieve?

Feels like I’m just getting started with treesitter, there’s just a lot more to discover there. My latest discovery is smart rename: selecting a variable, hitting grr, giving it a new name in the command line editor and see it change everywhere in the file. In nvim this depends on the nvim-treesitter-refactor plugin. There are also all kinds of tricks for looking up methods and classes, getting an overview of the hierarchies and so on that I haven’t yet gotten around to checking out.

Gotcha. I’ve been using LSP for intelligent renaming purposes. Seems to me that LSP and treesitter have quite some overlaps in functionality.

So it seems. tbh both of these are a bit of a jungle…