diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 2841c31..9f12200 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -183,6 +183,9 @@ in oneko plover.dev + + mupdf + inotify-tools ]; xsession = { enable = true; diff --git a/modules/shell/helix.nix b/modules/shell/helix.nix index 2238418..14029d7 100644 --- a/modules/shell/helix.nix +++ b/modules/shell/helix.nix @@ -1,5 +1,12 @@ {config, ...}: { - home-manager.users.jade = {pkgs, ...}: { + home-manager.users.jade = {pkgs, ...}: let + typstGrammar = pkgs.fetchFromGitHub { + owner = "uben0"; + repo = "tree-sitter-typst"; + rev = "baddc325e858afff90501dbefa00ecfa28528931"; + sha256 = "sha256-XZAgnpb1B8EZ2WXPj/JYSZGsmpKsnDiBFCDF0XjunOM"; + }; + in { home = { sessionVariables.EDITOR = "hx"; packages = [ @@ -7,15 +14,28 @@ pkgs.vscode-langservers-extracted pkgs.nodePackages.typescript-language-server pkgs.emmet-language-server + pkgs.typst-lsp ]; }; + home.file = { + ".config/helix/runtime/queries" = { + source = "${typstGrammar}/queries"; + }; + }; programs.helix = { enable = true; settings = { theme = "gruvbox"; editor = { line-number = "relative"; - lsp.display-messages = true; + bufferline = "multiple"; + color-modes = true; + lsp = { + display-messages = true; + display-inlay-hints = true; + }; + shell = ["nu" "-c"]; + idle-timeout = 0; indent-guides = { render = true; character = "│"; @@ -38,32 +58,86 @@ }; }; languages = { - language-server."nu-builtin-lsp" = { - command = "${config.users.defaultUserShell}/bin/nu"; - args = ["--lsp"]; - }; - language-server."rust-analyzer" = { - config = { - check.command = "clippy"; + language-server = { + "nu-builtin-lsp" = { + command = "${config.users.defaultUserShell}/bin/nu"; + args = ["--lsp"]; + }; + "rust-analyzer" = { + config = { + check.command = "clippy"; + completion.snippets.custom = { + "pub fn" = { + prefix = ["pfn" "pubfn"]; + postfix = ["pfn"]; + body = [ + "pub fn $\{receiver\}() {" + "\\t$1" + "}" + ]; + scope = "type"; + }; + }; + }; + }; + "emmet-language-server" = { + command = "emmet-language-server"; + args = ["--stdio"]; + }; + # "php" = { + # name = "php"; + # file-types = [ "php" ]; + # language-server = { + # command = "psalm"; + # args = ["--language-server"]; + # }; + # }; + "typst-lsp" = { + command = "typst-lsp"; + config = { + exportPdf = "onType"; + }; }; }; - language-server."emmet-language-server" = { - command = "emmet-language-server"; - args = ["--stdio"]; - }; - # "php" = { - # name = "php"; - # file-types = [ "php" ]; - # language-server = { - # command = "psalm"; - # args = ["--language-server"]; - # }; - # }; + grammar = [ + { + name = "typst"; + source = { + git = "https://github.com/uben0/tree-sitter-typst"; + rev = "baddc325e858afff90501dbefa00ecfa28528931"; + # path = "${typstGrammar}"; + }; + } + ]; language = [ { name = "nu"; language-servers = ["nu-builtin-lsp"]; } + { + name = "typst"; + scope = "source.typst"; + file-types = ["typ" "typst"]; + injection-regex = "typ(st)?"; + comment-token = "//"; + indent = { + tab-width = 2; + unit = " "; + }; + roots = ["typst.toml"]; + formatter = { + command = "${pkgs.typstfmt}/bin/typstfmt"; + }; + auto-format = true; + language-servers = ["typst-lsp"]; + auto-pairs = { + "(" = ")"; + "{" = "}"; + "[" = "]"; + "$" = "$"; + "\"" = "\""; + }; + } { name = "nix"; formatter = { diff --git a/other/config.nu b/other/config.nu index 2903d1d..2f1a437 100644 --- a/other/config.nu +++ b/other/config.nu @@ -803,18 +803,15 @@ def glog [ ] { git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n $amount | lines - | split column "»¦«" commit subject name email date + | split column "»¦«u commit subject name email date" } -def ed [ - file: path - ...cmdargs: string +def typed [ + name: string ] { - let ext = $file | path parse | get extension; - match $ext { - "typ" => {|| zellij run --direction down -- typst watch $file ($cmdargs | prepend '--open' | str join ' ') } - }; - hx $file + touch $"($name).typ" + typst compile $"($name).typ" + mprocs --names Editor,Viewer,Notify $"hx '($name).typ'" $"mupdf-x11 '($name).pdf'" $"while inotifywait -e modify '($name).pdf' ; do pkill -HUP mupdf; done" } alias gnix = cd ~/nix-configs;