mirror of
https://github.com/nix-community/nixvim.git
synced 2025-12-17 06:21:13 +01:00
plugins/treesitter: support let expressions with injections
This commit is contained in:
parent
8486f9144e
commit
a80557e142
2 changed files with 93 additions and 0 deletions
|
|
@ -59,6 +59,13 @@
|
|||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])
|
||||
|
||||
; Let expressions
|
||||
; extraConfigLua = let x = ...; in ''...''
|
||||
(let_expression body: [
|
||||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])
|
||||
]
|
||||
(#any-of? @_path "__raw" "extraConfigLua" "extraConfigLuaPre" "extraConfigLuaPost")
|
||||
(#set! injection.language "lua"))
|
||||
|
|
@ -97,6 +104,13 @@
|
|||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])))))
|
||||
|
||||
; Let expressions
|
||||
; luaConfig = { pre = let x = ...; in ''...'' }
|
||||
(let_expression body: [
|
||||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])
|
||||
]
|
||||
(#any-of? @_nested "pre" "post" "content")
|
||||
)))
|
||||
|
|
@ -134,6 +148,13 @@
|
|||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])))))
|
||||
|
||||
; Let expressions
|
||||
; luaConfig.pre = let x = ...; in ''...''
|
||||
(let_expression body: [
|
||||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])
|
||||
]
|
||||
(#eq? @ns "luaConfig")
|
||||
(#any-of? @name "pre" "post" "content")
|
||||
|
|
@ -182,6 +203,13 @@
|
|||
(indented_string_expression (string_fragment) @injection.content)
|
||||
]))
|
||||
]))
|
||||
|
||||
; Let expressions
|
||||
; extraConfigVim = let x = ...; in ''...''
|
||||
(let_expression body: [
|
||||
(string_expression (string_fragment) @injection.content)
|
||||
(indented_string_expression (string_fragment) @injection.content)
|
||||
])
|
||||
]
|
||||
(#any-of? @_path "extraConfigVim" "extraConfigVimPre" "extraConfigVimPost")
|
||||
(#set! injection.language "vim"))
|
||||
|
|
|
|||
|
|
@ -228,4 +228,69 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 10: Let expressions
|
||||
# ============================================================================
|
||||
section10 = {
|
||||
# Basic let expression with extraConfigLua
|
||||
extraConfigLua =
|
||||
let
|
||||
configPath = "${pkgs.neovim}/share/nvim";
|
||||
in
|
||||
''
|
||||
local config_path = "${configPath}"
|
||||
vim.opt.runtimepath:append(config_path)
|
||||
'';
|
||||
|
||||
# Let expression with luaConfig nested attrset
|
||||
luaConfig = {
|
||||
pre =
|
||||
let
|
||||
pluginPath = "${pkgs.vimPlugins.telescope-nvim}";
|
||||
in
|
||||
''
|
||||
vim.g.telescope_path = "${pluginPath}"
|
||||
'';
|
||||
};
|
||||
|
||||
# Let expression with dot notation
|
||||
luaConfig.post =
|
||||
let
|
||||
java-debug = "${pkgs.vscode-extensions.vscjava.vscode-java-debug}/share/vscode/extensions/vscjava.vscode-java-debug/server";
|
||||
java-test = "${pkgs.vscode-extensions.vscjava.vscode-java-test}/share/vscode/extensions/vscjava.vscode-java-test/server";
|
||||
in
|
||||
''
|
||||
local jdtls = require("jdtls")
|
||||
local jdtls_dap = require("jdtls.dap")
|
||||
local jdtls_setup = require("jdtls.setup")
|
||||
|
||||
_M.jdtls = {}
|
||||
_M.jdtls.bundles = {}
|
||||
|
||||
local java_debug_bundle = vim.split(vim.fn.glob("${java-debug}" .. "/*.jar"), "\n")
|
||||
local java_test_bundle = vim.split(vim.fn.glob("${java-test}" .. "/*.jar", true), "\n")
|
||||
|
||||
-- add jars to the bundle list if there are any
|
||||
if java_debug_bundle[1] ~= "" then
|
||||
vim.list_extend(_M.jdtls.bundles, java_debug_bundle)
|
||||
end
|
||||
|
||||
if java_test_bundle[1] ~= "" then
|
||||
vim.list_extend(_M.jdtls.bundles, java_test_bundle)
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
# Let expression with vim config
|
||||
section11 = {
|
||||
extraConfigVim =
|
||||
let
|
||||
customPath = "/custom/vim/config";
|
||||
in
|
||||
''
|
||||
set runtimepath+=${customPath}
|
||||
let g:custom_path = '${customPath}'
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue