nvim: use opts and config consistently for all plugins

This commit is contained in:
Fernando Schauenburg 2024-07-21 22:16:25 +02:00
parent 965173484f
commit 8dc1dd324a
10 changed files with 133 additions and 145 deletions

View file

@ -37,12 +37,14 @@ return {
-- stylua: ignore end -- stylua: ignore end
}, },
opts = function(_, opts) -- This really does need to be a function, because we need to defer requiring
return vim.tbl_deep_extend("force", opts or {}, { -- the `gitlinker.hosts` module until after the plugin is loaded.
opts = function()
return {
mappings = nil, -- I'm defining my 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,
} }

View file

@ -5,7 +5,7 @@ return {
ft = "markdown", ft = "markdown",
config = function() opts = function()
-- These work well with gruvbox. -- These work well with gruvbox.
vim.cmd([[highlight Headline1 guibg=#161613]]) vim.cmd([[highlight Headline1 guibg=#161613]])
vim.cmd([[highlight Headline2 guibg=#191915]]) vim.cmd([[highlight Headline2 guibg=#191915]])
@ -16,7 +16,7 @@ return {
vim.cmd([[highlight Quote guifg=#076678]]) vim.cmd([[highlight Quote guifg=#076678]])
vim.cmd([[highlight Dash guifg=#d5c4a1]]) vim.cmd([[highlight Dash guifg=#d5c4a1]])
require("headlines").setup { return {
markdown = { markdown = {
headline_highlights = { headline_highlights = {
"Headline1", "Headline1",

View file

@ -14,15 +14,14 @@ return {
keys = { keys = {
-- stylua: ignore start -- stylua: ignore start
{ "<leader>si", "<cmd>IBLToggle<cr>", desc = ui.Toggle.." toggle indent lines" }, { "<leader>si", "<cmd>IBLToggle<cr>", desc = ui.Toggle.." toggle [i]ndent lines" },
{ "<leader>so", "<cmd>IBLToggleScope<cr>", desc = ui.Toggle.." toggle indent line scope" }, { "<leader>so", "<cmd>IBLToggleScope<cr>", desc = ui.Toggle.." toggle indent line sc[o]pe" },
-- stylua: ignore end -- stylua: ignore end
}, },
main = "ibl", main = "ibl",
opts = function(_, opts) opts = {
return vim.tbl_deep_extend("force", opts or {}, {
enabled = false, enabled = false,
indent = { char = ui.LineLeft }, indent = { char = ui.LineLeft },
scope = { scope = {
@ -31,6 +30,5 @@ return {
show_start = false, show_start = false,
show_end = false, show_end = false,
}, },
}) },
end,
} }

View file

@ -20,19 +20,17 @@ local lsp_handlers = function()
end end
local lsp_on_attach = function(--[[client]]_, buffer) local lsp_on_attach = function(--[[client]]_, buffer)
local map = vim.keymap.set local map, opts = vim.keymap.set, { buffer = buffer }
local opts = { buffer = buffer }
local buf = vim.lsp.buf
-- stylua: ignore start -- stylua: ignore start
map("n", "<localleader>c", buf.code_action, opts) map("n", "<localleader>c", vim.lsp.buf.code_action, opts)
map("n", "<localleader>f", buf.format, opts) map("n", "<localleader>f", vim.lsp.buf.format, opts)
map("n", "gd", buf.definition, opts) map("n", "gd", vim.lsp.buf.definition, opts)
map("n", "gD", buf.declaration, opts) map("n", "gD", vim.lsp.buf.declaration, opts)
map("n", "gi", buf.implementation, opts) map("n", "gi", vim.lsp.buf.implementation, opts)
map("n", "grr", buf.rename, opts) map("n", "grr", vim.lsp.buf.rename, opts)
map("n", "gt", buf.type_definition, opts) map("n", "gt", vim.lsp.buf.type_definition, opts)
map("n", "K", buf.hover, opts) map("n", "K", vim.lsp.buf.hover, opts)
map("i", "<c-l>", buf.signature_help, opts) map("i", "<c-l>", vim.lsp.buf.signature_help, opts)
-- stylua: ignore end -- stylua: ignore end
end end

View file

@ -11,8 +11,7 @@ return {
{ "<leader>gs", "<cmd>Neogit<cr>", desc = ui.Git .. " [s]tatus (Neogit)" }, { "<leader>gs", "<cmd>Neogit<cr>", desc = ui.Git .. " [s]tatus (Neogit)" },
}, },
opts = function(_, opts) opts = {
return vim.tbl_deep_extend("force", opts or {}, {
commit_editor = { kind = "tab" }, commit_editor = { kind = "tab" },
disable_hint = true, disable_hint = true,
signs = { signs = {
@ -35,6 +34,5 @@ return {
["="] = "Toggle", ["="] = "Toggle",
}, },
}, },
}) },
end,
} }

View file

@ -30,9 +30,11 @@ return {
lazy = false, lazy = false,
opts = function(_, opts) config = function()
local notify = require("notify")
local icons = require("fschauen.util.icons") local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend("force", opts or {}, {
notify.setup {
icons = { icons = {
ERROR = icons.diagnostics_bold.Error, ERROR = icons.diagnostics_bold.Error,
WARN = icons.diagnostics_bold.Warn, WARN = icons.diagnostics_bold.Warn,
@ -48,12 +50,8 @@ return {
time_formats = { time_formats = {
notification_history = "%F %T │ ", notification_history = "%F %T │ ",
}, },
}) }
end,
config = function(_, opts)
local notify = require("notify")
notify.setup(opts)
vim.notify = notify vim.notify = notify
end, end,
} }

View file

@ -22,7 +22,7 @@ local on_attach = function(buffer)
-- stylua: ignore end -- stylua: ignore end
end end
local icon = require("fschauen.util.icons").ui.FileTree local icons = require("fschauen.util.icons")
return { return {
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
@ -31,14 +31,12 @@ return {
keys = { keys = {
-- stylua: ignore start -- stylua: ignore start
{ "<leader>tt", "<cmd>NvimTreeToggle<cr>", desc = icon.." [t]oggle [t]ree" }, { "<leader>tt", "<cmd>NvimTreeToggle<cr>", desc = icons.ui.FileTree.." [t]oggle [t]ree" },
{ "<leader>tf", "<cmd>NvimTreeFindFile<cr>", desc = icon.." Open [t]ree to current [f]ile " }, { "<leader>tf", "<cmd>NvimTreeFindFile<cr>", desc = icons.ui.FileTree.." Open [t]ree to current [f]ile " },
-- stylua: ignore end -- stylua: ignore end
}, },
opts = function( --[[plugin]]_, opts) opts = {
local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend("force", opts or {}, {
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
@ -88,6 +86,5 @@ return {
}, },
}, },
}, },
}) },
end,
} }

View file

@ -102,7 +102,7 @@ return {
-- stylua: ignore end -- stylua: ignore end
}, },
opts = function(_, opts) opts = function()
local actions = require("telescope.actions") local actions = require("telescope.actions")
local layout = require("telescope.actions.layout") local layout = require("telescope.actions.layout")
local state = require("telescope.actions.state") local state = require("telescope.actions.state")
@ -135,7 +135,7 @@ return {
["<c-l>"] = actions.smart_send_to_loclist + actions.open_loclist, ["<c-l>"] = actions.smart_send_to_loclist + actions.open_loclist,
} }
return vim.tbl_deep_extend("force", opts or {}, { return {
defaults = { defaults = {
mappings = { i = mappings, n = mappings }, mappings = { i = mappings, n = mappings },
@ -170,7 +170,7 @@ return {
colorscheme = { theme = "dropdown" }, colorscheme = { theme = "dropdown" },
spell_suggest = { theme = "cursor" }, spell_suggest = { theme = "cursor" },
}, },
}) }
end, end,
config = function(_, opts) config = function(_, opts)

View file

@ -1,3 +1,5 @@
local ui = require("fschauen.util.icons").ui
local helper = require("fschauen.plugins.telescope").keymap_helper local helper = require("fschauen.plugins.telescope").keymap_helper
local lhs, desc = helper.lhs, helper.description local lhs, desc = helper.lhs, helper.description
@ -15,17 +17,15 @@ return {
{ lhs("t"), "<cmd>TodoTelescope<cr>", desc = desc("[t]odos") }, { lhs("t"), "<cmd>TodoTelescope<cr>", desc = desc("[t]odos") },
}, },
opts = function(_, opts) opts = {
local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend("force", opts or {}, {
keywords = { keywords = {
TODO = { icon = icons.ui.Checkbox }, TODO = { icon = ui.Checkbox },
FIX = { icon = icons.ui.Bug }, FIX = { icon = ui.Bug },
HACK = { icon = icons.ui.Fire }, HACK = { icon = ui.Fire },
WARN = { icon = icons.ui.Warning }, WARN = { icon = ui.Warning },
PERF = { icon = icons.ui.Gauge }, PERF = { icon = ui.Gauge },
NOTE = { icon = icons.ui.Note }, NOTE = { icon = ui.Note },
TEST = { icon = icons.ui.TestTube }, TEST = { icon = ui.TestTube },
}, },
gui_style = { fg = "bold" }, gui_style = { fg = "bold" },
highlight = { highlight = {
@ -34,6 +34,5 @@ return {
keyword = "wide_fg", keyword = "wide_fg",
after = "", after = "",
}, },
}) },
end,
} }

View file

@ -17,9 +17,7 @@ return {
{ "<leader>sc", toggle_colorcolumn, desc = ui.Toggle .. " toggle virtual colunn" }, { "<leader>sc", toggle_colorcolumn, desc = ui.Toggle .. " toggle virtual colunn" },
}, },
opts = function(_, opts) opts = {
return vim.tbl_deep_extend("force", opts or {}, {
char = ui.LineMiddle, char = ui.LineMiddle,
}) },
end,
} }