]> Freerunner's - dotfiles.git/commitdiff
kak: integrate lsp
authorAndre Ramnitz <tux.rising@gmail.com>
Mon, 3 Feb 2025 05:27:46 +0000 (06:27 +0100)
committerAndre Ramnitz <tux.rising@gmail.com>
Mon, 3 Feb 2025 05:27:46 +0000 (06:27 +0100)
dot-config/kak/kakrc

index 391b8ca9f3ed3ed1c08ef7916b623a91866ceeb3..bc8449a3033b922b9f0c26e21631af46ea25a281 100644 (file)
@@ -63,11 +63,6 @@ evaluate-commands %sh{ kks init }
 #   } -- %val{session} %val{client} %arg{@}
 # }
 
-# kak-lsp integration
-# ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-evaluate-commands %sh{ kak-lsp }
-lsp-enable
-
 # Enable PLUGin manager
 # ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 # after first sync of the dotfiles, bundle needs to be installed manually,
@@ -101,6 +96,43 @@ bundle-noload dabruin.kak https://git.sr.ht/~nasmevka/dabruin.kak
         rm -f "${kak_config}/colors/dabruin-light.kak"
     }
 bundle kakoune-table https://gitlab.com/listentolist/kakoune-table
+bundle kakoune-lsp https://github.com/kakoune-lsp/kakoune-lsp %{
+    bundle-install-hook kakoune-lsp %{
+        cargo build --release --locked
+        cargo install --locked --force --path .
+    }
+    set global lsp_diagnostic_line_error_sign '║'
+    set global lsp_diagnostic_line_warning_sign '┊'
+
+    define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings }
+    define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings }
+    define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings }
+
+    define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start }
+    # hook global WinSetOption filetype=(c|cpp|cc|rust|javascript|typescript) %{
+    #     set-option window lsp_auto_highlight_references true
+    #     set-option window lsp_hover_anchor false
+    #     lsp-auto-hover-enable
+    #     echo -debug "Enabling LSP for filtetype %opt{filetype}"
+    #     lsp-enable-window
+    # }
+
+    # hook global WinSetOption filetype=(rust) %{
+    #     set window lsp_server_configuration rust.clippy_preference="on"
+    # }
+
+    # hook global WinSetOption filetype=rust %{
+    #     hook window BufWritePre .* %{
+    #         evaluate-commands %sh{
+    #             test -f rustfmt.toml && printf lsp-formatting-sync
+    #         }
+    #     }
+    # }
+    evaluate-commands %sh{ kak-lsp }
+    lsp-enable
+
+    hook global KakEnd .* lsp-exit
+}
 
 # Enable some linting and formatting
 # ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@@ -138,7 +170,7 @@ hook global WinSetOption filetype=(json|jsonc) %{
 
 # Enable some code linters
 # ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-hook global WinSetOption filetype=c %{
+hook global WinSetOption filetype=(c|h) %{
     set-option window lintcmd "cppcheck --language=c --enable=warning,style,information --template='{file}:{line}:{column}: {severity}: {message}' --suppress='*:*.h' 2>&1"
 }
 hook global WinSetOption filetype=css %{