I don't succeed to use cquery (kak-lsp)

I added those line in kakrc:

plug "ul/kak-lsp" do %{
         cargo build --release --locked
         cargo install --force --path .
} config %{
eval %sh{kak-lsp --kakoune -s $kak_session}

Put .query file where I open kakoune:
%c -std=gnu11
%cpp -std=gnu++14
# Includes
# -I space_is_not_allowed

I open kakoune with kak command in root directory of a cpp github project cloned. The same place where is the .cquery.
I can see all the commands of lsp. But It seems it is not connected to cquery or cquery is not well running.
I tried lsp-capabilities or other commands and nothing seems append.

I also try to start cquery with the sh script here to be sure it is started:

But I got the same as above.

Could someone advice me how to make cquery working with kakoune ? I saw that everybody is using it here.


Hi, plug.kak author here.
Here’s my config for Cquery and RLS (Rust)

plug "ul/kak-lsp" do %{
    cargo build --release --locked
    cargo install --force --path .
} config %{
    define-command lsp-restart %{ lsp-stop; lsp-start }
    set-option global lsp_completion_trigger "execute-keys 'h<a-h><a-k>\S[^\h\n,=;*(){}\[\]]\z<ret>'"
    set-option global lsp_diagnostic_line_error_sign "!"
    set-option global lsp_diagnostic_line_warning_sign "?"
    hook global WinSetOption filetype=(c|cpp|rust) %{
        map window user "l" ": enter-user-mode lsp<ret>" -docstring "LSP mode"
        set-option window lsp_hover_anchor true
        set-face window DiagnosticError default+u
        set-face window DiagnosticWarning default+u
    hook global WinSetOption filetype=rust %{
        set-option window lsp_server_configuration rust.clippy_preference="on"
    hook global KakEnd .* lsp-exit

You don’t need to use:

In your config file. Just call lsp-enable-window in config (see my config).

You also need to set up kak-lsp.toml like so:

verbosity = 2

timeout = 1800 # seconds = 30 minutes

filetypes = ["c", "cpp"]
roots = [".cquery", "compile_commands.json"]
command = "cquery"
args = ["--log-file=/tmp/cq.log", "--init={\"cacheDirectory\": \"/home/andreyorst/.cache/cquery\"}"]

This file should be located at ~/.config/kak-lsp/kak-lsp.toml

1 Like

Thanks Andreyorst
I did all.
Copy ~/.config/kak/plugin/kak-lsp.toml in ~/.config/kak-lsp/
I do the modifications as you. Just replace /home/andreyorst/ with mine.
In kak, I can see the menu with ‘user + l’
But no more event.
What should I see if I select capabilities ?
Also if I do ‘top’ in a terminal, I don’t see cquery. I was expecting that it is launched by the kak-lsp plugin ?

I’m under MANJARO
cquery is located here (installed with pacman) /usr/bin/


I’m under MANJARO

I’m on Arch Linux.

Everything else is the same as you’ve described. Does launching cquery from command line starts cquery without errors?

What should I see if I select capabilities ?


I got that (there is .cquery on the same place)
$ cquery
Content-Length: 152


If I select capabilities, I have not this next menu.

ok, it seems tha cquery itself is working fine.

Let’s narrow the search further. Here are some questions:

  1. Are you sure that kak-lsp binary is in $PATH?
    • Launching kak-lsp from shell provides any errors?
  2. Are there any errors in *debug* buffer?

Thanks a lot Andreyorst
I needed to do a symbolic link like so in /usr/local/bin

sudo ln -sf ~/.config/kak/plugins/kak-lsp/target/release/kak-lsp kak-lsp

Now, I can see the interaction with kak-lsp in kakoune.

I believed it was not necessary by reading “You can replace cargo install …” and it was done automatically by the command “cargo iinstall --force --path .” ?

Now, I can see in debug
Config-change detected:
kak-lsp: c_cpp language server error: ‘/home/xxxxxxxx/21st-century-pong/src/ball.cpp is being indexed.’
Does it mean that there is something wrong ?

Thanks again and Regards

No, this is usual behavior.

I suppose that you’ve installed kak-lsp by manually cloning the repo, and then added the plug.kak config for it. That’s not the proper way how to install plugins with plug.kak. Because if you install it via plug-install it will run post-install hooks, which are compilation and installation (if specified). So there’s no need to place a symbolic link in your /usr/local/bin, instead, you should check where cargo installs kak-lsp and add this folder to $PATH.

My recommendation would be: do :plug-list, move cursor to kak-lsp plugin in the list and press D – this will delete plugin. Next press I or Return – this will install kak-lsp and post install hooks will be executed. Wait until it is compiled and installed (you’ll see the done message), and press L. Installation log will be opened. At the bottom you’ll see where cargo had installed kak-lsp. Add this path to your $PATH.

I followed your recommendations and it is working as well.
I ‘unlink’ the symbolic link before and add the PATH "~/.cargo/bin/kak-lsp " that I saw in the log as advised. Maybe it can be added in the wiki of kak-lsp ?.

Now, I will need to improve the database with compile_commands.json instead of ‘.cquery’.
Thanks for your help Andreyorst.
The update of the plug.kak is very nice and useful.


1 Like

great. Now when kak-lsp gets an update you’ll be able to see it with :plug-list and after successful update it will be recompilated for you

Thanks, it’s greater with plug.kak
At the moment, could we have highlight tags and call-hierarchy with kak-lsp ?
I saw that tagbar is giving a lot of information too.

At the moment, could we have highlight tags and call-hierarchy with kak-lsp ?

I guess it’s a question to kak-lsp author. @ulis?

Also, cquery project is kinda dead. I’ve switched to clangd, and it’s awesome

Are you using clangd instead of cquery for c++ with Kakoune ?

yes I do

cquery is dead indeed, but the ccls fork seems to be going strong

for some reason it didn’t work for me. Server was initialized, lsp capabilities were fine, but neither completions nor diagnostics worked. Perhaps some compatibility issue with kak-lsp. clangd worked ootb like a charm on the other hand.

The only downside of clangd I’ve noticed so far is that it doesn’t display define value on hover. Not sure why they decided not to do that, cquery showed it just fine. That’s also the case for ctags, it doesn’t store define value in tags file for some reason, perhaps because of multi-line macros, but still is strange design choice to me to ignore them all the way

Right, so, I switched to clangd too in kak-lsp.toml and you are right it is working better.
Even the missing “highlight” is working.
Do you think rtags could be better (with call hierarchy) and should be used with kakoune for c++ ?

At the moment, could we have highlight tags and call-hierarchy with kak-lsp ?

I think LSP protocol doesn’t support call hierarchy atm, but you can search for references with lsp-references. Highlighting usages should work with lsp-highlight-references (and you also can do set buffer lsp_auto_highlight_references true) if the language server supports them.

I have problem with cquery as well. As this thread is first to pop-up in search engines I thought it will be good to keep all solutions in one place. If it’s better to create new thread, let me know.

I have everything configured as you adwised ( my configs: https://github.com/siriKeeton/kakrc ), both kak-lsp and cquery are in $PATH.
Running cquery outputs:

Content-Length: 152

And kak debug buffer contains only:

*** This is the debug buffer, where debug info will be written ***
Config-change detected:

Calling lsp-capabilities does not output anything at all.
I don’t know what to do next.

Thanks in advance

There are some good hints on how to start with kak-lsp debugging in this post: [SOLVED] Help needed setting texlab up - Latex Language Server Protocol