diff --git a/flake.lock b/flake.lock index 635d0ae..42b8a37 100644 --- a/flake.lock +++ b/flake.lock @@ -398,11 +398,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1687946342, - "narHash": "sha256-vRxti8pOuXS0rJmqjbD8ueEEFXWSK22ISHoCWkhgzzg=", + "lastModified": 1688221086, + "narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1c851e8c92b76a00ce84167984a7ec7ba2b1f29c", + "rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825", "type": "github" }, "original": { diff --git a/home/common.nix b/home/common.nix index 9eb4bdf..4a30ded 100644 --- a/home/common.nix +++ b/home/common.nix @@ -71,6 +71,8 @@ in ## Latex tectonic texlab + ## Typst + typst ## Python python3 diff --git a/home/kakoune/kak.nix b/home/kakoune/kak.nix index fa01eb2..5943403 100644 --- a/home/kakoune/kak.nix +++ b/home/kakoune/kak.nix @@ -56,6 +56,21 @@ in programs.my-kakoune.enable-fish-session = true; programs.kak-lsp.enable = true; programs.kak-lsp.package = kak-lsp; + programs.kak-lsp.semanticTokens.additionalFaces = [ + # Typst + { face = "header"; token = "heading"; } + { face = "ts_markup_link_url"; token = "link"; } + { face = "ts_markup_link_uri"; token = "ref"; } + { face = "ts_markup_link_label"; token = "label"; } + { face = "ts_property"; token = "pol"; } + { face = "ts_markup_list_checked"; token = "marker"; } + { face = "ts_constant_builtin_boolean"; token = "bool"; } + { face = "ts_keyword_control"; token = "delim"; } + { face = "ts_number"; token = "text"; modifiers = [ "math" ]; } + { face = "ts_markup_bold"; token = "text"; modifiers = [ "strong" ]; } + { face = "ts_markup_italic"; token = "text"; modifiers = [ "emph" ]; } + ]; + programs.kak-lsp.languages.typescript = { args = [ "--stdio" ]; command = "typescript-language-server"; @@ -95,6 +110,13 @@ in }); }; }; + programs.kak-lsp.languages.typst = { + command = "${pkgs.typst-lsp}/bin/typst-lsp"; + filetypes = [ "typst" ]; + roots = [ ".git" "main.typ" ]; + settings_section = "typst-lsp"; + settings.typst-lsp = { }; + }; programs.my-kakoune.tree-sitter.extraAliases = { # Scala stuff diff --git a/home/kakoune/kakrc b/home/kakoune/kakrc index 0d5bd6d..8666f8c 100644 --- a/home/kakoune/kakrc +++ b/home/kakoune/kakrc @@ -89,7 +89,7 @@ hook global InsertCompletionHide .* %{ try %{ eval %sh{test -z "$WE_STARTED_KAK" && kak-lsp --kakoune -s $kak_session} } -hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|fsharp|ocaml|haskell|nix|scala) %{ +hook global WinSetOption filetype=(racket|rust|python|go|javascript|typescript|c|cpp|tex|latex|fsharp|ocaml|haskell|nix|scala|typst) %{ lsp-enable-window map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next" map window normal ": enter-user-mode lsp" @@ -109,7 +109,7 @@ hook global WinSetOption filetype=(rust) %{ lsp-inlay-hints-enable window } -hook global WinSetOption filetype=(rust|go|fsharp) %{ +hook global WinSetOption filetype=(rust|go|fsharp|typst) %{ 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 @@ -150,6 +150,21 @@ hook global WinSetOption filetype=(scala) %{ set window indentwidth 2 } +hook global WinSetOption filetype=(typst) %{ + set-option window comment_line "//" + set-option window comment_block_begin "/*" + set-option window comment_block_end "*/" + + # borrow markdown's hooks + require-module markdown + + hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent + hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line + hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } +} + + define-command -params 0 -docstring "Set up build" scala-build-connect %{ lsp-execute-command 'build-connect' '"[]"' } @@ -185,6 +200,11 @@ hook global BufCreate .*[.]sc %{ set-option buffer filetype scala } +hook global BufCreate .*[.]typ %{ + set-option buffer filetype typst + add-highlighter buffer/ wrap +} + hook global BufOpenFile .* %{ modeline-parse } diff --git a/home/modules/programs/my-kakoune/kak-lsp.nix b/home/modules/programs/my-kakoune/kak-lsp.nix index 3df2385..33e898f 100644 --- a/home/modules/programs/my-kakoune/kak-lsp.nix +++ b/home/modules/programs/my-kakoune/kak-lsp.nix @@ -247,6 +247,11 @@ in default = lspConfig.semantic_tokens.faces; description = "The semantic tokens faces mapping given to kak"; }; + semanticTokens.additionalFaces = mkOption { + type = types.listOf types.anything; + default = [ ]; + description = "The semantic tokens faces mapping given to kak"; + }; serverTimeout = mkOption { type = types.int; @@ -274,7 +279,7 @@ in yj -jt -i \ < ${ pkgs.writeText "config.json" (builtins.toJSON { - semantic_tokens.faces = cfg.semanticTokens.faces; + semantic_tokens.faces = cfg.semanticTokens.faces ++ cfg.semanticTokens.additionalFaces; server.timeout = cfg.serverTimeout; snippet_support = cfg.enableSnippets; verbosity = 255; diff --git a/overlay.nix b/overlay.nix index e78110e..42eaffc 100644 --- a/overlay.nix +++ b/overlay.nix @@ -7,6 +7,10 @@ let overlay-needs-unstable = final: prev: { # override some packages that needs unstable that cannot be changed in the setup. nix-direnv = prev.unstable.nix-direnv; + + # Typst updates really quickly. + typst = final.unstable.typst; + typst-lsp = final.unstable.typst-lsp; }; overlay-imported = final: prev: { rnix-lsp = inputs.rnix-lsp.defaultPackage."${final.system}";