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.config = function(--[[plugin]]_, --[[opts]]_)
require('fidget').setup {
M.opts = {
text = {
done = require('fschauen.icons').ui.Checkmark,
spinner = {
@ -25,17 +24,10 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
'▱▱▱▱▱▱▰',
},
},
timer = {
spinner_rate = 75,
},
window = {
blend = 50,
},
fmt = {
max_messages = 10,
timer = { spinner_rate = 75 },
window = { blend = 50 },
fmt = { max_messages = 10 }
}
}
end
return M

View file

@ -1,9 +1,6 @@
local M = { 'tpope/vim-fugitive' }
M.cmd = {
'G',
'Git',
}
M.cmd = { 'G', 'Git' }
M.keys = {
{ '<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' },
}
M.config = function(--[[plugin]]_, --[[opts]]_)
require('gitlinker').setup {
mappings = nil, -- I'm defining me own mappings above.
M.opts = function(--[[plugin]]_, opts)
return vim.tbl_deep_extend('force', opts, {
mappings = nil, -- I'm defining my own mappings above.
callbacks = {
['git.schauenburg.me'] = require('gitlinker.hosts').get_gitea_type_url,
},
}
})
end
return M

View file

@ -1,22 +1,5 @@
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 = {
'IBLEnable',
'IBLDisable',
@ -31,4 +14,22 @@ M.keys = {
{ '<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

View file

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

View file

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

View file

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

View file

@ -9,29 +9,27 @@ M.keys = {
{ '<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')
require('nvim-tree').setup {
return vim.tbl_deep_extend('force', opts, {
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
on_attach = function(buffer)
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>.
api.config.mappings.default_on_attach(buffer)
vim.keymap.del('n', '<c-x>', { buffer = buffer })
map('n', 'l', api.node.open.edit, opts('Open'))
map('n', '<cr>', api.node.open.edit, opts('Open'))
map('n', '<c-s>', api.node.open.horizontal, opts('Open: Horizontal Split'))
map('n', 'h', api.node.navigate.parent_close, opts('Close directory'))
local opt = function(desc)
return { desc = '󰙅 nvim-tree: ' .. desc, buffer = buffer, silent = true }
end
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,
git = {
@ -79,7 +77,7 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
},
},
},
}
})
end
return M

View file

@ -1,8 +1,6 @@
local M = { 'nvim-telescope/telescope-file-browser.nvim' }
M.dependencies = {
'nvim-telescope/telescope.nvim',
}
M.dependencies = { 'nvim-telescope/telescope.nvim' }
M.keys = {
{ '<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 ') },
}
local icons = require('fschauen.icons')
M.config = function(--[[plugin]]_, --[[opts]]_)
M.opts = function(--[[plugin]]_, opts)
local actions = require('telescope.actions')
local layout = require('telescope.actions.layout')
local icons = require('fschauen.icons')
local trouble = vim.F.npcall(require, 'trouble.providers.telescope') or {}
local mappings = {
@ -145,12 +144,9 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
['<c-b>'] = trouble.smart_open_with_trouble,
}
require('telescope').setup {
return vim.tbl_deep_extend('force', opts, {
defaults = {
mappings = {
i = mappings,
n = mappings,
},
mappings = { i = mappings, n = mappings },
prompt_prefix = '',
selection_caret = icons.ui.Play .. ' ',
@ -172,11 +168,7 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
},
pickers = {
buffers = {
mappings = {
n = {
x = actions.delete_buffer,
},
},
mappings = { n = { x = actions.delete_buffer } },
},
colorscheme = {
theme = 'dropdown',
@ -190,10 +182,13 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
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', {
desc = 'Enable line number in Telescope previewers.',
group = vim.api.nvim_create_augroup('fschauen.telescope', { clear = true } ),

View file

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

View file

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

View file

@ -1,8 +1,6 @@
local M = { 'folke/trouble.nvim' }
M.dependencies = {
'nvim-tree/nvim-web-devicons',
}
M.dependencies = { 'nvim-tree/nvim-web-devicons' }
M.keys = {
{ '<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' },
}
M.config = function(--[[plugin]]_, --[[opts]]_)
require('trouble').setup {
M.opts = {
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

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

View file

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

View file

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