luaConfig question #3427
-
Hi, I just learned about and had a question about how to use I see that we have Ig, which is preferred? And is this lua code lazily loaded if we have lz-n enabled? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
The idea with Example from my config: jdtls = {
enable = true;
lazyLoad.settings.ft = "java";
luaConfig.pre =
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
# Lua
''
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
''; Custom unmanaged telescope extension loading with telescope {
config,
lib,
pkgs,
...
}:
{
extraPlugins = [
pkgs.vimPlugins.vs-tasks-nvim
];
plugins.telescope = {
luaConfig.post = ''
require("vstask").setup()
require("telescope").load_extension("vstask")
'';
};
keymaps = lib.mkIf (config.plugins.telescope.enable && (!config.plugins.overseer.enable)) [
{
mode = "n";
key = "<leader>RT";
action = "<cmd>Telescope vstask tasks<CR>";
options = {
desc = "Find tasks";
};
}
];
} |
Beta Was this translation helpful? Give feedback.
The idea with
luaConfig
is to allow per plugin custom lua injection into the final generated lua. Thepre
,content
, andpost
allow you to choose where to insert your custom lua code relative to the normal lua code provided by nixvim. Sometimes you want to inject configuration before the plugin gets intiialized and sometimes you have things you want to run right after.Example from my config: