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

**URL:** <https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425>\
**Category:** Plugins\
**Tags:** lsp\
**Created:** [April 3, 2019, 1:37pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425 "2019-04-03T13:37:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 3, 2019, 1:37pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/1 "2019-04-03T13:37:21Z")

</div>

**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}
> lsp-enable
> }
> 
> ```

**Put .query file where I open kakoune:**  
_%clang_  
_%c -std=gnu11_  
_%cpp -std=gnu++14_  
_-pthread_  
_# Includes_  
_-I/work/cquery/third\_party_  
_-I/work/cquery/another\_third\_party_  
_# -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:

> **[Initialization options](https://github.com/jacobdufault/cquery/wiki/Initialization-options)**
>
> C/C++ language server supporting multi-million line code base, powered by libclang. Emacs, Vim, VSCode, and others with language server protocol support. Cross references, completion, diagnostics, ...

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.

Thanks  
Regards

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 3, 2019, 4:02pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/2 "2019-04-03T16:02:03Z")

</div>

Hi, [plug.kak](https://github.com/andreyorst/plug.kak) author here.  
Here’s my config for Cquery and RLS (Rust)

```auto
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"
        lsp-enable-window
        lsp-auto-hover-enable
        lsp-auto-hover-insert-mode-disable
        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:

> [@lauccode](#):
>
> ```auto
> eval %sh{kak-lsp --kakoune -s $kak_session}
> lsp-enable
> 
> ```

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:

```auto
verbosity = 2

[server]
timeout = 1800 # seconds = 30 minutes

[language.c_cpp]
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`

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 4, 2019, 12:52pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/3 "2019-04-04T12:52:03Z")

</div>

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/

Regards

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 4, 2019, 2:08pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/4 "2019-04-04T14:08:24Z")

</div>

> 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 ?

![image](https://discuss.kakoune.com/uploads/default/original/1X/1e740a4541c64686713f6f9d08760a55881af2ef.png)

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 4, 2019, 2:12pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/5 "2019-04-04T14:12:46Z")

</div>

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

{“jsonrpc”:“2.0”,“method”:"$cquery/progress",“params”:{“indexRequestCount”:0,“doIdMapCount”:0,“onIdMappedCount”:0,“onIndexedCount”:0,“activeThreads”:0}}

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

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 4, 2019, 3:46pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/6 "2019-04-04T15:46:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 4, 2019, 7:45pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/7 "2019-04-04T19:45:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 5, 2019, 12:19pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/8 "2019-04-05T12:19:08Z")

</div>

> [@lauccode](#):
>
> Does it mean that there is something wrong ?

No, this is usual behavior.

> [@lauccode](#):
>
> **I needed to do a symbolic link like so** in /usr/local/bin

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`.

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 6, 2019, 11:13am UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/9 "2019-04-06T11:13:46Z")

</div>

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.

Regards

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 6, 2019, 4:30pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/10 "2019-04-06T16:30:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 10, 2019, 11:30am UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/11 "2019-04-10T11:30:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 10, 2019, 1:56pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/12 "2019-04-10T13:56:58Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 10, 2019, 7:45pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/13 "2019-04-10T19:45:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 10, 2019, 8:00pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/14 "2019-04-10T20:00:05Z")

</div>

yes I do

---

<div class="post-metadata">

**Author:** ![occivink](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/occivink/32/27_2.png) [@occivink](https://discuss.kakoune.com/u/occivink)\
**Post date:** [April 11, 2019, 6:15am UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/15 "2019-04-11T06:15:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 11, 2019, 6:28am UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/16 "2019-04-11T06:28:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [April 11, 2019, 1:44pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/17 "2019-04-11T13:44:24Z")

</div>

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++ ?**  
Thanks

---

<div class="post-metadata">

**Author:** ![ulis](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ulis/32/620_2.png) [@ulis](https://discuss.kakoune.com/u/ulis)\
**Post date:** [April 19, 2019, 11:36pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/18 "2019-04-19T23:36:59Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![jjatczak](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/j/50afbb/32.png) [@jjatczak](https://discuss.kakoune.com/u/jjatczak)\
**Post date:** [January 23, 2020, 1:03pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/19 "2020-01-23T13:03:31Z")

</div>

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](https://github.com/siriKeeton/kakrc) ), both kak-lsp and cquery are in $PATH.  
Running cquery outputs:

```auto
Content-Length: 152
{"jsonrpc":"2.0","method":"$cquery/progress","params":{"indexRequestCount":0,"doIdMapCount":0,"onIdMappedCount":0,"onIndexedCount":0,"activeThreads":0}}

```

And kak debug buffer contains only:

```auto
***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

---

<div class="post-metadata">

**Author:** ![ulis](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/ulis/32/620_2.png) [@ulis](https://discuss.kakoune.com/u/ulis)\
**Post date:** [January 30, 2020, 9:15pm UTC](https://discuss.kakoune.com/t/i-dont-succeed-to-use-cquery-kak-lsp/425/20 "2020-01-30T21:15:49Z")

</div>

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](https://discuss.kakoune.com/t/solved-help-needed-setting-texlab-up-latex-language-server-protocol/866/6)
