Make all plugin configs return a function

Simplifies writing the `config = ...` field for each plugin
This commit is contained in:
2023-09-25 16:08:06 +02:00
parent 7739ec5591
commit ac35b77c87
33 changed files with 747 additions and 618 deletions
+3 -3
View File
@@ -266,8 +266,8 @@ function P.setup_server(self, name)
self:reload_server_buf(name)
end
function P.setup(self)
self._setup_diagnostics()
function P.setup()
P._setup_diagnostics()
utils.try_require("cmp_nvim_lsp", package_name, function (mod)
P.capabilities = mod.default_capabilities()
@@ -276,7 +276,7 @@ function P.setup(self)
utils.try_require("mason-lspconfig", package_name, function (mod)
mod.setup_handlers({
function (name)
self:setup_server(name)
P:setup_server(name)
end,
})
end)
+29 -29
View File
@@ -30,14 +30,14 @@ local plugins = {
"rcarriga/nvim-notify",
priority = 900,
lazy = false,
config = function () require("plugins.notify") end,
config = require("plugins.notify"),
},
{
"rafamadriz/friendly-snippets",
},
{
"L3MON4D3/LuaSnip",
config = function () require("plugins.luasnip") end,
config = require("plugins.luasnip"),
-- comment out on windows and install jsregexp manually
build = (
require("utils").os_name ~= "Windows_NT"
@@ -48,7 +48,7 @@ local plugins = {
},
{
"windwp/nvim-autopairs",
config = function () require("plugins.autopairs") end,
config = require("plugins.autopairs"),
},
{
"saadparwaiz1/cmp_luasnip",
@@ -70,63 +70,63 @@ local plugins = {
},
{
"hrsh7th/nvim-cmp",
config = function () require("plugins.cmp") end,
config = require("plugins.cmp"),
},
{
"onsails/lspkind.nvim",
config = function () require("plugins.lspkind") end,
config = require("plugins.lspkind"),
},
{
"williamboman/mason.nvim",
config = function () require("plugins.mason") end,
config = require("plugins.mason"),
lazy = true,
event = "VimEnter",
},
{
"williamboman/mason-lspconfig.nvim",
config = function () require("plugins.mason_lspconfig") end,
config = require("plugins.mason_lspconfig"),
lazy = true,
event = "VimEnter",
},
{
"neovim/nvim-lspconfig",
config = function () require("lsp"):setup() end,
config = require("lsp").setup,
lazy = true,
ft = require("lsp"):filetypes(),
},
{
"nvim-treesitter/nvim-treesitter",
config = function () require("plugins.treesitter") end,
config = require("plugins.treesitter"),
build = ":TSUpdate",
lazy = true,
event = "VimEnter",
},
{
"mfussenegger/nvim-dap",
config = function () require("plugins.dap") end,
config = require("plugins.dap").setup,
lazy = true,
ft = require("lsp"):filetypes(),
},
{
"rcarriga/nvim-dap-ui",
config = function () require("plugins.dap_ui") end,
config = require("plugins.dap_ui"),
dependencies = {
"mfussenegger/nvim-dap",
},
},
{
"tpope/vim-fugitive",
config = function () require("plugins.fugitive") end,
config = require("plugins.fugitive"),
lazy = true,
event = "VimEnter",
},
{
"rbong/vim-flog",
config = function () require("plugins.flog") end,
config = require("plugins.flog"),
},
{
"nvim-lualine/lualine.nvim",
config = function () require("plugins.lualine") end,
config = require("plugins.lualine"),
lazy = true,
event = "VimEnter",
dependencies = {
@@ -135,13 +135,13 @@ local plugins = {
},
{
"lewis6991/gitsigns.nvim",
config = function () require("plugins.gitsigns") end,
config = require("plugins.gitsigns"),
lazy = true,
event = "VimEnter",
},
{
"nvim-telescope/telescope.nvim",
config = function () require("plugins.telescope") end,
config = require("plugins.telescope"),
lazy = true,
event = "VimEnter",
dependencies = {
@@ -150,25 +150,25 @@ local plugins = {
},
{
"numToStr/Comment.nvim",
config = function () require("plugins.comment") end,
config = require("plugins.comment"),
lazy = true,
event = "VimEnter",
},
{
"lukas-reineke/indent-blankline.nvim",
config = function () require("plugins.indent-blankline") end,
config = require("plugins.indent-blankline"),
lazy = true,
event = "VimEnter",
},
{
"simeji/winresizer",
config = function () require("plugins.winresizer") end,
config = require("plugins.winresizer"),
lazy = true,
keys = { "<C-W>r", },
},
{
"sindrets/winshift.nvim",
config = function () require("plugins.winshift") end,
config = require("plugins.winshift"),
lazy = true,
keys = { "<C-W>m", },
},
@@ -179,7 +179,7 @@ local plugins = {
},
{
"kyazdani42/nvim-tree.lua",
config = function () require("plugins.tree") end,
config = require("plugins.tree"),
dependencies = {
"nvim-tree/nvim-web-devicons",
},
@@ -191,7 +191,7 @@ local plugins = {
},
{
"stevearc/aerial.nvim",
config = function () require("plugins.aerial") end,
config = require("plugins.aerial"),
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons",
@@ -199,23 +199,23 @@ local plugins = {
},
{
"RubixDev/mason-update-all",
config = function () require("plugins.mason_update_all") end,
config = require("plugins.mason_update_all"),
},
{
"famiu/bufdelete.nvim",
config = function () require("plugins.bufdelete") end,
config = require("plugins.bufdelete"),
},
{
"nvim-treesitter/nvim-treesitter-context",
config = function () require("plugins.treesitter-context") end,
config = require("plugins.treesitter-context"),
},
{
"fedepujol/move.nvim",
config = function () require("plugins.move") end,
config = require("plugins.move"),
},
{
"nvim-orgmode/orgmode",
config = function () require("plugins.orgmode") end,
config = require("plugins.orgmode"),
dependencies = {
"nvim-treesitter/nvim-treesitter",
},
@@ -225,7 +225,7 @@ local plugins = {
},
{
"sindrets/diffview.nvim",
config = function () require("plugins.diffview") end,
config = require("plugins.diffview"),
dependencies = {
"nvim-tree/nvim-web-devicons",
},
@@ -233,7 +233,7 @@ local plugins = {
{
"iamcco/markdown-preview.nvim",
build = "cd app && npm install",
config = function () require("plugins.markdown-preview") end,
config = require("plugins.markdown-preview"),
},
}
+24 -20
View File
@@ -13,23 +13,27 @@
-- https://github.com/stevearc/aerial.nvim
require("aerial").setup({
layout = {
min_width = 40,
placement = "edge",
},
disable_max_size = 10000000,
highlight_on_hover = true,
ignore = {
unlisted_buffers = true,
},
on_attach = function (bufnr)
vim.keymap.set(
"n",
"<leader>at",
function () vim.cmd.AerialToggle({ bang = true, }) end,
{ buffer = bufnr, }
)
end,
show_guides = true,
})
local function setup()
require("aerial").setup({
layout = {
min_width = 40,
placement = "edge",
},
disable_max_size = 10000000,
highlight_on_hover = true,
ignore = {
unlisted_buffers = true,
},
on_attach = function (bufnr)
vim.keymap.set(
"n",
"<leader>at",
function () vim.cmd.AerialToggle({ bang = true, }) end,
{ buffer = bufnr, }
)
end,
show_guides = true,
})
end
return setup
+7 -3
View File
@@ -16,6 +16,10 @@
-- https://github.com/windwp/nvim-autopairs
require("nvim-autopairs").setup({
fast_wrap = {},
})
local function setup()
require("nvim-autopairs").setup({
fast_wrap = {},
})
end
return setup
+10 -6
View File
@@ -16,9 +16,13 @@
-- https://github.com/famiu/bufdelete.nvim
vim.keymap.set(
"n",
"<C-w>q",
vim.cmd.Bwipeout,
{ remap = false, silent = true, }
)
local function setup()
vim.keymap.set(
"n",
"<C-w>q",
vim.cmd.Bwipeout,
{ remap = false, silent = true, }
)
end
return setup
+51 -47
View File
@@ -16,57 +16,61 @@
-- https://github.com/catppuccin/nvim
local catppuccin = require("catppuccin")
local function setup()
local catppuccin = require("catppuccin")
-- Sometimes requires running :CatppuccinCompile,
-- like when switching to a font that supports italics.
catppuccin.setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
no_italic = false,
styles = {
comments = { "italic", },
},
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
treesitter = true,
notify = true,
aerial = true,
indent_blankline = {
enabled = true,
colored_indent_levels = false,
-- Sometimes requires running :CatppuccinCompile,
-- like when switching to a font that supports italics.
catppuccin.setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
no_italic = false,
styles = {
comments = { "italic", },
},
mason = true,
neogit = true,
noice = true,
dap = {
enabled = true,
enable_ui = true,
},
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic", },
hints = { "italic", },
warnings = { "italic", },
information = { "italic", },
integrations = {
cmp = true,
gitsigns = true,
nvimtree = true,
treesitter = true,
notify = true,
aerial = true,
indent_blankline = {
enabled = true,
colored_indent_levels = false,
},
underlines = {
errors = { "underline", },
hints = { "underline", },
warnings = { "underline", },
information = { "underline", },
mason = true,
neogit = true,
noice = true,
dap = {
enabled = true,
enable_ui = true,
},
inlay_hints = {
background = true,
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic", },
hints = { "italic", },
warnings = { "italic", },
information = { "italic", },
},
underlines = {
errors = { "underline", },
hints = { "underline", },
warnings = { "underline", },
information = { "underline", },
},
inlay_hints = {
background = true,
},
},
telescope = {
enabled = true,
},
lsp_trouble = true,
},
telescope = {
enabled = true,
},
lsp_trouble = true,
},
})
})
catppuccin.load()
catppuccin.load()
end
return setup
+147 -141
View File
@@ -16,9 +16,7 @@
-- https://github.com/hrsh7th/nvim-cmp
local module_name = "plugins.config.cmp"
local has_words_before = function ()
local function has_words_before()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
@@ -27,149 +25,157 @@ local has_words_before = function ()
:match("%s") == nil
end
local utils = require("utils")
local cmp = require("cmp")
local luasnip = require("luasnip")
local function setup()
local module_name = "plugins.config.cmp"
local utils = require("utils")
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind
utils.try_require("lspkind", module_name, function (module)
lspkind = module
end)
local lspkind
utils.try_require("lspkind", module_name, function (module)
lspkind = module
end)
cmp.setup({
enabled = function ()
-- disable completion in comments
local context = require "cmp.config.context"
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == "c" then
return true
else
return not context.in_treesitter_capture("comment") and
not context.in_syntax_group("Comment")
end
end,
completion = { keyword_length = 3, },
snippet = {
expand = function (args)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
format = function (entry, vim_item)
if lspkind then
vim_item = lspkind.cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = "...",
before = function (_, item)
item.dup = 0 -- remove duplicates, see nvim-cmp #511
return item
end,
})(entry, vim_item)
cmp.setup({
enabled = function ()
-- disable completion in comments
local context = require "cmp.config.context"
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == "c" then
return true
else
return not context.in_treesitter_capture("comment") and
not context.in_syntax_group("Comment")
end
return vim_item
end,
},
experimental = { ghost_text = true, },
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<CR>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.confirm(
{
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}
)
else
fallback()
completion = { keyword_length = 3, },
snippet = {
expand = function (args)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
format = function (entry, vim_item)
if lspkind then
vim_item = lspkind.cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = "...",
before = function (_, item)
item.dup = 0 -- remove duplicates, see nvim-cmp #511
return item
end,
})(entry, vim_item)
end
end, { "i", "s", }
),
["<Tab>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s", }
),
["<S-Tab>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s", }
),
["<Down>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { "i", "s", }
),
["<Up>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s", }
),
},
sources = {
{ name = "nvim_lsp", },
{ name = "luasnip", },
{ name = "nvim_lua", },
{ name = "orgmode", },
{ name = "path", },
-- { name = 'buffer' },
},
})
cmp.setup.cmdline(
"/",
{
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = "buffer", }, },
}
)
return vim_item
end,
},
experimental = { ghost_text = true, },
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<CR>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.confirm(
{
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}
)
else
fallback()
end
end, { "i", "s", }
),
["<Tab>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s", }
),
["<S-Tab>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s", }
),
["<Down>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { "i", "s", }
),
["<Up>"] = cmp.mapping(
function (fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s", }
),
},
sources = {
{ name = "nvim_lsp", },
{ name = "luasnip", },
{ name = "nvim_lua", },
{ name = "orgmode", },
{ name = "path", },
-- { name = 'buffer' },
},
})
cmp.setup.cmdline(
":",
{
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources(
{ { name = "path", }, },
{ { name = "cmdline", option = { ignore_cmds = { "Man", "!", }, }, }, }
),
}
)
cmp.setup.cmdline(
"/",
{
mapping = cmp.mapping.preset.cmdline(),
sources = { { name = "buffer", }, },
}
)
utils.try_require(
"nvim-autopairs.completion.cmp",
module_name,
function (cmp_autopairs)
cmp.event:on(
"confirm_done",
cmp_autopairs.on_confirm_done()
)
end
)
cmp.setup.cmdline(
":",
{
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources(
{ { name = "path", }, },
{ {
name = "cmdline",
option = { ignore_cmds = { "Man", "!", }, },
}, }
),
}
)
utils.try_require(
"nvim-autopairs.completion.cmp",
module_name,
function (cmp_autopairs)
cmp.event:on(
"confirm_done",
cmp_autopairs.on_confirm_done()
)
end
)
end
return setup
+10 -6
View File
@@ -16,9 +16,13 @@
-- https://github.com/numToStr/Comment.nvim
require("Comment").setup(
{
--ignore empty lines
ignore = "^$",
}
)
local function setup()
require("Comment").setup(
{
--ignore empty lines
ignore = "^$",
}
)
end
return setup
+29 -24
View File
@@ -16,29 +16,25 @@
-- https://github.com/mfussenegger/nvim-dap
local dap = require("dap")
vim.keymap.set("n", "<F5>", dap.continue)
vim.keymap.set("n", "<F10>", dap.step_over)
vim.keymap.set("n", "<F11>", dap.step_into)
vim.keymap.set("n", "<F12>", dap.step_out)
local utils = require("utils")
local M = {}
local env_ok = false
M.env_ok = false
function M.check_env()
local utils = require("utils")
local function check_env()
utils.assert_installed("python3")
utils.assert_python3_module_installed("debugpy")
env_ok = true
M.env_ok = true
end
local function start(config)
if not env_ok then
check_env()
function M.start(config)
local dap = require("dap")
if not M.env_ok then
M:check_env()
end
dap.adapters.python = {
type = "executable",
command = "python",
@@ -65,7 +61,7 @@ function M.launch(args)
console = "integratedTerminal",
args = args,
}
start(config)
M.start(config)
end
function M.pytest(args)
@@ -83,16 +79,25 @@ function M.pytest(args)
console = "integratedTerminal",
-- program = "${file}";
}
start(config)
M.start(config)
end
--[[
TODO: Add this after loading dap for integrating catppuccin:
local sign = vim.fn.sign_define
function M.setup()
local dap = require("dap")
sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = ""})
sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = ""})
sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = ""})
--]]
vim.keymap.set("n", "<F5>", dap.continue)
vim.keymap.set("n", "<F10>", dap.step_over)
vim.keymap.set("n", "<F11>", dap.step_into)
vim.keymap.set("n", "<F12>", dap.step_out)
--[[
TODO: Add this after loading dap for integrating catppuccin:
local sign = vim.fn.sign_define
sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = ""})
sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = ""})
sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = ""})
--]]
end
return M
+43 -39
View File
@@ -16,44 +16,48 @@
-- https://github.com/rcarriga/nvim-dap-ui
require("dapui").setup({
icons = { expanded = "", collapsed = "", },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>", },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
layouts = {
{
elements = {
"scopes",
"breakpoints",
"stacks",
"watches",
},
size = 40,
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 10,
position = "bottom",
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded"
local function setup()
require("dapui").setup({
icons = { expanded = "", collapsed = "", },
mappings = {
close = { "q", "<Esc>", },
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>", },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
},
windows = { indent = 1, },
})
layouts = {
{
elements = {
"scopes",
"breakpoints",
"stacks",
"watches",
},
size = 40,
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 10,
position = "bottom",
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>", },
},
},
windows = { indent = 1, },
})
end
return setup
+67 -63
View File
@@ -16,72 +16,76 @@
-- https://github.com/sindrets/diffview.nvim
local actions = require("diffview.actions")
local function setup()
local actions = require("diffview.actions")
require("diffview").setup({
enhanced_diff_hl = true,
view = {
default = {
layout = "diff2_horizontal",
winbar_info = true,
},
merge_tool = {
layout = "diff3_mixed",
disable_diagnostics = true,
winbar_info = true,
},
file_history = {
layout = "diff2_horizontal",
winbar_info = true,
},
},
default_args = {
DiffviewOpen = { "--imply-local", },
},
keymaps = {
file_panel = {
["<cr>"] = false,
{
"n",
"<CR>",
function ()
actions.select_entry()
vim.cmd.wincmd("l")
end,
{ desc = "Open the current file in diffview", },
require("diffview").setup({
enhanced_diff_hl = true,
view = {
default = {
layout = "diff2_horizontal",
winbar_info = true,
},
{
"n",
"s",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
merge_tool = {
layout = "diff3_mixed",
disable_diagnostics = true,
winbar_info = true,
},
{
"n",
"u",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
},
{
"n",
"cc",
function ()
vim.cmd.G("commit")
vim.cmd.wincmd("J")
end,
{ desc = "Commit staged changes", },
},
{
"n",
"ca",
function ()
vim.cmd.G("commit --amend")
vim.cmd.wincmd("J")
end,
{ desc = "Amend the last commit", },
file_history = {
layout = "diff2_horizontal",
winbar_info = true,
},
},
},
})
default_args = {
DiffviewOpen = { "--imply-local", },
},
keymaps = {
file_panel = {
["<cr>"] = false,
{
"n",
"<CR>",
function ()
actions.select_entry()
vim.cmd.wincmd("l")
end,
{ desc = "Open the current file in diffview", },
},
{
"n",
"s",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
},
{
"n",
"u",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry", },
},
{
"n",
"cc",
function ()
vim.cmd.G("commit")
vim.cmd.wincmd("J")
end,
{ desc = "Commit staged changes", },
},
{
"n",
"ca",
function ()
vim.cmd.G("commit --amend")
vim.cmd.wincmd("J")
end,
{ desc = "Amend the last commit", },
},
},
},
})
vim.keymap.set("n", "<leader>gg", vim.cmd.DiffviewOpen)
vim.keymap.set("n", "<leader>gg", vim.cmd.DiffviewOpen)
end
return setup
+5 -1
View File
@@ -16,4 +16,8 @@
-- https://github.com/rbong/vim-flog
vim.keymap.set("n", "<leader>gl", vim.cmd.Flog)
local function setup()
vim.keymap.set("n", "<leader>gl", vim.cmd.Flog)
end
return setup
+18 -14
View File
@@ -16,19 +16,23 @@
-- https://github.com/tpope/vim-fugitive
local function git_status_tab()
vim.cmd.tabnew()
vim.cmd("leftabove vertical G")
vim.cmd("vertical resize 60")
vim.cmd.set("wfw")
local function setup()
local function git_status_tab()
vim.cmd.tabnew()
vim.cmd("leftabove vertical G")
vim.cmd("vertical resize 60")
vim.cmd.set("wfw")
end
vim.keymap.set("n", "<leader>gd", vim.cmd.Gdiffsplit)
vim.keymap.set("n", "<leader>gc", function () vim.cmd.G("commit") end)
vim.keymap.set("n", "<leader>ga", function () vim.cmd.G("commit --amend") end)
vim.keymap.set("n", "<leader>gp", function () vim.cmd.G("push") end)
-- Only used if diffview is not available
if not pcall(require, "diffview") then
vim.keymap.set("n", "<leader>gg", git_status_tab)
end
end
vim.keymap.set("n", "<leader>gd", vim.cmd.Gdiffsplit)
vim.keymap.set("n", "<leader>gc", function () vim.cmd.G("commit") end)
vim.keymap.set("n", "<leader>ga", function () vim.cmd.G("commit --amend") end)
vim.keymap.set("n", "<leader>gp", function () vim.cmd.G("push") end)
-- Only used if diffview is not available
if not pcall(require, "diffview") then
vim.keymap.set("n", "<leader>gg", git_status_tab)
end
return setup
+32 -26
View File
@@ -16,29 +16,35 @@
-- https://github.com/lewis6991/gitsigns.nvim
require("gitsigns").setup({
on_attach = function (bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set("n", "<leader>gv", gs.select_hunk, { buffer = bufnr, })
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr, })
vim.keymap.set("n", "<leader>gu", gs.undo_stage_hunk, { buffer = bufnr, })
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr, })
vim.keymap.set(
"x",
"<leader>gr",
":Gitsigns reset_hunk<CR>",
{ buffer = bufnr, }
)
vim.keymap.set("n", "<leader>g?", gs.preview_hunk, { buffer = bufnr, })
vim.keymap.set(
"n",
"<leader>gb",
function ()
gs.blame_line { full = true, ignore_whitespace = true, }
end,
{ buffer = bufnr, })
end,
signs = {
untracked = { text = "", },
},
})
local function setup()
require("gitsigns").setup({
on_attach = function (bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set("n", "<leader>gv", gs.select_hunk, { buffer = bufnr, })
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr, })
vim.keymap.set("n", "<leader>gu", gs.undo_stage_hunk,
{ buffer = bufnr, })
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr, })
vim.keymap.set(
"x",
"<leader>gr",
":Gitsigns reset_hunk<CR>",
{ buffer = bufnr, }
)
vim.keymap.set("n", "<leader>g?", gs.preview_hunk,
{ buffer = bufnr, })
vim.keymap.set(
"n",
"<leader>gb",
function ()
gs.blame_line { full = true, ignore_whitespace = true, }
end,
{ buffer = bufnr, })
end,
signs = {
untracked = { text = "", },
},
})
end
return setup
+11 -7
View File
@@ -14,10 +14,14 @@
limitations under the License.
]]
require("indent_blankline").setup {
use_treesitter = true,
show_first_indent_level = false,
show_trailing_blankline_indent = false,
show_current_context = true,
max_indent_increase = 1
}
local function setup()
require("indent_blankline").setup {
use_treesitter = true,
show_first_indent_level = false,
show_trailing_blankline_indent = false,
show_current_context = true,
max_indent_increase = 1,
}
end
return setup
+4
View File
@@ -17,3 +17,7 @@
-- https://github.com/onsails/lspkind.nvim
-- configured and loaded in plugins.config.cmp
local function setup()
end
return setup
+31 -27
View File
@@ -16,32 +16,36 @@
-- https://github.com/nvim-lualine/lualine.nvim
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "", },
section_separators = { left = "", right = "", },
always_divide_middle = true,
globalstatus = true,
},
sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
"mode",
{ "filename", path = 1, },
"diff",
{ "diagnostics", sources = { "nvim_lsp", }, },
local function setup()
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "", },
section_separators = { left = "", right = "", },
always_divide_middle = true,
globalstatus = true,
},
lualine_x = {
"bo:filetype",
"encoding",
"bo:fileformat",
"progress",
"location",
sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
"mode",
{ "filename", path = 1, },
"diff",
{ "diagnostics", sources = { "nvim_lsp", }, },
},
lualine_x = {
"bo:filetype",
"encoding",
"bo:fileformat",
"progress",
"location",
},
lualine_y = {},
lualine_z = {},
},
lualine_y = {},
lualine_z = {},
},
})
})
end
return setup
+5 -1
View File
@@ -16,4 +16,8 @@
-- https://github.com/L3MON4D3/LuaSnip
require("luasnip.loaders.from_vscode").lazy_load()
local function setup()
require("luasnip.loaders.from_vscode").lazy_load()
end
return setup
+9 -5
View File
@@ -16,8 +16,12 @@
-- https://github.com/iamcco/markdown-preview.nvim
vim.g.mkdp_filetypes = { "markdown", }
vim.g.mkdp_port = "9080"
vim.g.mkdp_echo_preview_url = 1
vim.g.mkdp_open_ip = "192.168.2.22"
vim.g.mkdp_open_to_the_world = 1
local function setup()
vim.g.mkdp_filetypes = { "markdown", }
vim.g.mkdp_port = "9080"
vim.g.mkdp_echo_preview_url = 1
vim.g.mkdp_open_ip = "192.168.2.22"
vim.g.mkdp_open_to_the_world = 1
end
return setup
+5 -1
View File
@@ -16,4 +16,8 @@
-- https://github.com/williamboman/mason.nvim
require("mason").setup()
local function setup()
require("mason").setup()
end
return setup
+10 -6
View File
@@ -16,9 +16,13 @@
-- https://github.com/williamboman/mason-lspconfig.nvim
require("mason-lspconfig").setup({
-- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "lua_ls" }
-- This setting has no relation with the `automatic_installation` setting.
---@type string[]
ensure_installed = require("lsp"):language_servers(),
})
local function setup()
require("mason-lspconfig").setup({
-- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "lua_ls" }
-- This setting has no relation with the `automatic_installation` setting.
---@type string[]
ensure_installed = require("lsp"):language_servers(),
})
end
return setup
+5 -1
View File
@@ -16,4 +16,8 @@
-- https://github.com/RubixDev/mason-update-all
require("mason-update-all").setup()
local function setup()
require("mason-update-all").setup()
end
return setup
+13 -9
View File
@@ -16,12 +16,16 @@
-- https://github.com/fedepujol/move.nvim
local opts = { noremap = true, silent = true, }
vim.keymap.set("n", "<A-j>", function () vim.cmd.MoveLine(1) end, opts)
vim.keymap.set("n", "<A-k>", function () vim.cmd.MoveLine(-1) end, opts)
vim.keymap.set("n", "<A-h>", function () vim.cmd.MoveHChar(-1) end, opts)
vim.keymap.set("n", "<A-l>", function () vim.cmd.MoveHChar(1) end, opts)
vim.keymap.set("x", "<A-j>", ":MoveBlock(1)<CR>", opts)
vim.keymap.set("x", "<A-k>", ":MoveBlock(-1)<CR>", opts)
vim.keymap.set("x", "<A-h>", ":MoveHBlock(-1)<CR>", opts)
vim.keymap.set("x", "<A-l>", ":MoveHBlock(1)<CR>", opts)
local function setup()
local opts = { noremap = true, silent = true, }
vim.keymap.set("n", "<A-j>", function () vim.cmd.MoveLine(1) end, opts)
vim.keymap.set("n", "<A-k>", function () vim.cmd.MoveLine(-1) end, opts)
vim.keymap.set("n", "<A-h>", function () vim.cmd.MoveHChar(-1) end, opts)
vim.keymap.set("n", "<A-l>", function () vim.cmd.MoveHChar(1) end, opts)
vim.keymap.set("x", "<A-j>", ":MoveBlock(1)<CR>", opts)
vim.keymap.set("x", "<A-k>", ":MoveBlock(-1)<CR>", opts)
vim.keymap.set("x", "<A-h>", ":MoveHBlock(-1)<CR>", opts)
vim.keymap.set("x", "<A-l>", ":MoveHBlock(1)<CR>", opts)
end
return setup
+14 -10
View File
@@ -16,17 +16,21 @@
-- https://github.com/rcarriga/nvim-notify
local has_telescope, telescope = pcall(require, "telescope")
local function setup()
local has_telescope, telescope = pcall(require, "telescope")
local notify = require("notify")
notify.setup({
render = "default",
stages = "static",
})
local notify = require("notify")
notify.setup({
render = "default",
stages = "static",
})
vim.notify = notify
vim.notify = notify
if has_telescope then
telescope.load_extension("notify")
vim.keymap.set("n", "<leader>fn", telescope.extensions.notify.notify)
if has_telescope then
telescope.load_extension("notify")
vim.keymap.set("n", "<leader>fn", telescope.extensions.notify.notify)
end
end
return setup
+32 -28
View File
@@ -16,32 +16,36 @@
-- https://github.com/nvim-orgmode/orgmode
local orgmode = require("orgmode")
orgmode.setup_ts_grammar()
orgmode.setup({
org_agenda_files = { "~/Documents/org/**/*", },
org_default_notes_file = "~/Documents/org/notes.org",
org_todo_keywords = {
"TODO(t)",
"ACTIVE(a)",
"WAITING(w)",
"|",
"DONE(d)",
"DISCARDED(c)",
},
org_todo_keyword_faces = {
ACTIVE = ":foreground dodgerblue :weight bold",
WAITING = ":foreground lightgoldenrod :weight bold",
DISCARDED = ":foreground grey :weight bold",
},
win_split_mode = "float",
win_border = "single",
org_archive_location = "~/Documents/org/archive.org::",
org_log_done = "note",
org_log_into_drawer = "LOGBOOK",
org_highlight_latex_and_related = "entities",
org_agenda_span = "week",
org_agenda_skip_scheduled_if_done = true,
org_agenda_skip_deadline_if_done = true,
local function setup()
local orgmode = require("orgmode")
orgmode.setup_ts_grammar()
orgmode.setup({
org_agenda_files = { "~/Documents/org/**/*", },
org_default_notes_file = "~/Documents/org/notes.org",
org_todo_keywords = {
"TODO(t)",
"ACTIVE(a)",
"WAITING(w)",
"|",
"DONE(d)",
"DISCARDED(c)",
},
org_todo_keyword_faces = {
ACTIVE = ":foreground dodgerblue :weight bold",
WAITING = ":foreground lightgoldenrod :weight bold",
DISCARDED = ":foreground grey :weight bold",
},
win_split_mode = "float",
win_border = "single",
org_archive_location = "~/Documents/org/archive.org::",
org_log_done = "note",
org_log_into_drawer = "LOGBOOK",
org_highlight_latex_and_related = "entities",
org_agenda_span = "week",
org_agenda_skip_scheduled_if_done = true,
org_agenda_skip_deadline_if_done = true,
})
})
end
return setup
+32 -28
View File
@@ -16,32 +16,36 @@
-- https://github.com/nvim-telescope/telescope.nvim
local builtin = require("telescope.builtin")
local function setup()
local builtin = require("telescope.builtin")
vim.keymap.set(
"n",
"<leader>ff",
function () builtin.find_files({ hidden = true, }) end
)
vim.keymap.set(
"n",
"<leader>fr",
function () builtin.oldfiles({ hidden = true, }) end
)
vim.keymap.set(
"n", "<leader>fg", function ()
builtin.live_grep(
{
additional_args = function (_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
}
)
end
)
vim.keymap.set("n", "<leader>fb", builtin.buffers)
vim.keymap.set(
"n",
"<leader>ff",
function () builtin.find_files({ hidden = true, }) end
)
vim.keymap.set(
"n",
"<leader>fr",
function () builtin.oldfiles({ hidden = true, }) end
)
vim.keymap.set(
"n", "<leader>fg", function ()
builtin.live_grep(
{
additional_args = function (_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
}
)
end
)
vim.keymap.set("n", "<leader>fb", builtin.buffers)
end
return setup
+14 -10
View File
@@ -16,15 +16,19 @@
-- https://github.com/folke/tokyonight.nvim
local tokyonight = require("tokyonight")
local function setup()
local tokyonight = require("tokyonight")
tokyonight.setup({
style = "night",
styles = {
comments = { italic = false, },
keywords = { italic = false, },
},
lualine_bold = false,
})
tokyonight.setup({
style = "night",
styles = {
comments = { italic = false, },
keywords = { italic = false, },
},
lualine_bold = false,
})
tokyonight.load()
tokyonight.load()
end
return setup
+46 -42
View File
@@ -16,52 +16,56 @@
-- https://github.com/nvim-tree/nvim-tree.lua
require("nvim-tree").setup({
sync_root_with_cwd = true,
view = {
width = 40,
preserve_window_proportions = true,
},
renderer = {
add_trailing = true,
group_empty = true,
highlight_git = true,
indent_markers = {
enable = true,
local function setup()
require("nvim-tree").setup({
sync_root_with_cwd = true,
view = {
width = 40,
preserve_window_proportions = true,
},
icons = {
git_placement = "after",
show = {
folder_arrow = true,
renderer = {
add_trailing = true,
group_empty = true,
highlight_git = true,
indent_markers = {
enable = true,
},
icons = {
git_placement = "after",
show = {
folder_arrow = true,
},
},
},
},
update_focused_file = {
enable = true,
update_root = true,
ignore_list = {
"help",
update_focused_file = {
enable = true,
update_root = true,
ignore_list = {
"help",
},
},
},
diagnostics = {
enable = true,
show_on_dirs = false,
},
actions = {
change_dir = {
enable = false,
diagnostics = {
enable = true,
show_on_dirs = false,
},
open_file = {
resize_window = true,
actions = {
change_dir = {
enable = false,
},
open_file = {
resize_window = true,
},
},
},
filters = {
custom = { "^\\.git$", },
},
notify = {
threshold = vim.log.levels.WARN,
absolute_path = false,
},
})
filters = {
custom = { "^\\.git$", },
},
notify = {
threshold = vim.log.levels.WARN,
absolute_path = false,
},
})
vim.keymap.set("n", "<leader>tt", require("nvim-tree.api").tree.toggle)
vim.keymap.set("n", "<leader>tt", require("nvim-tree.api").tree.toggle)
end
return setup
+8 -4
View File
@@ -16,7 +16,11 @@
-- https://github.com/nvim-treesitter/nvim-treesitter-context
require("treesitter-context").setup({
max_lines = 1,
min_window_height = 10,
})
local function setup()
require("treesitter-context").setup({
max_lines = 1,
min_window_height = 10,
})
end
return setup
+4
View File
@@ -16,6 +16,7 @@
-- https://github.com/nvim-treesitter/nvim-treesitter
local function setup()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"c", -- recommended default
@@ -49,3 +50,6 @@ require("nvim-treesitter.configs").setup({
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.foldenable = false
end
return setup
+12 -8
View File
@@ -16,13 +16,17 @@
-- https://github.com/Mofiqul/vscode.nvim
local vscode = require("vscode")
local function setup()
local vscode = require("vscode")
vscode.setup({
style = "dark",
transparent = false,
italic_comments = false,
disable_nvimtree_bg = false,
})
vscode.setup({
style = "dark",
transparent = false,
italic_comments = false,
disable_nvimtree_bg = false,
})
vscode.load()
vscode.load()
end
return setup
+8 -4
View File
@@ -16,8 +16,12 @@
-- https://github.com/simeji/winresizer
vim.g.winresizer_vert_resize = "5"
vim.g.winresizer_horiz_resize = "5"
vim.g.winresizer_start_key = ""
local function setup()
vim.g.winresizer_vert_resize = "5"
vim.g.winresizer_horiz_resize = "5"
vim.g.winresizer_start_key = ""
vim.keymap.set("n", "<C-W>r", vim.cmd.WinResizerStartResize)
vim.keymap.set("n", "<C-W>r", vim.cmd.WinResizerStartResize)
end
return setup
+9 -5
View File
@@ -16,8 +16,12 @@
-- https://github.com/sindrets/winshift.nvim
vim.keymap.set(
"n",
"<C-W>m",
vim.cmd.WinShift
)
local function setup()
vim.keymap.set(
"n",
"<C-W>m",
vim.cmd.WinShift
)
end
return setup