diff --git a/init.lua b/init.lua index de946bb..124d2d1 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -local module_name = "core" +vim.loader.enable() local utils = require("utils") @@ -15,8 +15,8 @@ for _, file in ipairs(files) do local pkg = "core." .. file local ok, err = pcall(require, pkg) if not ok then - utils.err("Error while loading package " .. pkg, module_name) - utils.err(err, module_name) + utils.err("Error while loading package " .. pkg) + utils.err(err) return end end @@ -26,15 +26,26 @@ if vim.g.vscode then else local ok, err = pcall(require, "bootstrap") if not ok then - utils.err("Error during bootstrap", module_name) - utils.err(err:gsub("\t", " "), module_name) + utils.err("Error during bootstrap") + utils.err(err:gsub("\t", " ")) return end - ok, err = pcall(require, "plugins") - if not ok then - utils.err("Error while loading plugins", module_name) - utils.err(err:gsub("\t", " "), module_name) - return - end + ---@type LazyPluginSpec[] + local plugins = { + { + "neovim/nvim-lspconfig", + config = require("lsp").setup, + }, + { import = "plugins" }, + } + + ---@type LazyConfig + local opts = { + install = { + colorscheme = { "moonfly" }, + }, + } + + require("lazy").setup(plugins, opts) end diff --git a/lua/core/autocommands.lua b/lua/core/autocommands.lua index 5bb1930..b751632 100644 --- a/lua/core/autocommands.lua +++ b/lua/core/autocommands.lua @@ -1,6 +1,13 @@ vim.api.nvim_create_autocmd("FileType", { + desc = "Use tabs for indents in Go files", pattern = "go", - callback = function () + callback = function() vim.bo.expandtab = false end, }) + +vim.api.nvim_create_autocmd({ "BufReadPost" }, { + desc = "Return cursor to last position when re-opening a buffer", + pattern = "*", + command = 'silent! normal! g`"zv', +}) diff --git a/lua/lsp/server.lua b/lua/lsp/server.lua index de8ba6e..552d6e6 100644 --- a/lua/lsp/server.lua +++ b/lua/lsp/server.lua @@ -183,6 +183,11 @@ function M:on_attach(client, bufnr) { border = "single" }) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" }) + + ---@alias lsp.Client vim.lsp.Client + -- require("lsp_compl").attach(client, bufnr, { + -- server_side_fuzzy_completion = true, + -- }) end --- Configure the LSP client @@ -203,6 +208,22 @@ function M:configure_client() capabilities = vim.tbl_deep_extend("force", capabilities, cmp_nvim_lsp.default_capabilities()) end + + -- local epo = utils.try_require("epo") + -- if epo then + -- capabilities = vim.tbl_deep_extend( + -- "force", + -- capabilities, + -- epo.register_cap() + -- ) + -- end + + -- local lsp_compl = utils.try_require("lsp_compl") + -- if lsp_compl then + -- capabilities = vim.tbl_deep_extend("force", capabilities, lsp_compl.capabilities()) + -- end + -- + self.config.lspconfig.capabilities = capabilities self.config.lspconfig.on_attach = function(client, bufnr) local ok, ret = pcall(self.on_attach, self, client, bufnr) diff --git a/lua/plugins.lua b/lua/plugins.lua deleted file mode 100644 index 8f3c594..0000000 --- a/lua/plugins.lua +++ /dev/null @@ -1,203 +0,0 @@ -vim.loader.enable() - ----@type LazyPluginSpec[] -local plugins = { - { - "bluz71/vim-moonfly-colors", - priority = 1000, - lazy = false, - name = "moonfly", - config = require("plugins.moonfly"), - }, - --[[ { - "catppuccin/nvim", - name = "catppuccin", - priority = 100, - lazy = false, - config = require("plugins.catppuccin"), - }, ]] - --[[ { - "navarasu/onedark.nvim", - priority = 1000, - lazy = false, - -- name = "moonfly", - config = require("plugins.onedark"), - }, ]] - { - "rcarriga/nvim-notify", - priority = 900, - lazy = false, - config = require("plugins.notify"), - }, - { - "rafamadriz/friendly-snippets", - }, - { - "L3MON4D3/LuaSnip", - config = require("plugins.luasnip"), - -- comment out on windows and install jsregexp manually - build = (require("utils").os_name ~= "Windows_NT" and "make install_jsregexp" or nil), - version = "2.*", - }, - { - "saadparwaiz1/cmp_luasnip", - }, - { - "hrsh7th/cmp-path", - }, - { - "hrsh7th/cmp-cmdline", - }, - { - "hrsh7th/cmp-nvim-lsp", - }, - { - "hrsh7th/nvim-cmp", - config = require("plugins.cmp"), - }, - { - "onsails/lspkind.nvim", - config = require("plugins.lspkind"), - }, - { - "williamboman/mason.nvim", - config = require("plugins.mason"), - lazy = true, - event = "VimEnter", - }, - { - "neovim/nvim-lspconfig", - config = require("lsp").setup, - }, - { - "nvim-treesitter/nvim-treesitter", - config = require("plugins.treesitter"), - build = ":TSUpdate", - lazy = true, - event = "VimEnter", - }, - { - "tpope/vim-fugitive", - config = require("plugins.fugitive"), - lazy = true, - event = "VimEnter", - }, - { - "rbong/vim-flog", - config = require("plugins.flog"), - }, - { - "nvim-lualine/lualine.nvim", - config = require("plugins.lualine"), - lazy = true, - event = "VimEnter", - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - }, - { - "lewis6991/gitsigns.nvim", - config = require("plugins.gitsigns"), - lazy = true, - event = "VimEnter", - }, - { - "nvim-telescope/telescope.nvim", - config = require("plugins.telescope"), - lazy = true, - event = "VimEnter", - dependencies = { - "nvim-lua/plenary.nvim", - }, - }, - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release" - .. " && cmake --build build --config Release" - .. " && cmake --install build --prefix build", - }, - { - "numToStr/Comment.nvim", - config = require("plugins.comment"), - lazy = true, - event = "VimEnter", - }, - { - "simeji/winresizer", - config = require("plugins.winresizer"), - lazy = true, - keys = { "r" }, - }, - { - "sindrets/winshift.nvim", - config = require("plugins.winshift"), - lazy = true, - keys = { "m" }, - }, - { - "dstein64/vim-startuptime", - lazy = true, - event = "VimEnter", - }, - { - "famiu/bufdelete.nvim", - config = require("plugins.bufdelete"), - }, - { - "nvim-treesitter/nvim-treesitter-context", - config = require("plugins.treesitter-context"), - }, - { - "fedepujol/move.nvim", - config = require("plugins.move"), - }, - { - "nvim-orgmode/orgmode", - config = require("plugins.orgmode"), - dependencies = { - "nvim-treesitter/nvim-treesitter", - }, - }, - { - "farmergreg/vim-lastplace", - }, - { - "sindrets/diffview.nvim", - config = require("plugins.diffview"), - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - }, - { - "j-hui/fidget.nvim", - tag = "legacy", - event = "LspAttach", - config = require("plugins.fidget"), - }, - { - "lvimuser/lsp-inlayhints.nvim", - branch = "anticonceal", - config = require("plugins.lsp-inlayhints"), - }, - { - "cbochs/grapple.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - config = require("plugins.grapple"), - }, - { - "is0n/fm-nvim", - config = require("plugins.fm-nvim"), - }, - { - "NvChad/nvim-colorizer.lua", - config = require("plugins.nvim-colorizer"), - }, -} - -local opts = { - install = { - colorscheme = { "moonfly" }, - }, -} - -require("lazy").setup(plugins, opts) diff --git a/lua/plugins/bufdelete.lua b/lua/plugins/bufdelete.lua index 49d88c9..baccb72 100644 --- a/lua/plugins/bufdelete.lua +++ b/lua/plugins/bufdelete.lua @@ -1,12 +1,9 @@ -- https://github.com/famiu/bufdelete.nvim -local function setup() - vim.keymap.set( - "n", - "q", - vim.cmd.Bwipeout, - { remap = false, silent = true, } - ) -end - -return setup +---@type LazyPluginSpec +return { + "famiu/bufdelete.nvim", + keys = { + { "q", vim.cmd.Bwipeout, { remap = false, silent = true }, mode = "n" }, + }, +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 29976cc..0824f71 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -24,101 +24,112 @@ local function has_words_after() ~= nil end -local function setup() - local utils = require("utils") - local cmp = require("cmp") - local luasnip = require("luasnip") - local lspkind = utils.try_require("lspkind") - - local opt = { - preselect = cmp.PreselectMode.None, - completion = { keyword_length = 0 }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) +---@type LazyPluginSpec +return { + "hrsh7th/nvim-cmp", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp", + { + "L3MON4D3/LuaSnip", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() end, + build = (require("utils").os_name ~= "Windows_NT" and "make install_jsregexp" or nil), + version = "2.*", }, - 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 + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local utils = require("utils") + local lspkind = utils.try_require("lspkind") - return vim_item - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item({ - behavior = cmp.SelectBehavior.Select, - }), - [""] = cmp.mapping.select_next_item({ - behavior = cmp.SelectBehavior.Select, - }), - [""] = function(fallback) - if cmp.visible() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }) - else - fallback() - end - end, - [""] = cmp.mapping.complete(), - [""] = function(fallback) - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, - [""] = function(fallback) - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, - }, - sources = { - { name = "nvim_lsp" }, - -- { name = "luasnip", }, - { name = "orgmode" }, - { name = "path" }, - }, - } - - if utils.try_require("moonfly") then - local winhighlight = { - winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel", - } - opt.window = { - completion = cmp.config.window.bordered(winhighlight), - documentation = cmp.config.window.bordered(winhighlight), - } - end - - cmp.setup(opt) - - cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { { name = "buffer" } }, - }) - - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = "path" } }, { - { - name = "cmdline", - option = { ignore_cmds = { "Man", "!" } }, + local opts = { + preselect = cmp.PreselectMode.None, + completion = { + autocomplete = { "InsertEnter", "TextChanged" }, + keyword_length = 1, }, - }), - }) -end + 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 -return setup + return vim_item + end, + }, + + mapping = { + [""] = cmp.mapping.select_prev_item({ + behavior = cmp.SelectBehavior.Insert, + }), + [""] = cmp.mapping.select_next_item({ + behavior = cmp.SelectBehavior.Insert, + }), + [""] = cmp.mapping.complete(), + [""] = function(fallback) + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, + [""] = function(fallback) + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + }, + sources = { + { name = "nvim_lsp" }, + -- { name = "luasnip", }, + { name = "orgmode" }, + { name = "path" }, + }, + } + + if utils.try_require("moonfly") then + local winhighlight = { + winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel", + } + opts.window = { + completion = cmp.config.window.bordered(winhighlight), + documentation = cmp.config.window.bordered(winhighlight), + } + end + + cmp.setup(opts) + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { { name = "buffer" } }, + }) + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ { name = "path" } }, { + { + name = "cmdline", + option = { ignore_cmds = { "Man", "!" } }, + }, + }), + }) + end, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua index ea6a3ef..225ab6e 100644 --- a/lua/plugins/comment.lua +++ b/lua/plugins/comment.lua @@ -1,12 +1,12 @@ -- https://github.com/numToStr/Comment.nvim -local function setup() - require("Comment").setup( - { - --ignore empty lines - ignore = "^$", - } - ) -end - -return setup +---@type LazyPluginSpec +return { + "numToStr/Comment.nvim", + lazy = true, + event = "VimEnter", + opts = { + --ignore empty lines + ignore = "^$", + }, +} diff --git a/lua/plugins/diffview.lua b/lua/plugins/diffview.lua index a82a244..6c20bf6 100644 --- a/lua/plugins/diffview.lua +++ b/lua/plugins/diffview.lua @@ -1,75 +1,80 @@ -- https://github.com/sindrets/diffview.nvim -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", }, +---@type LazyPluginSpec +return { + "sindrets/diffview.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + keys = { + { "gg", vim.cmd.DiffviewOpen, mode = "n", remap = true }, + }, + config = function() + local actions = require("diffview.actions") + 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, }, }, - }, - }) - - vim.keymap.set("n", "gg", vim.cmd.DiffviewOpen) -end - -return setup + 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" }, + }, + }, + }, + }) + end, +} diff --git a/lua/plugins/fidget.lua b/lua/plugins/fidget.lua index 55ef068..122a900 100644 --- a/lua/plugins/fidget.lua +++ b/lua/plugins/fidget.lua @@ -1,7 +1,9 @@ -- https://github.com/j-hui/fidget.nvim -local function setup() - require("fidget").setup() -end - -return setup +---@type LazyPluginSpec +return { + "j-hui/fidget.nvim", + tag = "legacy", + event = "LspAttach", + config = true, +} diff --git a/lua/plugins/flog.lua b/lua/plugins/flog.lua index a77882d..23d3f97 100644 --- a/lua/plugins/flog.lua +++ b/lua/plugins/flog.lua @@ -1,7 +1,10 @@ -- https://github.com/rbong/vim-flog -local function setup() - vim.keymap.set("n", "gl", vim.cmd.Flog) -end - -return setup +---@type LazyPluginSpec +return { + "rbong/vim-flog", + ---@type LazyKeysSpec[] + keys = { + { "gl", vim.cmd.Flog, mode = "n" }, + }, +} diff --git a/lua/plugins/fm-nvim.lua b/lua/plugins/fm-nvim.lua index 1e72a47..a0dc56d 100644 --- a/lua/plugins/fm-nvim.lua +++ b/lua/plugins/fm-nvim.lua @@ -1,9 +1,19 @@ -- https://github.com/is0n/fm-nvim -local function setup() - local fm = require("fm-nvim") - - fm.setup({ +---@type LazyPluginSpec +return { + "is0n/fm-nvim", + keys = { + { + "fe", + function() + local file = vim.fn.expand("%:p") + if file ~= "" then vim.cmd.Lf(file) else vim.cmd.Lf() end + end, + mode = "n", + }, + }, + opts = { -- UI Options ui = { float = { @@ -16,20 +26,5 @@ local function setup() cmds = { nnn_cmd = "n", }, - }) - - vim.keymap.set( - "n", - "fe", - function() - local file = vim.fn.expand("%:p") - if file ~= "" then - vim.cmd.Lf(file) - else - vim.cmd.Lf() - end - end - ) -end - -return setup + }, +} diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua index 23c8d30..3fdf756 100644 --- a/lua/plugins/fugitive.lua +++ b/lua/plugins/fugitive.lua @@ -1,22 +1,23 @@ -- https://github.com/tpope/vim-fugitive -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 +local function git_status_tab() + vim.cmd.tabnew() + vim.cmd("leftabove vertical G") + vim.cmd("vertical resize 60") + vim.cmd.set("wfw") end -return setup +---@type LazyPluginSpec +return { + "tpope/vim-fugitive", + lazy = true, + event = "VimEnter", + ---@type LazyKeysSpec[] + keys = { + { "gd", vim.cmd.Gdiffsplit, mode = "n" }, + { "gc", function() vim.cmd.G("commit") end, mode = "n" }, + { "ga", function() vim.cmd.G("commit --amend") end, mode = "n" }, + { "gp", function() vim.cmd.G("push") end, mode = "n" }, + { "gg", git_status_tab, mode = "n", remap = false }, + }, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 414459a..b7a8f94 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,54 +1,60 @@ -- https://github.com/lewis6991/gitsigns.nvim -local function setup() - require("gitsigns").setup({ - on_attach = function (bufnr) +---@type LazyPluginSpec +return { + "lewis6991/gitsigns.nvim", + lazy = true, + event = "VimEnter", + opts = { + 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("x", "gs", function () - gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v"), }) - end, - { buffer = bufnr, }) - vim.keymap.set({ "n", "x", }, "gu", gs.undo_stage_hunk, - { buffer = bufnr, }) - vim.keymap.set("n", "gr", gs.reset_hunk, { buffer = bufnr, }) + vim.keymap.set("n", "gv", gs.select_hunk, { buffer = bufnr }) + vim.keymap.set("n", "gs", gs.stage_hunk, { buffer = bufnr }) vim.keymap.set( "x", - "gr", - ":Gitsigns reset_hunk", - { buffer = bufnr, } + "gs", + function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, + { buffer = bufnr } ) - vim.keymap.set("n", "g?", gs.preview_hunk, - { buffer = bufnr, }) + vim.keymap.set({ "n", "x" }, "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, } + function() + gs.blame_line { full = true, ignore_whitespace = true } end, - { buffer = bufnr, }) - vim.keymap.set({ "n", "x", }, "]g", function () - gs.next_hunk({ - wrap = true, - navigation_message = true, - foldopen = true, - preview = true, - }) - end) - vim.keymap.set({ "n", "x", }, "[g", function () - gs.prev_hunk({ - wrap = true, - navigation_message = true, - foldopen = true, - preview = true, - }) - end) + { buffer = bufnr } + ) + vim.keymap.set( + { "n", "x" }, + "]g", function() + gs.next_hunk({ + wrap = true, + navigation_message = true, + foldopen = true, + preview = true, + }) + end + ) + vim.keymap.set( + { "n", "x" }, + "[g", function() + gs.prev_hunk({ + wrap = true, + navigation_message = true, + foldopen = true, + preview = true, + }) + end + ) end, signs = { - untracked = { text = "│", }, + untracked = { text = "│" }, }, - }) -end - -return setup + }, +} diff --git a/lua/plugins/grapple.lua b/lua/plugins/grapple.lua index bae315c..161a45e 100644 --- a/lua/plugins/grapple.lua +++ b/lua/plugins/grapple.lua @@ -1,37 +1,40 @@ -- https://github.com/cbochs/grapple.nvim -local function setup() - local grapple = require("grapple") - grapple.setup() - vim.keymap.set("n", "'", grapple.toggle_tags) - vim.keymap.set("n", "mm", function () - if grapple.exists() then - grapple.untag() - return - end - - for i = 1, 9 do - local opts = { name = "m" .. i, } - if not grapple.exists(opts) then - grapple.tag(opts) +---@type LazyPluginSpec +return { + "cbochs/grapple.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local grapple = require("grapple") + grapple.setup() + vim.keymap.set("n", "'", grapple.toggle_tags) + vim.keymap.set("n", "mm", function() + if grapple.exists() then + grapple.untag() return end + + for i = 1, 9 do + local opts = { name = "m" .. i } + if not grapple.exists(opts) then + grapple.tag(opts) + return + end + end + + grapple.tag({ name = "m0" }) + end) + + for i = 1, 9 do + local opts = { name = "m" .. i } + + vim.keymap.set("n", "m" .. i, function() + grapple.tag(opts) + end) + + vim.keymap.set("n", "" .. i, function() + grapple.select(opts) + end) end - - grapple.tag({ name = "m?", }) - end) - - for i = 1, 9 do - local opts = { name = "m" .. i, } - - vim.keymap.set("n", "m" .. i, function () - grapple.tag(opts) - end) - - vim.keymap.set("n", "" .. i, function () - grapple.select(opts) - end) - end -end - -return setup + end, +} diff --git a/lua/plugins/lsp-inlayhints.lua b/lua/plugins/lsp-inlayhints.lua index 37b51ab..3a8dc9e 100644 --- a/lua/plugins/lsp-inlayhints.lua +++ b/lua/plugins/lsp-inlayhints.lua @@ -1,7 +1,8 @@ -- https://github.com/lvimuser/lsp-inlayhints.nvim -local function setup() - require("lsp-inlayhints").setup() -end - -return setup +---@type LazyPluginSpec +return { + "lvimuser/lsp-inlayhints.nvim", + branch = "anticonceal", + config = true, +} diff --git a/lua/plugins/lspkind.lua b/lua/plugins/lspkind.lua index d47cc8d..8ea0f39 100644 --- a/lua/plugins/lspkind.lua +++ b/lua/plugins/lspkind.lua @@ -1,12 +1,12 @@ -- https://github.com/onsails/lspkind.nvim -local function setup() - local ok, _ = pcall(require, "nvim-cmp") - if ok then - -- configured and loaded in plugins.config.cmp - else - require("lspkind").init() - end -end - -return setup +---@type LazyPluginSpec +return { + "onsails/lspkind.nvim", + config = function() + local ok, _ = pcall(require, "nvim-cmp") + if not ok then + require("lspkind").init() + end + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index aee95ec..53223fe 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,41 +1,45 @@ -- https://github.com/nvim-lualine/lualine.nvim -local function setup() - local custom_moonfly = require("lualine.themes.moonfly") - custom_moonfly.normal.c.bg = require("moonfly").palette.bg +---@type LazyPluginSpec +return { + "nvim-lualine/lualine.nvim", + lazy = true, + event = "VimEnter", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + local custom_moonfly = require("lualine.themes.moonfly") + custom_moonfly.normal.c.bg = require("moonfly").palette.bg - require("lualine").setup({ - options = { - icons_enabled = true, - theme = custom_moonfly, - component_separators = { left = "", right = "", }, - section_separators = { left = "", right = "", }, - always_divide_middle = true, - globalstatus = true, - }, - sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { - { "filename", path = 1, }, - "diff", - { "diagnostics", sources = { "nvim_lsp", }, }, - { - require("grapple").statusline, - cond = require("grapple").exists, + require("lualine").setup({ + options = { + icons_enabled = true, + theme = custom_moonfly, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + always_divide_middle = true, + globalstatus = true, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { "filename", path = 1 }, + { "diff" }, + { "diagnostics", sources = { "nvim_lsp" } }, + { require("grapple").statusline, cond = require("grapple").exists }, }, + lualine_x = { + "bo:filetype", + "encoding", + "bo:fileformat", + "progress", + "location", + }, + lualine_y = {}, + lualine_z = {}, }, - lualine_x = { - "bo:filetype", - "encoding", - "bo:fileformat", - "progress", - "location", - }, - lualine_y = {}, - lualine_z = {}, - }, - }) -end - -return setup + }) + end, +} diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua deleted file mode 100644 index d7415f5..0000000 --- a/lua/plugins/luasnip.lua +++ /dev/null @@ -1,7 +0,0 @@ --- https://github.com/L3MON4D3/LuaSnip - -local function setup() - require("luasnip.loaders.from_vscode").lazy_load() -end - -return setup diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 32fea3d..2ba928d 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -1,7 +1,9 @@ -- https://github.com/williamboman/mason.nvim -local function setup() - require("mason").setup() -end - -return setup +---@type LazyPluginSpec +return { + "williamboman/mason.nvim", + lazy = true, + event = "VimEnter", + config = true, +} diff --git a/lua/plugins/moonfly.lua b/lua/plugins/moonfly.lua index 0192803..b7f1800 100644 --- a/lua/plugins/moonfly.lua +++ b/lua/plugins/moonfly.lua @@ -1,11 +1,17 @@ -- https://github.com/bluz71/vim-moonfly-colors -local function setup() - vim.g.moonflyNormalFloat = true - vim.g.moonflyCursorColor = true - vim.g.moonflyWinSeparator = 2 - - vim.cmd.colorscheme("moonfly") -end - -return setup +---@type LazyPluginSpec +return { + "bluz71/vim-moonfly-colors", + priority = 1000, + lazy = false, + name = "moonfly", + init = function() + vim.g.moonflyNormalFloat = true + vim.g.moonflyCursorColor = true + vim.g.moonflyWinSeparator = 2 + end, + config = function() + vim.cmd.colorscheme("moonfly") + end, +} diff --git a/lua/plugins/move.lua b/lua/plugins/move.lua index 233afc0..97909de 100644 --- a/lua/plugins/move.lua +++ b/lua/plugins/move.lua @@ -1,21 +1,22 @@ -- https://github.com/fedepujol/move.nvim -local function setup() - require("move").setup({ +-- TODO: figure out how to add "silent" to keymaps +---@type LazyPluginSpec +return { + "fedepujol/move.nvim", + keys = { + { "", function() vim.cmd.MoveLine(1) end, mode = "n" }, + { "", function() vim.cmd.MoveLine(-1) end, mode = "n" }, + { "", function() vim.cmd.MoveHChar(-1) end, mode = "n" }, + { "", function() vim.cmd.MoveHChar(1) end, mode = "n" }, + { "", ":MoveBlock(1)", mode = "x" }, + { "", ":MoveBlock(-1)", mode = "x" }, + { "", ":MoveHBlock(-1)", mode = "x" }, + { "", ":MoveHBlock(1)", mode = "x" }, + }, + opts = { char = { enable = true, }, - }) - - 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 b9aac03..1ce834a 100644 --- a/lua/plugins/notify.lua +++ b/lua/plugins/notify.lua @@ -1,20 +1,16 @@ -- https://github.com/rcarriga/nvim-notify -local function setup() - local has_telescope, telescope = pcall(require, "telescope") - - local notify = require("notify") - notify.setup({ +---@type LazyPluginSpec +return { + "rcarriga/nvim-notify", + priority = 900, + lazy = false, + opts = { render = "default", stages = "static", - }) - - vim.notify = notify - - if has_telescope then - telescope.load_extension("notify") - vim.keymap.set("n", "fn", telescope.extensions.notify.notify) - end -end - -return setup + }, + config = function(_, opts) + vim.notify = require("notify") + vim.notify.setup(opts) + end, +} diff --git a/lua/plugins/nvim-colorizer.lua b/lua/plugins/nvim-colorizer.lua index 7f0d2b8..618f9be 100644 --- a/lua/plugins/nvim-colorizer.lua +++ b/lua/plugins/nvim-colorizer.lua @@ -1,14 +1,16 @@ -local function setup() - require("colorizer").setup({ +-- https://github.com/NvChad/nvim-colorizer.lua + +---@type LazyPluginSpec +return { + "NvChad/nvim-colorizer.lua", + opts = { user_default_options = { RRGGBBAA = true, AARRGGBB = true, css = true, mode = "virtualtext", tailwind = true, - sass = { enable = true, }, + sass = { enable = true }, }, - }) -end - -return setup + }, +} diff --git a/lua/plugins/orgmode.lua b/lua/plugins/orgmode.lua index 1ad9469..f10d3b8 100644 --- a/lua/plugins/orgmode.lua +++ b/lua/plugins/orgmode.lua @@ -1,9 +1,13 @@ -- https://github.com/nvim-orgmode/orgmode -local function setup() - local orgmode = require("orgmode") - orgmode.setup({ - org_agenda_files = { "~/Documents/org/**/*", }, +---@type LazyPluginSpec +return { + "nvim-orgmode/orgmode", + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, + opts = { + org_agenda_files = { "~/Documents/org/**/*" }, org_default_notes_file = "~/Documents/org/notes.org", org_todo_keywords = { "TODO(t)", @@ -28,7 +32,5 @@ local function setup() 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 52dd69b..5da2fac 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,100 +1,117 @@ -- https://github.com/nvim-telescope/telescope.nvim -local function setup() - local telescope = require("telescope") - local builtin = require("telescope.builtin") - local actions = require("telescope.actions") - - telescope.setup({ - defaults = { - mappings = { - n = { - q = actions.close, - [""] = actions.close, - l = actions.select_default, - }, - }, +---@type LazyPluginSpec +return { + "nvim-telescope/telescope.nvim", + lazy = true, + event = "VimEnter", + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release" + .. " && cmake --build build --config Release" + .. " && cmake --install build --prefix build", }, - pickers = { - oldfiles = { - initial_mode = "normal", - }, - buffers = { - initial_mode = "normal", + }, + config = function() + local telescope = require("telescope") + local builtin = require("telescope.builtin") + local actions = require("telescope.actions") + + telescope.setup({ + defaults = { mappings = { - i = { - [""] = actions.delete_buffer + actions.move_to_top, + n = { + q = actions.close, + [""] = actions.close, + l = actions.select_default, }, }, }, - diagnostics = { - initial_mode = "normal", + pickers = { + oldfiles = { + initial_mode = "normal", + }, + buffers = { + initial_mode = "normal", + mappings = { + i = { + [""] = actions.delete_buffer + actions.move_to_top, + }, + }, + }, + diagnostics = { + initial_mode = "normal", + }, + lsp_definitions = { + initial_mode = "normal", + }, + lsp_type_definitions = { + initial_mode = "normal", + }, + lsp_implementations = { + initial_mode = "normal", + }, + lsp_references = { + initial_mode = "normal", + }, + git_status = { + initial_mode = "normal", + }, }, - lsp_definitions = { - initial_mode = "normal", - }, - lsp_type_definitions = { - initial_mode = "normal", - }, - lsp_implementations = { - initial_mode = "normal", - }, - lsp_references = { - initial_mode = "normal", - }, - git_status = { - initial_mode = "normal", - }, - }, - }) + }) - vim.keymap.set( - "n", - "ff", - function () - builtin.find_files({ - hidden = true, - no_ignore = true, - no_ignore_parent = true, - previewer = false, - }) - end - ) - vim.keymap.set( - "n", - "fr", - function () - builtin.oldfiles({ - only_cwd = true, - hidden = true, - previewer = false, - }) - end - ) - vim.keymap.set( - "n", "fg", function () - builtin.live_grep({ - additional_args = function (_) - return { - "--hidden", - "--iglob=!.venv", - "--iglob=!vendor", - "--iglob=!.git", - } - end, - previewer = false, - }) - end - ) - vim.keymap.set( - "n", - "fb", - function () - builtin.buffers({ previewer = false, sort_mru = true, }) - end - ) + vim.keymap.set( + "n", + "ff", + function() + builtin.find_files({ + hidden = true, + no_ignore = true, + no_ignore_parent = true, + previewer = false, + }) + end + ) + vim.keymap.set( + "n", + "fr", + function() + builtin.oldfiles({ + only_cwd = true, + hidden = true, + previewer = false, + }) + end + ) + vim.keymap.set( + "n", + "fg", + function() + builtin.live_grep({ + additional_args = function(_) + return { + "--hidden", + "--iglob=!.venv", + "--iglob=!vendor", + "--iglob=!.git", + } + end, + previewer = false, + }) + end + ) + vim.keymap.set( + "n", + "fb", + function() + builtin.buffers({ previewer = false, sort_mru = true }) + end + ) - telescope.load_extension("fzf") -end - -return setup + telescope.load_extension("fzf") + telescope.load_extension("notify") + vim.keymap.set("n", "fn", telescope.extensions.notify.notify) + end, +} diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua deleted file mode 100644 index 43e712a..0000000 --- a/lua/plugins/tokyonight.lua +++ /dev/null @@ -1,18 +0,0 @@ --- https://github.com/folke/tokyonight.nvim - -local function setup() - local tokyonight = require("tokyonight") - - tokyonight.setup({ - style = "night", - styles = { - comments = { italic = false, }, - keywords = { italic = false, }, - }, - lualine_bold = false, - }) - - tokyonight.load() -end - -return setup diff --git a/lua/plugins/treesitter-context.lua b/lua/plugins/treesitter-context.lua deleted file mode 100644 index 5525d05..0000000 --- a/lua/plugins/treesitter-context.lua +++ /dev/null @@ -1,10 +0,0 @@ --- https://github.com/nvim-treesitter/nvim-treesitter-context - -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 cf6827f..a9ce9cb 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,47 +1,57 @@ -- https://github.com/nvim-treesitter/nvim-treesitter -local function setup() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "c", -- recommended default - "lua", -- recommended default - "vim", -- recommended default - "vimdoc", -- recommended default - "query", -- recommended default - "luadoc", - "phpdoc", - "regex", -- for noice - "bash", -- for noice - "markdown", -- for noice - "markdown_inline", -- for noice - "org", - "comment", +---@type LazyPluginSpec[] +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + lazy = true, + event = "VimEnter", + opts = { + ensure_installed = { + "c", -- recommended default + "lua", -- recommended default + "vim", -- recommended default + "vimdoc", -- recommended default + "query", -- recommended default + "luadoc", + "phpdoc", + "org", + "comment", + }, + auto_install = true, + highlight = { + enable = true, + disable = {}, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = { "org", "php" }, + }, }, - auto_install = true, + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) - highlight = { - enable = true, - disable = {}, + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + vim.opt.foldenable = true - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = { "org", "php" }, + -- Disable LSP semantic highlighting for comments because it will otherwise + -- override highlights from `comment`. + vim.api.nvim_set_hl(0, "@lsp.type.comment", {}) + + -- To set the priority of semantic highlighting lower than treesitter (100), + -- uncomment the line below: + -- vim.highlight.priorities.semantic_tokens = 99 + end, + }, + { + "nvim-treesitter/nvim-treesitter-context", + opts = { + max_lines = 1, + min_window_height = 10, }, - }) - - vim.opt.foldmethod = "expr" - vim.opt.foldexpr = "nvim_treesitter#foldexpr()" - vim.opt.foldenable = true - - -- Disable LSP semantic highlighting for comments because it will otherwise - -- override highlights from `comment`. - vim.api.nvim_set_hl(0, '@lsp.type.comment', {}) - - -- To set the priority of semantic highlighting lower than treesitter (100), - -- uncomment the line below: - -- vim.highlight.priorities.semantic_tokens = 99 -end - -return setup + }, +} diff --git a/lua/plugins/vscode.lua b/lua/plugins/vscode.lua deleted file mode 100644 index ab92eee..0000000 --- a/lua/plugins/vscode.lua +++ /dev/null @@ -1,16 +0,0 @@ --- https://github.com/Mofiqul/vscode.nvim - -local function setup() - local vscode = require("vscode") - - vscode.setup({ - style = "dark", - transparent = false, - italic_comments = false, - disable_nvimtree_bg = false, - }) - - vscode.load() -end - -return setup diff --git a/lua/plugins/winresizer.lua b/lua/plugins/winresizer.lua index 28934b3..61f9ac7 100644 --- a/lua/plugins/winresizer.lua +++ b/lua/plugins/winresizer.lua @@ -1,11 +1,15 @@ -- https://github.com/simeji/winresizer -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) -end - -return setup +---@type LazyPluginSpec +return { + "simeji/winresizer", + lazy = true, + keys = { + { "r", vim.cmd.WinResizerStartResize, mode = "n" }, + }, + init = function() + vim.g.winresizer_vert_resize = "5" + vim.g.winresizer_horiz_resize = "5" + vim.g.winresizer_start_key = "" + end, +} diff --git a/lua/plugins/winshift.lua b/lua/plugins/winshift.lua index c659293..d67c34a 100644 --- a/lua/plugins/winshift.lua +++ b/lua/plugins/winshift.lua @@ -1,11 +1,10 @@ -- https://github.com/sindrets/winshift.nvim -local function setup() - vim.keymap.set( - "n", - "m", - vim.cmd.WinShift - ) -end - -return setup +---@type LazyPluginSpec +return { + "sindrets/winshift.nvim", + lazy = true, + keys = { + { "m", vim.cmd.WinShift, mode = "n" }, + }, +}