-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About improvement of user customization experience. #888
Comments
ccording to #885 (review) , an override that does not rely on LazyNvim is likely necessary.
|
Maybe we can take a look at https://github.com/LazyVim/LazyVim/tree/main, imitate its behavior or develop based on it. |
Hmm I don't feel like things are gonna work this way. Cause compared to IMO this is not that viable regarding our current situation, but we can further discuss its feasibility as well 😄
cc @fecet |
Maybe we can discuss what's the best way to do custom config based on current setup. For me I forked this and do rebase from time to time,I don't really like this as I often have to deal with various conflicts. If would be better IMO if adding or removing plugins are happen at files level (not tables), but I guess there is some better approach |
Yeah that's sort of what we're going to implement. Quoting #885 (review):
|
My point is, if we have to refactor the code anyway, we can choose to adopt the approach of lazyvim, which seems more user-friendly (for regular users) and easier to develop and we can get free upstrem update(they appear to be very activte). Otherwise, I would rather keep the current configuration. One significant advantage of lazyvim I would like to mention is that it allows us to include some niche plugins as extras, and users can choose whether to import them or not. I dont really understand why
for neovim distributionn as I never use any of them, but lazyvim seems possible to do so? |
Yeah FWIW we are planning to use similar logic compared with If this is an existing plugin:Create a new file with the same name as the parent spec in Example:
(Parent spec [in the future(?)]:) return function()
local opts = {
show_jumps = true,
min_jump = 10,
popup = {
delay_ms = 0, -- delay before popup displays
inc_ms = 10, -- time increments used for fade/resize effects
blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend
width = 10,
winhl = "PmenuSbar",
fader = require("specs").pulse_fader,
resizer = require("specs").shrink_resizer,
},
ignore_filetypes = {},
ignore_buftypes = { nofile = true },
}
require("...").load_plugin("specs", opts)
end (Steps:)
2.1. I want to set -- Other configs... (new autocmds, usercmds, etc.)
return {
popup = {
delay_ms = 20,
}
}
2.2. I want to customize this plugin myself: return function(opts) -- This is the parent spec in case the user want to have some references
-- Other configs... (new autocmds, usercmds, etc.)
opts.show_jumps = true
-- OR (complete replacement) --
opts = { show_jumps = true }
end And 2.3 I want to disable this plugin: return nil Nothing will happen then. If this is a new plugin:Similar to
@fecet Does this make things a bit clearer? |
I think this would be really nice, I'm buying it lol |
Yes I like this way. But I'm wondering why our config is I think the correct way is use |
Sorry for the misleading wording - the main focus here is |
@Jint-lzxy
@fecet
step.2
The current PR does not support full overrides. |
The key point is here (lazy.nvim/lua/lazy/core/plugin.lua):
Because we are using a custom loader, the relative order in which plugins appear internally (inside |
Great! I feel like we are moving in the right direction. I still haven't find time to dig into lazyvim, is it possible to use our custom loader and import extras from lazyvim? So the config will look like require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "ayamir/nvimdots", import = "nvim.plugins" },
-- import any extras modules here
{ import = "lazyvim.plugins.extras.lang.typescript" },
-- { import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
-- import/override with your plugins
{ import = "plugins" },
}, I have many plugins that not suitable to add in main config but could be helpful for someone so it's good to have a |
Yeah it's possible. |
I thought of a function that would allow the user to override the plugin's options without making major changes to the current configuration.
---@param plugin_name string @Plugin name
---@param opts table @Default options for plugin
---@param isVimPlugin? boolean @If plugin is made by vimscript
---@param extraSetupFunc? function @When the plugin name that calls setup is different from `modules/configs/*.lua`
function M.load_plugin(plugin_name, opts, isVimPlugin, extraSetupFunc)
isVimPlugin = isVimPlugin or false
local ok, custom = pcall(require, "user.modules." .. plugin_name)
if ok then
local setupFunc = extraSetupFunc or require(plugin_name).setup
if custom == nil then
setupFunc(false)
elseif type(custom) == "table" then
assert(
not isVimPlugin,
"This plugin is not made by lua, so define options in functions (probably using `vim.g.*`)"
)
opts = vim.tbl_deep_extend("force", opts, custom)
setupFunc(opts)
elseif type(custom) == "function" then
local user_opts = custom()
if type(user_opts) == "table" and not isVimPlugin then
setupFunc(user_opts)
end
else
error(
"Please return `nil` if you disable plugin or `table` if you override config or `function` if you replace config completely "
)
end
elseif isVimPlugin then
else
local setupFunc = extraSetupFunc or require(plugin_name).setup
setupFunc(opts)
end
end |
You can isolate your own plugins by adding two lines to local get_plugins_list = function()
local list = {}
local plugins_list = vim.split(fn.glob(modules_dir .. "/plugins/*.lua"), "\n")
local user_plugins_list = vim.split(fn.glob(user_modules_dir .. "/plugins/*.lua"), "\n")
plugins_list = vim.list_extend(plugins_list, user_plugins_list) Since the user definition is added to the end of the list, you can also disable the plugin using the following method. local ui = {}
ui["goolord/alpha-nvim"] = {
enabled = false,
}
return ui |
IMO we have to think a bit about overriding keymap. |
I have implemented an override that does not significantly change the current file and directory structure. Could you please give me a review if possible? |
In 372d3c9 I introduced a |
Feature description
This is a suggestion regarding #885.
It contains major changes across the board.
Other suggestions welcome..
I'm looking for a way that doesn't change the original configuration too much.
Work is done at misumisumi/nvimdots/add-user-custom-function.
load_plugin
functionevent.lua
options.lua
settings.lua
keymap.lua
Additional information
No response
The text was updated successfully, but these errors were encountered: