vim: refactor plugin specs

This commit is contained in:
Fernando Schauenburg 2024-02-20 19:09:18 +01:00
parent c4db3de78a
commit c2b340ef88
32 changed files with 1062 additions and 1013 deletions

View file

@ -1,20 +1,18 @@
local M = { 'norcalli/nvim-colorizer.lua' } return {
"norcalli/nvim-colorizer.lua",
M.cond = function(--[[plugin]]_) cond = function(_)
return vim.o.termguicolors return vim.o.termguicolors
end end,
M.event = { event = { "BufNewFile", "BufReadPost" },
'BufReadPost',
'BufNewFile'
}
M.config = function(--[[plugin]]_, --[[opts]]_) opts = {
require('colorizer').setup(--[[filetypes]]nil, {
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
mode = 'foreground', mode = "foreground",
}) },
end
return M
config = function(_, opts)
require("colorizer").setup(nil, opts)
end,
}

View file

@ -1,55 +1,47 @@
local colorscheme = function(tbl) local colorscheme = function(tbl)
return vim.tbl_deep_extend('keep', tbl, { lazy = false, priority = 1000 }) return vim.tbl_deep_extend("keep", tbl, { lazy = false, priority = 1000 })
end end
return { return {
colorscheme { 'fschauen/gruvbox.nvim', dev = true }, colorscheme { "fschauen/gruvbox.nvim", dev = true },
colorscheme { 'fschauen/solarized.nvim', dev = true }, colorscheme { "fschauen/solarized.nvim", dev = true },
colorscheme {
colorscheme { 'catppuccin/nvim', "catppuccin/nvim",
name = 'catppuccin', name = "catppuccin",
opts = { opts = {
flavor = 'mocha', flavor = "mocha",
show_end_of_buffer = true, show_end_of_buffer = true,
dim_inactive = { enabled = true }, dim_inactive = { enabled = true },
integrations = { notify = true }, integrations = { notify = true },
custom_highlights = function(colors)
local extra_dark = false
return extra_dark
and {
Normal = { bg = colors.crust },
CursorLine = { bg = colors.mantle },
}
or {}
end,
}, },
}, },
colorscheme {
colorscheme { 'rebelot/kanagawa.nvim', "rebelot/kanagawa.nvim",
opts = { opts = {
dimInactive = true, dimInactive = true,
theme = 'dragon', theme = "dragon",
overrides = function(colors) overrides = function(colors)
local palette = colors.palette local palette = colors.palette
return { return {
-- stylua: ignore start
Normal = { bg = palette.sumiInk2 }, Normal = { bg = palette.sumiInk2 },
CursorLine = { bg = palette.sumiInk3 }, CursorLine = { bg = palette.sumiInk3 },
LineNr = { bg = palette.sumiInk2 }, LineNr = { bg = palette.sumiInk2 },
CursorLineNr = { bg = palette.sumiInk2 }, CursorLineNr = { bg = palette.sumiInk2 },
SignColumn = { bg = palette.sumiInk2 }, SignColumn = { bg = palette.sumiInk2 },
-- stylua: ignore end
} }
end, end,
}, },
}, },
colorscheme {
colorscheme { 'folke/tokyonight.nvim', "folke/tokyonight.nvim",
opts = { opts = {
style = 'night', style = "night",
dim_inactive = true, dim_inactive = true,
on_colors = function(colors) on_colors = function(colors)
colors.bg_highlight = '#1d212f' colors.bg_highlight = "#1d212f"
end, end,
}, },
}, },
} }

View file

@ -1,12 +1,13 @@
local M = { 'tpope/vim-commentary' } return {
"tpope/vim-commentary",
M.cmd = 'Commentary' cmd = "Commentary",
M.keys = { keys = {
{ 'gc', '<Plug>Commentary', mode = { 'n', 'x', 'o' }, desc = 'Comment in/out' }, -- stylua: ignore start
{ 'gcc', '<Plug>CommentaryLine', desc = 'Comment in/out line' }, { "gc", "<Plug>Commentary", mode = {"n", "x", "o"}, desc = "Comment in/out" },
{ 'gcu', '<Plug>Commentary<Plug>Commentary', desc = 'Undo comment in/out' }, { "gcc", "<Plug>CommentaryLine", desc = "Comment in/out line" },
{ "gcu", "<Plug>Commentary<Plug>Commentary", desc = "Undo comment in/out" },
-- stylua: ignore end
},
} }
return M

View file

@ -1,54 +1,45 @@
local M = { 'hrsh7th/nvim-cmp' } local icons = require("fschauen.util.icons")
M.dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lua',
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-cmdline',
'onsails/lspkind-nvim',
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
}
M.event = {
'CmdlineEnter',
'InsertEnter',
}
local make_keymap = function(cmp) local make_keymap = function(cmp)
local select = { behavior = cmp.SelectBehavior.Select } local select = { behavior = cmp.SelectBehavior.Select }
local either = function(yes, no) local if_visible = function(yes, no)
return function(fallback) return function(fallback)
if cmp.visible() then yes(fallback) else no(fallback) end if cmp.visible() then
yes(fallback)
else
no(fallback)
end
end end
end end
-- Mappings that should work in both command line and Insert mode. -- Mappings that should work in both command line and Insert mode.
local common = { local common = {
['<c-n>'] = either(cmp.mapping.select_next_item(select), cmp.mapping.complete()), -- stylua: ignore start
['<c-p>'] = either(cmp.mapping.select_prev_item(select), cmp.mapping.complete()), ["<c-n>"] = if_visible(cmp.mapping.select_next_item(select), cmp.mapping.complete()),
["<c-p>"] = if_visible(cmp.mapping.select_prev_item(select), cmp.mapping.complete()),
['<down>'] = cmp.mapping.select_next_item(select), ["<down>"] = cmp.mapping.select_next_item(select),
['<up>'] = cmp.mapping.select_prev_item(select), ["<up>"] = cmp.mapping.select_prev_item(select),
['<c-f>'] = cmp.mapping.scroll_docs( 3), ["<c-f>"] = cmp.mapping.scroll_docs( 3),
['<s-down>'] = cmp.mapping.scroll_docs( 3), ["<s-down>"] = cmp.mapping.scroll_docs( 3),
['<c-b>'] = cmp.mapping.scroll_docs(-3), ["<c-b>"] = cmp.mapping.scroll_docs(-3),
['<s-up>'] = cmp.mapping.scroll_docs(-3), ["<s-up>"] = cmp.mapping.scroll_docs(-3),
['<c-e>'] = cmp.mapping.abort(), ["<c-e>"] = cmp.mapping.abort(),
['<c-y>'] = cmp.mapping.confirm { select = true }, ["<c-y>"] = cmp.mapping.confirm { select = true },
-- stylua: ignore end
} }
-- I want <tab> to start completion on the command line, but not in Insert. -- I want <tab> to start completion on the command line, but not in Insert.
local keymap = { local keymap = {
['<tab>'] = { ["<tab>"] = {
i = either(cmp.mapping.confirm { select = true }, function(fallback) fallback() end), i = if_visible(cmp.mapping.confirm { select = true }, function(fallback)
c = either(cmp.mapping.confirm { select = true }, cmp.mapping.complete()), fallback()
} end),
c = if_visible(cmp.mapping.confirm { select = true }, cmp.mapping.complete()),
},
} }
-- Turn { lhs = rhs } into { lhs = { i = rhs, c = rhs } }. -- Turn { lhs = rhs } into { lhs = { i = rhs, c = rhs } }.
@ -59,47 +50,61 @@ local make_keymap = function(cmp)
return cmp.mapping.preset.insert(keymap) return cmp.mapping.preset.insert(keymap)
end end
M.config = function(--[[plugin]]_, --[[opts]]_) return {
local cmp = require 'cmp' "hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-cmdline",
"onsails/lspkind-nvim",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
event = { "CmdlineEnter", "InsertEnter" },
config = function()
local cmp = require("cmp")
local keymap = make_keymap(cmp) local keymap = make_keymap(cmp)
cmp.setup { cmp.setup {
mapping = keymap, mapping = keymap,
enabled = function() enabled = function()
local c = require 'cmp.config.context' local ctx = require("cmp.config.context")
return not c.in_treesitter_capture('comment') and return not ctx.in_treesitter_capture("comment") and not ctx.in_syntax_group("Comment")
not c.in_syntax_group('Comment')
end, end,
snippet = { snippet = {
expand = function(args) expand = function(args)
require('luasnip').lsp_expand(args.body) require("luasnip").lsp_expand(args.body)
end, end,
}, },
formatting = { formatting = {
format = require('lspkind').cmp_format { format = require("lspkind").cmp_format {
mode = 'symbol_text', mode = "symbol_text",
symbol_map = icons.kind,
menu = { menu = {
buffer = 'buf', buffer = "buf",
nvim_lsp = 'LSP', nvim_lsp = "LSP",
nvim_lua = 'lua', nvim_lua = "lua",
path = '', path = "",
}, },
symbol_map = require('fschauen.util.icons').kind,
}, },
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lua' }, { name = "nvim_lua" },
{ name = 'nvim_lsp' }, { name = "nvim_lsp" },
{ name = 'luasnip' }, { name = "luasnip" },
}, { }, {
{ name = 'path' }, { name = "path" },
{ name = 'buffer', keyword_length = 5 }, { name = "buffer", keyword_length = 5 },
}), }),
window = { window = {
@ -107,27 +112,21 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
experimental = { experimental = { ghost_text = true },
ghost_text = true,
},
} }
cmp.setup.cmdline(':', { cmp.setup.cmdline(":", {
mapping = keymap, mapping = keymap,
completion = { autocomplete = false },
completion = {
autocomplete = false,
},
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' } { name = "path" },
}, { }, {
{ name = 'cmdline' } { name = "cmdline" },
}), }),
}) })
cmp.setup.filetype('TelescopePrompt', { enabled = false }) cmp.setup.filetype("TelescopePrompt", {
end enabled = false,
})
return M end,
}

View file

@ -1,13 +1,11 @@
local M = { 'monaqa/dial.nvim' }
---Create a right hand side for `dial` key maps. ---Create a right hand side for `dial` key maps.
---@param cmd string: name of a function from `dial.map`. ---@param cmd string: name of a function from `dial.map`.
---@param suffix? string: keys to add after `dial`s mapping. ---@param suffix? string: keys to add after `dial`s mapping.
---@return function ---@return function
local dial_cmd = function(cmd, suffix) local dial_cmd = function(cmd, suffix)
suffix = suffix or '' suffix = suffix or ""
return function() return function()
return require('dial.map')[cmd]() .. suffix return require("dial.map")[cmd]() .. suffix
end end
end end
@ -15,41 +13,58 @@ end
---@param elements string[]: the elements to cycle. ---@param elements string[]: the elements to cycle.
---@return table: @see `dial.types.Augend` ---@return table: @see `dial.types.Augend`
local cyclic_augend = function(elements) local cyclic_augend = function(elements)
return require('dial.augend').constant.new { return require("dial.augend").constant.new {
elements = elements, elements = elements,
word = true, word = true,
cyclic = true cyclic = true,
} }
end end
M.keys = { local weekdays = {
{ '<c-a>', dial_cmd('inc_normal'), expr = true, desc = ' Increment' }, "Monday",
{ '<c-x>', dial_cmd('dec_normal'), expr = true, desc = ' Decrement' }, "Tuesday",
"Wednesday",
{ '<c-a>', dial_cmd('inc_visual', 'gv'), expr = true, desc = ' Increment', mode = 'v' }, "Thursday",
{ '<c-x>', dial_cmd('dec_visual', 'gv'), expr = true, desc = ' Decrement', mode = 'v' }, "Friday",
"Saturday",
{ 'g<c-a>', dial_cmd('inc_gvisual', 'gv'), expr = true, desc = ' Increment', mode = 'v' }, "Sunday",
{ 'g<c-x>', dial_cmd('dec_gvisual', 'gv'), expr = true, desc = ' Decrement', mode = 'v' },
} }
M.config = function( --[[plugin]] _, --[[opts]] _) local weekdays_short = vim.tbl_map(function(s)
local augend = require('dial.augend') return s:sub(1, 3)
require('dial.config').augends:register_group { end, weekdays)
return {
"monaqa/dial.nvim",
keys = {
-- stylua: ignore start
{ "<c-a>", dial_cmd("inc_normal"), expr = true, desc = " Increment" },
{ "<c-x>", dial_cmd("dec_normal"), expr = true, desc = " Decrement" },
{ "<c-a>", dial_cmd("inc_visual", "gv"), expr = true, desc = " Increment", mode = "v" },
{ "<c-x>", dial_cmd("dec_visual", "gv"), expr = true, desc = " Decrement", mode = "v" },
{ "g<c-a>", dial_cmd("inc_gvisual", "gv"), expr = true, desc = " Increment", mode = "v" },
{ "g<c-x>", dial_cmd("dec_gvisual", "gv"), expr = true, desc = " Decrement", mode = "v" },
-- stylua: ignore end
},
config = function()
local augend = require("dial.augend")
require("dial.config").augends:register_group {
default = { default = {
augend.integer.alias.decimal_int, augend.integer.alias.decimal_int,
augend.integer.alias.hex, augend.integer.alias.hex,
augend.integer.alias.binary, augend.integer.alias.binary,
augend.constant.alias.bool, augend.constant.alias.bool,
augend.semver.alias.semver, augend.semver.alias.semver,
augend.date.alias['%Y-%m-%d'], augend.date.alias["%Y-%m-%d"],
augend.date.alias['%d/%m/%Y'], augend.date.alias["%d/%m/%Y"],
augend.date.alias['%d.%m.%Y'], augend.date.alias["%d.%m.%Y"],
cyclic_augend { 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' }, cyclic_augend(weekdays),
cyclic_augend { 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' }, cyclic_augend(weekdays_short),
cyclic_augend { 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su' }, },
} }
end,
} }
end
return M

View file

@ -1,21 +1,21 @@
local M = { 'stevearc/dressing.nvim' } return {
"stevearc/dressing.nvim",
M.lazy = false -- `vim.ui.select()` and `vim.ui.input()` can be used from the start.
lazy = false,
M.opts = { opts = {
input = { input = {
insert_only = false, -- <esc> changes to Normal mode insert_only = false, -- <esc> changes to Normal mode
mappings = { mappings = {
n = { n = {
['<C-c>'] = 'Close', ["<C-c>"] = "Close",
}, },
i = { i = {
['<c-k>'] = 'HistoryPrev', ["<c-k>"] = "HistoryPrev",
['<c-j>'] = 'HistoryNext', ["<c-j>"] = "HistoryNext",
},
}, },
}, },
}, },
} }
return M

View file

@ -1,33 +1,34 @@
local M = { 'j-hui/fidget.nvim' } local icons = require("fschauen.util.icons")
M.branch = 'legacy' return {
"j-hui/fidget.nvim",
M.event = 'LspAttach' branch = "legacy",
M.opts = { event = "LspAttach",
opts = {
text = { text = {
done = require('fschauen.util.icons').ui.Checkmark, done = icons.ui.Checkmark,
spinner = { spinner = {
'▱▱▱▱▱▱▱', "▱▱▱▱▱▱▱",
'▰▱▱▱▱▱▱', "▰▱▱▱▱▱▱",
'▰▰▱▱▱▱▱', "▰▰▱▱▱▱▱",
'▰▰▰▱▱▱▱', "▰▰▰▱▱▱▱",
'▰▰▰▰▱▱▱', "▰▰▰▰▱▱▱",
'▰▰▰▰▰▱▱', "▰▰▰▰▰▱▱",
'▰▰▰▰▰▰▱', "▰▰▰▰▰▰▱",
'▰▰▰▰▰▰▰', "▰▰▰▰▰▰▰",
'▱▰▰▰▰▰▰', "▱▰▰▰▰▰▰",
'▱▱▰▰▰▰▰', "▱▱▰▰▰▰▰",
'▱▱▱▰▰▰▰', "▱▱▱▰▰▰▰",
'▱▱▱▱▰▰▰', "▱▱▱▱▰▰▰",
'▱▱▱▱▱▰▰', "▱▱▱▱▱▰▰",
'▱▱▱▱▱▱▰', "▱▱▱▱▱▱▰",
}, },
}, },
timer = { spinner_rate = 75 }, timer = { spinner_rate = 75 },
window = { blend = 50 }, window = { blend = 50 },
fmt = { max_messages = 10 } fmt = { max_messages = 10 },
},
} }
return M

View file

@ -1,21 +1,25 @@
local M = { 'mhartington/formatter.nvim' } return {
"mhartington/formatter.nvim",
M.cmd = { cmd = {
'Format', "Format",
'FormatLock', "FormatLock",
'FormatWrite', "FormatWrite",
'FormatWriteLock', "FormatWriteLock",
} },
M.keys = { keys = {
{ '<leader>F', '<cmd>Format<cr>', desc = '󰉼 Format file' }, -- stylua: ignore start
{ '<leader>F', "<cmd>'<,'>Format<cr>", mode = 'v', desc = '󰉼 Format file' }, { "<leader>F", "<cmd>Format<cr>", desc = "󰉼 Format file" },
} { "<leader>F", "<cmd>'<,'>Format<cr>", mode = "v", desc = "󰉼 Format file" },
-- stylua: ignore end
},
M.opts = function( --[[plugin]] _, opts) opts = function(_, opts)
local ft = require('formatter.filetypes') local ft = require("formatter.filetypes")
return vim.tbl_deep_extend('force', opts or {}, { return vim.tbl_deep_extend("force", opts or {}, {
filetype = { filetype = {
-- stylua: ignore start
c = {ft.c.clangformat}, c = {ft.c.clangformat},
cmake = {ft.cmake.cmakeformat}, cmake = {ft.cmake.cmakeformat},
cpp = {ft.cpp.clangformat}, cpp = {ft.cpp.clangformat},
@ -26,8 +30,8 @@ M.opts = function( --[[plugin]] _, opts)
python = {}, -- TODO: pick one python = {}, -- TODO: pick one
sh = {ft.sh.shfmt}, sh = {ft.sh.shfmt},
zsh = {ft.zsh.beautysh}, zsh = {ft.zsh.beautysh},
} -- stylua: ignore end
},
}) })
end end,
}
return M

View file

@ -1,11 +1,12 @@
local M = { 'tpope/vim-fugitive' } return {
"tpope/vim-fugitive",
M.cmd = { 'G', 'Git' } cmd = { "G", "Git" },
M.keys = { keys = {
{ '<leader>gS', '<cmd>tab Git<cr>', desc = ' [S]status with fugitive' }, -- stylua: ignore start
{ '<leader>gb', '<cmd>Git blame<cr>', desc = ' [b]lame' } { "<leader>gS", "<cmd>tab Git<cr>", desc = " [S]status with fugitive" },
{ "<leader>gb", "<cmd>Git blame<cr>", desc = " [b]lame" },
-- stylua: ignore end
},
} }
return M

View file

@ -1,12 +1,15 @@
local M = { 'rhysd/git-messenger.vim' } return {
"rhysd/git-messenger.vim",
M.cmd = 'GitMessenger' cmd = "GitMessenger",
M.keys = { keys = {
{ '<leader>gm', '<cmd>GitMessenger<cr>', desc = ' open [m]essenger' }, -- stylua: ignore start
} { "<leader>gm", "<cmd>GitMessenger<cr>", desc = " open [m]essenger" },
-- stylua: ignore end
},
M.init = function(--[[plugin]]_) init = function()
-- Disable default mappings, as I have my own for lazy-loading. -- Disable default mappings, as I have my own for lazy-loading.
vim.g.git_messenger_no_default_mappings = true vim.g.git_messenger_no_default_mappings = true
@ -14,14 +17,14 @@ M.init = function(--[[plugin]]_)
vim.g.git_messenger_always_into_popup = true vim.g.git_messenger_always_into_popup = true
-- Add a border to the floating window, otherwise it's confusing. -- Add a border to the floating window, otherwise it's confusing.
vim.g.git_messenger_floating_win_opts = { border = 'rounded' } vim.g.git_messenger_floating_win_opts = {
border = "rounded",
}
-- Make the UI a bit more compact by removing margins. -- Make the UI a bit more compact by removing margins.
vim.g.git_messenger_popup_content_margins = false vim.g.git_messenger_popup_content_margins = false
-- Extra arguments passed to `git blame`: -- Extra arguments passed to `git blame`:
-- vim.g.git_messenger_extra_blame_args = '-w' -- vim.g.git_messenger_extra_blame_args = '-w'
end end,
}
return M

View file

@ -1,39 +1,46 @@
local M = { 'ruifm/gitlinker.nvim' }
M.dependencies = { 'nvim-lua/plenary.nvim' }
local open_repo = function() local open_repo = function()
require('gitlinker').get_repo_url { action_callback = require('gitlinker.actions').open_in_browser } require("gitlinker").get_repo_url {
action_callback = require("gitlinker.actions").open_in_browser,
}
end end
local browser = function(mode) local browser = function(mode)
return function() return function()
require('gitlinker').get_buf_range_url(mode, { action_callback = require('gitlinker.actions').open_in_browser }) require("gitlinker").get_buf_range_url(mode, {
action_callback = require("gitlinker.actions").open_in_browser,
})
end end
end end
local clipboard = function(mode) local clipboard = function(mode)
return function() return function()
require('gitlinker').get_buf_range_url(mode, { action_callback = require('gitlinker.actions').copy_to_clipboard }) require("gitlinker").get_buf_range_url(mode, {
end action_callback = require("gitlinker.actions").copy_to_clipboard,
end
M.keys = {
{ '<leader>gr', open_repo, desc = ' open [r]epository in browser' },
{ '<leader>gl', clipboard('n'), desc = ' copy perma[l]ink to clipboard' },
{ '<leader>gl', clipboard('v'), desc = ' copy perma[l]ink to clipboard', mode = 'v' },
{ '<leader>gL', browser('n'), desc = ' open perma[L]ink in browser' },
{ '<leader>gL', browser('v'), desc = ' open perma[L]ink in browser', mode = 'v' },
}
M.opts = function(--[[plugin]]_, opts)
return vim.tbl_deep_extend('force', opts or {}, {
mappings = nil, -- I'm defining my own mappings above.
callbacks = {
['git.schauenburg.me'] = require('gitlinker.hosts').get_gitea_type_url,
},
}) })
end end
end
return M return {
"ruifm/gitlinker.nvim",
dependencies = "nvim-lua/plenary.nvim",
keys = {
-- stylua: ignore start
{ "<leader>gr", open_repo, desc = " open [r]epository in browser" },
{ "<leader>gl", clipboard("n"), desc = " copy perma[l]ink to clipboard" },
{ "<leader>gl", clipboard("v"), desc = " copy perma[l]ink to clipboard", mode = "v" },
{ "<leader>gL", browser("n"), desc = " open perma[L]ink in browser" },
{ "<leader>gL", browser("v"), desc = " open perma[L]ink in browser", mode = "v" },
-- stylua: ignore end
},
opts = function(_, opts)
return vim.tbl_deep_extend("force", opts or {}, {
mappings = nil, -- I'm defining my own mappings above.
callbacks = {
["git.schauenburg.me"] = require("gitlinker.hosts").get_gitea_type_url,
},
})
end,
}

View file

@ -1,30 +1,30 @@
local M = { 'lukas-reineke/indent-blankline.nvim' } local icons = require("fschauen.util.icons")
M.cmd = { return {
'IBLEnable', "lukas-reineke/indent-blankline.nvim",
'IBLDisable',
'IBLToggle',
'IBLEnableScope',
'IBLDisableScope',
'IBLToggleScope',
}
local toggle = require('fschauen.util.icons').ui.Toggle .. ' toggle ' cmd = {
"IBLEnable",
M.keys = { "IBLDisable",
{ '<leader>si', '<cmd>IBLToggle<cr>', desc = toggle .. 'indent lines' }, "IBLToggle",
{ '<leader>so', '<cmd>IBLToggleScope<cr>', desc = toggle .. 'indent line scope' }, "IBLEnableScope",
} "IBLDisableScope",
"IBLToggleScope",
M.main = 'ibl'
M.opts = function(--[[plugin]]_, opts)
local icons = require('fschauen.util.icons')
return vim.tbl_deep_extend('force', opts or {}, {
enabled = false,
indent = {
char = icons.ui.LineLeft,
}, },
keys = {
-- stylua: ignore start
{ "<leader>si", "<cmd>IBLToggle<cr>", desc = icons.ui.Toggle .. " toggle indent lines" },
{ "<leader>so", "<cmd>IBLToggleScope<cr>", desc = icons.ui.Toggle .. " toggle indent line scope" },
-- stylua: ignore end
},
main = "ibl",
opts = function(_, opts)
return vim.tbl_deep_extend("force", opts or {}, {
enabled = false,
indent = { char = icons.ui.LineLeft },
scope = { scope = {
char = icons.ui.LineLeftBold, char = icons.ui.LineLeftBold,
enabled = false, enabled = false,
@ -32,6 +32,5 @@ M.opts = function(--[[plugin]]_, opts)
show_end = false, show_end = false,
}, },
}) })
end end,
}
return M

View file

@ -1,63 +1,61 @@
local M = { 'neovim/nvim-lspconfig' } local border = { border = "rounded" }
M.dependencies = { local lsp_capabilities = function()
'williamboman/mason.nvim', local basic = vim.lsp.protocol.make_client_capabilities()
'williamboman/mason-lspconfig.nvim', local completion = vim.F.npcall(require, "cmp_nvim_lsp")
'Hoffs/omnisharp-extended-lsp.nvim', if completion then
return vim.tbl_deep_extend("force", basic, completion.default_capabilities())
end
return basic
end
local lsp_handlers = function()
return {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, border),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, border),
} }
end
M.event = { 'BufReadPre', 'BufNewFile' } local lsp_on_attach = function( --[[client]]_, buffer)
M.config = function( --[[plugin]] _, --[[opts]] _)
local border = { border = 'rounded' }
local defaults = {
capabilities = vim.tbl_deep_extend('force',
vim.lsp.protocol.make_client_capabilities(),
vim.F.npcall(function() require('cmp_nvim_lsp').default_capabilities() end) or {}),
handlers = {
['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, border),
['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, border),
},
on_attach = function( --[[client]] _, buffer)
local map = vim.keymap.set local map = vim.keymap.set
local opts = { buffer = buffer }
local buf = vim.lsp.buf local buf = vim.lsp.buf
local map_opts = { buffer = buffer } -- stylua: ignore start
map('n', '<localleader>c', buf.code_action, map_opts) map("n", "<localleader>c", buf.code_action, opts)
map('n', '<localleader>f', buf.format, map_opts) map("n", "<localleader>f", buf.format, opts)
map('n', 'gd', buf.definition, map_opts) map("n", "gd", buf.definition, opts)
map('n', 'gD', buf.declaration, map_opts) map("n", "gD", buf.declaration, opts)
map('n', 'gi', buf.implementation, map_opts) map("n", "gi", buf.implementation, opts)
map('n', 'grr', buf.rename, map_opts) map("n", "grr", buf.rename, opts)
map('n', 'gt', buf.type_definition, map_opts) map("n", "gt", buf.type_definition, opts)
map('n', 'K', buf.hover, map_opts) map("n", "K", buf.hover, opts)
map('i', '<c-l>', buf.signature_help, map_opts) map("i", "<c-l>", buf.signature_help, opts)
end, -- stylua: ignore end
end
on_init = function(client, --[[init_result]] _) local lsp_on_init = function(client)
-- Opt out of semantic highlighting because it has been causing the issues -- Opt out of semantic highlighting because it has been causing the issues
-- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213 -- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213
if client.server_capabilities then if client.server_capabilities then
client.server_capabilities.semanticTokensProvider = false client.server_capabilities.semanticTokensProvider = false
end end
end, end
}
local server_opts = setmetatable({ local server_opts = setmetatable({
lua_ls = function(opts) lua_ls = function(opts)
return vim.tbl_deep_extend('force', opts, { return vim.tbl_deep_extend("force", opts, {
settings = { settings = {
Lua = { Lua = {
-- I'm using lua only inside neovim, so the runtime is LuaJIT. -- I'm using lua only inside neovim, so the runtime is LuaJIT.
runtime = { version = 'LuaJIT' }, runtime = { version = "LuaJIT" },
-- Get the language server to recognize the `vim` global. -- Get the language server to recognize the `vim` global.
diagnostics = { globals = { 'vim' } }, diagnostics = { globals = { "vim" } },
-- Make the server aware of Neovim runtime files. -- Make the server aware of Neovim runtime files.
workspace = { library = vim.api.nvim_get_runtime_file('', true) }, workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier -- Do not send telemetry data containing a randomized but unique identifier
telemetry = { enable = false }, telemetry = { enable = false },
@ -66,7 +64,7 @@ M.config = function( --[[plugin]] _, --[[opts]] _)
}) })
end, end,
omnisharp = function(opts) omnisharp = function(opts)
return vim.tbl_deep_extend('force', opts, { return vim.tbl_deep_extend("force", opts, {
-- Use .editoconfig for code style, naming convention and analyzer settings. -- Use .editoconfig for code style, naming convention and analyzer settings.
enable_editorconfig_support = true, enable_editorconfig_support = true,
@ -79,31 +77,54 @@ M.config = function( --[[plugin]] _, --[[opts]] _)
-- Don't include preview versions of the .NET SDK. -- Don't include preview versions of the .NET SDK.
sdk_include_prereleases = false, sdk_include_prereleases = false,
handlers = { ['textDocument/definition'] = require('omnisharp_extended').handler }, handlers = {
["textDocument/definition"] = require("omnisharp_extended").handler,
},
}) })
end, end,
}, { }, {
__index = function( --[[tbl]] _, --[[key]] _) -- The default is a just a passthrough of the options.
return function(opts) return opts end __index = function()
return function(opts)
return opts
end end
end,
}) })
require('lspconfig.ui.windows').default_options = border return {
require('mason').setup { ui = border } "neovim/nvim-lspconfig",
require('mason-lspconfig').setup {
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"Hoffs/omnisharp-extended-lsp.nvim",
},
event = { "BufReadPre", "BufNewFile" },
config = function()
local defaults = {
capabilities = lsp_capabilities(),
handlers = lsp_handlers(),
on_attach = lsp_on_attach,
lsp_on_init = lsp_on_init,
}
require("lspconfig.ui.windows").default_options = border
require("mason").setup { ui = border }
require("mason-lspconfig").setup {
ensure_installed = { ensure_installed = {
'clangd', "clangd",
'cmake', "cmake",
'lua_ls', "lua_ls",
'pyright', "pyright",
}, },
handlers = { handlers = {
function(server_name) function(server_name)
local opts = server_opts[server_name](defaults) local opts = server_opts[server_name](defaults)
require('lspconfig')[server_name].setup(opts) require("lspconfig")[server_name].setup(opts)
end, end,
}, },
} }
end end,
}
return M

View file

@ -4,9 +4,7 @@ local icons = require('fschauen.util.icons')
local orange = '#d65d0e' local orange = '#d65d0e'
local bright = '#ffffff' -- alternative: '#f9f5d7' local bright = '#ffffff' -- alternative: '#f9f5d7'
M.dependencies = { M.dependencies = 'nvim-tree/nvim-web-devicons'
'nvim-tree/nvim-web-devicons',
}
M.config = function(--[[plugin]]_, --[[opts]]_) M.config = function(--[[plugin]]_, --[[opts]]_)
local window = require 'fschauen.window' local window = require 'fschauen.window'

View file

@ -1,2 +1 @@
return { 'milisims/nvim-luaref' } return { "milisims/nvim-luaref" }

View file

@ -1,22 +1,19 @@
local M = { 'iamcco/markdown-preview.nvim' } return {
"iamcco/markdown-preview.nvim",
M.build = function() build = function()
vim.fn["mkdp#util#install"]() vim.fn["mkdp#util#install"]()
end end,
M.cmd = { cmd = {
'MarkdownPreview', "MarkdownPreview",
'MarkdownPreviewStop', "MarkdownPreviewStop",
'MarkdownPreviewToggle', "MarkdownPreviewToggle",
},
ft = "markdown",
init = function()
vim.g.mkdp_theme = "dark"
end,
} }
M.ft = {
'markdown',
}
M.init = function(--[[plugin]]_)
vim.g.mkdp_theme = 'dark'
end
return M

View file

@ -1,30 +1,39 @@
local M = { 'NeogitOrg/neogit' } local icons = require("fschauen.util.icons")
M.cmd = 'Neogit' return {
"NeogitOrg/neogit",
M.dependencies = { 'nvim-lua/plenary.nvim' } cmd = "Neogit",
M.keys = { dependencies = "nvim-lua/plenary.nvim",
{ '<leader>gs', '<cmd>Neogit<cr>', desc = ' [s]tatus with neogit' },
}
M.opts = function(--[[plugin]]_, opts) keys = {
local icons = require('fschauen.util.icons') { "<leader>gs", "<cmd>Neogit<cr>", desc = " [s]tatus with neogit" },
return vim.tbl_deep_extend('force', opts or {}, { },
opts = function(_, opts)
return vim.tbl_deep_extend("force", opts or {}, {
disable_hint = true, disable_hint = true,
signs = { signs = {
section = { icons.ui.Folder, icons.ui.EmptyFolderOpen }, section = {
item = { icons.ui.ChevronRight, icons.ui.ChevronDown }, icons.ui.Folder,
hunk = { icons.ui.ChevronSmallRight, icons.ui.ChevronSmallDown }, icons.ui.EmptyFolderOpen,
},
item = {
icons.ui.ChevronRight,
icons.ui.ChevronDown,
},
hunk = {
icons.ui.ChevronSmallRight,
icons.ui.ChevronSmallDown,
},
}, },
mappings = { mappings = {
status = { status = {
o = 'GoToFile', o = "GoToFile",
['='] = 'Toggle', ["="] = "Toggle",
}, },
}, },
}) })
end end,
}
return M

View file

@ -1,18 +1,17 @@
local M = { '2kabhishek/nerdy.nvim' } local helper = require("fschauen.plugins.telescope").keymap_helper
local lhs, desc = helper.lhs, helper.description
M.cmd = 'Nerdy' return {
"2kabhishek/nerdy.nvim",
M.dependencies = { cmd = "Nerdy",
'stevearc/dressing.nvim',
'nvim-telescope/telescope.nvim', dependencies = {
"stevearc/dressing.nvim",
"nvim-telescope/telescope.nvim",
},
keys = {
{ lhs("i"), "<cmd>Nerdy<cr>", desc = desc("Nerd [i]cons") },
},
} }
local ts = require('fschauen.plugins.telescope')
local lhs, desc = ts.keymap.lhs, ts.keymap.description
M.keys = {
{ lhs('i'), '<cmd>Nerdy<cr>', desc = desc('Nerd [i]cons') },
}
return M

View file

@ -1,32 +1,40 @@
local M = { 'rcarriga/nvim-notify' } local helper = require("fschauen.plugins.telescope").keymap_helper
local lhs, desc = helper.lhs, helper.description
local telescope_notify = function() local telescope_notifications = function()
local ts = vim.F.npcall(require, 'telescope') local telescope = vim.F.npcall(require, "telescope")
if not ts then return end if not telescope then
vim.notify("Telescope is not installed!", vim.log.levels.WARN)
local theme = require('telescope.themes').get_dropdown { return
results_title = ' Results ',
prompt_title = '  Notifications ',
}
local notify = ts.extensions.notify or ts.load_extension('notify')
notify.notify(theme)
end end
local ts = require('fschauen.plugins.telescope') local theme = require("telescope.themes").get_dropdown {
local lhs, desc = ts.keymap.lhs, ts.keymap.description results_title = " Results ",
prompt_title = "  Notifications ",
M.keys = {
{ '<leader>n', '<cmd>Notifications<cr>', desc = 'Display notification history' },
{ '<c-q>', function() require('notify').dismiss() end, desc = 'Dismiss notifications' },
{ lhs('n'), telescope_notify, desc = desc('[n]otifications') },
} }
telescope.load_extension("notify").notify(theme)
end
M.lazy = false local dismiss_notifications = function()
require("notify").dismiss()
end
M.opts = function(--[[plugin]]_, opts) return {
local icons = require('fschauen.util.icons') "rcarriga/nvim-notify",
return vim.tbl_deep_extend('force', opts or {}, {
keys = {
-- stylua: ignore start
{ "<leader>n", "<cmd>Notifications<cr>", desc = "Display notification history" },
{ "<c-q>", dismiss_notifications, desc = "Dismiss notifications" },
{ lhs("n"), telescope_notifications, desc = desc("[n]otifications") },
-- stylua: ignore end
},
lazy = false,
opts = function(_, opts)
local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend("force", opts or {}, {
icons = { icons = {
ERROR = icons.diagnostics_bold.Error, ERROR = icons.diagnostics_bold.Error,
WARN = icons.diagnostics_bold.Warn, WARN = icons.diagnostics_bold.Warn,
@ -37,17 +45,17 @@ M.opts = function(--[[plugin]]_, opts)
fps = 24, fps = 24,
max_width = 50, max_width = 50,
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 │ ",
},
}) })
end end,
M.config = function(--[[plugin]]_, opts) config = function(_, opts)
local notify = require('notify') local notify = require("notify")
notify.setup(opts) notify.setup(opts)
vim.notify = notify vim.notify = notify
end end,
}
return M

View file

@ -1,37 +1,46 @@
local M = { 'nvim-tree/nvim-tree.lua' } local on_attach = function(buffer)
local api = require("nvim-tree.api")
M.dependencies = {
'nvim-tree/nvim-web-devicons',
}
M.keys = {
{ '<leader>tt', '<cmd>NvimTreeToggle<cr>', desc = '󰙅 [t]oggle [t]ree' },
{ '<leader>tf', '<cmd>NvimTreeFindFile<cr>', desc = '󰙅 Open [t]ree to current [f]ile ' },
}
M.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 = function(buffer)
local api = require('nvim-tree.api')
-- 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 })
local opt = function(desc) local map = vim.keymap.set
return { desc = '󰙅 nvim-tree: ' .. desc, buffer = buffer, silent = true } local opts = function(desc)
return {
desc = "󰙅 nvim-tree: " .. desc,
buffer = buffer,
silent = true,
}
end 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,
-- stylua: ignore start
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"))
-- stylua: ignore end
end
return {
"nvim-tree/nvim-tree.lua",
dependencies = "nvim-tree/nvim-web-devicons",
keys = {
-- stylua: ignore start
{ "<leader>tt", "<cmd>NvimTreeToggle<cr>", desc = "󰙅 [t]oggle [t]ree" },
{ "<leader>tf", "<cmd>NvimTreeFindFile<cr>", desc = "󰙅 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 = { git = {
ignore = false, -- don't hide files from .gitignore ignore = false, -- don't hide files from .gitignore
show_on_open_dirs = false, -- don't show indication if dir is open show_on_open_dirs = false, -- don't show indication if dir is open
@ -43,14 +52,14 @@ M.opts = function(--[[plugin]]_, opts)
}, },
filters = { filters = {
dotfiles = false, -- show files starting with a . dotfiles = false, -- show files starting with a .
custom = { '^\\.git' }, -- don't show .git directory custom = { "^\\.git" }, -- don't show .git directory
}, },
renderer = { renderer = {
add_trailing = true, -- add trailing / to folders add_trailing = true, -- add trailing / to folders
highlight_git = true, -- enable highlight based on git attributes highlight_git = true, -- enable highlight based on git attributes
icons = { icons = {
webdev_colors = false, -- highlight icons with NvimTreeFileIcon webdev_colors = false, -- highlight icons with NvimTreeFileIcon
git_placement = 'signcolumn', git_placement = "signcolumn",
glyphs = { glyphs = {
default = icons.ui.File, default = icons.ui.File,
symlink = icons.ui.FileSymlink, symlink = icons.ui.FileSymlink,
@ -78,7 +87,5 @@ M.opts = function(--[[plugin]]_, opts)
}, },
}, },
}) })
end end,
}
return M

View file

@ -1,7 +1,5 @@
return { return {
{ 'mityu/vim-applescript', ft = 'applescript' }, { "mityu/vim-applescript", ft = "applescript" },
{ 'chr4/nginx.vim', ft = 'nginx' }, { "chr4/nginx.vim", ft = "nginx" },
{ 'keith/swift.vim', ft = 'swift'}, { "keith/swift.vim", ft = "swift" },
} }

View file

@ -1,18 +1,17 @@
local M = { 'godlygeek/tabular' } return {
"godlygeek/tabular",
M.cmd ={ cmd = {
'AddTabularPattern', "AddTabularPattern",
'AddTabularPipeline', "AddTabularPipeline",
'Tabularize', "Tabularize",
},
config = function()
if vim.fn.exists("g:tabular_loaded") == 1 then
vim.cmd([[ AddTabularPattern! first_comma /^[^,]*\zs,/ ]])
vim.cmd([[ AddTabularPattern! first_colon /^[^:]*\zs:/ ]])
vim.cmd([[ AddTabularPattern! first_equal /^[^=]*\zs=/ ]])
end
end,
} }
M.config = function(--[[plugin]]_, --[[opts]]_)
if vim.fn.exists('g:tabular_loaded') == 1 then
vim.cmd [[ AddTabularPattern! first_comma /^[^,]*\zs,/ ]]
vim.cmd [[ AddTabularPattern! first_colon /^[^:]*\zs:/ ]]
vim.cmd [[ AddTabularPattern! first_equal /^[^=]*\zs=/ ]]
end
end
return M

View file

@ -1,17 +1,16 @@
local M = { 'nvim-telescope/telescope-file-browser.nvim' } local helper = require("fschauen.plugins.telescope").keymap_helper
local lhs, desc = helper.lhs, helper.description
M.dependencies = { 'nvim-telescope/telescope.nvim' } return {
"nvim-telescope/telescope-file-browser.nvim",
local ts = require('fschauen.plugins.telescope') dependencies = "nvim-telescope/telescope.nvim",
local lhs, desc = ts.keymap.lhs, ts.keymap.description
M.keys = { keys = {
{ lhs('B'), '<cmd>Telescope file_browser<cr>' , desc = desc('file [B]rowser') }, { lhs("B"), "<cmd>Telescope file_browser<cr>", desc = desc("file [B]rowser") },
},
config = function()
require("telescope").load_extension("file_browser")
end,
} }
M.config = function(--[[plugin]]_, --[[opts]]_)
require('telescope').load_extension('file_browser')
end
return M

View file

@ -1,144 +1,148 @@
local M = { 'nvim-telescope/telescope.nvim' } local util = require("fschauen.util")
local icons = require("fschauen.util.icons")
M.dependencies = { ---Create the left hand side for a Telescope keymap.
'nvim-telescope/telescope-fzf-native.nvim', local lhs = function(keys)
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release ' .. return "<leader>f" .. keys
'&& cmake --build build --config Release ' .. end
'&& cmake --install build --prefix build',
}
M.cmd = 'Telescope' ---Create the description for a Telescope keymap.
local desc = function(text)
return icons.ui.Telescope .. " Telescope " .. text
end
local builtin_picker = function(name, opts) local builtin_picker = function(name, opts)
return function(title) return function(title)
return function() return function()
local picker = require('telescope.builtin')[name] local picker = require("telescope.builtin")[name]
picker(vim.tbl_extend('force', opts or {}, { prompt_title = title })) picker(vim.tbl_extend("force", opts or {}, {
prompt_title = title,
}))
end end
end end
end end
local util = require('fschauen.util')
local icons = require('fschauen.util.icons')
local pickers = setmetatable({ local pickers = setmetatable({
all_files = builtin_picker('find_files', { all_files = builtin_picker("find_files", {
hidden = true, hidden = true,
no_ignore = true, no_ignore = true,
no_ignore_parent = true, no_ignore_parent = true,
}), }),
colorscheme = builtin_picker('colorscheme', { colorscheme = builtin_picker("colorscheme", { enable_preview = true }),
enable_preview = true, diagnostics = builtin_picker("diagnostics", { bufnr = 0 }),
}), dotfiles = builtin_picker("find_files", { cwd = "~/.dotfiles", hidden = true }),
diagnostics = builtin_picker('diagnostics', {
bufnr = 0
}),
dotfiles = builtin_picker('find_files', {
cwd = '~/.dotfiles',
hidden = true,
}),
selection = function(title) selection = function(title)
return function() return function()
local text = util.get_selected_text() local text = util.get_selected_text()
return require('telescope.builtin').grep_string { return require("telescope.builtin").grep_string {
prompt_title = string.format(title .. ': %s ', text), prompt_title = string.format(title .. ": %s ", text),
search = text, search = text,
} }
end end
end, end,
here = builtin_picker('current_buffer_fuzzy_find'), here = builtin_picker("current_buffer_fuzzy_find"),
}, { }, {
-- Fall back to telescope's built-in pickers if a custom one is not defined -- Fall back to telescope's built-in pickers if a custom one is not defined
-- above, but make sure to keep the title we defined. -- above, but make sure to keep the title we defined.
__index = function( --[[tbl]] _, key) __index = function(_, key)
return builtin_picker(key) return builtin_picker(key)
end end,
}) })
M.keymap = { return {
lhs = function(keys) return '<leader>f' .. keys end, "nvim-telescope/telescope.nvim",
description = function(text) return icons.ui.Telescope .. ' Telescope ' .. text end
}
local lhs, desc = M.keymap.lhs, M.keymap.description
M.keys = { dependencies = {
{ lhs'a', pickers.autocommands ' Autocommands' , desc = desc('[a]utocommands') }, "nvim-telescope/telescope-fzf-native.nvim",
{ lhs'b', pickers.buffers ' Buffers' , desc = desc('[b]uffers') }, build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release "
--lhs'B' used in telescope-file-browser .. "&& cmake --build build --config Release "
{ lhs'c', pickers.colorscheme ' Colorschemes' , desc = desc('[c]olorschemes') }, .. "&& cmake --install build --prefix build",
{ lhs'C', pickers.commands ' Commands' , desc = desc('[C]ommands') }, },
{ lhs'd', pickers.diagnostics '󰀪 Diagnostics' , desc = desc('[d]iagnostics') },
--lhs'e'
{ lhs'f', pickers.find_files ' Files' , desc = desc('[f]ind files') },
{ lhs'F', pickers.all_files ' ALL files' , desc = desc('all [F]iles') },
{ lhs'gr', pickers.live_grep ' Live grep' , desc = desc('Live [gr]ep') },
{ lhs'gf', pickers.git_files ' Git files' , desc = desc('[g]it [f]iles') },
{ lhs'gc', pickers.git_commits ' Commits' , desc = desc('[g]it [c]ommits') },
{ lhs'h', pickers.here ' Current buffer' , desc = desc('[b]uffer [h]ere') },
{ lhs'H', pickers.highlights '󰌶 Highlights' , desc = desc('[H]ighlights') },
--lhs'i' used in nerdy
{ lhs'j', pickers.jumplist ' Jumplist' , desc = desc('[j]umplist') },
{ lhs'k', pickers.keymaps ' Keymaps' , desc = desc('[k]eymaps') },
{ lhs'K', pickers.help_tags ' Help tags' , desc = desc('[K] help/documentation') },
{ lhs'l', pickers.loclist ' Location list' , desc = desc('[l]ocation List') },
{ lhs'm', pickers.man_pages ' Man pages' , desc = desc('[m]an pages') },
--lhs'n' used in vim-notify
{ lhs'o', pickers.vim_options ' Vim options' , desc = desc('[o]ptions') },
--lhs'p'
{ lhs'q', pickers.quickfix ' Quickfix' , desc = desc('[q]uickfix') },
{ lhs'r', pickers.lsp_references ' References' , desc = desc('[r]eferences') },
{ lhs'R', pickers.registers '󱓥 Registers' , desc = desc('[R]registers') },
{ lhs's', pickers.lsp_document_symbols '󰫧 Document Symbols ' , desc = desc('LSP document [s]ymbols') },
{ lhs'S', pickers.lsp_workspace_symbols '󱄑 Workspace Symbols ' , desc = desc('LSP workspace [S]ymbols') },
--lhs't' used in todo_comments
{ lhs'T', pickers.treesitter ' Treesitter symbols' , desc = desc('[T]reesitter Symbols') },
--lhs'u'
--lhs'v'
{ lhs'w', pickers.selection ' Grep' , desc = desc('[w]word under cursor') },
{ lhs'w', pickers.selection ' Grep', mode = 'v' , desc = desc('[w]ord(s) selected') },
--lhs'x'
--lhs'y'
{ lhs'z', pickers.spell_suggest '󰓆 Spelling suggestions' , desc = desc('[z] spell suggestions') },
{ lhs'.', pickers.dotfiles ' Dotfiles' , desc = desc('[.]dotfiles') },
{ lhs':', pickers.command_history ' Command history' , desc = desc('[:]command history') },
{ lhs'/', pickers.search_history ' Search history' , desc = desc('[/]search history') },
{ lhs'<leader>', pickers.resume '󰐎 Resume' , desc = desc('Resume ') },
}
M.opts = function(--[[plugin]]_, opts) cmd = "Telescope",
local actions = require('telescope.actions')
local layout = require('telescope.actions.layout') keymap_helper = { lhs = lhs, description = desc },
local trouble = vim.F.npcall(require, 'trouble.providers.telescope') or {}
keys = {
-- stylua: ignore start
{ lhs"a", pickers.autocommands " Autocommands" , desc = desc("[a]utocommands") },
{ lhs"b", pickers.buffers " Buffers" , desc = desc("[b]uffers") },
--lhs"B" used in telescope-file-browser
{ lhs"c", pickers.colorscheme " Colorschemes" , desc = desc("[c]olorschemes") },
{ lhs"C", pickers.commands " Commands" , desc = desc("[C]ommands") },
{ lhs"d", pickers.diagnostics "󰀪 Diagnostics" , desc = desc("[d]iagnostics") },
--lhs"e"
{ lhs"f", pickers.find_files " Files" , desc = desc("[f]ind files") },
{ lhs"F", pickers.all_files " ALL files" , desc = desc("all [F]iles") },
{ lhs"gr", pickers.live_grep " Live grep" , desc = desc("Live [gr]ep") },
{ lhs"gf", pickers.git_files " Git files" , desc = desc("[g]it [f]iles") },
{ lhs"gc", pickers.git_commits " Commits" , desc = desc("[g]it [c]ommits") },
{ lhs"h", pickers.here " Current buffer" , desc = desc("[b]uffer [h]ere") },
{ lhs"H", pickers.highlights "󰌶 Highlights" , desc = desc("[H]ighlights") },
--lhs"i" used in nerdy
{ lhs"j", pickers.jumplist " Jumplist" , desc = desc("[j]umplist") },
{ lhs"k", pickers.keymaps " Keymaps" , desc = desc("[k]eymaps") },
{ lhs"K", pickers.help_tags " Help tags" , desc = desc("[K] help/documentation") },
{ lhs"l", pickers.loclist " Location list" , desc = desc("[l]ocation List") },
{ lhs"m", pickers.man_pages " Man pages" , desc = desc("[m]an pages") },
--lhs"n" used in vim-notify
{ lhs"o", pickers.vim_options " Vim options" , desc = desc("[o]ptions") },
--lhs"p"
{ lhs"q", pickers.quickfix " Quickfix" , desc = desc("[q]uickfix") },
{ lhs"r", pickers.lsp_references " References" , desc = desc("[r]eferences") },
{ lhs"R", pickers.registers "󱓥 Registers" , desc = desc("[R]registers") },
{ lhs"s", pickers.lsp_document_symbols "󰫧 Document Symbols " , desc = desc("LSP document [s]ymbols") },
{ lhs"S", pickers.lsp_workspace_symbols "󱄑 Workspace Symbols " , desc = desc("LSP workspace [S]ymbols") },
--lhs"t" used in todo_comments
{ lhs"T", pickers.treesitter " Treesitter symbols" , desc = desc("[T]reesitter Symbols") },
--lhs"u"
--lhs"v"
{ lhs"w", pickers.selection " Grep" , desc = desc("[w]word under cursor") },
{ lhs"w", pickers.selection " Grep", mode = "v" , desc = desc("[w]ord(s) selected") },
--lhs"x"
--lhs"y"
{ lhs"z", pickers.spell_suggest "󰓆 Spelling suggestions" , desc = desc("[z] spell suggestions") },
{ lhs".", pickers.dotfiles " Dotfiles" , desc = desc("[.]dotfiles") },
{ lhs":", pickers.command_history " Command history" , desc = desc("[:]command history") },
{ lhs"/", pickers.search_history " Search history" , desc = desc("[/]search history") },
{ lhs"<leader>", pickers.resume "󰐎 Resume" , desc = desc("Resume ") },
-- stylua: ignore end
},
opts = function(_, opts)
local actions = require("telescope.actions")
local layout = require("telescope.actions.layout")
local trouble = vim.F.npcall(require, "trouble.providers.telescope") or {}
local mappings = { local mappings = {
['<c-j>'] = actions.cycle_history_next, ["<c-j>"] = actions.cycle_history_next,
['<c-k>'] = actions.cycle_history_prev, ["<c-k>"] = actions.cycle_history_prev,
['<s-down>'] = actions.preview_scrolling_down, ["<s-down>"] = actions.preview_scrolling_down,
['<s-up>'] = actions.preview_scrolling_up, ["<s-up>"] = actions.preview_scrolling_up,
['<c-y>'] = layout.cycle_layout_next, ["<c-y>"] = layout.cycle_layout_next,
['<c-o>'] = layout.toggle_mirror, ["<c-o>"] = layout.toggle_mirror,
['<c-h>'] = layout.toggle_preview, ["<c-h>"] = layout.toggle_preview,
['<c-s>'] = actions.select_horizontal, ["<c-s>"] = actions.select_horizontal,
['<c-x>'] = false, ["<c-x>"] = false,
['<c-c>'] = actions.close, ["<c-c>"] = actions.close,
['<c-q>'] = actions.smart_send_to_qflist + actions.open_qflist, ["<c-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
['<c-l>'] = actions.smart_send_to_loclist + actions.open_loclist, ["<c-l>"] = actions.smart_send_to_loclist + actions.open_loclist,
['<c-b>'] = trouble.smart_open_with_trouble, ["<c-b>"] = trouble.smart_open_with_trouble,
} }
return vim.tbl_deep_extend('force', opts or {}, { return vim.tbl_deep_extend("force", opts or {}, {
defaults = { defaults = {
mappings = { i = mappings, n = mappings }, mappings = { i = mappings, n = mappings },
prompt_prefix = ' ' .. icons.ui.Telescope .. ' ', prompt_prefix = " " .. icons.ui.Telescope .. " ",
selection_caret = icons.ui.Play .. ' ', selection_caret = icons.ui.Play .. " ",
multi_icon = icons.ui.Checkbox .. ' ', multi_icon = icons.ui.Checkbox .. " ",
scroll_strategy = 'limit', -- Don't wrap around in results. scroll_strategy = "limit", -- Don't wrap around in results.
dynamic_preview_title = true, dynamic_preview_title = true,
layout_strategy = 'flex', layout_strategy = "flex",
layout_config = { layout_config = {
width = 0.9, width = 0.9,
height = 0.9, height = 0.9,
@ -146,37 +150,34 @@ M.opts = function(--[[plugin]]_, opts)
horizontal = { preview_width = 0.5 }, horizontal = { preview_width = 0.5 },
vertical = { preview_height = 0.5 }, vertical = { preview_height = 0.5 },
}, },
cycle_layout_list = { 'horizontal', 'vertical' }, cycle_layout_list = {
"horizontal",
"vertical",
},
}, },
pickers = { pickers = {
buffers = { buffers = {
mappings = { n = { x = actions.delete_buffer } }, mappings = {
n = { x = actions.delete_buffer },
}, },
colorscheme = {
theme = 'dropdown',
},
spell_suggest = {
theme = 'cursor',
}, },
colorscheme = { theme = "dropdown" },
spell_suggest = { theme = "cursor" },
}, },
extensions = { extensions = {
file_browser = { file_browser = { theme = "ivy" },
theme = 'ivy'
},
}, },
}) })
end end,
M.config = function( --[[plugin]] _, opts) config = function(_, opts)
require('telescope').setup(opts) require("telescope").setup(opts)
require('telescope').load_extension('fzf') 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 }),
pattern = 'TelescopePreviewerLoaded', pattern = "TelescopePreviewerLoaded",
command = 'setlocal number' command = "setlocal number",
}) })
end end,
}
return M

