vim: use the opts key in plugin specs where possible

This commit is contained in:
Fernando Schauenburg 2024-02-18 01:46:46 +01:00
parent 5286b9f987
commit 5f2dd220d9
17 changed files with 96 additions and 143 deletions

View file

@ -4,8 +4,7 @@ M.branch = 'legacy'
M.event = 'LspAttach' M.event = 'LspAttach'
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = {
require('fidget').setup {
text = { text = {
done = require('fschauen.icons').ui.Checkmark, done = require('fschauen.icons').ui.Checkmark,
spinner = { spinner = {
@ -25,17 +24,10 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
'▱▱▱▱▱▱▰', '▱▱▱▱▱▱▰',
}, },
}, },
timer = { timer = { spinner_rate = 75 },
spinner_rate = 75, window = { blend = 50 },
}, fmt = { max_messages = 10 }
window = {
blend = 50,
},
fmt = {
max_messages = 10,
} }
}
end
return M return M

View file

@ -1,9 +1,6 @@
local M = { 'tpope/vim-fugitive' } local M = { 'tpope/vim-fugitive' }
M.cmd = { M.cmd = { 'G', 'Git' }
'G',
'Git',
}
M.keys = { M.keys = {
{ '<leader>gS', '<cmd>tab Git<cr>', desc = ' [S]status with fugitive' }, { '<leader>gS', '<cmd>tab Git<cr>', desc = ' [S]status with fugitive' },

View file

@ -26,14 +26,13 @@ M.keys = {
{ '<leader>gL', browser('v'), desc = ' open perma[L]ink in browser', mode = 'v' }, { '<leader>gL', browser('v'), desc = ' open perma[L]ink in browser', mode = 'v' },
} }
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = function(--[[plugin]]_, opts)
require('gitlinker').setup { return vim.tbl_deep_extend('force', opts, {
mappings = nil, -- I'm defining me own mappings above. mappings = nil, -- I'm defining my own mappings above.
callbacks = { callbacks = {
['git.schauenburg.me'] = require('gitlinker.hosts').get_gitea_type_url, ['git.schauenburg.me'] = require('gitlinker.hosts').get_gitea_type_url,
}, },
} })
end end
return M return M

View file

@ -1,22 +1,5 @@
local M = { 'lukas-reineke/indent-blankline.nvim' } local M = { 'lukas-reineke/indent-blankline.nvim' }
local icons = require('fschauen.icons')
M.config = function(--[[plugin]]_, --[[opts]]_)
require('ibl').setup {
enabled = false,
indent = {
char = icons.ui.LineLeft,
},
scope = {
char = icons.ui.LineLeftBold,
enabled = false,
show_start = false,
show_end = false,
},
}
end
M.cmd = { M.cmd = {
'IBLEnable', 'IBLEnable',
'IBLDisable', 'IBLDisable',
@ -31,4 +14,22 @@ M.keys = {
{ '<leader>so', '<cmd>IBLToggleScope<cr>' }, { '<leader>so', '<cmd>IBLToggleScope<cr>' },
} }
M.main = 'ibl'
M.opts = function(--[[plugin]]_, opts)
local icons = require('fschauen.icons')
return vim.tbl_deep_extend('force', opts, {
enabled = false,
indent = {
char = icons.ui.LineLeft,
},
scope = {
char = icons.ui.LineLeftBold,
enabled = false,
show_start = false,
show_end = false,
},
})
end
return M return M

View file

@ -14,7 +14,7 @@ M.ft = {
'markdown', 'markdown',
} }
M.init = function(--[[plugin]]__) M.init = function(--[[plugin]]_)
vim.g.mkdp_theme = 'dark' vim.g.mkdp_theme = 'dark'
end end

View file

@ -2,18 +2,15 @@ local M = { 'NeogitOrg/neogit' }
M.cmd = 'Neogit' M.cmd = 'Neogit'
M.dependencies = { M.dependencies = { 'nvim-lua/plenary.nvim' }
'nvim-lua/plenary.nvim',
}
M.keys = { M.keys = {
{ '<leader>gs', '<cmd>Neogit<cr>', desc = ' [s]tatus with neogit' }, { '<leader>gs', '<cmd>Neogit<cr>', desc = ' [s]tatus with neogit' },
} }
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = function(--[[plugin]]_, opts)
local icons = require('fschauen.icons') local icons = require('fschauen.icons')
return vim.tbl_deep_extend('force', opts, {
require('neogit').setup {
disable_hint = true, disable_hint = true,
signs = { signs = {
section = { icons.ui.Folder, icons.ui.EmptyFolderOpen }, section = { icons.ui.Folder, icons.ui.EmptyFolderOpen },
@ -26,7 +23,7 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
['='] = 'Toggle', ['='] = 'Toggle',
}, },
}, },
} })
end end
return M return M

View file

@ -20,11 +20,9 @@ M.keys = {
M.lazy = false M.lazy = false
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = function(--[[plugin]]_, opts)
local icons = require('fschauen.icons') local icons = require('fschauen.icons')
local notify = require('notify') return vim.tbl_deep_extend('force', opts, {
notify.setup {
icons = { icons = {
ERROR = icons.diagnostics_bold.Error, ERROR = icons.diagnostics_bold.Error,
WARN = icons.diagnostics_bold.Warn, WARN = icons.diagnostics_bold.Warn,
@ -37,10 +35,13 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
minimum_width = 50, minimum_width = 50,
render = 'wrapped-compact', render = 'wrapped-compact',
stages = 'fade', stages = 'fade',
time_formats = { notification_history = '%F %T' }, time_formats = { notification_history = '%F %T' },
top_down = true, })
} end
M.config = function(--[[plugin]]_, opts)
local notify = require('notify')
notify.setup(opts)
vim.notify = notify vim.notify = notify
end end

View file

@ -9,29 +9,27 @@ M.keys = {
{ '<leader>tf', '<cmd>NvimTreeFindFile<cr>', desc = '󰙅 Open [t]ree to current [f]ile ' }, { '<leader>tf', '<cmd>NvimTreeFindFile<cr>', desc = '󰙅 Open [t]ree to current [f]ile ' },
} }
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = function(--[[plugin]]_, opts)
local icons = require('fschauen.icons') local icons = require('fschauen.icons')
return vim.tbl_deep_extend('force', opts, {
require('nvim-tree').setup {
disable_netrw = true, -- replace netrw with nvim-tree disable_netrw = true, -- replace netrw with nvim-tree
hijack_cursor = true, -- keep the cursor on begin of the filename hijack_cursor = true, -- keep the cursor on begin of the filename
sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree
on_attach = function(buffer) on_attach = function(buffer)
local api = require('nvim-tree.api') local api = require('nvim-tree.api')
local map = vim.keymap.set
local opts = function(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = buffer, silent = true }
end
-- Give me the default mappings except <c-x>, which I replace with <c-s>. -- Give me the default mappings except <c-x>, which I replace with <c-s>.
api.config.mappings.default_on_attach(buffer) api.config.mappings.default_on_attach(buffer)
vim.keymap.del('n', '<c-x>', { buffer = buffer }) vim.keymap.del('n', '<c-x>', { buffer = buffer })
map('n', 'l', api.node.open.edit, opts('Open')) local opt = function(desc)
map('n', '<cr>', api.node.open.edit, opts('Open')) return { desc = '󰙅 nvim-tree: ' .. desc, buffer = buffer, silent = true }
map('n', '<c-s>', api.node.open.horizontal, opts('Open: Horizontal Split')) end
map('n', 'h', api.node.navigate.parent_close, opts('Close directory')) vim.keymap.set('n', 'l', api.node.open.edit, opt('Open'))
vim.keymap.set('n', '<cr>', api.node.open.edit, opt('Open'))
vim.keymap.set('n', '<c-s>', api.node.open.horizontal, opt('Open: Horizontal Split'))
vim.keymap.set('n', 'h', api.node.navigate.parent_close, opt('Close directory'))
end, end,
git = { git = {
@ -79,7 +77,7 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
}, },
}, },
}, },
} })
end end
return M return M

View file

