vim: make it easy to reload plugin configs with :lua R('...').config()

This commit is contained in:
Fernando Schauenburg 2023-08-18 00:05:47 +02:00
parent 350d0073f7
commit b185ac5311
8 changed files with 177 additions and 168 deletions

View file

@ -9,7 +9,8 @@ M.lazy = false -- trows an error when lazy loading
local chars = { '', '¦', '', '', '', '', '', '', '', '' }
local show_first_level = false
M.opts = {
M.config = function()
require('indent_blankline').setup {
enabled = false,
use_treesitter = true,
show_first_indent_level = show_first_level,
@ -18,6 +19,7 @@ M.opts = {
char_list = chars,
context_char_list = chars,
indent_level = #chars + (not show_first_level and 1 or 0),
}
}
end
return M

View file

@ -8,7 +8,8 @@ M.keys = {
{ '<leader>gn', '<cmd>Neogit<cr>' },
}
M.opts = {
M.config = function()
require('neogit').setup {
disable_hint = true,
signs = {
section = { '', '' },
@ -21,7 +22,8 @@ M.opts = {
['='] = 'Toggle',
},
},
}
}
end
return M

View file

@ -10,7 +10,8 @@ M.keys = {
{ '<leader>nc', '<cmd>NvimTreeClose<cr>' },
}
M.opts = {
M.config = function()
require('nvim-tree').setup {
disable_netrw = true, -- replace netrw with nvim-tree
hijack_cursor = true, -- keep the cursor on begin of the filename
sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree
@ -71,7 +72,8 @@ M.opts = {
},
},
},
}
}
end
return M

View file

@ -118,7 +118,7 @@ M.keys = {
{ '<leader>f<leader>', pickers.resume '󰐎 Resume' , desc = ' Telescope Resume ' },
}
M.opts = function()
M.config = function()
local actions = require('telescope.actions')
local layout = require('telescope.actions.layout')
local trouble = vim.F.npcall(require, 'trouble.providers.telescope') or {}
@ -136,7 +136,7 @@ M.opts = function()
['<c-b>'] = trouble.smart_open_with_trouble,
}
return {
require('telescope').setup {
defaults = {
mappings = {
i = mappings,
@ -182,10 +182,7 @@ M.opts = function()
},
},
}
end
M.config = function(_, opts)
require('telescope').setup(opts)
require('telescope').load_extension 'fzf'
vim.api.nvim_create_autocmd('User', {

View file

@ -14,7 +14,8 @@ M.keys = {
{ '<leader>ft', '<cmd>TodoTelescope<cr>' },
}
M.opts = {
M.config = function()
require('todo-comments').setup {
keywords = {
TODO = { icon = '󰄬 ' },
FIX = { icon = '' },
@ -24,7 +25,8 @@ M.opts = {
NOTE = { icon = '' },
TEST = { icon = '󰙨 ' },
},
}
}
end
return M

View file

@ -27,9 +27,8 @@ M.keys = {
{ '<leader>tn', '<cmd>TSNodeUnderCursor<cr>' },
}
M.main = 'nvim-treesitter.configs'
M.opts = {
M.config = function()
require('nvim-treesitter.configs').setup {
ensure_installed = {
'bash',
'c',
@ -104,7 +103,8 @@ M.opts = {
playground = {
enable = true,
},
}
}
end
return M

View file

@ -10,10 +10,12 @@ M.keys = {
{ '<leader>ld', '<cmd>TroubleToggle document_diagnostics<cr>' },
}
M.opts = {
M.config = function()
require('trouble').setup {
padding = false, -- don't add an extra new line of top of the list
auto_preview = false, -- don't preview automatically
}
}
end
return M

View file

@ -17,9 +17,11 @@ M.keys = {
{ '<leader>sc', toggle_colorcolumn, desc = 'Toggle virtual colunn' },
}
M.opts = {
M.config = function()
require('virt-column').setup {
char = '',
}
}
end
return M