View file

@ -1,8 +1,7 @@
local M = { 'johmsalas/text-case.nvim' } return {
"johmsalas/text-case.nvim",
M.event = { 'BufReadPost', 'BufNewFile' } event = { "BufReadPost", "BufNewFile" },
M.opts = { prefix = '<leader>c' }
return M
opts = { prefix = "<leader>c" },
}

View file

@ -1,22 +1,23 @@
local M = { 'folke/todo-comments.nvim' } local helper = require("fschauen.plugins.telescope").keymap_helper
local lhs, desc = helper.lhs, helper.description
M.dependencies = { return {
'nvim-lua/plenary.nvim', "folke/todo-comments.nvim",
'nvim-telescope/telescope.nvim',
}
M.event = { 'BufReadPost', 'BufNewFile' } dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
local ts = require('fschauen.plugins.telescope') event = { "BufReadPost", "BufNewFile" },
local lhs, desc = ts.keymap.lhs, ts.keymap.description
M.keys = { keys = {
{ lhs('t'), '<cmd>TodoTelescope<cr>', desc = desc('[t]odos') }, { lhs("t"), "<cmd>TodoTelescope<cr>", desc = desc("[t]odos") },
} },
M.opts = function(--[[plugin]]_, opts) opts = function(_, opts)
local icons = require('fschauen.util.icons') local icons = require("fschauen.util.icons")
return vim.tbl_deep_extend('force', opts or {}, { return vim.tbl_deep_extend("force", opts or {}, {
keywords = { keywords = {
TODO = { icon = icons.ui.Checkbox }, TODO = { icon = icons.ui.Checkbox },
FIX = { icon = icons.ui.Bug }, FIX = { icon = icons.ui.Bug },
@ -26,15 +27,13 @@ M.opts = function(--[[plugin]]_, opts)
NOTE = { icon = icons.ui.Note }, NOTE = { icon = icons.ui.Note },
TEST = { icon = icons.ui.TestTube }, TEST = { icon = icons.ui.TestTube },
}, },
gui_style = { fg = 'bold' }, gui_style = { fg = "bold" },
highlight = { highlight = {
multiline = false, multiline = false,
before = 'fg', before = "fg",
keyword = 'wide_fg', keyword = "wide_fg",
after = '', after = "",
} },
}) })
end end,
}
return M

