I’m new to kakoune and so far I really like it. The configuration is much smaller than in other terminal based editors. Still, I have some difficulties with setup LSP’s. I want to use python and ansible with their corresponding LSP’s. I read through the documentation but didn’t find sense in it.
That’s a “me” problem in general, I don’t want to say the documentation is bad or so. I just did not get the hang of it.
So I’m asking here for help and I hope I got some. Please be patience with me, I will give my best to understand anything you would say.
Info
I installed kakoune new and deleted the configuration file to start from 0.
Firstly, I will thank you for taking time to help, really appreciate this!
Not really, I know that POSIX standard exist but never used it, at least
never consciously. But why did you ask?
My set-up way:
I installed kakoune via dnf successfully.
I also installed kak-lsp via pre-build binary. And I can execute it.
The ruff language server is installed in a virtual python environment.
So far so good, I guess, but in the next step where I should uncomment the [language_server.ruff] paragraph I stuck, because my file is empty.
So I looked around and found a setup for the helix editor in the ruff-lsp
repository here, which also uses a toml configuration style.
I also added the recommended lines to my kakrc file.
That’s my kakrc file:
eval %sh{kak-lsp --kakoune -s $kak_session}
hook global WinSetOption filetype=(rust|python|go|json|javascript|typescript) %{
lsp-enable-window
}
# mappings lsp
map global user l %{:enter-user-mode lsp<ret>} -docstring "LSP mode"
map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct'
map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors'
Because Kakoune being a relatively niche editor, and Kakoune-lsp being a plugin for said editor is a setup more accessible to people familiar with compiling, installing, and updating via Git under a typical file system hierarchy than by waiting OS package managers to take care of doing it, and most don’t event provide a framework to deploy config files, but anyway I digress…
Kakoune-lsp repo contains a default configuration for most of LSPs. So your kak-lsp.toml could be, I guess:
file_watch_support = false
snippet_support = true
verbosity = 2
[server]
# exit session if no requests were received during given period in seconds
# set to 0 to disable
timeout = 1800 # seconds = 30 minutes
[language_server.ruff]
filetypes = ["python"]
roots = ["requirements.txt", "setup.py", ".git", ".hg"]
command = "ruff-lsp"
settings_section = "_"
[language_server.ruff.settings._.globalSettings]
organizeImports = true
fixAll = true
given that ruff-lsp should be in your $PATH environment variable.
In case it’s not clear, you should have a file such as setup.py in your working directory (or a pyproject.toml as current practice goes).