Skip to content

How to install servers

Kratacoa edited this page Mar 1, 2024 · 71 revisions

This is a short reference for installation of language servers listed in default kak-lsp.toml configuration.

Rust

rustup component add rust-analyzer rust-src

crystalline

Clojure

To install, follow https://clojure-lsp.io/installation/, then add it to ~/.config/kak-lsp/kak-lsp.toml.

[language.clojure]
filetypes = ["clojure"]
roots = ["project.clj", "deps.edn", ".lsp/config.edn", ".git/"]
command = "clojure-lsp"

C, C++

See https://clangd.llvm.org/.

If you prefer ccls, change language.c_cpp section in kak-lsp to something like this:

[language.c_cpp]
filetypes = ["c", "cpp"]
roots = ["compile_commands.json", ".ccls", ".git"]
command = "ccls"
# Disable additional information in autocompletion menus that Kakoune inserts into the buffer until https://github.com/ul/kak-lsp/issues/40 gets fixed
args = ["--init={\"completion\":{\"detailedLabel\":false}}"]

and refer https://github.com/MaskRay/ccls/wiki for installing and configuring ccls itself.

kak-lspsupports nearly all ccls lsp extensions, including semantic highlighting, navigations, and special cross references. See the ccls-{navigate,vars,inheritance,member,call} kak functions for a reference. They are also described in the ccls wiki.

JavaScript

Refer to the TypeScript section.

JavaScript + Flow

npm install -g flow-bin

Typescript

with https://github.com/typescript-language-server/typescript-language-server

npm install -g typescript
npm install -g typescript-language-server
[language.typescript]
filetypes = ["typescript"]
roots = ["package.json"]
command = "typescript-language-server"
args = ["--stdio"]

Deno

Deno has official support for the LSP (from version 1.6.0). Just make sure deno command is available in PATH.

[language.typescript]
filetypes = ["typescript"]
roots = [".git"]
command = "deno"
args = ["lsp"]
[language.typescript.settings.deno]
enable = true
lint = true

Source

HTML, CSS, JSON

npm install -g vscode-{html,css,json}-languageserver-bin

The code is extracted from vscode itself and modules have the following dependencies hierarchy: binserverservice

HTML

CSS

JSON

OCaml, ReasonML

opam install ocaml-lsp-server

Haskell

language server: https://github.com/haskell/haskell-language-server#kakoune

ide engine: (deprecated) https://github.com/haskell/haskell-ide-engine#installation

Ruby

By default kak-lsp uses solargraph language server.

Installation

gem install solargraph

Configuration

~/.config/kak-lsp/kak-lsp.toml

[language.ruby]
filetypes = ["ruby"]
roots = ["Gemfile"]
command = "solargraph"
args = ["stdio"]

or alternatively, if solargraph needs to run in bundler:

[language.ruby]
filetypes = ["ruby"]
roots = ["Gemfile"]
command = "bundle"
args = ["exec", "solargraph", "stdio"]

If you prefer using ruby-lsp, install it with:

gem install ruby-lsp

and then use the following config in your kak-lsp.toml:

[language.ruby]
filetypes = ["ruby"]
roots = ["Gemfile"]
command = "ruby-lsp"
args = ["stdio"]

Python

Installation

pip install 'python-lsp-server[all]'

Recommended way to install is using virtualenv, available by default in python3.

python -m venv /path/to/virtualenv # use a real path in file system
# activate virtualenv for bash or zsh (for fish use activate.fish)
source /path/to/virtualenv/bin/activate # use a real path in file system
pip install 'python-lsp-server[all]'

Usually, virtualenv directories are stored under ~/.local/share/virtualenvs.

Configuration

If installation is done within virtualenv, add it to your SHELL env variable - $PATH.

Edit ~/.config/kak-lsp/kak-lsp.toml to add following configuration,

[language.python]
filetypes = ["python"]
roots = ["requirements.txt", "setup.py", ".git", ".hg"]
command = "pylsp"
offset_encoding = "utf-8"