View file

@ -1,60 +1,57 @@
local M = { 'nvim-treesitter/nvim-treesitter' } return {
"nvim-treesitter/nvim-treesitter",
M.build = ':TSUpdate' build = ":TSUpdate",
M.cmd = { cmd = { "TSInstall", "TSUpdate", "TSUpdateSync" },
'TSInstall',
'TSUpdate',
'TSUpdateSync',
}
M.dependencies = { dependencies = {
'nvim-treesitter/nvim-treesitter-refactor', "nvim-treesitter/nvim-treesitter-refactor",
'nvim-treesitter/nvim-treesitter-textobjects', "nvim-treesitter/nvim-treesitter-textobjects",
'nvim-treesitter/playground', "nvim-treesitter/playground",
} },
M.event = 'VeryLazy' event = "VeryLazy",
M.keys = { keys = {
{ '<leader>Tp', '<cmd>TSPlaygroundToggle<cr>', desc = ' [T]reesitter [p]layground (toggle)' }, -- stylua: ignore start
{ '<leader>Th', '<cmd>TSHighlightCapturesUnderCursor<cr>', desc = ' [T]reesitter [h]ighlights' }, { "<leader>Tp", "<cmd>TSPlaygroundToggle<cr>", desc = " [T]reesitter [p]layground (toggle)" },
{ '<leader>Tn', '<cmd>TSNodeUnderCursor<cr>', desc = ' [T]reesitter [n]ode under cursor' }, { "<leader>Th", "<cmd>TSHighlightCapturesUnderCursor<cr>", desc = " [T]reesitter [h]ighlights" },
} { "<leader>Tn", "<cmd>TSNodeUnderCursor<cr>", desc = " [T]reesitter [n]ode under cursor" },
-- stylua: ignore end
},
M.config = function(--[[plugin]]_, --[[opts]]_) config = function()
require('nvim-treesitter.configs').setup { require("nvim-treesitter.configs").setup {
ensure_installed = { ensure_installed = {
'bash', "bash",
'c', "c",
'cpp', "cpp",
'haskell', "haskell",
'html', "html",
'javascript', "javascript",
'latex', "latex",
'lua', "lua",
'make', "make",
'markdown', "markdown",
'markdown_inline', "markdown_inline",
'python', "python",
'query', "query",
'toml', "toml",
'vim', "vim",
'vimdoc', "vimdoc",
'yaml', "yaml",
}, },
highlight = { highlight = {
enable = true, enable = true,
disable = { disable = { "vimdoc" },
'vimdoc',
},
}, },
incremental_selection = { incremental_selection = {
enable = true, enable = true,
keymaps = { keymaps = {
init_selection = 'gnn', -- mapped in normal mode init_selection = "gnn", -- mapped in normal mode
node_incremental = '<CR>', -- mapped in visual mode node_incremental = "<CR>", -- mapped in visual mode
node_decremental = '<BS>', -- mapped in visual mode node_decremental = "<BS>", -- mapped in visual mode
scope_incremental = nil, -- disabled, normally mapped in visual mode scope_incremental = nil, -- disabled, normally mapped in visual mode
}, },
}, },
@ -63,18 +60,16 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
highlight_current_scope = { enable = false }, highlight_current_scope = { enable = false },
smart_rename = { smart_rename = {
enable = true, enable = true,
keymaps = { keymaps = { smart_rename = "grr" },
smart_rename = 'grr',
},
}, },
navigation = { navigation = {
enable = true, enable = true,
keymaps = { keymaps = {
goto_definition = 'gd', -- default: 'gnd' goto_definition = "gd", -- default: 'gnd'
list_definitions = nil, -- disabled, default: 'gnD' list_definitions = nil, -- disabled, default: 'gnD'
list_definitions_toc = 'gO', list_definitions_toc = "gO",
goto_next_usage = '<a-*>', goto_next_usage = "<a-*>",
goto_previous_usage = '<a-#>', goto_previous_usage = "<a-#>",
}, },
}, },
}, },
@ -82,24 +77,20 @@ M.config = function(--[[plugin]]_, --[[opts]]_)
select = { select = {
enable = true, enable = true,
keymaps = { keymaps = {
['ab'] = '@block.outer', ["ab"] = "@block.outer",
['ib'] = '@block.inner', ["ib"] = "@block.inner",
['ac'] = '@conditional.outer', ["ac"] = "@conditional.outer",
['ic'] = '@conditional.inner', ["ic"] = "@conditional.inner",
['af'] = '@function.outer', ["af"] = "@function.outer",
['if'] = '@function.inner', ["if"] = "@function.inner",
['al'] = '@loop.outer', ["al"] = "@loop.outer",
['il'] = '@loop.inner', ["il"] = "@loop.inner",
['aa'] = '@parameter.outer', ["aa"] = "@parameter.outer",
['ia'] = '@parameter.inner', ["ia"] = "@parameter.inner",
}, },
}, },
}, },
playground = { playground = { enable = true },
enable = true, }
}, end,
} }
end
return M

View file

@ -1,17 +1,18 @@
local M = { 'folke/trouble.nvim' } return {
"folke/trouble.nvim",
M.dependencies = { 'nvim-tree/nvim-web-devicons' } dependencies = "nvim-tree/nvim-web-devicons",
M.keys = { keys = {
{ '<leader>lt', '<cmd>TroubleToggle<cr>', desc = '󱠪 trouble [t]toggle' }, -- stylua: ignore start
{ '<leader>lw', '<cmd>TroubleToggle workspace_diagnostics<cr>', desc = '󱠪 trouble [w]orkspace' }, { "<leader>lt", "<cmd>TroubleToggle<cr>", desc = "󱠪 trouble [t]toggle" },
{ '<leader>ld', '<cmd>TroubleToggle document_diagnostics<cr>', desc = '󱠪 trouble [d]ocument' }, { "<leader>lw", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "󱠪 trouble [w]orkspace" },
} { "<leader>ld", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "󱠪 trouble [d]ocument" },
-- stylua: ignore end
},
M.opts = { opts = {
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
},
} }
return M

View file

@ -1,18 +1,17 @@
local M = { 'mbbill/undotree' } return {
"mbbill/undotree",
M.init = function(--[[plugin]]_) init = function()
vim.g.undotree_WindowLayout = 2 -- tree: left, diff: bottom vim.g.undotree_WindowLayout = 2 -- tree: left, diff: bottom
vim.g.undotree_DiffAutoOpen = 0 -- don't open diff by default vim.g.undotree_DiffAutoOpen = 0 -- don't open diff by default
vim.g.undotree_SetFocusWhenToggle = 1 vim.g.undotree_SetFocusWhenToggle = 1
vim.g.undotree_TreeNodeShape = '' vim.g.undotree_TreeNodeShape = ""
vim.g.undotree_TreeVertShape = '' vim.g.undotree_TreeVertShape = ""
vim.g.undotree_TreeSplitShape = '' vim.g.undotree_TreeSplitShape = ""
vim.g.undotree_TreeReturnShape = '' vim.g.undotree_TreeReturnShape = ""
end end,
M.keys = { keys = {
{ '<leader>u', '<cmd>UndotreeToggle<cr>' }, { "<leader>u", "<cmd>UndotreeToggle<cr>" },
},
} }
return M

View file

@ -1,26 +1,25 @@
local M = { 'lukas-reineke/virt-column.nvim' }
M.event = { 'BufReadPost', 'BufNewFile' }
local toggle_colorcolumn = function() local toggle_colorcolumn = function()
if vim.o.colorcolumn == '' then if vim.o.colorcolumn == "" then
vim.o.colorcolumn = '+1' -- one after 'textwidth' vim.o.colorcolumn = "+1" -- one after 'textwidth'
else else
vim.o.colorcolumn = '' -- none vim.o.colorcolumn = "" -- none
end end
end end
local toggle = require('fschauen.util.icons').ui.Toggle .. ' toggle ' local icons = require("fschauen.util.icons")
M.keys = { return {
{ '<leader>sc', toggle_colorcolumn, desc = toggle .. 'virtual colunn' }, "lukas-reineke/virt-column.nvim",
}
M.opts = function(--[[plugin]]_, opts) event = { "BufReadPost", "BufNewFile" },
return vim.tbl_deep_extend('force', opts or {}, {
char = require('fschauen.util.icons').ui.LineMiddle, keys = {
{ "<leader>sc", toggle_colorcolumn, desc = icons.ui.Toggle .. " toggle virtual colunn" },
},
opts = function(_, opts)
return vim.tbl_deep_extend("force", opts or {}, {
char = icons.ui.LineMiddle,
}) })
end end,
}
return M

View file

@ -1,23 +1,22 @@
local M = { 'ntpeters/vim-better-whitespace' } return {
"ntpeters/vim-better-whitespace",
M.init = function(--[[plugin]]_) event = { "BufReadPost", "BufNewFile" },
init = function()
vim.g.better_whitespace_filetypes_blacklist = { vim.g.better_whitespace_filetypes_blacklist = {
'diff', "diff",
'fugitive', "fugitive",
'git', "git",
'gitcommit', "gitcommit",
'help', "help",
} }
end end,
M.event = { 'BufReadPost', 'BufNewFile' } keys = {
{ "<leader>ww", "<cmd>ToggleWhitespace<cr>" },
M.keys = { { "<leader>wj", "<cmd>NextTrailingWhitespace<cr>" },
{ '<leader>ww', '<cmd>ToggleWhitespace<cr>' }, { "<leader>wk", "<cmd>PrevTrailingWhitespace<cr>" },
{ '<leader>wj', '<cmd>NextTrailingWhitespace<cr>' }, { "<leader>W", "<cmd>StripWhitespace<cr>" },
{ '<leader>wk', '<cmd>PrevTrailingWhitespace<cr>' }, },
{ '<leader>W', '<cmd>StripWhitespace<cr>' },
} }
return M

7
config/nvim/stylua.toml Normal file
View file

@ -0,0 +1,7 @@
column_width = 100
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "NoSingleTable"
collapse_simple_statement = "Never"