From b8ea7dd266bfe86defb2f6c4f77c424265286bb4 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Fri, 6 May 2022 13:40:27 -0400 Subject: [PATCH] Set a new set of semantic tokens --- .gitignore | 2 +- home/kakoune/kakrc | 42 ++++++++++++------ home/modules/programs/my-kakoune/kak-lsp.nix | 46 +++++++++++++++----- 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index e56b43d..ff2ccdc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ home.nix -/result +result diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc index 7d16fa9..367ad65 100644 --- a/home/kakoune/kakrc +++ b/home/kakoune/kakrc @@ -1,10 +1,30 @@ # Color scheme colorscheme github -face global Default rgb:121213,default -face global BufferPadding rgb:A0A0A0,default +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 +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 # Enable line numbers addhl global/ number-lines @@ -101,13 +121,16 @@ hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c lsp-auto-hover-enable # lsp-auto-hover-insert-mode-enable set buffer lsp_hover_anchor true + lsp-inlay-diagnostics-enable buffer } hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|haskell|nix) %{ + # Note that fsharp is not here + lsp-inlay-hints-enable buffer # Format the document if possible hook window BufWritePre .* %{ lsp-formatting-sync } } -hook global WinSetOption filetype=(rust|go) %{ +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 @@ -116,19 +139,10 @@ hook global WinSetOption filetype=(rust|go) %{ } } -hook global WinSetOption filetype=rust %{ - hook window -group rust-inlay-hints BufReload .* rust-analyzer-inlay-hints - hook window -group rust-inlay-hints NormalIdle .* rust-analyzer-inlay-hints - hook window -group rust-inlay-hints InsertIdle .* rust-analyzer-inlay-hints - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window rust-inlay-hints - } -} - # in Insert mode moves to end of line. map global insert 'A' -hook global WinSetOption filetype=(fsharp) %{ + hook global WinSetOption filetype=(fsharp) %{ set-option buffer comment_line "//" } diff --git a/home/modules/programs/my-kakoune/kak-lsp.nix b/home/modules/programs/my-kakoune/kak-lsp.nix index 9b1c06e..6def88c 100644 --- a/home/modules/programs/my-kakoune/kak-lsp.nix +++ b/home/modules/programs/my-kakoune/kak-lsp.nix @@ -152,13 +152,35 @@ let roots = [ "Cargo.toml" ]; }; }; - semantic_scopes = { - entity_name_function = "function"; - entity_name_namespace = "module"; - entity_name_type = "type"; - variable = "variable"; - variable_other_enummember = "variable"; - }; + semantic_tokens.faces = [ + ## Items + # (Rust) Macros + { face = "attribute"; token = "attribute"; } + { face = "attribute"; token = "derive"; } + { face = "macro"; token = "macro"; } # Function-like Macro + # Keyword and Fixed Tokens + { face = "keyword"; token = "keyword"; } + { face = "operator"; token = "operator"; } + # Functions and Methods + { face = "function"; token = "function"; } + { face = "method"; token = "method"; } + # Constants + { face = "string"; token = "string"; } + { face = "format_specifier"; token = "formatSpecifier"; } + # Variables + { face = "mutable_variable"; token = "variable"; modifiers = [ "mutable" ]; } + { face = "variable"; token = "variable"; } + { face = "module"; token = "namespace"; } + { face = "variable"; token = "type_parameter"; } + { face = "class"; token = "enum"; } + { face = "class"; token = "struct"; } + { face = "class"; token = "trait"; } + { face = "class"; token = "union"; } + + ## Comments + { face = "documentation"; token = "comment"; modifiers = [ "documentation" ]; } + { face = "comment"; token = "comment"; } + ]; server = { timeout = 1800; }; snippet_support = false; verbosity = 255; @@ -218,10 +240,10 @@ in description = "Enable snippet support"; }; - semanticScopes = mkOption { - type = types.attrsOf types.str; - default = lspConfig.semantic_scopes; - description = "The semantic scopes mapping given to kak"; + semanticTokens.faces = mkOption { + type = types.listOf types.anything; + default = lspConfig.semantic_tokens.faces; + description = "The semantic tokens faces mapping given to kak"; }; serverTimeout = mkOption { @@ -250,7 +272,7 @@ in yj -jt -i \ < ${ pkgs.writeText "config.json" (builtins.toJSON { - semantic_scopes = cfg.semanticScopes; + semantic_tokens.faces = cfg.semanticTokens.faces; server.timeout = cfg.serverTimeout; snippet_support = cfg.enableSnippets; verbosity = 255;