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,23 +14,21 @@ 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,
indent = { char = ui.LineLeft },
scope = {
char = ui.LineLeftBold,
enabled = false, enabled = false,
indent = { char = ui.LineLeft }, show_start = false,
scope = { show_end = false,
char = ui.LineLeftBold, },
enabled = false, },
show_start = false,
show_end = false,
},
})
end,
} }

View file

@ -19,20 +19,18 @@ 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,30 +11,28 @@ 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 = { section = {
section = { ui.Folder,
ui.Folder, ui.EmptyFolderOpen,
ui.EmptyFolderOpen,
},
item = {
ui.ChevronRight,
ui.ChevronDown,
},
hunk = {
ui.ChevronSmallRight,
ui.ChevronSmallDown,
},
}, },
mappings = { item = {
status = { ui.ChevronRight,
o = "GoToFile", ui.ChevronDown,
["="] = "Toggle",
},
}, },
}) hunk = {
end, ui.ChevronSmallRight,
ui.ChevronSmallDown,
},
},
mappings = {
status = {
o = "GoToFile",
["="] = "Toggle",
},
},
},
} }

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,63 +31,60 @@ 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") disable_netrw = true, -- replace netrw with nvim-tree
return vim.tbl_deep_extend("force", opts or {}, { hijack_cursor = true, -- keep the cursor on begin of the filename
disable_netrw = true, -- replace netrw with nvim-tree sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree
hijack_cursor = true, -- keep the cursor on begin of the filename on_attach = on_attach,
sync_root_with_cwd = true, -- watch for `DirChanged` and refresh the tree git = {
on_attach = on_attach, ignore = false, -- don't hide files from .gitignore
git = { show_on_open_dirs = false, -- don't show indication if dir is open
ignore = false, -- don't hide files from .gitignore },
show_on_open_dirs = false, -- don't show indication if dir is open view = {
}, adaptive_size = true, -- resize the window based on the longest line
view = { cursorline = false, -- don't enable 'cursorline' in the tree
adaptive_size = true, -- resize the window based on the longest line width = 35, -- a little wider than the default 30
cursorline = false, -- don't enable 'cursorline' in the tree },
width = 35, -- a little wider than the default 30 filters = {
}, dotfiles = false, -- show files starting with a .
filters = { custom = { "^\\.git" }, -- don't show .git directory
dotfiles = false, -- show files starting with a . },
custom = { "^\\.git" }, -- don't show .git directory renderer = {
}, add_trailing = true, -- add trailing / to folders
renderer = { highlight_git = true, -- enable highlight based on git attributes
add_trailing = true, -- add trailing / to folders icons = {
highlight_git = true, -- enable highlight based on git attributes webdev_colors = false, -- highlight icons with NvimTreeFileIcon
icons = { git_placement = "signcolumn",
webdev_colors = false, -- highlight icons with NvimTreeFileIcon glyphs = {
git_placement = "signcolumn", default = icons.ui.File,
glyphs = { symlink = icons.ui.FileSymlink,
default = icons.ui.File, modified = icons.ui.Circle,
symlink = icons.ui.FileSymlink, folder = {
modified = icons.ui.Circle, arrow_closed = icons.ui.ChevronSmallRight,
folder = { arrow_open = icons.ui.ChevronSmallDown,
arrow_closed = icons.ui.ChevronSmallRight, default = icons.ui.Folder,
arrow_open = icons.ui.ChevronSmallDown, open = icons.ui.FolderOpen,
default = icons.ui.Folder, empty = icons.ui.EmptyFolder,
open = icons.ui.FolderOpen, empty_open = icons.ui.EmptyFolderOpen,
empty = icons.ui.EmptyFolder, symlink = icons.ui.FolderSymlink,
empty_open = icons.ui.EmptyFolderOpen, symlink_open = icons.ui.FolderSymlink,
symlink = icons.ui.FolderSymlink, },
symlink_open = icons.ui.FolderSymlink, git = {
}, untracked = icons.git.file.Untracked,
git = { unstaged = icons.git.file.Unstaged,
untracked = icons.git.file.Untracked, staged = icons.git.file.Staged,
unstaged = icons.git.file.Unstaged, deleted = icons.git.file.Deleted,
staged = icons.git.file.Staged, unmerged = icons.git.file.Unmerged,
deleted = icons.git.file.Deleted, renamed = icons.git.file.Renamed,
unmerged = icons.git.file.Unmerged, ignored = icons.git.file.Ignored,
renamed = icons.git.file.Renamed,
ignored = icons.git.file.Ignored,
},
}, },
}, },
}, },
}) },
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,25 +17,22 @@ 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") keywords = {
return vim.tbl_deep_extend("force", opts or {}, { TODO = { icon = ui.Checkbox },
keywords = { FIX = { icon = ui.Bug },
TODO = { icon = icons.ui.Checkbox }, HACK = { icon = ui.Fire },
FIX = { icon = icons.ui.Bug }, WARN = { icon = ui.Warning },
HACK = { icon = icons.ui.Fire }, PERF = { icon = ui.Gauge },
WARN = { icon = icons.ui.Warning }, NOTE = { icon = ui.Note },
PERF = { icon = icons.ui.Gauge }, TEST = { icon = ui.TestTube },
NOTE = { icon = icons.ui.Note }, },
TEST = { icon = icons.ui.TestTube }, gui_style = { fg = "bold" },
}, highlight = {
gui_style = { fg = "bold" }, multiline = false,
highlight = { before = "fg",
multiline = false, keyword = "wide_fg",
before = "fg", after = "",
keyword = "wide_fg", },
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,
} }