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
},
opts = function(_, opts)
return vim.tbl_deep_extend("force", opts or {}, {
-- This really does need to be a function, because we need to defer requiring
-- the `gitlinker.hosts` module until after the plugin is loaded.
opts = function()
return {
mappings = nil, -- I'm defining my own mappings above.
callbacks = {
["git.schauenburg.me"] = require("gitlinker.hosts").get_gitea_type_url,
},
})
}
end,
}

View file

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

View file

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

View file

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

View file

@ -11,30 +11,28 @@ return {
{ "<leader>gs", "<cmd>Neogit<cr>", desc = ui.Git .. " [s]tatus (Neogit)" },
},
opts = function(_, opts)
return vim.tbl_deep_extend("force", opts or {}, {
commit_editor = { kind = "tab" },
disable_hint = true,
signs = {
section = {
ui.Folder,
ui.EmptyFolderOpen,
},
item = {
ui.ChevronRight,
ui.ChevronDown,
},
hunk = {
ui.ChevronSmallRight,
ui.ChevronSmallDown,
},
opts = {
commit_editor = { kind = "tab" },
disable_hint = true,
signs = {
section = {
ui.Folder,
ui.EmptyFolderOpen,
},
mappings = {
status = {
o = "GoToFile",
["="] = "Toggle",
},
item = {
ui.ChevronRight,
ui.ChevronDown,
},
})
end,
hunk = {
ui.ChevronSmallRight,
ui.ChevronSmallDown,
},
},
mappings = {
status = {
o = "GoToFile",
["="] = "Toggle",
},
},
},
}

View file

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

View file

@ -22,7 +22,7 @@ local on_attach = function(buffer)
-- stylua: ignore end
end
local icon = require("fschauen.util.icons").ui.FileTree
local icons = require("fschauen.util.icons")
return {
"nvim-tree/nvim-tree.lua",
@ -31,63 +31,60 @@ return {
keys = {
-- stylua: ignore start
{ "<leader>tt", "<cmd>NvimTreeToggle<cr>", desc = icon.." [t]oggle [t]ree" },
{ "<leader>tf", "<cmd>NvimTreeFindFile<cr>", desc = icon.." Open [t]ree to current [f]ile " },
{ "<leader>tt", "<cmd>NvimTreeToggle<cr>", desc = icons.ui.FileTree.." [t]oggle [t]ree" },
{ "<leader>tf", "<cmd>NvimTreeFindFile<cr>", desc = icons.ui.FileTree.." Open [t]ree to current [f]ile " },
-- stylua: ignore end
},
opts = function( --[[plugin]]_, opts)
local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend("force", opts or {}, {
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 = on_attach,
git = {
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
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 .
custom = { "^\\.git" }, -- don't show .git directory
},
renderer = {
add_trailing = true, -- add trailing / to folders
highlight_git = true, -- enable highlight based on git attributes
icons = {
webdev_colors = false, -- highlight icons with NvimTreeFileIcon
git_placement = "signcolumn",
glyphs = {
default = icons.ui.File,
symlink = icons.ui.FileSymlink,
modified = icons.ui.Circle,
folder = {
arrow_closed = icons.ui.ChevronSmallRight,
arrow_open = icons.ui.ChevronSmallDown,
default = icons.ui.Folder,
open = icons.ui.FolderOpen,
empty = icons.ui.EmptyFolder,
empty_open = icons.ui.EmptyFolderOpen,
symlink = icons.ui.FolderSymlink,
symlink_open = icons.ui.FolderSymlink,
},
git = {
untracked = icons.git.file.Untracked,
unstaged = icons.git.file.Unstaged,
staged = icons.git.file.Staged,
deleted = icons.git.file.Deleted,
unmerged = icons.git.file.Unmerged,
renamed = icons.git.file.Renamed,
ignored = icons.git.file.Ignored,
},
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 = on_attach,
git = {
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
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 .
custom = { "^\\.git" }, -- don't show .git directory
},
renderer = {
add_trailing = true, -- add trailing / to folders
highlight_git = true, -- enable highlight based on git attributes
icons = {
webdev_colors = false, -- highlight icons with NvimTreeFileIcon
git_placement = "signcolumn",
glyphs = {
default = icons.ui.File,
symlink = icons.ui.FileSymlink,
modified = icons.ui.Circle,
folder = {
arrow_closed = icons.ui.ChevronSmallRight,
arrow_open = icons.ui.ChevronSmallDown,
default = icons.ui.Folder,
open = icons.ui.FolderOpen,
empty = icons.ui.EmptyFolder,
empty_open = icons.ui.EmptyFolderOpen,
symlink = icons.ui.FolderSymlink,
symlink_open = icons.ui.FolderSymlink,
},
git = {
untracked = icons.git.file.Untracked,
unstaged = icons.git.file.Unstaged,
staged = icons.git.file.Staged,
deleted = icons.git.file.Deleted,
unmerged = icons.git.file.Unmerged,
renamed = icons.git.file.Renamed,
ignored = icons.git.file.Ignored,
},
},
},
})
end,
},
},
}

View file

@ -102,7 +102,7 @@ return {
-- stylua: ignore end
},
opts = function(_, opts)
opts = function()
local actions = require("telescope.actions")
local layout = require("telescope.actions.layout")
local state = require("telescope.actions.state")
@ -135,7 +135,7 @@ return {
["<c-l>"] = actions.smart_send_to_loclist + actions.open_loclist,
}
return vim.tbl_deep_extend("force", opts or {}, {
return {
defaults = {
mappings = { i = mappings, n = mappings },
@ -170,7 +170,7 @@ return {
colorscheme = { theme = "dropdown" },
spell_suggest = { theme = "cursor" },
},
})
}
end,
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 lhs, desc = helper.lhs, helper.description
@ -15,25 +17,22 @@ return {
{ lhs("t"), "<cmd>TodoTelescope<cr>", desc = desc("[t]odos") },
},
opts = function(_, opts)
local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend("force", opts or {}, {
keywords = {
TODO = { icon = icons.ui.Checkbox },
FIX = { icon = icons.ui.Bug },
HACK = { icon = icons.ui.Fire },
WARN = { icon = icons.ui.Warning },
PERF = { icon = icons.ui.Gauge },
NOTE = { icon = icons.ui.Note },
TEST = { icon = icons.ui.TestTube },
},
gui_style = { fg = "bold" },
highlight = {
multiline = false,
before = "fg",
keyword = "wide_fg",
after = "",
},
})
end,
opts = {
keywords = {
TODO = { icon = ui.Checkbox },
FIX = { icon = ui.Bug },
HACK = { icon = ui.Fire },
WARN = { icon = ui.Warning },
PERF = { icon = ui.Gauge },
NOTE = { icon = ui.Note },
TEST = { icon = ui.TestTube },
},
gui_style = { fg = "bold" },
highlight = {
multiline = false,
before = "fg",
keyword = "wide_fg",
after = "",
},
},
}

View file

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