diff --git a/lua/lsp.lua b/lua/lsp.lua index e4bb6f8..e3dcf3f 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -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) diff --git a/lua/plugins.lua b/lua/plugins.lua index 945be8e..de8066c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -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 = { "r", }, }, { "sindrets/winshift.nvim", - config = function () require("plugins.winshift") end, + config = require("plugins.winshift"), lazy = true, keys = { "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"), }, } diff --git a/lua/plugins/aerial.lua b/lua/plugins/aerial.lua index 82fb03b..8bb87f2 100644 --- a/lua/plugins/aerial.lua +++ b/lua/plugins/aerial.lua @@ -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", - "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", + "at", + function () vim.cmd.AerialToggle({ bang = true, }) end, + { buffer = bufnr, } + ) + end, + show_guides = true, + }) +end + +return setup diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua index a4ff9e2..620677b 100644 --- a/lua/plugins/autopairs.lua +++ b/lua/plugins/autopairs.lua @@ -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 diff --git a/lua/plugins/bufdelete.lua b/lua/plugins/bufdelete.lua index dcb7a28..c40231c 100644 --- a/lua/plugins/bufdelete.lua +++ b/lua/plugins/bufdelete.lua @@ -16,9 +16,13 @@ -- https://github.com/famiu/bufdelete.nvim -vim.keymap.set( - "n", - "q", - vim.cmd.Bwipeout, - { remap = false, silent = true, } -) +local function setup() + vim.keymap.set( + "n", + "q", + vim.cmd.Bwipeout, + { remap = false, silent = true, } + ) +end + +return setup diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua index 8529968..f9737c9 100644 --- a/lua/plugins/catppuccin.lua +++ b/lua/plugins/catppuccin.lua @@ -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 diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 07924d4..94bcb9a 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -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 = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = 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", } - ), - [""] = 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", } - ), - [""] = 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", } - ), - [""] = cmp.mapping( - function (fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { "i", "s", } - ), - [""] = 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 = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping( + function (fallback) + if cmp.visible() then + cmp.confirm( + { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + } + ) + else + fallback() + end + end, { "i", "s", } + ), + [""] = 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", } + ), + [""] = 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", } + ), + [""] = cmp.mapping( + function (fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s", } + ), + [""] = 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 diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua index 6fd22d2..400a45d 100644 --- a/lua/plugins/comment.lua +++ b/lua/plugins/comment.lua @@ -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 diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index d10965e..30180d0 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -16,29 +16,25 @@ -- https://github.com/mfussenegger/nvim-dap -local dap = require("dap") - -vim.keymap.set("n", "", dap.continue) -vim.keymap.set("n", "", dap.step_over) -vim.keymap.set("n", "", dap.step_into) -vim.keymap.set("n", "", 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", "", dap.continue) + vim.keymap.set("n", "", dap.step_over) + vim.keymap.set("n", "", dap.step_into) + vim.keymap.set("n", "", 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 diff --git a/lua/plugins/dap_ui.lua b/lua/plugins/dap_ui.lua index 3e1fec8..22269b5 100644 --- a/lua/plugins/dap_ui.lua +++ b/lua/plugins/dap_ui.lua @@ -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 = { "", "<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", "", }, + -- Use a table to apply multiple mappings + expand = { "", "<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", "", }, + }, + }, + windows = { indent = 1, }, + }) +end + +return setup diff --git a/lua/plugins/diffview.lua b/lua/plugins/diffview.lua index a276077..0d34c74 100644 --- a/lua/plugins/diffview.lua +++ b/lua/plugins/diffview.lua @@ -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 = { - [""] = false, - { - "n", - "", - 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 = { + [""] = false, + { + "n", + "", + 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", "gg", vim.cmd.DiffviewOpen) + vim.keymap.set("n", "gg", vim.cmd.DiffviewOpen) +end + +return setup diff --git a/lua/plugins/flog.lua b/lua/plugins/flog.lua index e85778a..418b1d4 100644 --- a/lua/plugins/flog.lua +++ b/lua/plugins/flog.lua @@ -16,4 +16,8 @@ -- https://github.com/rbong/vim-flog -vim.keymap.set("n", "gl", vim.cmd.Flog) +local function setup() + vim.keymap.set("n", "gl", vim.cmd.Flog) +end + +return setup diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index c5c3da2..b30b441 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -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", "gd", vim.cmd.Gdiffsplit) + vim.keymap.set("n", "gc", function () vim.cmd.G("commit") end) + vim.keymap.set("n", "ga", function () vim.cmd.G("commit --amend") end) + vim.keymap.set("n", "gp", function () vim.cmd.G("push") end) + + -- Only used if diffview is not available + if not pcall(require, "diffview") then + vim.keymap.set("n", "gg", git_status_tab) + end end -vim.keymap.set("n", "gd", vim.cmd.Gdiffsplit) -vim.keymap.set("n", "gc", function () vim.cmd.G("commit") end) -vim.keymap.set("n", "ga", function () vim.cmd.G("commit --amend") end) -vim.keymap.set("n", "gp", function () vim.cmd.G("push") end) - --- Only used if diffview is not available -if not pcall(require, "diffview") then - vim.keymap.set("n", "gg", git_status_tab) -end +return setup diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 9ce9444..71d7369 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -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", "gv", gs.select_hunk, { buffer = bufnr, }) - vim.keymap.set("n", "gs", gs.stage_hunk, { buffer = bufnr, }) - vim.keymap.set("n", "gu", gs.undo_stage_hunk, { buffer = bufnr, }) - vim.keymap.set("n", "gr", gs.reset_hunk, { buffer = bufnr, }) - vim.keymap.set( - "x", - "gr", - ":Gitsigns reset_hunk", - { buffer = bufnr, } - ) - vim.keymap.set("n", "g?", gs.preview_hunk, { buffer = bufnr, }) - vim.keymap.set( - "n", - "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", "gv", gs.select_hunk, { buffer = bufnr, }) + vim.keymap.set("n", "gs", gs.stage_hunk, { buffer = bufnr, }) + vim.keymap.set("n", "gu", gs.undo_stage_hunk, + { buffer = bufnr, }) + vim.keymap.set("n", "gr", gs.reset_hunk, { buffer = bufnr, }) + vim.keymap.set( + "x", + "gr", + ":Gitsigns reset_hunk", + { buffer = bufnr, } + ) + vim.keymap.set("n", "g?", gs.preview_hunk, + { buffer = bufnr, }) + vim.keymap.set( + "n", + "gb", + function () + gs.blame_line { full = true, ignore_whitespace = true, } + end, + { buffer = bufnr, }) + end, + signs = { + untracked = { text = "│", }, + }, + }) +end + +return setup diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua index d80b79c..008546c 100644 --- a/lua/plugins/indent-blankline.lua +++ b/lua/plugins/indent-blankline.lua @@ -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 diff --git a/lua/plugins/lspkind.lua b/lua/plugins/lspkind.lua index ce1fefb..e7a48bc 100644 --- a/lua/plugins/lspkind.lua +++ b/lua/plugins/lspkind.lua @@ -17,3 +17,7 @@ -- https://github.com/onsails/lspkind.nvim -- configured and loaded in plugins.config.cmp +local function setup() +end + +return setup diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index cbdd968..151f2e1 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -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 diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua index 0390cb2..99c20d7 100644 --- a/lua/plugins/luasnip.lua +++ b/lua/plugins/luasnip.lua @@ -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 diff --git a/lua/plugins/markdown-preview.lua b/lua/plugins/markdown-preview.lua index cb10268..7459052 100644 --- a/lua/plugins/markdown-preview.lua +++ b/lua/plugins/markdown-preview.lua @@ -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 diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 6a6be87..49565fe 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -16,4 +16,8 @@ -- https://github.com/williamboman/mason.nvim -require("mason").setup() +local function setup() + require("mason").setup() +end + +return setup diff --git a/lua/plugins/mason_lspconfig.lua b/lua/plugins/mason_lspconfig.lua index 2efb210..4b2123e 100644 --- a/lua/plugins/mason_lspconfig.lua +++ b/lua/plugins/mason_lspconfig.lua @@ -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 diff --git a/lua/plugins/mason_update_all.lua b/lua/plugins/mason_update_all.lua index 657e386..2ebf674 100644 --- a/lua/plugins/mason_update_all.lua +++ b/lua/plugins/mason_update_all.lua @@ -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 diff --git a/lua/plugins/move.lua b/lua/plugins/move.lua index 5611e0a..ad8b653 100644 --- a/lua/plugins/move.lua +++ b/lua/plugins/move.lua @@ -16,12 +16,16 @@ -- https://github.com/fedepujol/move.nvim -local opts = { noremap = true, silent = true, } -vim.keymap.set("n", "", function () vim.cmd.MoveLine(1) end, opts) -vim.keymap.set("n", "", function () vim.cmd.MoveLine(-1) end, opts) -vim.keymap.set("n", "", function () vim.cmd.MoveHChar(-1) end, opts) -vim.keymap.set("n", "", function () vim.cmd.MoveHChar(1) end, opts) -vim.keymap.set("x", "", ":MoveBlock(1)", opts) -vim.keymap.set("x", "", ":MoveBlock(-1)", opts) -vim.keymap.set("x", "", ":MoveHBlock(-1)", opts) -vim.keymap.set("x", "", ":MoveHBlock(1)", opts) +local function setup() + local opts = { noremap = true, silent = true, } + vim.keymap.set("n", "", function () vim.cmd.MoveLine(1) end, opts) + vim.keymap.set("n", "", function () vim.cmd.MoveLine(-1) end, opts) + vim.keymap.set("n", "", function () vim.cmd.MoveHChar(-1) end, opts) + vim.keymap.set("n", "", function () vim.cmd.MoveHChar(1) end, opts) + vim.keymap.set("x", "", ":MoveBlock(1)", opts) + vim.keymap.set("x", "", ":MoveBlock(-1)", opts) + vim.keymap.set("x", "", ":MoveHBlock(-1)", opts) + vim.keymap.set("x", "", ":MoveHBlock(1)", opts) +end + +return setup diff --git a/lua/plugins/notify.lua b/lua/plugins/notify.lua index 1980d17..c3c616f 100644 --- a/lua/plugins/notify.lua +++ b/lua/plugins/notify.lua @@ -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", "fn", telescope.extensions.notify.notify) + if has_telescope then + telescope.load_extension("notify") + vim.keymap.set("n", "fn", telescope.extensions.notify.notify) + end end + +return setup diff --git a/lua/plugins/orgmode.lua b/lua/plugins/orgmode.lua index a39a4bb..e5f8829 100644 --- a/lua/plugins/orgmode.lua +++ b/lua/plugins/orgmode.lua @@ -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 diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index a0d90fd..161af0d 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -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", - "ff", - function () builtin.find_files({ hidden = true, }) end -) -vim.keymap.set( - "n", - "fr", - function () builtin.oldfiles({ hidden = true, }) end -) -vim.keymap.set( - "n", "fg", function () - builtin.live_grep( - { - additional_args = function (_) - return { - "--hidden", - "--iglob=!.venv", - "--iglob=!vendor", - "--iglob=!.git", - } - end, - } - ) - end -) -vim.keymap.set("n", "fb", builtin.buffers) + vim.keymap.set( + "n", + "ff", + function () builtin.find_files({ hidden = true, }) end + ) + vim.keymap.set( + "n", + "fr", + function () builtin.oldfiles({ hidden = true, }) end + ) + vim.keymap.set( + "n", "fg", function () + builtin.live_grep( + { + additional_args = function (_) + return { + "--hidden", + "--iglob=!.venv", + "--iglob=!vendor", + "--iglob=!.git", + } + end, + } + ) + end + ) + vim.keymap.set("n", "fb", builtin.buffers) +end + +return setup diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua index ee8351f..dc01208 100644 --- a/lua/plugins/tokyonight.lua +++ b/lua/plugins/tokyonight.lua @@ -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 diff --git a/lua/plugins/tree.lua b/lua/plugins/tree.lua index d2ea35a..9460d7a 100644 --- a/lua/plugins/tree.lua +++ b/lua/plugins/tree.lua @@ -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", "tt", require("nvim-tree.api").tree.toggle) + vim.keymap.set("n", "tt", require("nvim-tree.api").tree.toggle) +end + +return setup diff --git a/lua/plugins/treesitter-context.lua b/lua/plugins/treesitter-context.lua index 3f71168..3b0082f 100644 --- a/lua/plugins/treesitter-context.lua +++ b/lua/plugins/treesitter-context.lua @@ -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 diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index b606065..4e67cff 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -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 diff --git a/lua/plugins/vscode.lua b/lua/plugins/vscode.lua index 90befad..f7d1b06 100644 --- a/lua/plugins/vscode.lua +++ b/lua/plugins/vscode.lua @@ -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 diff --git a/lua/plugins/winresizer.lua b/lua/plugins/winresizer.lua index 561a680..304cdad 100644 --- a/lua/plugins/winresizer.lua +++ b/lua/plugins/winresizer.lua @@ -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", "r", vim.cmd.WinResizerStartResize) + vim.keymap.set("n", "r", vim.cmd.WinResizerStartResize) +end + +return setup diff --git a/lua/plugins/winshift.lua b/lua/plugins/winshift.lua index bb4d462..1bce088 100644 --- a/lua/plugins/winshift.lua +++ b/lua/plugins/winshift.lua @@ -16,8 +16,12 @@ -- https://github.com/sindrets/winshift.nvim -vim.keymap.set( - "n", - "m", - vim.cmd.WinShift -) +local function setup() + vim.keymap.set( + "n", + "m", + vim.cmd.WinShift + ) +end + +return setup