diff --git a/flake.lock b/flake.lock index 712fb33..635d0ae 100644 --- a/flake.lock +++ b/flake.lock @@ -398,11 +398,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1686398752, - "narHash": "sha256-nGWNQVhSw4VSL+S0D0cbrNR9vs9Bq7rlYR+1K5f5j6w=", + "lastModified": 1687946342, + "narHash": "sha256-vRxti8pOuXS0rJmqjbD8ueEEFXWSK22ISHoCWkhgzzg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a30520bf8eabf8a5c37889d661e67a2dbcaa59e6", + "rev": "1c851e8c92b76a00ce84167984a7ec7ba2b1f29c", "type": "github" }, "original": { diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index dc5fe67..d06a9ad 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -42,8 +42,14 @@ in { imports = [ ../modules/programs/my-kakoune ./kaktex.nix ]; - # ctags for peneira - home.packages = [ pkgs.universal-ctags ]; + home.packages = with pkgs; [ + # ctags for peneira + universal-ctags + # tree-sitter for kak + kak-tree-sitter + ]; + + # xdg.configFile."kak-tree-sitter/config.toml".source = ./kak-tree-sitter.toml; # Enable the kakoune package. programs.my-kakoune.enable = true; @@ -92,7 +98,8 @@ in programs.my-kakoune.package = kakounePkg; programs.my-kakoune.rc = - builtins.readFile ./kakrc + '' + builtins.readFile ./kakrc + + builtins.readFile ./reload-faces.kak + '' # Source any settings in the current working directory, # recursive upwards @@ -269,5 +276,11 @@ in ''; } ]; + programs.my-kakoune.themes = { + catppuccin-latte = builtins.fetchurl { + url = "https://raw.githubusercontent.com/catppuccin/kakoune/f6d43770609433c45046632f1bb68d1395305dbb/colors/catppuccin_latte.kak"; + sha256 = "sha256:0ycvxs8hmsvd0zrpxiby16wzmapvmz6p34b6j343pc1girw6fi4i"; + }; + }; } diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc index 53db378..0d5bd6d 100644 --- a/home/kakoune/kakrc +++ b/home/kakoune/kakrc @@ -1,30 +1,8 @@ +# Enable kak-tree-sitter +eval %sh{ kak-tree-sitter --kakoune -d } # Color scheme -colorscheme github -face global Default rgb:121213,default -face global BufferPadding rgb:A0A0A0,default -face global MenuForeground blue,white+bF -face global MenuBackground bright-blue,white+F -face global Information bright-blue,white -# Markdown help color scheme -face global InfoDefault Information -face global InfoBlock @block -face global InfoBlockQuote +i@block -face global InfoBullet @bullet -face global InfoHeader @header -face global InfoLink @link -face global InfoLinkMono +b@mono -face global InfoMono @mono -face global InfoRule +b@Information -face global InfoDiagnosticError @DiagnosticError -face global InfoDiagnosticHint @DiagnosticHint -face global InfoDiagnosticInformation @Information -face global InfoDiagnosticWarning @DiagnosticWarning -# Extra faces -face global macro +b@function -face global method +i@function -face global format_specifier +i@string -face global mutable_variable +u@variable -face global class +b@variable +colorscheme catppuccin-latte +set global background default # Assistant set global ui_options terminal_assistant=cat @@ -131,7 +109,7 @@ hook global WinSetOption filetype=(rust) %{ lsp-inlay-hints-enable window } -hook global WinSetOption filetype=(rust|go|fsharp|scala) %{ +hook global WinSetOption filetype=(rust|go|fsharp) %{ hook window -group semantic-tokens BufReload .* lsp-semantic-tokens hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens diff --git a/home/kakoune/reload-faces.kak b/home/kakoune/reload-faces.kak new file mode 100644 index 0000000..20a174c --- /dev/null +++ b/home/kakoune/reload-faces.kak @@ -0,0 +1,130 @@ +# Reload all faces +# our faces +set-face global Default "%opt{white},%opt{background}" +set-face global BufferPadding "%opt{background},%opt{background}" +# face global Default rgb:121213,default +# face global BufferPadding rgb:A0A0A0,default +face global MenuForeground blue,white+bF +face global MenuBackground bright-blue,white+F +face global Information bright-blue,white +# Markdown help color scheme +face global InfoDefault Information +face global InfoBlock @block +face global InfoBlockQuote +i@block +face global InfoBullet @bullet +face global InfoHeader @header +face global InfoLink @link +face global InfoLinkMono +b@mono +face global InfoMono @mono +face global InfoRule +b@Information +face global InfoDiagnosticError @DiagnosticError +face global InfoDiagnosticHint @DiagnosticHint +face global InfoDiagnosticInformation @Information +face global InfoDiagnosticWarning @DiagnosticWarning +# Extra faces +face global macro +b@function +face global method +i@function +face global format_specifier +i@string +face global mutable_variable +u@variable +face global class +b@variable + +# tree-sitter +#set-face global ts_unknown red+ub +set-face global ts_attribute "@attribute" +set-face global ts_comment "@comment" +set-face global ts_comment_block "@ts_comment" +set-face global ts_comment_line "@ts_comment" +set-face global ts_conceal "%opt{mauve}+i" +set-face global ts_constant "%opt{peach}" +set-face global ts_constant_builtin_boolean "%opt{sky}" +set-face global ts_constant_character "%opt{yellow}" +set-face global ts_constant_character_escape "@ts_constant_character" +set-face global ts_constant_macro "%opt{mauve}" +set-face global ts_constant_numeric "%opt{peach}" +set-face global ts_constant_numeric_float "@ts_constant_numeric" +set-face global ts_constant_numeric_integer "@ts_constant_numeric" +set-face global ts_constructor "%opt{sapphire}" +set-face global ts_diff_plus "%opt{green}" +set-face global ts_diff_minus "%opt{red}" +set-face global ts_diff_delta "%opt{blue}" +set-face global ts_diff_delta_moved "%opt{mauve}" +set-face global ts_error "%opt{red}+b" +set-face global ts_function "@function" +set-face global ts_function_builtin "@builtin" +set-face global ts_function_macro "+i@ts_function" +set-face global ts_function_method "@ts_function" +set-face global ts_function_special "@ts_function" +set-face global ts_hint "%opt{blue}+b" +set-face global ts_info "%opt{green}+b" +set-face global ts_keyword "keyword" +set-face global ts_keyword_control "@ts_keyword" +set-face global ts_keyword_conditional "+i@ts_keyword" +set-face global ts_keyword_control_conditional "+i@ts_keyword" +set-face global ts_keyword_control_directive "+i@ts_keyword" +set-face global ts_keyword_control_import "+i@ts_keyword" +set-face global ts_keyword_control_repeat "@ts_keyword" +set-face global ts_keyword_control_return "@ts_keyword" +set-face global ts_keyword_control_except "@ts_keyword" +set-face global ts_keyword_control_exception "@ts_keyword" +set-face global ts_keyword_directive "+i@ts_keyword" +set-face global ts_keyword_function "@ts_keyword" +set-face global ts_keyword_operator "@ts_keyword" +set-face global ts_keyword_special "@ts_keyword" +set-face global ts_keyword_storage "@ts_keyword" +set-face global ts_keyword_storage_modifier "@ts_keyword" +set-face global ts_keyword_storage_modifier_mut "@ts_keyword" +set-face global ts_keyword_storage_modifier_ref "@ts_keyword" +set-face global ts_keyword_storage_type "@ts_keyword" +set-face global ts_label "%opt{sapphire}+i" +set-face global ts_markup_bold "%opt{peach}+b" +set-face global ts_markup_heading "%opt{red}" +set-face global ts_markup_heading_1 "%opt{red}" +set-face global ts_markup_heading_2 "%opt{mauve}" +set-face global ts_markup_heading_3 "%opt{green}" +set-face global ts_markup_heading_4 "%opt{yellow}" +set-face global ts_markup_heading_5 "%opt{pink}" +set-face global ts_markup_heading_6 "%opt{teal}" +set-face global ts_markup_heading_marker "%opt{peach}+b" +set-face global ts_markup_italic "%opt{pink}+i" +set-face global ts_markup_list_checked "%opt{green}" +set-face global ts_markup_list_numbered "%opt{blue}+i" +set-face global ts_markup_list_unchecked "%opt{teal}" +set-face global ts_markup_list_unnumbered "%opt{mauve}" +set-face global ts_markup_link_label "%opt{blue}" +set-face global ts_markup_link_url "%opt{teal}+u" +set-face global ts_markup_link_uri "%opt{teal}+u" +set-face global ts_markup_link_text "%opt{blue}" +set-face global ts_markup_quote "%opt{gray1}" +set-face global ts_markup_raw "%opt{sky}" +set-face global ts_markup_raw_block "%opt{sky}" +set-face global ts_markup_raw_inline "%opt{green}" +set-face global ts_markup_strikethrough "%opt{gray1}+s" +set-face global ts_namespace "@module" +set-face global ts_operator "@operator" +set-face global ts_property "%opt{sky}" +set-face global ts_punctuation "%opt{overlay2}" +set-face global ts_punctuation_bracket "@ts_punctuation" +set-face global ts_punctuation_delimiter "@ts_punctuation" +set-face global ts_punctuation_special "%opt{sky}" +set-face global ts_special "%opt{blue}" +set-face global ts_spell "%opt{mauve}" +set-face global ts_string "%opt{green}" +set-face global ts_string_regex "%opt{peach}" +set-face global ts_string_regexp "%opt{peach}" +set-face global ts_string_escape "%opt{mauve}" +set-face global ts_string_special "%opt{blue}" +set-face global ts_string_special_path "%opt{green}" +set-face global ts_string_special_symbol "%opt{mauve}" +set-face global ts_string_symbol "%opt{red}" +set-face global ts_tag "%opt{teal}" +set-face global ts_tag_error "%opt{red}" +set-face global ts_text "@ts_string" +set-face global ts_text_title "%opt{mauve}" +set-face global ts_type "%opt{yellow}" +set-face global ts_type_builtin "@ts_type" +set-face global ts_type_enum_variant "%opt{flamingo}" +set-face global ts_variable "@variable" +set-face global ts_variable_builtin "@builtin" +set-face global ts_variable_other_member "%opt{teal}" +set-face global ts_variable_parameter "%opt{maroon}+i" +set-face global ts_warning "%opt{peach}+b" diff --git a/home/modules/programs/my-kakoune/default.nix b/home/modules/programs/my-kakoune/default.nix index 97a445c..aa34efc 100644 --- a/home/modules/programs/my-kakoune/default.nix +++ b/home/modules/programs/my-kakoune/default.nix @@ -47,47 +47,52 @@ in default = [ ]; description = "Sources to autoload"; }; + themes = mkOption { + type = types.attrsOf types.path; + default = { }; + description = "Themes to load"; + }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; - home.file = + xdg.configFile = let kakouneAutoload = { name, src, wrapAsModule ? false, activationScript ? null }: [ (if !wrapAsModule then { - name = "kakoune/autoload/${name}"; - value = { - source = src; - target = ".config/kak/autoload/${name}"; - }; + name = "kak/autoload/${name}"; + value.source = src; } else { - name = "kakoune/autoload/${name}/module.kak"; - value = { - text = '' - provide-module ${name} %◍ - ${readFile src} - ◍ - ''; - target = ".config/kak/autoload/${name}/module.kak"; - }; + name = "kak/autoload/${name}/module.kak"; + value.text = '' + provide-module ${name} %◍ + ${readFile src} + ◍ + ''; }) ] ++ (if activationScript == null then [ ] else [{ - name = "kakoune/autoload/on-load/${name}.kak"; - value = { - text = '' - hook global KakBegin .* %{ - ${activationScript} - } - ''; - target = ".config/kak/autoload/on-load/${name}.kak"; - }; + name = "kak/autoload/on-load/${name}.kak"; + value.text = '' + hook global KakBegin .* %{ + ${activationScript} + } + ''; }]); + + kakouneThemes = builtins.listToAttrs (builtins.attrValues ( + builtins.mapAttrs + (name: src: { + name = "kak/colors/${name}.kak"; + value.source = src; + }) + cfg.themes + )); in { # kakrc - ".config/kak/kakrc".text = cfg.rc; + "kak/kakrc".text = cfg.rc; } // (builtins.listToAttrs (lib.lists.flatten (map kakouneAutoload ([ # include the original autoload files @@ -95,7 +100,8 @@ in name = "rc"; src = "${cfg.package}/share/kak/autoload/rc"; } - ] ++ cfg.autoload)))); + ] ++ cfg.autoload)))) + // kakouneThemes; }; } diff --git a/overlay.nix b/overlay.nix index 6d13bf3..e070726 100644 --- a/overlay.nix +++ b/overlay.nix @@ -37,6 +37,7 @@ let overlay-packages = final: prev: { gotosocial-bin = final.callPackage ./packages/x86_64-linux/gotosocial-bin.nix { }; + kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter.nix { rustPlatform = final.unstable.rustPlatform; }; }; overlay-aarch64-linux = final: prev: diff --git a/packages/common/kak-tree-sitter.nix b/packages/common/kak-tree-sitter.nix new file mode 100644 index 0000000..d506223 --- /dev/null +++ b/packages/common/kak-tree-sitter.nix @@ -0,0 +1,33 @@ +{ lib, rustPlatform, fetchFromGitHub, symlinkJoin, clang, git, ... }: +let + src = fetchFromGitHub { + owner = "phaazon"; + repo = "kak-tree-sitter"; + rev = "fcc4ec36385ee5ce1378dae1b3eca4288619ff0d"; + sha256 = "sha256-a2EBTe6SucxHHMhElhnvyf3b6AOj5CyhHE7RHVx/Ulc="; + }; + + kak-tree-sitter = rustPlatform.buildRustPackage rec { + inherit src; + pname = "kak-tree-sitter"; + version = "0.3.0"; + cargoSha256 = "sha256-eDkIN7uzy2euywsjm3152R36B181Jj9KqnHsFDjyxhI="; + cargoBuildOptions = [ "--package" "kak-tree-sitter" ]; + }; + + ktsctl = rustPlatform.buildRustPackage rec { + inherit src; + name = "ktsctl"; + version = "0.2.0"; + cargoSha256 = "sha256-k16nuC50n9TSiGdkzP58gr6zpFR/Jh21Bw33SRWRi8U="; + + cargoBuildOptions = [ "--package" "ktsctl" ]; + + buildInputs = [ clang git ]; + }; +in +symlinkJoin { + name = "kak-tree-sitter"; + paths = [ kak-tree-sitter ktsctl ]; +} +