@ -1,8 +1,6 @@
local M = { 'nvim-telescope/telescope-file-browser.nvim' } local M = { 'nvim-telescope/telescope-file-browser.nvim' }
M.dependencies = { M.dependencies = { 'nvim-telescope/telescope.nvim' }
'nvim-telescope/telescope.nvim',
}
M.keys = { M.keys = {
{ '<leader>fB', '<cmd>Telescope file_browser<cr>' , desc = ' Telescope file [B]rowser' }, { '<leader>fB', '<cmd>Telescope file_browser<cr>' , desc = ' Telescope file [B]rowser' },

View file

@ -122,11 +122,10 @@ M.keys = {
{ '<leader>f<leader>', pickers.resume '󰐎 Resume' , desc = desc('Resume ') }, { '<leader>f<leader>', pickers.resume '󰐎 Resume' , desc = desc('Resume ') },
} }
local icons = require('fschauen.icons') M.opts = function(--[[plugin]]_, opts)
M.config = function(--[[plugin]]_, --[[opts]]_)
local actions = require('telescope.actions') local actions = require('telescope.actions')
local layout = require('telescope.actions.layout') local layout = require('telescope.actions.layout')
local icons = require('fschauen.icons')
local trouble = vim.F.npcall(require, 'trouble.providers.telescope') or {} local trouble = vim.F.npcall(require, 'trouble.providers.telescope') or {}
local mappings = { local mappings = {
@ -145,12 +144,9 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
['<c-b>'] = trouble.smart_open_with_trouble, ['<c-b>'] = trouble.smart_open_with_trouble,
} }
require('telescope').setup { return vim.tbl_deep_extend('force', opts, {
defaults = { defaults = {
mappings = { mappings = { i = mappings, n = mappings },
i = mappings,
n = mappings,
},
prompt_prefix = '', prompt_prefix = '',
selection_caret = icons.ui.Play .. ' ', selection_caret = icons.ui.Play .. ' ',
@ -172,11 +168,7 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
}, },
pickers = { pickers = {
buffers = { buffers = {
mappings = { mappings = { n = { x = actions.delete_buffer } },
n = {
x = actions.delete_buffer,
},
},
}, },
colorscheme = { colorscheme = {
theme = 'dropdown', theme = 'dropdown',
@ -190,10 +182,13 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
theme = 'ivy' theme = 'ivy'
}, },
}, },
} })
end
require('telescope').load_extension 'fzf'
M.config = function(--[[plugin]]_, opts)
require('telescope').setup(opts)
require('telescope').load_extension('fzf')
vim.api.nvim_create_autocmd('User', { vim.api.nvim_create_autocmd('User', {
desc = 'Enable line number in Telescope previewers.', desc = 'Enable line number in Telescope previewers.',
group = vim.api.nvim_create_augroup('fschauen.telescope', { clear = true } ), group = vim.api.nvim_create_augroup('fschauen.telescope', { clear = true } ),

View file

@ -1,15 +1,8 @@
local M = { 'johmsalas/text-case.nvim' } local M = { 'johmsalas/text-case.nvim' }
M.event = { M.event = { 'BufReadPost', 'BufNewFile' }
'BufReadPost',
'BufNewFile',
}
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = { prefix = '<leader>c' }
require('textcase').setup {
prefix = '<leader>c',
}
end
return M return M

View file

@ -5,19 +5,15 @@ M.dependencies = {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
} }
M.event = { M.event = { 'BufReadPost', 'BufNewFile' }
'BufReadPost',
'BufNewFile'
}
M.keys = { M.keys = {
{ '<leader>ft', '<cmd>TodoTelescope<cr>', desc = ' Telescope [t]odos' }, { '<leader>ft', '<cmd>TodoTelescope<cr>', desc = ' Telescope [t]odos' },
} }
M.opts = function(--[[plugin]]_, opts)
local icons = require('fschauen.icons') local icons = require('fschauen.icons')
return vim.tbl_deep_extend('force', opts, {
M.config = function(--[[plugin]]_, --[[opts]]_)
require('todo-comments').setup {
keywords = { keywords = {
TODO = { icon = icons.ui.Checkbox }, TODO = { icon = icons.ui.Checkbox },
FIX = { icon = icons.ui.Bug }, FIX = { icon = icons.ui.Bug },
@ -27,7 +23,7 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
NOTE = { icon = icons.ui.Note }, NOTE = { icon = icons.ui.Note },
TEST = { icon = icons.ui.TestTube }, TEST = { icon = icons.ui.TestTube },
}, },
} })
end end
return M return M

View file

@ -1,8 +1,6 @@
local M = { 'folke/trouble.nvim' } local M = { 'folke/trouble.nvim' }
M.dependencies = { M.dependencies = { 'nvim-tree/nvim-web-devicons' }
'nvim-tree/nvim-web-devicons',
}
M.keys = { M.keys = {
{ '<leader>lt', '<cmd>TroubleToggle<cr>', desc = '󱠪 trouble [t]toggle' }, { '<leader>lt', '<cmd>TroubleToggle<cr>', desc = '󱠪 trouble [t]toggle' },
@ -10,12 +8,10 @@ M.keys = {
{ '<leader>ld', '<cmd>TroubleToggle document_diagnostics<cr>', desc = '󱠪 trouble [d]ocument' }, { '<leader>ld', '<cmd>TroubleToggle document_diagnostics<cr>', desc = '󱠪 trouble [d]ocument' },
} }
M.config = function(--[[plugin]]_, --[[opts]]_) M.opts = {
require('trouble').setup {
padding = false, -- don't add an extra new line of top of the list padding = false, -- don't add an extra new line of top of the list
auto_preview = false, -- don't preview automatically auto_preview = false, -- don't preview automatically
} }
end
return M return M

View file

@ -14,7 +14,5 @@ M.keys = {
{ '<leader>u', '<cmd>UndotreeToggle<cr>' }, { '<leader>u', '<cmd>UndotreeToggle<cr>' },
} }
M.config = false
return M return M

View file

@ -1,9 +1,6 @@
local M = { 'lukas-reineke/virt-column.nvim' } local M = { 'lukas-reineke/virt-column.nvim' }
M.event = { M.event = { 'BufReadPost', 'BufNewFile' }
'BufReadPost',
'BufNewFile'
}
local toggle_colorcolumn = function() local toggle_colorcolumn = function()
if vim.o.colorcolumn == '' then if vim.o.colorcolumn == '' then

View file

@ -10,10 +10,7 @@ M.init = function(--[[plugin]]_)
} }
end end
M.event = { M.event = { 'BufReadPost', 'BufNewFile' }
'BufReadPost',
'BufNewFile'
}
M.keys = { M.keys = {
{ '<leader>ww', '<cmd>ToggleWhitespace<cr>' }, { '<leader>ww', '<cmd>ToggleWhitespace<cr>' },
@ -22,7 +19,5 @@ M.keys = {
{ '<leader>W', '<cmd>StripWhitespace<cr>' }, { '<leader>W', '<cmd>StripWhitespace<cr>' },
} }
M.config = false
return M return M