{ config, lib, pkgs, ... }: let nixpkgs = import {}; kakCmd = "kak"; rustPlugins = with pkgs; [ cargo cargo-watch clippy rust-analyzer ]; cppPlugins = with pkgs; [ clang-tools ]; latexPlugins = with pkgs; [ texlab ]; pythonPlugins = with pkgs.python38Packages; [ pyls-black python-language-server ]; nixPlugins = with pkgs; [ rnix-lsp ]; spellingPlugins = with pkgs; [ aspell aspellDicts.en aspellDicts.en-computers aspellDicts.en-science aspellDicts.it ]; dataFormats = with pkgs; [ # yaml-language-server ]; in { home.sessionVariables = { EDITOR = kakCmd; VISUAL = kakCmd; }; programs.bash.shellAliases = { k = kakCmd; }; programs.zsh.shellAliases = { k = kakCmd; }; programs.kakoune = { enable = true; config = { colorScheme = "nord"; tabStop = 2; indentWidth = 2; alignWithTabs = true; scrollOff = { lines = 5; columns = 3; }; ui = { setTitle = true; changeColors = true; enableMouse = true; }; wrapLines = { enable = true; word = true; }; numberLines = { enable = true; highlightCursor = true; }; keyMappings = [ { mode = "normal"; docstring = "Open file"; key = ""; effect = ":edit"; } { mode = "user"; docstring = "Code actions"; key = "a"; effect = ":lsp-code-actions"; } { mode = "user"; docstring = "Comment block"; key = "b"; effect = ":comment-block"; } { mode = "user"; docstring = "Comment line"; key = "l"; effect = ":comment-line"; } { mode = "user"; docstring = "Copy to clipboard"; key = "y"; effect = "${pkgs.xclip}/bin/xclip -i -selection clipboard"; } { mode = "user"; docstring = "Format code"; key = "F"; effect = ":lsp-formatting-sync"; } { mode = "user"; docstring = "Jump to definition"; key = "d"; effect = ":lsp-definition"; } { mode = "user"; docstring = "Jump to type definition"; key = "t"; effect = ":lsp-type-definition"; } { mode = "user"; docstring = "List project diagnostics"; key = "i"; effect = ":lsp-diagnostics"; } { mode = "user"; docstring = "Paste from clipboard (after)"; key = "P"; effect = "${pkgs.xclip}/bin/xclip -selection clipboard -o"; } { mode = "user"; docstring = "Paste from clipboard (before)"; key = "p"; effect = "!${pkgs.xclip}/bin/xclip -selection clipboard -o"; } { mode = "user"; docstring = "Show hover info"; key = "q"; effect = ":lsp-hover"; } { mode = "user"; docstring = "Spellcheck English"; key = "S"; effect = ":spell en"; } { mode = "user"; docstring = "Spellcheck"; key = "s"; effect = ":spell "; } { mode = "normal"; docstring = "Try next snippet placeholder"; key = ""; effect = ": insert-c-n"; } ]; hooks = [ { name = "BufCreate"; option = ".*"; commands = "editorconfig-load"; } { name = "ModuleLoaded"; option = "auto-pairs"; commands = "auto-pairs-enable"; } { name = "ModuleLoaded"; option = "powerline"; commands = builtins.concatStringsSep "\n" [ "powerline-enable" ]; } { name = "WinSetOption"; option = "filetype=(rust|python|c|cpp|latex|javascript|go|nix)"; commands = builtins.concatStringsSep "\n" [ "lsp-enable-window" ]; } ]; }; extraConfig = builtins.concatStringsSep "\n" [ "# Custom commands" "define-command -docstring 'save and quit' x 'write-all; quit' # Save and quit with 'x'" "add-highlighter global/ regex \\h+$ 0:Error # Highlight trailing spaces" "eval %sh{kak-lsp --kakoune -s \$kak_session} # Start kak-lsp" # Kak-lsp snippet support '' def -hidden insert-c-n %{ try %{ lsp-snippets-select-next-placeholders exec 'd' } catch %{ exec -with-hooks '' } } '' "require-module prelude" "# require-module auto-pairs" "require-module connect" "require-module connect-broot" "require-module connect-lf" "require-module connect-rofi" "require-module powerline" ]; plugins = ( with pkgs; [ broot lf editorconfig-core-c kakounePlugins.auto-pairs-kak kakounePlugins.kak-lsp kakounePlugins.powerline-kak kakounePlugins.prelude-kak ] ) ++ ( with nixpkgs; [ kakounePlugins.connect-kak ] ) ++ rustPlugins ++ cppPlugins ++ pythonPlugins ++ latexPlugins ++ nixPlugins ++ spellingPlugins ++ dataFormats; }; xdg.configFile."kak/colors/nord.kak".source = ../configs/kak/colors/nord.kak; xdg.configFile."kak-lsp/kak-lsp.toml".source = ../configs/kak-lsp/kak-lsp.toml; }