This isn't a bug report, but rather a feature proposal/ discussion
Description
In the generated init.lua file, I'd like to be able add some lua code before/ after (or even inside) of a plugins setup() call to tidy up the generated file's structure.
Adding the code to extraCofnigLua or extraConfigLuaPre just adds tons of code to the top/ bottom of the init.lua and therefore doesn't creates any tight coupling between it and the plugin it's relevant or even necessary for. This goes against what I saw on some neovim setup and also should help human readers to understand the init.lua, which might be shown as a setup-reference to plain old neovim users.
Example
When trying to configure plugins.cmp, I'm in need of the following code snippet:
local symbols = {
Variable = '𝛸',
-- --snip--
}
local kinds = vim.lsp.protocol.CompletionItemKind
for i, kind in ipairs(kinds) do
kinds[i] = symbols[kind] or kind
end
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
I'm currently solving this as follows:
extraConfigLuaPre = builtins.readFile ./cmp.lua;
# https://github.com/hrsh7th/nvim-cmp
plugins.cmp = {
enable = true;
autoEnableSources = true;
settings = {
# __raw = builtins.readFile ./cmp.lua;
formatting.format = ''
function(entry, vim_item)
vim_item.kind = symbols[vim_item.kind]
vim_item.menu = '[' .. entry.source.name .. ']'
return vim_item
end
'';
# --snip--
};
};
This results in the symbols map being created beginning from line 36 and cmp from line 243, and my config is rather small atm...
Description
In the generated
init.luafile, I'd like to be able add some lua code before/ after (or even inside) of a pluginssetup()call to tidy up the generated file's structure.Adding the code to
extraCofnigLuaorextraConfigLuaPrejust adds tons of code to the top/ bottom of theinit.luaand therefore doesn't creates any tight coupling between it and the plugin it's relevant or even necessary for. This goes against what I saw on some neovim setup and also should help human readers to understand theinit.lua, which might be shown as a setup-reference to plain old neovim users.Example
When trying to configure
plugins.cmp, I'm in need of the following code snippet:I'm currently solving this as follows:
This results in the
symbolsmap being created beginning from line 36 andcmpfrom line 243, and my config is rather small atm...