# load plugin eval %sh{kak-lsp} # mappings map global user l ': enter-user-mode lsp' -docstring 'LSP mode' map global insert ':try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks tab> }' -docstring 'Select next snippet placeholder' map global object a 'lsp-object' -docstring 'LSP any symbol' map global object 'lsp-object' -docstring 'LSP any symbol' map global object f 'lsp-object Function Method' -docstring 'LSP function or method' map global object t 'lsp-object Class Interface Struct' -docstring 'LSP class interface or struct' map global object d 'lsp-diagnostic-object --include-warnings' -docstring 'LSP errors and warnings' map global object D 'lsp-diagnostic-object' -docstring 'LSP errors' # override the code actions icon in the modeline define-command -hidden -override lsp-show-code-actions -params 1.. %{ set-option buffer lsp_modeline_code_actions "" } define-command -hidden -override lsp-hide-code-actions %{ set-option buffer lsp_modeline_code_actions "" } # Server Config set-option global lsp_debug false # list of filetypes for which LSP will be activated in the window scope declare-option str-list lsp_filetypes python go rust bash fish c cpp typst markdown yaml json jsonc bash sh define-command -hidden lsp-filetype-hooks-update %{ try %{ remove-hooks global lsp-filetypes } # convert the str-list into regex of form (a|b|c|...) hook -group lsp-filetypes global WinSetOption %exp~filetype=%sh{ # printf '%s' "(${kak_opt_lsp_filetypes// /|})" printf '%s\n' "$kak_opt_lsp_filetypes" | sed 's/ /|/g' }~ %{ # commands to execute for lsp window settings lsp-enable-window lsp-inlay-hints-enable window } } lsp-filetype-hooks-update hook global WinSetOption lsp_filetypes=.* lsp-filetype-hooks-update hook global BufSetOption lsp_filetypes=.* lsp-filetype-hooks-update hook global GlobalSetOption lsp_filetypes=.* lsp-filetype-hooks-update # TODO: set up toggle binding for this # or even better, show them on hover...? # lsp-inlay-diagnostics-enable global remove-hooks global lsp-filetype-python hook -group lsp-filetype-python global BufSetOption filetype=python %{ set-option buffer lsp_servers %{ [basedpyright-langserver] root_globs = ["requirements.txt", "setup.py", "pyproject.toml", "pyrightconfig.json", ".git", ".hg"] args = ["--stdio"] settings_section = "basedpyright" [basedpyright-langserver.settings.basedpyright.analysis] typeCheckingMode = "standard" inlayHints.genericTypes = true } } # use our custom fish-lsp wrapper because it sets env vars hook -group lsp-filetype-fish global BufSetOption filetype=fish %{ set-option buffer lsp_servers %{ [fish-lsp] root_globs = [".git"] args = ["start"] command = "/home/fic/.config/kak/scripts/fish-lsp.fish" } }