diff --git a/modules/kak/colors.nix b/modules/kak/colors.nix index 7ff85eb..78a9928 100644 --- a/modules/kak/colors.nix +++ b/modules/kak/colors.nix @@ -23,5 +23,6 @@ pkgs.writeTextFile (rec { face global crosshairs_line "default,rgb:${background.normal}" face global MenuForeground "default,rgb:${blue.normal}" face global MenuBackground "default,rgb:313131" + ''; }) diff --git a/modules/kak/default.nix b/modules/kak/default.nix index 18d54b1..ce0b45e 100644 --- a/modules/kak/default.nix +++ b/modules/kak/default.nix @@ -1,140 +1,8 @@ { lib, pkgs, config, ... }: -let kakrc = pkgs.writeTextFile (rec { - name = "kakrc.kak"; - destination = "/share/kak/autoload/${name}"; - text = with config.riley.theme; '' +let kakoune = import ./kakoune.nix; in - # Line numbering - add-highlighter global/ number-lines -separator ' │ ' -hlcursor - - # Setting the tabstop to 4 (even though I have an ultrawide monitor) - set-option global tabstop 4 - - set global ui_options ncurses_assistant=cat - - # Use Alt-Tab to switch between open buffers - map global insert :buffer-next - map global normal :buffer-next - - def new-tab %{ prompt -file-completion '>' 'terminal kak -c %val{session} %val{text}' } - - map global normal ': new-tab' - - colorscheme common - - face global LineNumbers rgb:${background.slight} - face global BufferPadding rgb:${background.slight} - face global LineNumberCursor rgb:${foreground.primary} - face global crosshairs_line "default,rgb:${background.normal}" - face global MenuForeground "default,blue" - face global MenuBackground "default,rgb:313131" - face global InlayHint rgb:828282 - - face global comment rgb:${foreground.slight} - - '' + (lib.optionalString (config.riley.kak.ide) '' - - eval %sh{ kak-lsp --kakoune -s $kak_session } - - hook global -group yeet ModuleLoaded rust %{ - - # Override the Rust highlighting with semantic - # tokens supplied by the LSP client - remove-hooks global rust-highlight - remove-highlighter shared/rust - - # Request tokens - lsp-semantic-tokens - - # Self-destruct this hook (it should only run once) - remove-hooks global yeet - - } - - # Load language-specific color schemes - hook global WinSetOption filetype=(haskell) %{ - - colorscheme haskell - lsp-enable-window - - lsp-inlay-diagnostics-enable window - - map global normal ': lsp-code-actions' - map global normal ': lsp-hover' - - hook window ModeChange .*:.*:insert %{ - remove-highlighter window/lsp_diagnostics - } - - hook window ModeChange .*:insert:normal %{ - lsp-inlay-diagnostics-enable window - } - - set global lsp_inlay_diagnostic_sign '>' - map global insert '' - - } - - hook global WinSetOption filetype=(rust) %{ - - lsp-enable-window - lsp-inlay-diagnostics-enable window - - colorscheme rust - - git show-diff - - hook buffer BufReload .* %{ - git update-diff - } - - hook buffer NormalIdle .* %{ git update-diff } - hook buffer InsertIdle .* %{ git update-diff } - - hook window -group semtok BufReload .* lsp-semantic-tokens - hook window -group semtok NormalIdle .* lsp-semantic-tokens - hook window -group semtok InsertIdle .* lsp-semantic-tokens - - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window semtok - } - - hook window ModeChange .*:.*:insert %{ - remove-highlighter window/lsp_diagnostics - } - - hook window ModeChange .*:insert:normal %{ - lsp-inlay-diagnostics-enable window - } - - set global lsp_inlay_diagnostic_sign '>' - - map global normal ': lsp-code-actions' - map global normal ': lsp-hover' - - } - - hook global WinSetOption filetype=(nix) %{ - colorscheme nix - lsp-enable-window - } - - face global InlayDiagnosticWarning rgb:a39e31+f - face global InlayDiagnosticError rgb:ad494f+f - face global InlayDiagnosticHint rgb:4d965a+f - face global InlayDiagnosticInfo rgb:4d965a+f - - ''); - }); - - # Syntax colors - colors = (import ./colors { - theme = config.riley.theme; - inherit lib pkgs; - }); - -in with lib; { +with lib; { options.editor = { @@ -148,19 +16,20 @@ in with lib; { }; - config = mkIf (config.editor.kak.enable) { + config = with config.editor; mkIf (kak.enable) { - environment.systemPackages = with pkgs; [ - (pkgs.kakoune.override { - plugins = [ + environment.systemPackages = [ + (kakoune { - # Custom config - kakrc - - ] ++ (lib.optionals config.riley.kak.ide (import ./lsp.nix { - inherit pkgs lib config; - })) ++ colors; - }) + inherit (kak) haskell python rust nix; + typescript = kak.ts; + + kak-crosshairs = pkgs.kakounePlugins.kak-crosshairs; + + inherit pkgs lib; + theme = config.riley.theme; + + }) ]; }; diff --git a/modules/kak/kakrc.nix b/modules/kak/kakrc.nix index 80a85ca..34bfe51 100644 --- a/modules/kak/kakrc.nix +++ b/modules/kak/kakrc.nix @@ -23,17 +23,10 @@ let keybinds = '' ''; # Initialization code for IDE mode needed for every supported - # language. + # language, and inlay diagnostics. ide-init = '' eval %sh{ kak-lsp --kakoune -s $kak_session } lsp-enable-window - ''; - - # Implies `ide-init`. Adds inlay diagnostics support, code actions - # and hover. - ide-core = '' - - ${ide-init} lsp-inlay-diagnostics-enable window @@ -45,6 +38,13 @@ let keybinds = '' lsp-inlay-diagnostics-enable window } + ''; + + # Implies `ide-init`. Adds code actions and hover. + ide-core = '' + + ${ide-init} + map buffer normal ': lsp-code-actions' map buffer normal ': lsp-hover'