string or function in setup and config keys #474
-
Are there any downsides/upsides with using either strings or functions in the For example I'm thinking if I should do things like: use { -- packer can manage itself as an optional plugin {{{
'wbthomason/packer.nvim',
module = 'packer',
config = 'require("plugin_settings.packer")', -- where plugin_settings/packer.lua contains what's below
} -- }}} or use { -- packer can manage itself as an optional plugin {{{
'wbthomason/packer.nvim',
module = 'packer',
config = function() -- {{{
local keymap = {
p = {
name = "plugin",
d = {"<Cmd>PackerClean<CR>", "packer clean"},
c = {"<Cmd>PackerCompile<CR>", "packer compile"},
i = {"<Cmd>PackerInstall<CR>", "packer install"},
l = {"<Cmd>PackerLoad<CR>", "packer load"},
p = {
name = 'profile',
p = {"<Cmd>PackerProfile<CR>", "packer profile"},
},
s = {"<Cmd>PackerStatus<CR>", "packer status"},
S = {"<Cmd>PackerSync<CR>", "packer sync"},
u = {"<Cmd>PackerUpdate<CR>", "packer update"},
}
}
require("which-key").register(keymap, {prefix = '<leader>', silent = false})
end, -- }}}
} -- }}} Would you say there is any difference? Or would you recommend some other third way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The short answer is "not really". It largely depends on how you like to organize your config. For instance, if you provide a string Hope this helps, and sorry for the delay! |
Beta Was this translation helpful? Give feedback.
The short answer is "not really". It largely depends on how you like to organize your config. For instance, if you provide a string
require
ing some other file, then you don't need to recompile to change your configuration. However, if you prefer to have all your configuration in one place and decrease the number ofrequire
s (which can have a small time cost) in your config, then using a function may be better (this becomes more true once I get to the PR making recompilation automatic). There shouldn't be any significant difference in loading time between the two, though, again, this may change with the aforementioned PR (which may make the function style slightly faster; I'll have to expe…