mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +00:00
Merge pull request #1536 from snoweuph/feat/injections
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Treewide Checks / Validate flake (push) Has been cancelled
Treewide Checks / Check formatting (push) Has been cancelled
Treewide Checks / Check source tree for typos (push) Has been cancelled
Treewide Checks / Validate documentation builds (push) Has been cancelled
Treewide Checks / Validate documentation builds-1 (push) Has been cancelled
Treewide Checks / Validate documentation builds-2 (push) Has been cancelled
Treewide Checks / Validate documentation builds-3 (push) Has been cancelled
Treewide Checks / Validate hyperlinks in documentation sources (push) Has been cancelled
Treewide Checks / Validate Editorconfig conformance (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Treewide Checks / Validate flake (push) Has been cancelled
Treewide Checks / Check formatting (push) Has been cancelled
Treewide Checks / Check source tree for typos (push) Has been cancelled
Treewide Checks / Validate documentation builds (push) Has been cancelled
Treewide Checks / Validate documentation builds-1 (push) Has been cancelled
Treewide Checks / Validate documentation builds-2 (push) Has been cancelled
Treewide Checks / Validate documentation builds-3 (push) Has been cancelled
Treewide Checks / Validate hyperlinks in documentation sources (push) Has been cancelled
Treewide Checks / Validate Editorconfig conformance (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
Feat/injections 💉
This commit is contained in:
commit
4de19e1209
7 changed files with 120 additions and 70 deletions
|
|
@ -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.<name>` to contain LSP configurations. This allows for
|
||||
more flexibility in nvf and reuse of LSPs across languages. Dropped
|
||||
|
|
|
|||
|
|
@ -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"])
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
)
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue