Kakoune Language Server Protocol Client
kak-lsp is a Language Server Protocol client for Kakoune implemented in Rust.
Note
|
Version 5 is compatible with the latest breaking changes of Kakoune (as of 2018-07-11). If you haven’t upgraded Kakoune yet then you might want to use version 4 |
Installation
Pre-built binaries
MacOS
Homebrew
brew install ul/kak-lsp/kak-lsp
Manual
curl -O -L https://github.com/ul/kak-lsp/releases/download/v5.1.3/kak-lsp-v5.1.3-x86_64-apple-darwin.tar.gz tar xzvf kak-lsp-v5.1.3-x86_64-apple-darwin.tar.gz # replace `~/.local/bin/` with something on your `$PATH` mv kak-lsp ~/.local/bin/ mkdir -p ~/.config/kak-lsp mv kak-lsp.toml ~/.config/kak-lsp/
Linux
wget https://github.com/ul/kak-lsp/releases/download/v5.1.3/kak-lsp.x86_64-unknown-linux-musl.tar.gz tar xzvf kak-lsp.x86_64-unknown-linux-musl.tar.gz # replace `~/.local/bin/` with something on your `$PATH` mv kak-lsp ~/.local/bin/ mkdir -p ~/.config/kak-lsp mv kak-lsp.toml ~/.config/kak-lsp/
FreeBSD
wget https://github.com/ul/kak-lsp/releases/download/v5.1.3/kak-lsp-v5.1.3-x86_64-unknown-freebsd.tar.gz tar xzvf kak-lsp-v5.1.3-x86_64-unknown-freebsd.tar.gz # replace `~/.local/bin/` with something on your `$PATH` mv kak-lsp ~/.local/bin/ mkdir -p ~/.config/kak-lsp mv kak-lsp.toml ~/.config/kak-lsp/
From the source
Note
|
ArchLinux users can automate most of the following steps with the kak-lsp-git AUR package. |
git clone https://github.com/ul/kak-lsp cd kak-lsp cargo build --release # replace `~/.local/bin/` with something on your `$PATH` ln -s $PWD/target/release/kak-lsp ~/.local/bin/ mkdir -p ~/.config/kak-lsp # or just link if you are okay with default config cp kak-lsp.toml ~/.config/kak-lsp/
Language servers
kak-lsp doesn’t manage installation of language servers, please install them by yourself for the languages you plan to use kak-lsp with. Please consult the How to install servers wiki page for quick installation of language servers supported by kak-lsp out of the box.
Usage
To enable LSP support for configured languages (see the next section) just add following commands to
your kakrc
:
eval %sh{kak-lsp --kakoune -s $kak_session}
It adds:
-
completions
-
lsp-definition
command to go to definition, mapped togd
by default -
lsp-hover
command to show hover info; to automatically show hover when you move around uselsp-auto-hover-enable
; to show hover anchored to hovered position doset global lsp_hover_anchor true
-
lsp-references
command to find references for a symbol under the main cursor, mapped togr
by default -
lsp-document-symbol
command to list current buffer’s symbols -
lsp-diagnostics
command to list project-wide diagnostics (current buffer determines project and language to collect diagnostics) -
inline diagnostics highlighting using
DiagnosticError
andDiagnosticWarning
faces; could be disabled withlsp-inline-diagnostics-disable
command -
lsp-formatting
command to format current buffer -
starting new kak-lsp session when Kakoune session begins and stopping it when Kakoune session ends
Note
|
By default, kak-lsp exits when it doesn’t receive any request from Kakoune during 30 minutes,
even if Kakoune session is still up and running. Change server.timeout in kak-lsp.toml to tweak
duration, or set it to 0 to disable this behaviour. In any scenario making new request would lead to
attempt to spin up server if it is down.
|
To know which subset of kak-lsp commands is backed by current buffer filetype’s language server use
lsp-capabilities
command.
Configuration
kak-lsp is configured via configuration file in TOML format. By default kak-lsp tries to read $HOME/.config/kak-lsp/kak-lsp.toml
, but you can override it with command-line option --config
.
Look into the default kak-lsp.toml
in the root of repository, it should be quite self-descriptive.
If you are setting any options to server via cli do not forget to append them to
%sh{kak-lsp --kakoune …}
in your kakrc
. It’s not needed if you change options in
~/.config/kak-lsp/kak-lsp.toml
file.
Please let us know if you have any ideas about how to make default config more sensible.
Troubleshooting
If kak-lsp fails try to put this line in your kakrc
after kak-lsp --kakoune
invocation:
nop %sh{ (kak-lsp -s $kak_session -vvv ) > /tmp/kak-lsp.log 2>&1 < /dev/null & }
to explicitly start server and enable debug logging. If it will not give enough insights to fix the problem or if the problem is a bug in kak-lsp itself please don’t hesitate to raise an issue.
Note
|
Some Kakoune plugins could interfere with kak-lsp, particularly completions providers.
E.g. racer.kak competes for autocompletion in Rust files.
|
Versioning
kak-lsp follows SemVer with one notable difference from common practice: we don’t use 0 major version to indicate that product is not yet reached stability. Even for non-stable and not feature-complete product user should be clearly informed about breaking change. Therefore we start with major version 1 and increment it each time when upgrade requires user’s attention.