diff --git a/modules/kak/colors.nix b/modules/kak/colors.nix new file mode 100644 index 0000000..75f1322 --- /dev/null +++ b/modules/kak/colors.nix @@ -0,0 +1,21 @@ +{ theme, lib, pkgs }: + +pkgs.writeTextFile (rec { + name = "colors.kak"; + destination = "/share/kak/colors/${name}"; + text = with theme; '' + + face global comment rgb:525252 + + face global value rgb:${blue.normal} + face global string rgb:${green.normal} + face global keyword rgb:${cyan.normal} + face global operator rgb:${cyan.normal} + face global function rgb:${cyan.normal} + face global builtin rgb:${orange.normal} + face global module rgb:${yellow.normal} + face global meta rgb:${green.bright} + face global type rgb:${blue.bright} + + ''; +}) diff --git a/modules/kak/default.nix b/modules/kak/default.nix index 22ab4da..3b4b1c8 100644 --- a/modules/kak/default.nix +++ b/modules/kak/default.nix @@ -136,12 +136,18 @@ let kakrc = pkgs.writeTextFile (rec { in with lib; { - options.riley = { + options.editor = { + kak.enable = (mkEnableOption "kakoune editor") // { default = true; }; - kak.ide = mkEnableOption "kakoune with ide plugins"; + + kak.ide = (mkEnableOption "kakoune with ide plugins") // { default = false; }; + + kak.rust = mkEnableOption "Rust support in Kakoune"; + kak.haskell = mkEnableOption "Haskell support in Kakoune"; + }; - config = mkIf (config.riley.kak.enable || config.riley.kak.ide) { + config = mkIf (config.editor.kak.enable || config.editor.kak.ide) { environment.systemPackages = with pkgs; [ (pkgs.kakoune.override { diff --git a/modules/kak/kakoune.nix b/modules/kak/kakoune.nix new file mode 100644 index 0000000..fc079c0 --- /dev/null +++ b/modules/kak/kakoune.nix @@ -0,0 +1,62 @@ +# Preconfigured kakoune editor. + +{ + # Feature flags + typescript ? false, + haskell ? false, + python ? false, + rust ? false, + nix ? true, + + # Allow extra plugins to be defined + # outside of the package + extraPlugins ? [], + + # Color theme + theme, + + # Build context + pkgs, + lib +}: + +let kakrc = (import ./kakrc.nix { + inherit typescript + haskell + python + rust + nix + theme + pkgs + lib; + }); + + colors = (import ./colors.nix { + inherit theme + pkgs + lib; + }); + + kak-lsp = (import ./kak-lsp.nix { + inherit typescript + haskell + python + rust + nix + pkgs + lib; + }); + +in (pkgs.kakoune.override { + plugins = [ + + # Configuration + kak-lsp + colors + kakrc + + # Plugins + crosshairs + + ] ++ extraPlugins; +}) diff --git a/modules/kak/kakrc.nix b/modules/kak/kakrc.nix new file mode 100644 index 0000000..c329359 --- /dev/null +++ b/modules/kak/kakrc.nix @@ -0,0 +1,72 @@ +# Defines the kakrc. + +{ + # Feature flags + typescript ? false, + haskell ? false, + python ? false, + rust ? false, + nix ? true, + + # Color theme + theme, + + # Build tools + pkgs, + lib, +}: + + # If any of the language features are enabled, enable the + # extra language server-related keybinds and options. +let ide = typescript || haskell || python || rust || nix; + + # Generic keybinds + keybinds = '' + + ''; + + # IDE mode enables the language server protocol client + # and adds keybinds for lsp-hover and lsp-code-actions. + # If `rust` is enabled, lsp-semantic-tokens is also used. + ide-config = (lib.optionalString ide '' + + ''); + + # Sometimes work requires me to touch the frontend. Ew + typescript-config = (lib.optionalString typescript '' + + ''); + + # Haskell development + haskell-config = (lib.optionalString haskell '' + + ''); + + # Python-related config + python-config = (lib.optionalString python '' + + ''); + + # Rust development + rust-config = (lib.optionalString rust '' + + ''); + + # Nix hacking-related configuration + nix-config = (lib.optionalString nix '' + + ''); + + +in pkgs.writeTextFile (rec { + name = "kakrc.kak"; + destination = "/share/kak/autoload/${name}"; + text = with theme; '' + + '' ++ keybinds + ++ typescript-config + ++ haskell-config + ++ python-config + ++ rust-config + ++ nix-config; +})