diff --git a/docs/manual/release-notes/rl-0.9.md b/docs/manual/release-notes/rl-0.9.md index 1975bb91..604a241b 100644 --- a/docs/manual/release-notes/rl-0.9.md +++ b/docs/manual/release-notes/rl-0.9.md @@ -104,6 +104,10 @@ - Renamed `languages.ts` to `languages.typescript`. +- Added {option}`vim.languages.go.treesitter.gotmpl.injection` and Renamed + `languages.go.treesitter.gotmplPackage` to + {option}`vim.languages.go.treesitter.gotmpl.package` + ## Changelog {#sec-release-0-9-changelog} [SecBear](https://github.com/SecBear): @@ -274,7 +278,10 @@ - Added {option}`vim.treesitter.queries` to support adding custom queries. - Added injections for `vim.treesitter.queries.*.content` as `query` and - `mkLualine ""` as `lua`. + `mkLualine`, `entryAnywhere`, `entryBefore`, `entryAfter` as `lua` in nix. + +- Added {option}`vim.languages.tera.treesitter.injection` to configure, what + language the content is. - Added `vim.lsp.presets.` to contain LSP configurations. This allows for more flexibility in nvf and reuse of LSPs across languages. Dropped diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 760b7b38..99785c2e 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -362,6 +362,7 @@ in { # 2026-04-19 [ (mkRenamedOptionModule ["vim" "utility" "vim-wakatime" "cli-path"] ["vim" "utility" "vim-wakatime" "setupOpts" "cli_path"]) + (mkRenamedOptionModule ["vim" "languages" "go" "treesitter" "gotmplPackage"] ["vim" "languages" "go" "treesitter" "gotmpl" "package"]) ] ]; } diff --git a/modules/plugins/completion/blink-cmp/config.nix b/modules/plugins/completion/blink-cmp/config.nix index 7b29b380..76f8a7eb 100644 --- a/modules/plugins/completion/blink-cmp/config.nix +++ b/modules/plugins/completion/blink-cmp/config.nix @@ -54,13 +54,10 @@ in { # event = ["InsertEnter" "CmdlineEnter"]; after = - # lua - '' - ${optionalString (config.vim.lazy.enable && cmpCfg.enable) - (concatStringsSep "\n" (map - (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})") - cmpCfg.sourcePlugins))} - ''; + optionalString (config.vim.lazy.enable && cmpCfg.enable) + (concatStringsSep "\n" (map + (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})") + cmpCfg.sourcePlugins)); }; }; @@ -111,18 +108,16 @@ in { next = [ "select_next" "snippet_forward" - (mkLuaInline - # lua - '' - function(cmp) - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + (mkLuaInline '' + function(cmp) + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - if has_words_before then - return cmp.show() - end + if has_words_before then + return cmp.show() end - '') + end + '') "fallback" ]; previous = [ diff --git a/modules/plugins/languages/go.nix b/modules/plugins/languages/go.nix index 6831fe9c..afe9d1b2 100644 --- a/modules/plugins/languages/go.nix +++ b/modules/plugins/languages/go.nix @@ -143,7 +143,14 @@ in { gomodPackage = mkGrammarOption pkgs "gomod"; gosumPackage = mkGrammarOption pkgs "gosum"; goworkPackage = mkGrammarOption pkgs "gowork"; - gotmplPackage = mkGrammarOption pkgs "gotmpl"; + gotmpl = { + package = mkGrammarOption pkgs "gotmpl"; + injection = mkOption { + type = str; + default = "html"; + description = "Treesitter language to inject in Go templates"; + }; + }; }; lsp = { @@ -274,7 +281,21 @@ in { cfg.treesitter.gomodPackage cfg.treesitter.gosumPackage cfg.treesitter.goworkPackage - cfg.treesitter.gotmplPackage + cfg.treesitter.gotmpl.package + ]; + queries = [ + { + type = "injections"; + filetypes = ["gotmpl"]; + content = '' + ;; extends + + ((text) @injection.content + (#set! injection.language "${cfg.treesitter.gotmpl.injection}") + (#set! injection.combined) + ) + ''; + } ]; }; }) diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 3c4a05ed..09507a55 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -138,44 +138,43 @@ in { filetypes = ["nix"]; content = '' ;; extends - ( - (binding - attrpath: (attrpath - (identifier) @_a - (identifier) @_b - (identifier)? @_c) - (#eq? @_a "vim") - (#any-of? @_b "treesitter") - (#any-of? @_c "queries") - expression: (attrset_expression - (binding_set - (binding - attrpath: (attrpath - (identifier) @_queries) - (#eq? @_queries "queries") + ((binding + attrpath: (attrpath + (identifier) @_a + (identifier) @_b + (identifier)? @_c) + (#eq? @_a "vim") + (#any-of? @_b "treesitter") + (#any-of? @_c "queries") - expression: (list_expression - (attrset_expression - (binding_set - (binding - attrpath: (attrpath - (identifier) @_field) - (#eq? @_field "content") + expression: (attrset_expression + (binding_set + (binding + attrpath: (attrpath + (identifier) @_queries) + (#eq? @_queries "queries") - expression: [ - (string_expression - (string_fragment) @injection.content) - (indented_string_expression - (string_fragment) @injection.content) - ] + expression: (list_expression + (attrset_expression + (binding_set + (binding + attrpath: (attrpath + (identifier) @_field) + (#eq? @_field "content") - (#set! injection.language "query") - (#set! injection.combined))))))))) - ) + expression: [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + + (#set! injection.language "query") + (#set! injection.combined)))))))))) ''; } - # mkLuaInline = lua + # mkLuaInline, entryAnywhere, entryBefore, entryAfter = lua { type = "injections"; filetypes = ["nix"]; @@ -185,13 +184,22 @@ in { ((apply_expression function: (variable_expression name: (identifier) @_func - (#eq? @_func "mkLuaInline")) - + (#any-of? @_func "mkLuaInline" "entryAnywhere")) argument: (indented_string_expression - (string_fragment) @injection.content) + (string_fragment) @injection.content)) + (#set! injection.language "lua") + (#set! injection.combined)) - (#set! injection.language "lua") - (#set! injection.combined))) + ((apply_expression + function: (apply_expression + function: (variable_expression + name: (identifier) @_func + (#any-of? @_func "entryBefore" "entryAfter")) + argument: (_)) + argument: (indented_string_expression + (string_fragment) @injection.content)) + (#set! injection.language "lua") + (#set! injection.combined)) ''; } ]; diff --git a/modules/plugins/languages/tera.nix b/modules/plugins/languages/tera.nix index 0a28014c..3135df9f 100644 --- a/modules/plugins/languages/tera.nix +++ b/modules/plugins/languages/tera.nix @@ -7,7 +7,7 @@ inherit (lib) genAttrs; inherit (lib.options) mkEnableOption literalExpression mkOption; inherit (lib.modules) mkIf mkMerge; - inherit (lib.types) enum listOf; + inherit (lib.types) enum listOf str; inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.tera; @@ -26,6 +26,11 @@ in { defaultText = literalExpression "config.vim.languages.enableTreesitter"; }; package = mkGrammarOption pkgs "tera"; + injection = mkOption { + type = str; + default = "html"; + description = "Treesitter language to inject in Tera templates"; + }; }; lsp = { @@ -45,8 +50,24 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; + vim.treesitter = { + enable = true; + grammars = [cfg.treesitter.package]; + queries = [ + { + type = "injections"; + filetypes = ["tera"]; + content = '' + ;; extends + + ((content) @injection.content + (#set! injection.language "${cfg.treesitter.injection}") + (#set! injection.combined) + ) + ''; + } + ]; + }; }) (mkIf cfg.lsp.enable { diff --git a/modules/plugins/lsp/lspsaga/lspsaga.nix b/modules/plugins/lsp/lspsaga/lspsaga.nix index 570cee1a..f70c8c9d 100644 --- a/modules/plugins/lsp/lspsaga/lspsaga.nix +++ b/modules/plugins/lsp/lspsaga/lspsaga.nix @@ -11,12 +11,9 @@ uiKindSetupOpts = if config.vim.theme.enable && config.vim.theme.name == "catppuccin" then { - ui.kind = - mkLuaInline - # lua - '' - require("catppuccin.groups.integrations.lsp_saga").custom_kind() - ''; + ui.kind = mkLuaInline '' + require("catppuccin.groups.integrations.lsp_saga").custom_kind() + ''; } else {}; in {