Go

By default kak-lsp uses gopls language server.

See https://github.com/golang/tools/tree/master/gopls#installation for installation instructions.

If you want to use gopls for formatting on save, including adding/removing imports, use this (vscode-go does the same):

hook global BufWritePre .*[.]go %{
    try %{ lsp-code-action-sync '^Organize Imports$' }
    lsp-formatting-sync
}

If you prefer using go-langserver, install it with

go get -u github.com/sourcegraph/go-langserver

and then use the following config in your kak-lsp.toml:

[language.go]
filetypes = ["go"]
roots = ["Gopkg.toml", "go.mod", ".git", ".hg"]
command = "go-langserver"
args = ["-mode", "stdio", "-gocodecompletion"]

PHP (Intelephense)

Install the server component globally using npm:

npm i -g intelephense

Then in kak-lsp.toml add the following, where <path-to-intelephense> is the output of which intelephense:

[language.php]
filetypes = ["php"]
roots = ["composer.json"]
command = "node"
args = ["<path-to-intelephense>"]

PHP (PHP Language Server)

Install globally according to the installation instructions. For ArchLinux you may install through the AUR: https://aur.archlinux.org/packages/php-language-server/

Then in kak-lsp.toml add

[language.php]
filetypes = ["php"]
roots = ["composer.json"]
command = "php"
args = ["path/to/php-language-server.php"]

Where you change path/to/php-language-server.php to the path to the php-language-server.php file. You can use composer g show felixfbecker/language-server to get the path to the global installation, then append bin/php-language-server.php to get the path.

PHP (Psalm)

Install it to your project according to the installation instructions. Once installed, you can configure your kak-lsp.toml as follows:

[language.php]
filetypes = ["php"]
roots     = ["composer.json"]
command   = "php"
args      = ["vendor/bin/psalm-language-server"]

Despite not being an absolute path, this will still work as the context of execution of the php command is where your composer.json file is.

Bash

npm i -g bash-language-server

Dart

See https://github.com/natebosch/dart_language_server#installing

pub global activate dart_language_server

D

Install the D Language Server by running dub fetch dls, then dub run dls:bootstrap. The second command will print the location where dub installed the server. You will need to place this executable on your path, e.g. by making the path absolute (dub will likely print a relative path) and creating a symlink sudo ln -s <absolute path to dls> /usr/local/bin/dls.

Nim

nimble install nimlsp

[language.nim]
filetypes = ["nim"]
roots = ["*.nimble", ".git"]
command = "nimlsp"
args = ["path/to/nim/installation"] # optional (if installed from nimble or path wasn't provided at compiletime)

Elm

You may be able to install the elm-language-server with npm:

`npm install -g elm-language-server'

If this doesn't work, or to install the latest version of the elm-language-server, clone the repo and compile it:

git clone git@github.com:elm-tooling/elm-language-server.git
cd elm-language-server
npm install
npm run compile
npm link

Then, you should be able to run the language server with the following command:

elm-language-server --stdio

Installation of elm-test and elm-format is normally done with npm:

npm install -g elm-test
npm install -g elm-format

LaTeX

Install texlab from your distribution’s repo. If not available, follow texlab’s installation instructions.

YAML

npm install -g yaml-language-server

Svelte

npm install -g svelte-language-server
[language.svelte]
filetypes = ["svelte"]
roots = ["package.json"]
command = "svelteserver"
args = ["--stdio"]

Then make sure that you have svelte support in kakoune or set the filetypes = ["html"]

Zig

Server: zls, see also https://github.com/zigtools/zls/wiki/Installing-for-Kakoune

GDScript (Godot)

Requires netcat.

[language.gdscript]
filetypes = ["gd", "gdscript"]
roots = [".import"]
command = "nc"
args = ["localhost", "6008"]

Dhall

Server: dhall-lsp-server

[language.dhall]
filetypes = ["dhall"]
roots = []
command = "dhall-lsp-server"