From 464b497d35025522fbf92e69047981db9944b69a Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Tue, 20 Dec 2022 17:49:10 -0600 Subject: feat(nvim)!: migrate from packer.nvim to lazy.nvim --- nvim/.config/nvim/init.lua | 1 - nvim/.config/nvim/lua/tobyvin.lua | 4 +- nvim/.config/nvim/lua/tobyvin/autocmds.lua | 9 +- nvim/.config/nvim/lua/tobyvin/keymaps.lua | 1 - nvim/.config/nvim/lua/tobyvin/lazy.lua | 20 + nvim/.config/nvim/lua/tobyvin/plugins.lua | 461 ++++----------------- nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua | 264 ++++++------ nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua | 7 - nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua | 7 - nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua | 247 ++++++----- nvim/.config/nvim/lua/tobyvin/plugins/comment.lua | 14 - nvim/.config/nvim/lua/tobyvin/plugins/crates.lua | 59 +-- nvim/.config/nvim/lua/tobyvin/plugins/dap.lua | 198 ++++----- nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua | 50 ++- nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua | 109 ++--- nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua | 29 +- .../nvim/lua/tobyvin/plugins/git-conflict.lua | 26 +- nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua | 132 +++--- nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua | 80 ++-- .../nvim/lua/tobyvin/plugins/indent_blankline.lua | 56 +-- .../nvim/lua/tobyvin/plugins/lsp-signature.lua | 8 +- .../.config/nvim/lua/tobyvin/plugins/lspconfig.lua | 47 ++- nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua | 6 - nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua | 258 ++++++------ nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua | 30 +- nvim/.config/nvim/lua/tobyvin/plugins/mason.lua | 88 ++-- nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua | 46 +- nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua | 31 +- nvim/.config/nvim/lua/tobyvin/plugins/notify.lua | 49 ++- nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua | 57 +-- nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua | 45 +- .../lua/tobyvin/plugins/nvim-dap-virtual-text.lua | 7 - .../nvim/lua/tobyvin/plugins/nvim-navic.lua | 51 ++- nvim/.config/nvim/lua/tobyvin/plugins/packer.lua | 32 -- .../nvim/lua/tobyvin/plugins/rust-tools.lua | 86 ++-- .../nvim/lua/tobyvin/plugins/session_manager.lua | 30 +- nvim/.config/nvim/lua/tobyvin/plugins/surround.lua | 10 - .../.config/nvim/lua/tobyvin/plugins/telescope.lua | 182 ++++---- .../nvim/lua/tobyvin/plugins/tokyonight.lua | 26 +- .../nvim/lua/tobyvin/plugins/treesitter.lua | 108 ++--- nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua | 25 +- nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua | 38 +- 42 files changed, 1417 insertions(+), 1617 deletions(-) create mode 100644 nvim/.config/nvim/lua/tobyvin/lazy.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/comment.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/packer.lua delete mode 100644 nvim/.config/nvim/lua/tobyvin/plugins/surround.lua diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index beee497..7215c31 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,3 +1,2 @@ -pcall(require, "impatient") require("tobyvin.utils.log") require("tobyvin") diff --git a/nvim/.config/nvim/lua/tobyvin.lua b/nvim/.config/nvim/lua/tobyvin.lua index fea0abe..78f0fa7 100644 --- a/nvim/.config/nvim/lua/tobyvin.lua +++ b/nvim/.config/nvim/lua/tobyvin.lua @@ -1,6 +1,8 @@ require("tobyvin.options") require("tobyvin.autocmds") + +require("tobyvin.lazy") + require("tobyvin.keymaps") -require("tobyvin.plugins") require("tobyvin.diagnostic") require("tobyvin.lsp") diff --git a/nvim/.config/nvim/lua/tobyvin/autocmds.lua b/nvim/.config/nvim/lua/tobyvin/autocmds.lua index ba02592..edc0991 100644 --- a/nvim/.config/nvim/lua/tobyvin/autocmds.lua +++ b/nvim/.config/nvim/lua/tobyvin/autocmds.lua @@ -1,5 +1,3 @@ -local Path = require("plenary").path - vim.api.nvim_create_autocmd("TextYankPost", { group = vim.api.nvim_create_augroup("tobyvin_hl", { clear = true }), pattern = "*", @@ -12,7 +10,12 @@ vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("BufWritePre", { group = vim.api.nvim_create_augroup("tobyvin_mkdir", { clear = true }), callback = function(args) - local parent = Path:new(args.file):parent() + local status_ok, plenary = pcall(require, "plenary") + if not status_ok then + return + end + + local parent = plenary.path:new(args.file):parent() local prompt = string.format("%s does not exist. Create it?", parent:make_relative()) if not parent:is_dir() and vim.fn.confirm(prompt, "&Yes\n&No") == 1 then parent:mkdir() diff --git a/nvim/.config/nvim/lua/tobyvin/keymaps.lua b/nvim/.config/nvim/lua/tobyvin/keymaps.lua index 63f5dcb..2258162 100644 --- a/nvim/.config/nvim/lua/tobyvin/keymaps.lua +++ b/nvim/.config/nvim/lua/tobyvin/keymaps.lua @@ -12,7 +12,6 @@ end vim.keymap.set("n", "gn", "bnext", { desc = "bnext" }) vim.keymap.set("n", "gp", "bprev", { desc = "bprev" }) -vim.keymap.set("n", "gb", utils.buffer.bselect, { desc = "bselect" }) vim.keymap.set("n", "gk", utils.documentation.open, { desc = "documentation" }) vim.keymap.set("n", "K", hover, { expr = true, desc = "hover" }) vim.keymap.set("n", "c", utils.buffer.bdelete, { desc = "bdelete" }) diff --git a/nvim/.config/nvim/lua/tobyvin/lazy.lua b/nvim/.config/nvim/lua/tobyvin/lazy.lua new file mode 100644 index 0000000..33eab4b --- /dev/null +++ b/nvim/.config/nvim/lua/tobyvin/lazy.lua @@ -0,0 +1,20 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--single-branch", + "https://github.com/folke/lazy.nvim.git", + lazypath, + }) +end +vim.opt.runtimepath:prepend(lazypath) + +require("lazy").setup("tobyvin.plugins", { + dev = { path = "~/src" }, + install = { colorscheme = { "gruvbox" } }, + checker = { enabled = true }, +}) + +vim.keymap.set("n", "p", ":Lazy") diff --git a/nvim/.config/nvim/lua/tobyvin/plugins.lua b/nvim/.config/nvim/lua/tobyvin/plugins.lua index 85dc281..687b31b 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins.lua @@ -1,388 +1,75 @@ -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) - vim.cmd([[packadd packer.nvim]]) - return true - end - return false -end - -local packer_bootstrap = ensure_packer() -local packer = require("tobyvin.plugins.packer") - -return packer.startup({ - function(use) - use("wbthomason/packer.nvim") - - use("lewis6991/impatient.nvim") - - use({ - "goolord/alpha-nvim", - requires = { "kyazdani42/nvim-web-devicons" }, - config = function() - require("tobyvin.plugins.alpha") - end, - }) - - use({ - "rcarriga/nvim-notify", - event = "VimEnter", - config = function() - require("tobyvin.plugins.notify") - end, - }) - - use({ - "stevearc/dressing.nvim", - config = function() - require("tobyvin.plugins.dressing") - end, - }) - - use({ - "ellisonleao/gruvbox.nvim", - config = function() - require("tobyvin.plugins.gruvbox") - end, - }) - - use({ - "folke/tokyonight.nvim", - config = function() - require("tobyvin.plugins.tokyonight") - end, - }) - - use({ - "Shatur/neovim-session-manager", - config = function() - require("tobyvin.plugins.session_manager") - end, - }) - - use({ - "williamboman/mason.nvim", - requires = { - "RubixDev/mason-update-all", - "williamboman/mason-lspconfig.nvim", - "jayp0521/mason-null-ls.nvim", - "jayp0521/mason-nvim-dap.nvim", - }, - config = function() - require("tobyvin.plugins.mason") - end, - }) - - use({ - "jose-elias-alvarez/null-ls.nvim", - requires = { - "nvim-lua/plenary.nvim", - }, - config = function() - require("tobyvin.plugins.null-ls") - end, - }) - - use({ - "saecki/crates.nvim", - event = { "BufRead Cargo.toml" }, - requires = { - "nvim-lua/plenary.nvim", - "jose-elias-alvarez/null-ls.nvim", - }, - config = function() - require("tobyvin.plugins.crates") - end, - }) - - use({ - "hrsh7th/nvim-cmp", - requires = { - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lsp-document-symbol", - "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-cmdline", - "petertriho/cmp-git", - "Dosx001/cmp-commit", - "davidsierradz/cmp-conventionalcommits", - "rcarriga/cmp-dap", - "ray-x/lsp_signature.nvim", - "saadparwaiz1/cmp_luasnip", - "saecki/crates.nvim", - "kdheepak/cmp-latex-symbols", - }, - config = function() - require("tobyvin.plugins.cmp") - end, - }) - - use({ - "petertriho/cmp-git", - requires = "nvim-lua/plenary.nvim", - config = function() - require("tobyvin.plugins.cmp-git") - end, - }) - - use({ - "David-Kunz/cmp-npm", - event = { "BufRead package.json" }, - requires = { - "nvim-lua/plenary.nvim", - }, - config = function() - require("tobyvin.plugins.cmp-npm") - end, - }) - - use({ - "onsails/lspkind-nvim", - config = function() - require("tobyvin.plugins.lspkind") - end, - }) - - use({ - "folke/neodev.nvim", - config = function() - require("tobyvin.plugins.neodev") - end, - }) - - use({ - "simrat39/rust-tools.nvim", - requires = { - "neovim/nvim-lspconfig", - "nvim-lua/plenary.nvim", - }, - config = function() - require("tobyvin.plugins.rust-tools") - end, - }) - - use({ - "neovim/nvim-lspconfig", - after = { - "neodev.nvim", - "cmp-nvim-lsp", - }, - config = function() - require("tobyvin.plugins.lspconfig") - end, - }) - - use({ - "kevinhwang91/nvim-bqf", - requires = { - "nvim-treesitter/nvim-treesitter", - "junegunn/fzf", - }, - ft = "qf", - config = function() - require("tobyvin.plugins.nvim-bqf") - end, - }) - - use({ - "nvim-telescope/telescope.nvim", - requires = { - "nvim-lua/plenary.nvim", - "BurntSushi/ripgrep", - { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, - "nvim-telescope/telescope-file-browser.nvim", - "nvim-telescope/telescope-live-grep-args.nvim", - "nvim-telescope/telescope-dap.nvim", - }, - config = function() - require("tobyvin.plugins.telescope") - end, - }) - - use({ - "gbprod/yanky.nvim", - config = function() - require("tobyvin.plugins.yanky") - end, - }) - - use({ - "L3MON4D3/LuaSnip", - requires = { - "rafamadriz/friendly-snippets", - "molleweide/LuaSnip-snippets.nvim", - }, - config = function() - require("tobyvin.plugins.luasnip") - end, - }) - - use({ - "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - requires = { - "nvim-treesitter/playground", - "nvim-treesitter/nvim-treesitter-textobjects", - "nvim-treesitter/nvim-treesitter-context", - "JoosepAlviste/nvim-ts-context-commentstring", - "mfussenegger/nvim-ts-hint-textobject", - }, - config = function() - require("tobyvin.plugins.treesitter") - end, - }) - - use("norcalli/nvim-colorizer.lua") - - use({ - "lukas-reineke/indent-blankline.nvim", - config = function() - require("tobyvin.plugins.indent_blankline") - end, - }) - - use({ - "lukas-reineke/virt-column.nvim", - config = function() - require("virt-column").setup() - end, - }) - - use({ - "nvim-lualine/lualine.nvim", - requires = { - "kyazdani42/nvim-web-devicons", - "SmiteshP/nvim-navic", - }, - config = function() - require("tobyvin.plugins.lualine") - end, - }) - - use({ - "j-hui/fidget.nvim", - config = function() - require("tobyvin.plugins.fidget") - end, - }) - - use({ - "SmiteshP/nvim-navic", - requires = "onsails/lspkind-nvim", - config = function() - require("tobyvin.plugins.nvim-navic") - end, - }) - - use({ - "TimUntersberger/neogit", - requires = { "sindrets/diffview.nvim" }, - config = function() - require("tobyvin.plugins.neogit") - end, - }) - - use({ - "sindrets/diffview.nvim", - requires = { - "nvim-lua/plenary.nvim", - "kyazdani42/nvim-web-devicons", - }, - config = function() - require("tobyvin.plugins.diffview") - end, - }) - - use({ - "akinsho/git-conflict.nvim", - config = function() - require("tobyvin.plugins.git-conflict") - end, - }) - - use({ - "lewis6991/gitsigns.nvim", - requires = "nvim-lua/plenary.nvim", - config = function() - require("tobyvin.plugins.gitsigns") - end, - }) - - if vim.fn.executable("gh") == 1 then - use("pwntester/octo.nvim") - end - - use({ - "jiaoshijie/undotree", - requires = { - "nvim-lua/plenary.nvim", - }, - config = function() - require("tobyvin.plugins.undotree") - end, - }) - - use({ +return { + "lewis6991/impatient.nvim", + "nvim-lua/plenary.nvim", + "ThePrimeagen/harpoon", + "norcalli/nvim-colorizer.lua", + "b0o/SchemaStore.nvim", + { + "nacro90/numb.nvim", + config = function() + require("numb").setup() + end, + }, + { + "tiagovla/scope.nvim", + config = function() + require("scope").setup() + end, + }, + { + "lukas-reineke/virt-column.nvim", + config = function() + require("virt-column").setup() + end, + }, + { + "petertriho/cmp-git", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("cmp_git").setup() + end, + }, + { + "David-Kunz/cmp-npm", + event = "BufRead package.json", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("cmp-npm").setup() + end, + }, + { + "onsails/lspkind-nvim", + config = function() + require("lspkind").init() + end, + }, + { + "nvim-treesitter/nvim-treesitter-context", + event = "BufReadPre", + config = function() + require("treesitter-context").setup() + end, + }, + { + "theHamsta/nvim-dap-virtual-text", + dependencies = { "mfussenegger/nvim-dap", - requires = { - "nvim-telescope/telescope-dap.nvim", - "mfussenegger/nvim-dap-python", - "leoluz/nvim-dap-go", - }, - config = function() - require("tobyvin.plugins.dap") - end, - }) - - use({ - "theHamsta/nvim-dap-virtual-text", - requires = { - "mfussenegger/nvim-dap", - "nvim-treesitter/nvim-treesitter", - }, - config = function() - require("tobyvin.plugins.nvim-dap-virtual-text") - end, - }) - - use({ - "ur4ltz/surround.nvim", - config = function() - require("tobyvin.plugins.surround") - end, - }) - - use({ - "numToStr/Comment.nvim", - config = function() - require("tobyvin.plugins.comment") - end, - }) - - use("ThePrimeagen/harpoon") - - use("b0o/SchemaStore.nvim") - - use({ - "nacro90/numb.nvim", - config = function() - require("numb").setup() - end, - }) - - use({ - "tiagovla/scope.nvim", - config = function() - require("scope").setup() - end, - }) - - if packer_bootstrap then - require("packer").sync() - end - end, -}) + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("nvim-dap-virtual-text").setup({}) + end, + }, + { + "ur4ltz/surround.nvim", + config = function() + require("surround").setup({}) + end, + }, + { + "numToStr/Comment.nvim", + config = function() + require("Comment").setup() + end, + }, +} diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua b/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua index 569f3ce..02adc45 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua @@ -1,152 +1,162 @@ -local Icons = require("nvim-web-devicons") -local utils = require("tobyvin.utils") +local M = { + "goolord/alpha-nvim", + dependencies = { "kyazdani42/nvim-web-devicons" }, +} -local file_button = function(filename, sc) - local short_fn = utils.fs.shorten_path(filename, 60) - local hl = {} +function M.config() + local alpha = require("alpha") + local Icons = require("nvim-web-devicons") + local utils = require("tobyvin.utils") - local filetype, _ = vim.filetype.match({ filename = filename }) - filetype = vim.F.if_nil(filetype, "") - local ico, ico_hl = Icons.get_icon_by_filetype(filetype, { default = true }) - table.insert(hl, { ico_hl, 0, 3 }) - local ico_txt = ico .. " " - local fn_start = short_fn:match(".*[/\\]") - if fn_start ~= nil then - table.insert(hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt }) - end + local file_button = function(filename, sc) + local short_fn = utils.fs.shorten_path(filename, 60) + local hl = {} - local keybind = "e " .. filename .. " " - local button = { - type = "button", - val = ico_txt .. short_fn, - on_press = function() - local key = vim.api.nvim_replace_termcodes(keybind .. "", true, false, true) - vim.api.nvim_feedkeys(key, "t", false) - end, - opts = { - position = "center", - shortcut = "[" .. sc .. "]", - cursor = 60, - width = 60, - align_shortcut = "right", - hl = hl, - hl_shortcut = { { "Special", 0, 1 }, { "Number", 1, #sc + 1 }, { "Special", #sc + 1, #sc + 2 } }, - shrink_margin = false, - keymap = { "n", sc:gsub("%s", ""), keybind, { desc = "oldfile_" .. sc } }, - }, - } - return button -end + local filetype, _ = vim.filetype.match({ filename = filename }) + filetype = vim.F.if_nil(filetype, "") + local ico, ico_hl = Icons.get_icon_by_filetype(filetype, { default = true }) + table.insert(hl, { ico_hl, 0, 3 }) + local ico_txt = ico .. " " + local fn_start = short_fn:match(".*[/\\]") + if fn_start ~= nil then + table.insert(hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt }) + end -local mru_filter = function(filename) - local ignored_ft = { "gitcommit" } - local cwd = vim.fn.getcwd() - local filetype, _ = vim.filetype.match({ filename = filename }) - filetype = vim.F.if_nil(filetype, "") - local ignored = false - for _, pattern in pairs(ignored_ft) do - ignored = ignored or filetype:match(pattern) ~= nil + local keybind = "e " .. filename .. " " + local button = { + type = "button", + val = ico_txt .. short_fn, + on_press = function() + local key = vim.api.nvim_replace_termcodes(keybind .. "", true, false, true) + vim.api.nvim_feedkeys(key, "t", false) + end, + opts = { + position = "center", + shortcut = "[" .. sc .. "]", + cursor = 60, + width = 60, + align_shortcut = "right", + hl = hl, + hl_shortcut = { { "Special", 0, 1 }, { "Number", 1, #sc + 1 }, { "Special", #sc + 1, #sc + 2 } }, + shrink_margin = false, + keymap = { "n", sc:gsub("%s", ""), keybind, { desc = "oldfile_" .. sc } }, + }, + } + return button end - return not ignored and (vim.fn.filereadable(filename) == 1) and vim.startswith(filename, cwd) -end -local mru_cache = nil -local get_mru = function() - if mru_cache == nil then - local oldfiles = { unpack(vim.tbl_filter(mru_filter, vim.v.oldfiles), 1, 20) } - local tbl = {} - for i, filename in ipairs(oldfiles) do - tbl[i] = file_button(filename, tostring(i % 10)) + local mru_filter = function(filename) + local ignored_ft = { "gitcommit" } + local cwd = vim.fn.getcwd() + local filetype, _ = vim.filetype.match({ filename = filename }) + filetype = filetype or "" + local ignored = false + for _, pattern in pairs(ignored_ft) do + ignored = ignored or filetype:match(pattern) ~= nil end - mru_cache = { { - type = "group", - val = tbl, - } } + return not ignored and (vim.fn.filereadable(filename) == 1) and vim.startswith(filename, cwd) end - return mru_cache -end -local status_ok, alpha = pcall(require, "alpha") -if not status_ok then - vim.notify("Failed to load module 'alpha'", vim.log.levels.ERROR) - return -end + local mru_cache = nil + local get_mru = function() + if mru_cache == nil then + local oldfiles = { unpack(vim.tbl_filter(mru_filter, vim.v.oldfiles), 1, 20) } + local tbl = {} + for i, filename in ipairs(oldfiles) do + tbl[i] = file_button(filename, tostring(i % 10)) + end + mru_cache = { { + type = "group", + val = tbl, + } } + end + return mru_cache + end -alpha.keymaps_element.button = function(el, _, state) - if el.opts and el.opts.keymap then - if type(el.opts.keymap[1]) == "table" then - for _, map in el.opts.keymap do + alpha.keymaps_element.button = function(el, _, state) + if el.opts and el.opts.keymap then + if type(el.opts.keymap[1]) == "table" then + for _, map in el.opts.keymap do + map[4].buffer = state.buffer + vim.keymap.set(unpack(map)) + end + else + local map = el.opts.keymap map[4].buffer = state.buffer vim.keymap.set(unpack(map)) end - else - local map = el.opts.keymap - map[4].buffer = state.buffer - vim.keymap.set(unpack(map)) end end -end -local fortune = require("alpha.fortune") + local fortune = require("alpha.fortune") -local function info_value() - local total_plugins = #vim.tbl_keys(packer_plugins) - local v = vim.F.if_nil(vim.version(), {}) - return string.format("VIM: v%d.%d.%d PLUGINS: %d", v.major, v.minor, v.patch, total_plugins) -end + local function info_value() + local plugins = require("lazy").stats().count + local v = vim.version() or {} -local config = { - layout = { - { - type = "text", - val = { - " ", - " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", - " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", - " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ", - " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ", - " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", - " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", + local info = string.format("VIM: v%d.%d.%d PLUGINS: %d", v.major, v.minor, v.patch, plugins) + if require("lazy.status").has_updates() then + local updates = require("lazy.status").updates() + info = string.format("%s ( %s )", info, updates) + end + return info + end + + local config = { + layout = { + { + type = "text", + val = { + " ", + " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ", + " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ", + " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ", + " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ", + " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ", + " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ", + }, + opts = { + position = "center", + hl = "DevIconVim", + }, }, - opts = { - position = "center", - hl = "DevIconVim", + { + type = "text", + val = info_value, + opts = { + hl = "DevIconVim", + position = "center", + }, }, - }, - { - type = "text", - val = info_value(), - opts = { - hl = "DevIconVim", - position = "center", + { + type = "text", + val = fortune({ max_width = 60 }), + opts = { + position = "center", + hl = "Statement", + }, }, - }, - { - type = "text", - val = fortune({ max_width = 60 }), - opts = { - position = "center", - hl = "Statement", + { type = "padding", val = 1 }, + { + type = "group", + val = get_mru, }, }, - { type = "padding", val = 1 }, - { - type = "group", - val = get_mru, - }, - }, -} + } -alpha.setup(config) + alpha.setup(config) -vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("alpha_user", { clear = true }), - pattern = "BDeleteLast", - callback = function(args) - local bufnr = vim.F.if_nil(args.data.buf, args.buf) - if vim.api.nvim_buf_get_option(bufnr, "filetype") ~= "alpha" then - alpha.start(false) - end - end, - desc = "Run Alpha when last buffer closed", -}) + vim.api.nvim_create_autocmd("User", { + group = vim.api.nvim_create_augroup("alpha_user", { clear = true }), + pattern = "BDeleteLast", + callback = function(args) + local bufnr = vim.F.if_nil(args.data.buf, args.buf) + if vim.api.nvim_buf_get_option(bufnr, "filetype") ~= "alpha" then + alpha.start(false) + end + end, + desc = "Run Alpha when last buffer closed", + }) +end + +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua deleted file mode 100644 index 44cb82f..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status_ok, cmp_git = pcall(require, "cmp_git") -if not status_ok then - vim.notify("Failed to load module 'cmp_git'", vim.log.levels.ERROR) - return -end - -cmp_git.setup() diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua deleted file mode 100644 index 3205ba0..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status_ok, cmp_npm = pcall(require, "cmp-npm") -if not status_ok then - vim.notify("Failed to load module 'cmp-npm'", vim.log.levels.ERROR) - return -end - -cmp_npm.setup() diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua index e5446e2..6d1acad 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua @@ -1,126 +1,147 @@ -local status_ok, cmp = pcall(require, "cmp") -if not status_ok then - vim.notify("Failed to load module 'cmd'", vim.log.levels.ERROR) - return -end +local M = { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lsp-document-symbol", + "hrsh7th/cmp-nvim-lsp-signature-help", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-cmdline", + "petertriho/cmp-git", + "Dosx001/cmp-commit", + "davidsierradz/cmp-conventionalcommits", + "rcarriga/cmp-dap", + "ray-x/lsp_signature.nvim", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "saecki/crates.nvim", + "kdheepak/cmp-latex-symbols", + }, +} -local lsp = require("tobyvin.lsp") -local luasnip = require("luasnip") -local default = require("cmp.config.default")() -local context = require("cmp.config.context") -local cmp_dap = require("cmp_dap") -local cmp_nvim_lsp = require("cmp_nvim_lsp") - -local in_comment = function() - return vim.api.nvim_get_mode().mode ~= "c" - and context.in_treesitter_capture("comment") - and context.in_syntax_group("Comment") -end +function M.config() + local cmp = require("cmp") -local enabled = function() - return (default.enabled() or cmp_dap.is_dap_buffer()) and not in_comment() -end + local lsp = require("tobyvin.lsp") + local default = require("cmp.config.default")() + local context = require("cmp.config.context") + local cmp_dap = require("cmp_dap") + local cmp_nvim_lsp = require("cmp_nvim_lsp") -local expand_snip = function(args) - luasnip.lsp_expand(args.body) -end + local in_comment = function() + return vim.api.nvim_get_mode().mode ~= "c" + and context.in_treesitter_capture("comment") + and context.in_syntax_group("Comment") + end -cmp.setup.global({ - enabled = enabled, - window = { - completion = cmp.config.window.bordered({ border = "single" }), - documentation = cmp.config.window.bordered({ border = "single" }), - }, - snippet = { - expand = expand_snip, - }, - mapping = cmp.mapping.preset.insert({ - [""] = { i = cmp.mapping.select_next_item() }, - [""] = { i = cmp.mapping.select_prev_item() }, - [""] = { i = cmp.mapping.scroll_docs(4) }, - [""] = { i = cmp.mapping.scroll_docs(-4) }, - [""] = { i = cmp.mapping.complete() }, - [""] = { i = cmp.mapping.confirm() }, - }), - sources = { - { name = "nvim_lsp" }, - { name = "nvim_lsp_signature_help" }, - { name = "luasnip" }, - { name = "path" }, - { name = "dap" }, - }, -}) + local enabled = function() + return (default.enabled() or cmp_dap.is_dap_buffer()) and not in_comment() + end -local cmd_mapping = cmp.mapping.preset.cmdline({ - [""] = { c = cmp.mapping.complete() }, - [""] = { c = cmp.mapping.abort() }, -}) + local expand_snip = function(args) + require("luasnip").lsp_expand(args.body) + end -cmp.setup.cmdline(":", { - mapping = cmd_mapping, - sources = { - { name = "cmdline", max_item_count = 10 }, - }, -}) + cmp.setup.global({ + enabled = enabled, + window = { + completion = cmp.config.window.bordered({ border = "single" }), + documentation = cmp.config.window.bordered({ border = "single" }), + }, + snippet = { + expand = expand_snip, + }, + mapping = cmp.mapping.preset.insert({ + [""] = { i = cmp.mapping.select_next_item() }, + [""] = { i = cmp.mapping.select_prev_item() }, + [""] = { i = cmp.mapping.scroll_docs(4) }, + [""] = { i = cmp.mapping.scroll_docs(-4) }, + [""] = { i = cmp.mapping.complete() }, + [""] = { i = cmp.mapping.confirm() }, + }), + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lsp_signature_help" }, + { name = "luasnip" }, + { name = "path" }, + { name = "dap" }, + }, + }) -cmp.setup.cmdline({ "/", "?", "@" }, { - mapping = cmd_mapping, - sources = { - { name = "nvim_lsp_document_symbol", max_item_count = 10, group_index = 1 }, - { name = "buffer", keyword_length = 3, max_item_count = 10, group_index = 2 }, - }, -}) + local cmd_mapping = cmp.mapping.preset.cmdline({ + [""] = { c = cmp.mapping.complete() }, + [""] = { c = cmp.mapping.abort() }, + }) -cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, { - sources = { - { name = "dap" }, - }, -}) - -cmp.setup.filetype({ - "tex", - "bib", - "sh", - "zsh", - "xml", - "markdown", -}, { - sources = { - { name = "nvim_lsp", group_index = 1 }, - { name = "nvim_lsp_signature_help", group_index = 1 }, - { name = "luasnip", group_index = 1 }, - { name = "path", group_index = 1 }, - { name = "dap", group_index = 1 }, - { name = "buffer", keyword_length = 3, group_index = 2 }, - }, -}) + cmp.setup.cmdline(":", { + mapping = cmd_mapping, + sources = { + { name = "cmdline", max_item_count = 10 }, + }, + }) -cmp.setup.filetype({ "tex", "bib" }, { - sources = { - { name = "latex_symbols" }, - }, -}) + cmp.setup.cmdline({ "/", "?", "@" }, { + mapping = cmd_mapping, + sources = { + { name = "nvim_lsp_document_symbol", max_item_count = 10, group_index = 1 }, + { name = "buffer", keyword_length = 3, max_item_count = 10, group_index = 2 }, + }, + }) -cmp.setup.filetype("gitcommit", { - sources = { - { name = "git" }, - { name = "commit" }, - { name = "conventionalcommits" }, - }, -}) + cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, { + sources = { + { name = "dap" }, + }, + }) -cmp.setup.filetype("json", { - sources = { - { name = "npm" }, - }, -}) + cmp.setup.filetype({ + "tex", + "bib", + "sh", + "zsh", + "xml", + "markdown", + }, { + sources = { + { name = "nvim_lsp", group_index = 1 }, + { name = "nvim_lsp_signature_help", group_index = 1 }, + { name = "luasnip", group_index = 1 }, + { name = "path", group_index = 1 }, + { name = "dap", group_index = 1 }, + { name = "buffer", keyword_length = 3, group_index = 2 }, + }, + }) -cmp.setup.filetype("toml", { - sources = { - { name = "crates" }, - }, -}) + cmp.setup.filetype({ "tex", "bib" }, { + sources = { + { name = "latex_symbols" }, + }, + }) + + cmp.setup.filetype("gitcommit", { + sources = { + { name = "git" }, + { name = "commit" }, + { name = "conventionalcommits" }, + }, + }) + + cmp.setup.filetype("json", { + sources = { + { name = "npm" }, + }, + }) + + cmp.setup.filetype("toml", { + sources = { + { name = "crates" }, + }, + }) + + lsp.default_config = vim.tbl_extend("force", lsp.default_config, { + capabilities = cmp_nvim_lsp.default_capabilities(), + }) +end -lsp.default_config = vim.tbl_extend("force", lsp.default_config, { - capabilities = cmp_nvim_lsp.default_capabilities(), -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua b/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua deleted file mode 100644 index 8fc8ef1..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua +++ /dev/null @@ -1,14 +0,0 @@ -local status_ok, comment = pcall(require, "Comment") -if not status_ok then - vim.notify("Failed to load module 'Comment'", vim.log.levels.ERROR) - return -end - -comment.setup({ - toggler = { - block = "gCc", - }, - opleader = { - block = "gC", - }, -}) diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua b/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua index 9e41d5b..b23ca29 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua @@ -1,28 +1,37 @@ -local status_ok, crates = pcall(require, "crates") -if not status_ok then - vim.notify("Failed to load module 'crates'", vim.log.levels.ERROR) - return -end +local M = { + "saecki/crates.nvim", + event = "BufRead Cargo.toml", + dependencies = { + "nvim-lua/plenary.nvim", + "jose-elias-alvarez/null-ls.nvim", + }, +} -local utils = require("tobyvin.utils") +function M.config() + local crates = require("crates") -crates.setup({ - null_ls = { - enabled = true, - }, -}) + local utils = require("tobyvin.utils") + + crates.setup({ + null_ls = { + enabled = true, + }, + }) + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("tobyvin_crates", { clear = true }), + pattern = "*/Cargo.toml", + desc = "setup crates", + callback = function(args) + utils.documentation.register("toml", crates.open_documentation) + utils.hover.register(crates.show_popup, { + enabled = crates.popup_available, + desc = "crates", + buffer = args.buf, + priority = 10, + }) + end, + }) +end -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("tobyvin_crates", { clear = true }), - pattern = "*/Cargo.toml", - desc = "setup crates", - callback = function(args) - utils.documentation.register("toml", crates.open_documentation) - utils.hover.register(crates.show_popup, { - enabled = crates.popup_available, - desc = "crates", - buffer = args.buf, - priority = 10, - }) - end, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua b/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua index 4ae19b6..eb131c2 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua @@ -1,130 +1,98 @@ local M = { - configs = require("tobyvin.plugins.dap.configs"), - adapters = require("tobyvin.plugins.dap.adapters"), - events = require("tobyvin.plugins.dap.events"), - hover = require("tobyvin.plugins.dap.hover"), + "mfussenegger/nvim-dap", + dependencies = { + "mfussenegger/nvim-dap-python", + "leoluz/nvim-dap-go", + "nvim-telescope/telescope.nvim", + "nvim-telescope/telescope-dap.nvim", + }, } -local status_ok, dap = pcall(require, "dap") -if not status_ok then - vim.notify("Failed to load module 'dap'", vim.log.levels.ERROR) - return -end +function M.config() + local dap = require("dap") -local utils = require("tobyvin.utils") + local utils = require("tobyvin.utils") -local set_custom_breakpoint = function() - vim.ui.input({ prompt = "Condition: " }, function(condition) - vim.ui.input({ prompt = "Hit condition: " }, function(hit_condition) - vim.ui.input({ prompt = "Log point message: " }, function(log_message) - require("dap").set_breakpoint(condition, hit_condition, log_message) + local set_custom_breakpoint = function() + vim.ui.input({ prompt = "Condition: " }, function(condition) + vim.ui.input({ prompt = "Hit condition: " }, function(hit_condition) + vim.ui.input({ prompt = "Log point message: " }, function(log_message) + dap.set_breakpoint(condition, hit_condition, log_message) + end) end) end) - end) -end - ----@param config table ----@return function -local with_eval = function(config) - return function() - local evaluated = {} - for key, value in pairs(config) do - if type(value) == "function" then - evaluated[key] = value() - end - end - return vim.tbl_extend("keep", evaluated, config) end -end ----@param config table ----@return boolean -local contains_func = function(config) - for _, value in pairs(config) do - if type(value) == "function" then - return true - end - end - return false -end - ----@param config table ----@return table|function -local make_config = function(config) - if contains_func(config) then - return with_eval(config) - end - return config -end + dap.defaults.fallback.focus_terminal = true + dap.defaults.fallback.terminal_win_cmd = "15split new" -dap.defaults.fallback.focus_terminal = true -dap.defaults.fallback.terminal_win_cmd = "15split new" + require("tobyvin.plugins.dap.events").setup() + require("tobyvin.plugins.dap.hover").setup() -M.events.setup() -M.hover.setup() - -for name, config in pairs(M.configs) do - if dap.configurations[name] == nil then - dap.configurations[name] = config + local configs = require("tobyvin.plugins.dap.configs") + for name, config in pairs(configs) do + if dap.configurations[name] == nil then + dap.configurations[name] = config + end end -end - -require("dap-python").setup() -require("dap-go").setup() - -require("nvim-dap-virtual-text").setup({ - -- only_first_definition = false, - -- all_references = true, - virt_text_pos = "right_align", -}) -require("telescope").load_extension("dap") -local telescope = require("telescope").extensions.dap - -vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "toggle breakpoint" }) -vim.keymap.set("n", "dB", set_custom_breakpoint, { desc = "custom breakpoint" }) -vim.keymap.set("n", "dC", telescope.commands, { desc = "commands" }) -vim.keymap.set("n", "dd", telescope.configurations, { desc = "configurations" }) -vim.keymap.set("n", "dl", telescope.list_breakpoints, { desc = "list breakpoints" }) - -vim.api.nvim_create_autocmd("User", { - pattern = "DapAttach", - callback = function() - vim.keymap.set("n", "", dap.continue, { desc = "continue" }) - vim.keymap.set("n", "", dap.step_over, { desc = "step over" }) - vim.keymap.set("n", "", dap.step_into, { desc = "step into" }) - vim.keymap.set("n", "", dap.step_out, { desc = "step out" }) - vim.keymap.set("n", "dc", dap.continue, { desc = "continue" }) - vim.keymap.set("n", "da", dap.step_over, { desc = "step over" }) - vim.keymap.set("n", "di", dap.step_into, { desc = "step into" }) - vim.keymap.set("n", "do", dap.step_out, { desc = "step out" }) - vim.keymap.set("n", "dq", dap.terminate, { desc = "terminate" }) - vim.keymap.set("n", "dv", telescope.variables, { desc = "variables" }) - vim.keymap.set("n", "df", telescope.frames, { desc = "frames" }) - end, -}) - -vim.api.nvim_create_autocmd("User", { - pattern = "DapDetach", - callback = function() - vim.keymap.del("n", "dv") - vim.keymap.del("n", "df") - vim.keymap.del("n", "dc") - vim.keymap.del("n", "da") - vim.keymap.del("n", "di") - vim.keymap.del("n", "do") - vim.keymap.del("n", "dq") - vim.keymap.del("n", "") - vim.keymap.del("n", "") - vim.keymap.del("n", "") - vim.keymap.del("n", "") - end, -}) - -vim.fn.sign_define("DapBreakpoint", utils.debug.signs.breakpoint) -vim.fn.sign_define("DapBreakpointCondition", utils.debug.signs.condition) -vim.fn.sign_define("DapBreakpointRejected", utils.debug.signs.rejected) -vim.fn.sign_define("DapStopped", utils.debug.signs.stopped) -vim.fn.sign_define("DapLogPoint", utils.debug.signs.logpoint) + require("dap-python").setup() + require("dap-go").setup() + + require("nvim-dap-virtual-text").setup({ + -- only_first_definition = false, + -- all_references = true, + virt_text_pos = "right_align", + }) + + require("telescope").load_extension("dap") + local telescope = require("telescope").extensions.dap + + vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "toggle breakpoint" }) + vim.keymap.set("n", "dB", set_custom_breakpoint, { desc = "custom breakpoint" }) + vim.keymap.set("n", "dC", telescope.commands, { desc = "commands" }) + vim.keymap.set("n", "dd", telescope.configurations, { desc = "configurations" }) + vim.keymap.set("n", "dl", telescope.list_breakpoints, { desc = "list breakpoints" }) + + vim.api.nvim_create_autocmd("User", { + pattern = "DapAttach", + callback = function() + vim.keymap.set("n", "", dap.continue, { desc = "continue" }) + vim.keymap.set("n", "", dap.step_over, { desc = "step over" }) + vim.keymap.set("n", "", dap.step_into, { desc = "step into" }) + vim.keymap.set("n", "", dap.step_out, { desc = "step out" }) + vim.keymap.set("n", "dc", dap.continue, { desc = "continue" }) + vim.keymap.set("n", "da", dap.step_over, { desc = "step over" }) + vim.keymap.set("n", "di", dap.step_into, { desc = "step into" }) + vim.keymap.set("n", "do", dap.step_out, { desc = "step out" }) + vim.keymap.set("n", "dq", dap.terminate, { desc = "terminate" }) + vim.keymap.set("n", "dv", telescope.variables, { desc = "variables" }) + vim.keymap.set("n", "df", telescope.frames, { desc = "frames" }) + end, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "DapDetach", + callback = function() + vim.keymap.del("n", "dv") + vim.keymap.del("n", "df") + vim.keymap.del("n", "dc") + vim.keymap.del("n", "da") + vim.keymap.del("n", "di") + vim.keymap.del("n", "do") + vim.keymap.del("n", "dq") + vim.keymap.del("n", "") + vim.keymap.del("n", "") + vim.keymap.del("n", "") + vim.keymap.del("n", "") + end, + }) + + vim.fn.sign_define("DapBreakpoint", utils.debug.signs.breakpoint) + vim.fn.sign_define("DapBreakpointCondition", utils.debug.signs.condition) + vim.fn.sign_define("DapBreakpointRejected", utils.debug.signs.rejected) + vim.fn.sign_define("DapStopped", utils.debug.signs.stopped) + vim.fn.sign_define("DapLogPoint", utils.debug.signs.logpoint) +end return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua b/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua index 470c360..1689a8d 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua @@ -1,26 +1,34 @@ -local status_ok, diffview = pcall(require, "diffview") -if not status_ok then - vim.notify("Failed to load module 'diffview'", vim.log.levels.ERROR) - return -end +local M = { + "sindrets/diffview.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "kyazdani42/nvim-web-devicons", + }, +} -local file_history = function() - require("diffview").file_history(nil, vim.fn.bufname()) -end +function M.config() + local diffview = require("diffview") -local workspace_history = function() - require("diffview").file_history() -end + local file_history = function() + require("diffview").file_history(nil, vim.fn.bufname()) + end -local selection_history = function() - local first = vim.api.nvim_buf_get_mark(0, "<")[1] - local last = vim.api.nvim_buf_get_mark(0, ">")[1] - require("diffview").file_history({ first, last }) -end + local workspace_history = function() + require("diffview").file_history() + end -diffview.setup() + local selection_history = function() + local first = vim.api.nvim_buf_get_mark(0, "<")[1] + local last = vim.api.nvim_buf_get_mark(0, ">")[1] + require("diffview").file_history({ first, last }) + end + + diffview.setup() + + vim.keymap.set("n", "gd", diffview.open, { desc = "diffview" }) + vim.keymap.set("n", "gh", file_history, { desc = "file history" }) + vim.keymap.set("n", "gH", workspace_history, { desc = "workspace history" }) + vim.keymap.set("v", "gh", selection_history, { desc = "selection history" }) +end -vim.keymap.set("n", "gd", diffview.open, { desc = "diffview" }) -vim.keymap.set("n", "gh", file_history, { desc = "file history" }) -vim.keymap.set("n", "gH", workspace_history, { desc = "workspace history" }) -vim.keymap.set("v", "gh", selection_history, { desc = "selection history" }) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua b/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua index e9ddbaa..d0748c8 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua @@ -1,58 +1,65 @@ -local themes = require("telescope.themes") -local status_ok, dressing = pcall(require, "dressing") -if not status_ok then - vim.notify("Failed to load module 'dressing'", vim.log.levels.ERROR) - return -end - -local format_item_override = { - ["rust-tools/debuggables"] = function(item) - item = item:gsub(" %-%-no%-run", "") - item = item:gsub(" %-%-package", " -p") - item = item:gsub(" %-%-all%-features", "") - item = item:gsub(" %-%-all%-targets", "") - item = item:gsub(" %-%-exact", "") - item = item:gsub(" %-%-nocapture", "") - return item - end, +local M = { + "stevearc/dressing.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + }, } -local config_overrides = { - select = { - ["Ring history"] = { - telescope = themes.get_dropdown({ preview = true }), +function M.config() + local dressing = require("dressing") + local themes = require("telescope.themes") + + local format_item_override = { + ["rust-tools/debuggables"] = function(item) + item = item:gsub(" %-%-no%-run", "") + item = item:gsub(" %-%-package", " -p") + item = item:gsub(" %-%-all%-features", "") + item = item:gsub(" %-%-all%-targets", "") + item = item:gsub(" %-%-exact", "") + item = item:gsub(" %-%-nocapture", "") + return item + end, + } + + local config_overrides = { + select = { + ["Ring history"] = { + telescope = themes.get_dropdown({ preview = true }), + }, }, - }, - input = { - cmd = { - relative = "win", - insert_only = false, + input = { + cmd = { + relative = "win", + insert_only = false, + }, }, - }, -} + } -dressing.setup({ - input = { - get_config = function(opts) - local overrides = config_overrides.input + dressing.setup({ + input = { + get_config = function(opts) + local overrides = config_overrides.input - if overrides[opts.kind] ~= nil then - return overrides[opts.kind] - elseif overrides[opts.prompt] ~= nil then - return overrides[opts.prompt] - end - end, - }, - select = { - get_config = function(opts) - local overrides = config_overrides.select + if overrides[opts.kind] ~= nil then + return overrides[opts.kind] + elseif overrides[opts.prompt] ~= nil then + return overrides[opts.prompt] + end + end, + }, + select = { + get_config = function(opts) + local overrides = config_overrides.select - if overrides[opts.kind] ~= nil then - return overrides[opts.kind] - elseif overrides[opts.prompt] ~= nil then - return overrides[opts.prompt] - end - end, - format_item_override = format_item_override, - }, -}) + if overrides[opts.kind] ~= nil then + return overrides[opts.kind] + elseif overrides[opts.prompt] ~= nil then + return overrides[opts.prompt] + end + end, + format_item_override = format_item_override, + }, + }) +end + +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua b/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua index ac4bcca..f73e99d 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua @@ -1,15 +1,18 @@ -local status_ok, fidget = pcall(require, "fidget") -if not status_ok then - vim.notify("Failed to load module 'fidget'", vim.log.levels.ERROR) - return -end +local M = { + "j-hui/fidget.nvim", +} + +function M.config() + local fidget = require("fidget") + local utils = require("tobyvin.utils") -local utils = require("tobyvin.utils") + fidget.setup({ + text = { + spinner = utils.status.signs.spinner.text, + done = vim.trim(utils.status.signs.completed.text), + }, + window = { blend = 0 }, + }) +end -fidget.setup({ - text = { - spinner = utils.status.signs.spinner.text, - done = vim.trim(utils.status.signs.completed.text), - }, - window = { blend = 0 }, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua b/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua index efc7618..81ae499 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua @@ -1,13 +1,17 @@ -local status_ok, git_conflict = pcall(require, "git-conflict") -if not status_ok then - vim.notify("Failed to load module 'git_conflict'", vim.log.levels.ERROR) - return +local M = { + "akinsho/git-conflict.nvim", +} + +function M.config() + local git_conflict = require("git-conflict") + + git_conflict.setup({ + disable_diagnostics = true, + highlights = { + incoming = "diffText", + current = "diffAdd", + }, + }) end -git_conflict.setup({ - disable_diagnostics = true, - highlights = { - incoming = "diffText", - current = "diffAdd", - }, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua b/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua index a2b97ae..109a596 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua @@ -1,78 +1,88 @@ -local status_ok, gitsigns = pcall(require, "gitsigns") -if not status_ok then - vim.notify("Failed to load module 'gitsigns'", vim.log.levels.ERROR) - return -end +local M = { + "lewis6991/gitsigns.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, +} + +function M.config() + local gitsigns = require("gitsigns") -local utils = require("tobyvin.utils") + local utils = require("tobyvin.utils") -local with_range = function(callback) - return function() - callback(utils.buffer.get_visual_range()) + local with_range = function(callback) + return function() + callback(utils.buffer.get_visual_range()) + end end -end -local show_blameline = function() - gitsigns.blame_line({ full = true }) -end + local show_blameline = function() + gitsigns.blame_line({ full = true }) + end -local toggle_blameline = function() - gitsigns.toggle_current_line_blame() -end + local toggle_blameline = function() + gitsigns.toggle_current_line_blame() + end -local next_hunk = function() - if vim.wo.diff then - return "]c" + local next_hunk = function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + gitsigns.next_hunk() + end) + return "" end - vim.schedule(function() - gitsigns.next_hunk() - end) - return "" -end -local prev_hunk = function() - if vim.wo.diff then - return "[c" + local prev_hunk = function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + gitsigns.prev_hunk() + end) + return "" end - vim.schedule(function() - gitsigns.prev_hunk() - end) - return "" -end -local on_attach = function(bufnr) - vim.keymap.set("n", "]c", next_hunk, { expr = true, desc = "next hunk", buffer = bufnr }) - vim.keymap.set("n", "[c", prev_hunk, { expr = true, desc = "previous hunk", buffer = bufnr }) + local on_attach = function(bufnr) + vim.keymap.set("n", "]c", next_hunk, { expr = true, desc = "next hunk", buffer = bufnr }) + vim.keymap.set("n", "[c", prev_hunk, { expr = true, desc = "previous hunk", buffer = bufnr }) - vim.keymap.set("n", "gb", gitsigns.blame_line, { desc = "show blame", buffer = bufnr }) - vim.keymap.set("n", "gB", show_blameline, { desc = "show blame", buffer = bufnr }) - vim.keymap.set("n", "g", toggle_blameline, { desc = "toggle blame", buffer = bufnr }) + vim.keymap.set("n", "gb", gitsigns.blame_line, { desc = "show blame", buffer = bufnr }) + vim.keymap.set("n", "gB", show_blameline, { desc = "show blame", buffer = bufnr }) + vim.keymap.set("n", "g", toggle_blameline, { desc = "toggle blame", buffer = bufnr }) - vim.keymap.set("n", "gp", gitsigns.preview_hunk, { desc = "preview hunk", buffer = bufnr }) - vim.keymap.set("n", "gr", gitsigns.reset_hunk, { desc = "reset hunk", buffer = bufnr }) - vim.keymap.set("n", "gs", gitsigns.stage_hunk, { desc = "stage hunk", buffer = bufnr }) - vim.keymap.set("n", "gu", gitsigns.undo_stage_hunk, { desc = "undo stage hunk", buffer = bufnr }) + vim.keymap.set("n", "gp", gitsigns.preview_hunk, { desc = "preview hunk", buffer = bufnr }) + vim.keymap.set("n", "gr", gitsigns.reset_hunk, { desc = "reset hunk", buffer = bufnr }) + vim.keymap.set("n", "gs", gitsigns.stage_hunk, { desc = "stage hunk", buffer = bufnr }) + vim.keymap.set("n", "gu", gitsigns.undo_stage_hunk, { desc = "undo stage hunk", buffer = bufnr }) - vim.keymap.set("n", "gR", gitsigns.reset_buffer, { desc = "reset buffer", buffer = bufnr }) - vim.keymap.set("n", "gS", gitsigns.stage_buffer, { desc = "stage buffer", buffer = bufnr }) - vim.keymap.set("n", "gU", gitsigns.reset_buffer_index, { desc = "undo stage buffer", buffer = bufnr }) + vim.keymap.set("n", "gR", gitsigns.reset_buffer, { desc = "reset buffer", buffer = bufnr }) + vim.keymap.set("n", "gS", gitsigns.stage_buffer, { desc = "stage buffer", buffer = bufnr }) + vim.keymap.set("n", "gU", gitsigns.reset_buffer_index, { desc = "undo stage buffer", buffer = bufnr }) - vim.keymap.set("v", "gp", with_range(gitsigns.preview_hunk), { desc = "preview hunk", buffer = bufnr }) - vim.keymap.set("v", "gr", with_range(gitsigns.reset_hunk), { desc = "reset hunk", buffer = bufnr }) - vim.keymap.set("v", "gs", with_range(gitsigns.stage_hunk), { desc = "stage hunk", buffer = bufnr }) - vim.keymap.set("v", "gu", with_range(gitsigns.undo_stage_hunk), { desc = "unstage hunk", buffer = bufnr }) + vim.keymap.set("v", "gp", with_range(gitsigns.preview_hunk), { desc = "preview hunk", buffer = bufnr }) + vim.keymap.set("v", "gr", with_range(gitsigns.reset_hunk), { desc = "reset hunk", buffer = bufnr }) + vim.keymap.set("v", "gs", with_range(gitsigns.stage_hunk), { desc = "stage hunk", buffer = bufnr }) + vim.keymap.set( + "v", + "gu", + with_range(gitsigns.undo_stage_hunk), + { desc = "unstage hunk", buffer = bufnr } + ) + + vim.api.nvim_exec_autocmds("User", { pattern = "GitAttach", data = { buf = bufnr } }) + end - vim.api.nvim_exec_autocmds("User", { pattern = "GitAttach", data = { buf = bufnr } }) + gitsigns.setup({ + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "契" }, + topdelete = { text = "契" }, + changedelete = { text = "▎" }, + }, + preview_config = { border = "single" }, + on_attach = on_attach, + }) end -gitsigns.setup({ - signs = { - add = { text = "▎" }, - change = { text = "▎" }, - delete = { text = "契" }, - topdelete = { text = "契" }, - changedelete = { text = "▎" }, - }, - preview_config = { border = "single" }, - on_attach = on_attach, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua b/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua index 973e302..fad7ad4 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua @@ -1,41 +1,45 @@ -local status_ok, gruvbox = pcall(require, "gruvbox") -if not status_ok then - vim.notify("Failed to load module 'gruvbox'", vim.log.levels.ERROR) - return -end +local M = { + "ellisonleao/gruvbox.nvim", +} + +function M.config() + local gruvbox = require("gruvbox") -local colors = require("gruvbox.palette") -gruvbox.setup({ - contrast = "hard", - transparent_mode = true, - overrides = { - GruvboxRedSign = { bg = "" }, - GruvboxGreenSign = { bg = "" }, - GruvboxYellowSign = { bg = "" }, - GruvboxBlueSign = { bg = "" }, - GruvboxPurpleSign = { bg = "" }, - GruvboxAquaSign = { bg = "" }, - GruvboxOrangeSign = { bg = "" }, - NormalFloat = { bg = "" }, - FloatBorder = { bg = "" }, - ColorColumn = { bg = "" }, - CursorLine = { bg = "" }, - CursorLineNr = { bg = "" }, - SignColumn = { bg = "" }, - DiffDelete = { reverse = false }, - DiffAdd = { reverse = false }, - DiffChange = { reverse = false }, - DiffText = { reverse = false }, - StatusLine = { fg = colors.light1, bg = colors.dark2, reverse = false }, - StatusLineNC = { fg = colors.light4, bg = colors.dark1, reverse = false }, - WinBar = { link = "StatusLineNC" }, - WinBarNC = { fg = colors.light4, bg = "" }, - QuickFixLine = { fg = "", bg = "" }, + local colors = require("gruvbox.palette") + gruvbox.setup({ + contrast = "hard", + transparent_mode = true, + overrides = { + GruvboxRedSign = { bg = "" }, + GruvboxGreenSign = { bg = "" }, + GruvboxYellowSign = { bg = "" }, + GruvboxBlueSign = { bg = "" }, + GruvboxPurpleSign = { bg = "" }, + GruvboxAquaSign = { bg = "" }, + GruvboxOrangeSign = { bg = "" }, + NormalFloat = { bg = "" }, + FloatBorder = { bg = "" }, + ColorColumn = { bg = "" }, + CursorLine = { bg = "" }, + CursorLineNr = { bg = "" }, + SignColumn = { bg = "" }, + DiffDelete = { reverse = false }, + DiffAdd = { reverse = false }, + DiffChange = { reverse = false }, + DiffText = { reverse = false }, + StatusLine = { fg = colors.light1, bg = colors.dark2, reverse = false }, + StatusLineNC = { fg = colors.light4, bg = colors.dark1, reverse = false }, + WinBar = { link = "StatusLineNC" }, + WinBarNC = { fg = colors.light4, bg = "" }, + QuickFixLine = { fg = "", bg = "" }, - -- TODO: workaround for weird highlights in lsp hover/signature - -- SEE: https://github.com/neovim/neovim/issues/13746 - markdownError = { link = "Normal" }, - }, -}) + -- TODO: workaround for weird highlights in lsp hover/signature + -- SEE: https://github.com/neovim/neovim/issues/13746 + markdownError = { link = "Normal" }, + }, + }) + + vim.cmd([[colorscheme gruvbox]]) +end -vim.cmd([[colorscheme gruvbox]]) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua b/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua index f151011..fb299b3 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua @@ -1,28 +1,32 @@ -local status_ok, indent_blankline = pcall(require, "indent_blankline") -if not status_ok then - vim.notify("Failed to load module 'indent_blankline'", vim.log.levels.ERROR) - return -end +local M = { + "lukas-reineke/indent-blankline.nvim", +} + +function M.config() + local indent_blankline = require("indent_blankline") -vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#E06C75", nocombine = true }) -vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#E5C07B", nocombine = true }) -vim.api.nvim_set_hl(0, "IndentBlanklineIndent3", { fg = "#98C379", nocombine = true }) -vim.api.nvim_set_hl(0, "IndentBlanklineIndent4", { fg = "#56B6C2", nocombine = true }) -vim.api.nvim_set_hl(0, "IndentBlanklineIndent5", { fg = "#61AFEF", nocombine = true }) -vim.api.nvim_set_hl(0, "IndentBlanklineIndent6", { fg = "#C678DD", nocombine = true }) + vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#E06C75", nocombine = true }) + vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#E5C07B", nocombine = true }) + vim.api.nvim_set_hl(0, "IndentBlanklineIndent3", { fg = "#98C379", nocombine = true }) + vim.api.nvim_set_hl(0, "IndentBlanklineIndent4", { fg = "#56B6C2", nocombine = true }) + vim.api.nvim_set_hl(0, "IndentBlanklineIndent5", { fg = "#61AFEF", nocombine = true }) + vim.api.nvim_set_hl(0, "IndentBlanklineIndent6", { fg = "#C678DD", nocombine = true }) + + indent_blankline.setup({ + context_highlight_list = { + "IndentBlanklineIndent1", + "IndentBlanklineIndent2", + "IndentBlanklineIndent3", + "IndentBlanklineIndent4", + "IndentBlanklineIndent5", + "IndentBlanklineIndent6", + }, + space_char_blankline = " ", + show_end_of_line = true, + show_current_context = true, + use_treesitter = true, + use_treesitter_scope = true, + }) +end -indent_blankline.setup({ - context_highlight_list = { - "IndentBlanklineIndent1", - "IndentBlanklineIndent2", - "IndentBlanklineIndent3", - "IndentBlanklineIndent4", - "IndentBlanklineIndent5", - "IndentBlanklineIndent6", - }, - space_char_blankline = " ", - show_end_of_line = true, - show_current_context = true, - use_treesitter = true, - use_treesitter_scope = true, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lsp-signature.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lsp-signature.lua index 6cc6bdc..e515ec8 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/lsp-signature.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/lsp-signature.lua @@ -1,13 +1,15 @@ -local M = {} +local M = { + "ray-x/lsp_signature.nvim", +} -M.setup = function() +M.config = function() local status_ok, lsp_signature = pcall(require, "lsp_signature") if not status_ok then return end vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("tobyvin_lsp_signature", { clear = true }), + group = vim.api.nvim_create_augroup("tobyvin_lsp_signature", { clear = true }), desc = "setup lsp_signature", callback = function(args) local bufnr = args.buf diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua index 3549fe2..3edd973 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua @@ -1,27 +1,34 @@ -local status_ok, lspconfig = pcall(require, "lspconfig") -if not status_ok then - vim.notify("Failed to load module 'lspconfig'", vim.log.levels.ERROR) - return -end +local M = { + "neovim/nvim-lspconfig", + dependencies = { + "folke/neodev.nvim", + "hrsh7th/cmp-nvim-lsp", + }, +} -local lsp = require("tobyvin.lsp") +function M.config() + local lspconfig = require("lspconfig") + local lsp = require("tobyvin.lsp") -require("lspconfig.ui.windows").default_options.border = "single" + require("lspconfig.ui.windows").default_options.border = "single" -lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, lsp.default_config) + lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, lsp.default_config) -local available = lspconfig.util.available_servers() -for name, config in pairs(lsp.configs) do - if not vim.tbl_contains(available, name) then - lspconfig[name].setup(config) + local available = lspconfig.util.available_servers() + for name, config in pairs(lsp.configs) do + if not vim.tbl_contains(available, name) then + lspconfig[name].setup(config) + end end + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("tobyvin_lsp_config", { clear = true }), + desc = "lsp", + callback = function(args) + local lspinfo = require("lspconfig.ui.lspinfo") + vim.keymap.set("n", "li", lspinfo, { desc = "lsp info", buffer = args.buf }) + end, + }) end -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("tobyvin_lsp_config", { clear = true }), - desc = "lsp", - callback = function(args) - local lspinfo = require("lspconfig.ui.lspinfo") - vim.keymap.set("n", "li", lspinfo, { desc = "lsp info", buffer = args.buf }) - end, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua deleted file mode 100644 index ffca80b..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua +++ /dev/null @@ -1,6 +0,0 @@ -local status_ok, lspkind = pcall(require, "lspkind") -if not status_ok then - return -end - -lspkind.init() diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua index aace592..44adc0a 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua @@ -1,147 +1,155 @@ -local status_ok, lualine = pcall(require, "lualine") -if not status_ok then - vim.notify("Failed to load module 'lualine'", vim.log.levels.ERROR) - return -end - -local utils = require("tobyvin.utils") +local M = { + "nvim-lualine/lualine.nvim", + dependencies = { + "kyazdani42/nvim-web-devicons", + "SmiteshP/nvim-navic", + }, +} -local get_short_cwd = function() - return vim.fn.fnamemodify(vim.fn.getcwd(), ":~") -end +function M.config() + local lualine = require("lualine") -local to_char = function(str) - return str:sub(1, 1) -end + local utils = require("tobyvin.utils") -local winbar_cond = function() - return vim.bo.buflisted -end + local get_short_cwd = function() + return vim.fn.fnamemodify(vim.fn.getcwd(), ":~") + end -local git = { - "branch", - { - "diff", - source = function() - local gitsigns = vim.b.gitsigns_status_dict - if gitsigns then - return { - added = gitsigns.added, - modified = gitsigns.changed, - removed = gitsigns.removed, - } - end - end, - padding = { left = 0, right = 1 }, - }, -} + local to_char = function(str) + return str:sub(1, 1) + end -local workspace = { - { - function() - return utils.diagnostic - .indicator(nil) - :gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal") - :gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal") - :gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal") - :gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal") - end, - padding = { left = 1, right = 0 }, - color = "StatusLineNC", - }, - { - "filename", - path = 1, - }, -} + local winbar_cond = function() + return vim.bo.buflisted + end -local buffer = { - { - "filename", - color = "WinBar", - cond = winbar_cond, - }, - { - "diagnostics", - source = { utils.diagnostic.buf_count }, - symbols = { - error = utils.diagnostic.signs.error.text, - warn = utils.diagnostic.signs.warn.text, - info = utils.diagnostic.signs.info.text, - hint = utils.diagnostic.signs.hint.text, + local git = { + "branch", + { + "diff", + source = function() + local gitsigns = vim.b["gitsigns_status_dict"] + if gitsigns then + return { + added = gitsigns.added, + modified = gitsigns.changed, + removed = gitsigns.removed, + } + end + end, + padding = { left = 0, right = 1 }, }, - update_in_insert = true, - color = "WinBar", - padding = { left = 0, right = 1 }, - cond = winbar_cond, - }, -} + } -lualine.setup({ - options = { - component_separators = "", - section_separators = "", - disabled_filetypes = { - "netrw", - "alpha", - winbar = vim.fn.getcompletion("Neogit*", "filetype"), + local workspace = { + { + function() + return utils.diagnostic + .indicator(nil) + :gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal") + :gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal") + :gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal") + :gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal") + end, + padding = { left = 1, right = 0 }, + color = "StatusLineNC", }, - }, + { + "filename", + path = 1, + }, + } - sections = { - lualine_a = { { "mode", fmt = to_char } }, - lualine_b = git, - lualine_c = workspace, - lualine_x = { - "encoding", - "fileformat", - "filetype", + local buffer = { + { + "filename", + color = "WinBar", + cond = winbar_cond, }, - }, + { + "diagnostics", + source = { utils.diagnostic.buf_count }, + symbols = { + error = utils.diagnostic.signs.error.text, + warn = utils.diagnostic.signs.warn.text, + info = utils.diagnostic.signs.info.text, + hint = utils.diagnostic.signs.hint.text, + }, + update_in_insert = true, + color = "WinBar", + padding = { left = 0, right = 1 }, + cond = winbar_cond, + }, + } - inactive_sections = { - lualine_c = { "filename" }, - lualine_x = { - "filetype", - "location", + lualine.setup({ + options = { + component_separators = "", + section_separators = "", + disabled_filetypes = { + "netrw", + "alpha", + winbar = vim.fn.getcompletion("Neogit*", "filetype"), + }, }, - }, - winbar = { - lualine_b = buffer, - lualine_c = { - { - -- Hack to prevent lualine_b from taking over the lualine_c when navic has no results - function() - return require("nvim-navic").get_location():gsub("^$", " ") - end, - color = "WinBarNC", - cond = winbar_cond, + sections = { + lualine_a = { { "mode", fmt = to_char } }, + lualine_b = git, + lualine_c = workspace, + lualine_x = { + "encoding", + "fileformat", + "filetype", }, }, - }, - tabline = { - lualine_b = { { "buffers", mode = 4 } }, - lualine_y = { "tabs" }, - }, + inactive_sections = { + lualine_c = { "filename" }, + lualine_x = { + "filetype", + "location", + }, + }, - extensions = { - "fzf", - "man", - "nvim-dap-ui", - "symbols-outline", - "quickfix", - "toggleterm", - { - sections = { - lualine_c = { - get_short_cwd, + winbar = { + lualine_b = buffer, + lualine_c = { + { + -- Hack to prevent lualine_b from taking over the lualine_c when navic has no results + function() + return require("nvim-navic").get_location():gsub("^$", " ") + end, + color = "WinBarNC", + cond = winbar_cond, }, }, - filetypes = { - "netrw", + }, + + tabline = { + lualine_b = { { "buffers", mode = 4 } }, + lualine_y = { "tabs" }, + }, + + extensions = { + "fzf", + "man", + "nvim-dap-ui", + "symbols-outline", + "quickfix", + "toggleterm", + { + sections = { + lualine_c = { + get_short_cwd, + }, + }, + filetypes = { + "netrw", + }, }, }, - }, -}) + }) +end + +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua b/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua index c0c56d5..588592d 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua @@ -1,12 +1,24 @@ -local status_ok, luasnip = pcall(require, "luasnip") -if not status_ok then - return -end +local M = { + "L3MON4D3/LuaSnip", + dependencies = { + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + "molleweide/LuaSnip-snippets.nvim", + }, +} + +function M.config() + local luasnip = require("luasnip") -luasnip.config.set_config({ - updateevents = "TextChanged,TextChangedI", -}) + luasnip.config.set_config({ + updateevents = "TextChanged,TextChangedI", + }) -luasnip.snippets = require("luasnip_snippets").load_snippets() + luasnip.snippets = require("luasnip_snippets").load_snippets() +end -require("luasnip.loaders.from_vscode").lazy_load() +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua b/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua index 53d345b..e25e132 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua @@ -1,46 +1,56 @@ -local status_ok, mason = pcall(require, "mason") -if not status_ok then - vim.notify("Failed to load module 'mason'", vim.log.levels.ERROR) - return -end +local M = { + "williamboman/mason.nvim", + dependencies = { + "RubixDev/mason-update-all", + "williamboman/mason-lspconfig.nvim", + "jayp0521/mason-null-ls.nvim", + "jayp0521/mason-nvim-dap.nvim", + }, +} -local nil_wrap = function(func) - return function(opts) - func(vim.F.if_nil(opts, {})) +function M.config() + local mason = require("mason") + + local nil_wrap = function(func) + return function(opts) + func(vim.F.if_nil(opts, {})) + end end -end -mason.setup({ - ui = { - border = "single", - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗", + mason.setup({ + ui = { + border = "single", + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, }, - }, -}) + }) + + local mason_update_all = require("mason-update-all") + local mason_lspconfig = require("mason-lspconfig.api.command") + local mason_null_ls = require("mason-null-ls.api.command") + local mason_nvim_dap = require("mason-nvim-dap.api.command") -local mason_update_all = require("mason-update-all") -local mason_lspconfig = require("mason-lspconfig.api.command") -local mason_null_ls = require("mason-null-ls.api.command") -local mason_nvim_dap = require("mason-nvim-dap.api.command") + local api = require("mason.api.command") + api.UpdateAll = mason_update_all.update_all + api.LspInstall = nil_wrap(mason_lspconfig.LspInstall) + api.LspUninstall = nil_wrap(mason_lspconfig.LspUninstall) + api.NullLsInstall = nil_wrap(mason_null_ls.NullLsInstall) + api.NullLsUninstall = nil_wrap(mason_null_ls.NullLsUninstall) + api.DapInstall = nil_wrap(mason_nvim_dap.DapInstall) + api.DapUninstall = nil_wrap(mason_nvim_dap.DapUninstall) -local api = require("mason.api.command") -api.UpdateAll = mason_update_all.update_all -api.LspInstall = nil_wrap(mason_lspconfig.LspInstall) -api.LspUninstall = nil_wrap(mason_lspconfig.LspUninstall) -api.NullLsInstall = nil_wrap(mason_null_ls.NullLsInstall) -api.NullLsUninstall = nil_wrap(mason_null_ls.NullLsUninstall) -api.DapInstall = nil_wrap(mason_nvim_dap.DapInstall) -api.DapUninstall = nil_wrap(mason_nvim_dap.DapUninstall) + vim.keymap.set("n", "ii", api.Mason, { desc = "mason" }) + vim.keymap.set("n", "iI", api.MasonLog, { desc = "log" }) + vim.keymap.set("n", "iu", api.UpdateAll, { desc = "update all" }) + vim.keymap.set("n", "il", api.LspInstall, { desc = "lsp install" }) + vim.keymap.set("n", "iL", api.LspUninstall, { desc = "lsp uninstall" }) + vim.keymap.set("n", "in", api.NullLsInstall, { desc = "null-ls install" }) + vim.keymap.set("n", "iN", api.NullLsUninstall, { desc = "null-ls uninstall" }) + vim.keymap.set("n", "id", api.DapInstall, { desc = "dap install" }) + vim.keymap.set("n", "iD", api.DapUninstall, { desc = "dap uninstall" }) +end -vim.keymap.set("n", "ii", api.Mason, { desc = "mason" }) -vim.keymap.set("n", "iI", api.MasonLog, { desc = "log" }) -vim.keymap.set("n", "iu", api.UpdateAll, { desc = "update all" }) -vim.keymap.set("n", "il", api.LspInstall, { desc = "lsp install" }) -vim.keymap.set("n", "iL", api.LspUninstall, { desc = "lsp uninstall" }) -vim.keymap.set("n", "in", api.NullLsInstall, { desc = "null-ls install" }) -vim.keymap.set("n", "iN", api.NullLsUninstall, { desc = "null-ls uninstall" }) -vim.keymap.set("n", "id", api.DapInstall, { desc = "dap install" }) -vim.keymap.set("n", "iD", api.DapUninstall, { desc = "dap uninstall" }) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua b/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua index a3b1f40..d70f005 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua @@ -1,23 +1,27 @@ -local status_ok, neodev = pcall(require, "neodev") -if not status_ok then - vim.notify("Failed to load module 'neodev'", vim.log.levels.ERROR) - return +local M = { + "folke/neodev.nvim", +} + +function M.config() + local neodev = require("neodev") + + neodev.setup({ + library = { + enabled = true, + runtime = true, + types = true, + plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, + }, + override = function(root_dir, library) + local lua_dev_utils = require("lua-dev.util") + if lua_dev_utils.has_file(root_dir, lua_dev_utils.fqn("~/.dotfiles/nvim/.config/nvim")) then + library.enabled = true + library.runtime = true + library.types = true + library.plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" } + end + end, + }) end -neodev.setup({ - library = { - enabled = true, - runtime = true, - types = true, - plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, - }, - override = function(root_dir, library) - local lua_dev_utils = require("lua-dev.util") - if lua_dev_utils.has_file(root_dir, lua_dev_utils.fqn("~/.dotfiles/nvim/.config/nvim")) then - library.enabled = true - library.runtime = true - library.types = true - library.plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" } - end - end, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua b/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua index f9dfd43..81bd9b6 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua @@ -1,15 +1,20 @@ -local status_ok, neogit = pcall(require, "neogit") -if not status_ok then - vim.notify("Failed to load module 'neogit'", vim.log.levels.ERROR) - return -end +local M = { + "TimUntersberger/neogit", + dependencies = { "sindrets/diffview.nvim" }, +} + +function M.config() + local neogit = require("neogit") -neogit.setup({ - disable_commit_confirmation = true, - disable_signs = true, - integrations = { - diffview = true, - }, -}) + neogit.setup({ + disable_commit_confirmation = true, + disable_signs = true, + integrations = { + diffview = true, + }, + }) + + vim.keymap.set("n", "gg", neogit.open, { desc = "neogit" }) +end -vim.keymap.set("n", "gg", neogit.open, { desc = "neogit" }) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua b/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua index 6d46936..56506f4 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua @@ -1,29 +1,34 @@ -local status_ok, notify = pcall(require, "notify") -if not status_ok then - vim.notify("Failed to load module 'notify'", vim.log.levels.ERROR) - return -end +local M = { + "rcarriga/nvim-notify", + dependencies = { + "nvim-telescope/telescope.nvim", + }, +} + +function M.config() + local notify = require("notify") -local global_instance, _ = notify.instance({ - max_width = 100, - on_open = function(win) - vim.api.nvim_win_set_option(win, "wrap", true) - end, -}) + local global_instance, _ = notify.instance({ + max_width = 100, + on_open = function(win) + vim.api.nvim_win_set_option(win, "wrap", true) + end, + }) -vim.notify.use_console = false -vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("tobyvin_nvim-notify", { clear = true }), - pattern = "Notify", - callback = function(args) - global_instance.notify(unpack(args.data)) - end, -}) + vim.notify.use_console = false + vim.api.nvim_create_autocmd("User", { + group = vim.api.nvim_create_augroup("tobyvin_nvim-notify", { clear = true }), + pattern = "Notify", + callback = function(args) + global_instance.notify(unpack(args.data)) + end, + }) -vim.api.nvim_set_hl(0, "NotifyBackground", { link = "WinBar" }) + vim.api.nvim_set_hl(0, "NotifyBackground", { link = "WinBar" }) -local telescope_ok, telescope = pcall(require, "telescope") -if telescope_ok then + local telescope = require("telescope") telescope.load_extension("notify") vim.keymap.set("n", "fn", telescope.extensions.notify.notify, { desc = "notifications" }) end + +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua b/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua index 4f008fc..51e7308 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua @@ -1,29 +1,36 @@ -local status_ok, null_ls = pcall(require, "null-ls") -if not status_ok then - vim.notify("Failed to load module 'null-ls'", vim.log.levels.ERROR) - return -end +local M = { + "jose-elias-alvarez/null-ls.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, +} -local info = require("null-ls.info") +function M.config() + local null_ls = require("null-ls") -null_ls.setup({ - sources = { - -- Disabled until sorting for code_actions gets pushed. See: https://github.com/stevearc/dressing.nvim/issues/22 - -- null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.code_actions.gitrebase, - null_ls.builtins.code_actions.shellcheck, + local info = require("null-ls.info") - null_ls.builtins.diagnostics.markdownlint, + null_ls.setup({ + sources = { + -- Disabled until sorting for code_actions gets pushed. See: https://github.com/stevearc/dressing.nvim/issues/22 + -- null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.code_actions.gitrebase, + null_ls.builtins.code_actions.shellcheck, - null_ls.builtins.formatting.prettier.with({ - extra_args = { "--prose-wrap=always" }, - }), - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.shfmt, - null_ls.builtins.formatting.cbfmt, - }, - on_attach = function(_, bufnr) - vim.keymap.set("n", "ln", info.show_window, { desc = "null-ls info", buffer = bufnr }) - end, -}) + null_ls.builtins.diagnostics.markdownlint, + + null_ls.builtins.formatting.prettier.with({ + extra_args = { "--prose-wrap=always" }, + }), + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.shfmt, + null_ls.builtins.formatting.cbfmt, + }, + on_attach = function(_, bufnr) + vim.keymap.set("n", "ln", info.show_window, { desc = "null-ls info", buffer = bufnr }) + end, + }) +end + +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua index 54de37e..5308df5 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua @@ -1,20 +1,29 @@ -local status_ok, bqf = pcall(require, "bqf") -if not status_ok then - vim.notify("Failed to load module 'bqf'", vim.log.levels.ERROR) - return +local M = { + "kevinhwang91/nvim-bqf", + ft = "qf", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "junegunn/fzf", + }, +} + +function M.config() + local bqf = require("bqf") + + bqf.setup({ + auto_resize_height = true, + preview = { + border_chars = { "│", "│", "─", "─", "┌", "┐", "└", "┘", "█" }, + }, + func_map = { + open = "o", + openc = "", + tabc = "t", + tab = "", + pscrollup = "", + pscrolldown = "", + }, + }) end -bqf.setup({ - auto_resize_height = true, - preview = { - border_chars = { "│", "│", "─", "─", "┌", "┐", "└", "┘", "█" }, - }, - func_map = { - open = "o", - openc = "", - tabc = "t", - tab = "", - pscrollup = "", - pscrolldown = "", - }, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua deleted file mode 100644 index a31c244..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status_ok, nvim_dap_virtual_text = pcall(require, "nvim-dap-virtual-text") -if not status_ok then - vim.notify("Failed to load module 'dap-virtual-text'", vim.log.levels.ERROR) - return -end - -nvim_dap_virtual_text.setup({}) diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua index 4b2d3de..c5ff794 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua @@ -1,27 +1,32 @@ -local status_ok, nvim_navic = pcall(require, "nvim-navic") -if not status_ok then - vim.notify("Failed to load module 'nvim-navic'", vim.log.levels.ERROR) - return -end +local M = { + "SmiteshP/nvim-navic", + dependencies = { "onsails/lspkind-nvim" }, +} -local icons = require("lspkind").symbol_map -for i, _ in pairs(icons) do - icons[i] = icons[i] .. " " -end +function M.config() + local nvim_navic = require("nvim-navic") + + local icons = require("lspkind").symbol_map + for i, _ in pairs(icons) do + icons[i] = icons[i] .. " " + end -nvim_navic.setup({ - icons = icons, -}) + nvim_navic.setup({ + icons = icons, + }) -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("tobyvin_nvim-navic", { clear = true }), - desc = "setup nvim-navic", - callback = function(args) - local bufnr = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("tobyvin_nvim-navic", { clear = true }), + desc = "setup nvim-navic", + callback = function(args) + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + + if client.name ~= "cssls" and client.server_capabilities.documentSymbolProvider then + require("nvim-navic").attach(client, bufnr) + end + end, + }) +end - if client.name ~= "cssls" and client.server_capabilities.documentSymbolProvider then - require("nvim-navic").attach(client, bufnr) - end - end, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/packer.lua b/nvim/.config/nvim/lua/tobyvin/plugins/packer.lua deleted file mode 100644 index 9892f44..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/packer.lua +++ /dev/null @@ -1,32 +0,0 @@ -local status_ok, packer = pcall(require, "packer") -if not status_ok then - vim.notify("Failed to load module 'packer'", vim.log.levels.ERROR) - return -end - -vim.keymap.set("n", "pc", packer.compile, { desc = "compile" }) -vim.keymap.set("n", "pC", packer.clean, { desc = "clean" }) -vim.keymap.set("n", "pi", packer.install, { desc = "install" }) -vim.keymap.set("n", "pp", packer.profile_output, { desc = "profile" }) -vim.keymap.set("n", "ps", packer.sync, { desc = "sync" }) -vim.keymap.set("n", "pu", packer.update, { desc = "update" }) - -vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("tobyvin_packer_complete", { clear = true }), - pattern = "PackerComplete", - callback = function() - packer.snapshot(os.date("%Y-%m-%d_%H-%M-%S")) - end, - desc = "create snapshot on PackerComplete", -}) - -packer.init({ - display = { - open_fn = function() - return require("packer.util").float({ border = "single" }) - end, - }, - autoremove = true, -}) - -return packer diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua index d98ae32..2e32d6e 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua @@ -1,46 +1,54 @@ -local status_ok, rust_tools = pcall(require, "rust-tools") -if not status_ok then - vim.notify("Failed to load module 'rust-tools'", vim.log.levels.ERROR) - return -end +local M = { + "simrat39/rust-tools.nvim", + dependencies = { + "neovim/nvim-lspconfig", + "nvim-lua/plenary.nvim", + "mfussenegger/nvim-dap", + }, +} -local utils = require("tobyvin.utils") -local lsp = require("tobyvin.lsp") -local dap = require("tobyvin.plugins.dap") +function M.config() + local rust_tools = require("rust-tools") + local utils = require("tobyvin.utils") + local lsp = require("tobyvin.lsp") + local adapters = require("tobyvin.plugins.dap.adapters") -rust_tools.setup({ - tools = { - hover_actions = { - border = "single", + rust_tools.setup({ + tools = { + hover_actions = { + border = "single", + }, }, - }, - server = lsp.configs.rust_analyzer, - dap = { adapter = dap.adapters.codelldb }, -}) + server = lsp.configs.rust_analyzer, + dap = { adapter = adapters.codelldb }, + }) -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("tobyvin_rust-tools", { clear = true }), - desc = "setup rust-tools", - callback = function(args) - local bufnr = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client.name ~= "rust_analyzer" then - return - end + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("tobyvin_rust-tools", { clear = true }), + desc = "setup rust-tools", + callback = function(args) + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.name ~= "rust_analyzer" then + return + end - local runnables = rust_tools.runnables.runnables - local debuggables = rust_tools.debuggables.debuggables - local open_cargo_toml = rust_tools.open_cargo_toml.open_cargo_toml - local external_docs = rust_tools.external_docs.open_external_docs - local expand_macro = rust_tools.expand_macro.expand_macro - local hover_actions = rust_tools.hover_actions.hover_actions + local runnables = rust_tools.runnables.runnables + local debuggables = rust_tools.debuggables.debuggables + local open_cargo_toml = rust_tools.open_cargo_toml.open_cargo_toml + local external_docs = rust_tools.external_docs.open_external_docs + local expand_macro = rust_tools.expand_macro.expand_macro + local hover_actions = rust_tools.hover_actions.hover_actions - vim.keymap.set("n", "dd", debuggables, { desc = "debug", buffer = bufnr }) - vim.keymap.set("n", "tt", runnables, { desc = "test", buffer = bufnr }) - vim.keymap.set("n", "lo", open_cargo_toml, { desc = "open Cargo.toml", buffer = bufnr }) - vim.keymap.set("n", "le", expand_macro, { desc = "expand macro", buffer = bufnr }) + vim.keymap.set("n", "dd", debuggables, { desc = "debug", buffer = bufnr }) + vim.keymap.set("n", "tt", runnables, { desc = "test", buffer = bufnr }) + vim.keymap.set("n", "lo", open_cargo_toml, { desc = "open Cargo.toml", buffer = bufnr }) + vim.keymap.set("n", "le", expand_macro, { desc = "expand macro", buffer = bufnr }) + + utils.documentation.register("rust", external_docs) + utils.hover.register(hover_actions, { desc = "rust-tools hover actions", buffer = bufnr, priority = 10 }) + end, + }) +end - utils.documentation.register("rust", external_docs) - utils.hover.register(hover_actions, { desc = "rust-tools hover actions", buffer = bufnr, priority = 10 }) - end, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua b/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua index da83baa..7d63342 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua @@ -1,15 +1,19 @@ -local status_ok, session_manager = pcall(require, "session_manager") -if not status_ok then - vim.notify("Failed to load module 'session_manager'", vim.log.levels.ERROR) - return -end +local M = { + "Shatur/neovim-session-manager", +} + +function M.config() + local session_manager = require("session_manager") -session_manager.setup({ - autoload_mode = require("session_manager.config").AutoloadMode.Disabled, -}) + session_manager.setup({ + autoload_mode = require("session_manager.config").AutoloadMode.Disabled, + }) + + vim.keymap.set("n", "ss", session_manager.save_current_session, { desc = "save session" }) + vim.keymap.set("n", "sl", session_manager.load_current_dir_session, { desc = "load session" }) + vim.keymap.set("n", "sL", session_manager.load_session, { desc = "pick session" }) + vim.keymap.set("n", "sr", session_manager.load_last_session, { desc = "last session" }) + vim.keymap.set("n", "sd", session_manager.delete_session, { desc = "delete session" }) +end -vim.keymap.set("n", "ss", session_manager.save_current_session, { desc = "save session" }) -vim.keymap.set("n", "sl", session_manager.load_current_dir_session, { desc = "load session" }) -vim.keymap.set("n", "sL", session_manager.load_session, { desc = "pick session" }) -vim.keymap.set("n", "sr", session_manager.load_last_session, { desc = "last session" }) -vim.keymap.set("n", "sd", session_manager.delete_session, { desc = "delete session" }) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua b/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua deleted file mode 100644 index fa080ae..0000000 --- a/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua +++ /dev/null @@ -1,10 +0,0 @@ -local status_ok, surround = pcall(require, "surround") -if not status_ok then - vim.notify("Failed to load module 'surround'", vim.log.levels.ERROR) - return -end - -surround.setup({ - map_insert_mode = false, - prefix = "", -}) diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua b/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua index 1341c98..fec3bad 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua @@ -1,94 +1,106 @@ -local status_ok, telescope = pcall(require, "telescope") -if not status_ok then - vim.notify("Failed to load module 'telescope'", vim.log.levels.ERROR) - return -end +local M = { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "BurntSushi/ripgrep", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-telescope/telescope-file-browser.nvim", + "nvim-telescope/telescope-live-grep-args.nvim", + "nvim-telescope/telescope-dap.nvim", + }, +} + +function M.config() + local telescope = require("telescope") -local actions = require("telescope.actions") + local actions = require("telescope.actions") -telescope.setup({ - defaults = { - borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, - mappings = { - i = { - [""] = actions.close, - [""] = actions.which_key, + telescope.setup({ + defaults = { + borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + mappings = { + i = { + [""] = actions.close, + [""] = actions.which_key, + }, + }, + file_ignore_patterns = { "^.git/", "^target/" }, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--hidden", + "--smart-case", + "--trim", + }, + history = { + path = vim.fn.stdpath("data") .. "/databases/telescope_history.sqlite3", + limit = 100, + }, + cache_picker = { + num_pickers = 10, }, }, - file_ignore_patterns = { "^.git/", "^target/" }, - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--hidden", - "--smart-case", - "--trim", - }, - history = { - path = vim.fn.stdpath("data") .. "/databases/telescope_history.sqlite3", - limit = 100, - }, - cache_picker = { - num_pickers = 10, - }, - }, - pickers = { - find_files = { - find_command = { "fd", "--type", "f", "--hidden", "--strip-cwd-prefix" }, - }, - live_grep = { theme = "ivy" }, - buffers = { - show_all_buffers = true, - sort_lastused = true, + pickers = { + find_files = { + find_command = { "fd", "--type", "f", "--hidden", "--strip-cwd-prefix" }, + }, + live_grep = { theme = "ivy" }, + buffers = { + show_all_buffers = true, + sort_lastused = true, + }, }, - }, - extensions = { - live_grep_args = { - theme = "ivy", + extensions = { + live_grep_args = { + theme = "ivy", + }, }, - }, -}) + }) --- Extensions -telescope.load_extension("fzf") -telescope.load_extension("file_browser") -telescope.load_extension("live_grep_args") + -- Extensions + telescope.load_extension("fzf") + telescope.load_extension("file_browser") + telescope.load_extension("live_grep_args") -local builtins = require("telescope.builtin") -local extensions = telescope.extensions + local builtins = require("telescope.builtin") + local extensions = telescope.extensions + + vim.keymap.set("n", "fa", builtins.autocommands, { desc = "autocommands" }) + vim.keymap.set("n", "fb", builtins.buffers, { desc = "buffers" }) + vim.keymap.set("n", "fc", builtins.commands, { desc = "commands" }) + vim.keymap.set("n", "fC", builtins.command_history, { desc = "command history" }) + vim.keymap.set("n", "fd", extensions.file_browser.file_browser, { desc = "file browser" }) + vim.keymap.set("n", "fe", builtins.diagnostics, { desc = "diagnostics" }) + vim.keymap.set("n", "ff", builtins.find_files, { desc = "find files" }) + vim.keymap.set("n", "fF", builtins.filetypes, { desc = "filetypes" }) + vim.keymap.set("n", "fg", extensions.live_grep_args.live_grep_args, { desc = "live grep" }) + vim.keymap.set("n", "fh", builtins.help_tags, { desc = "help" }) + vim.keymap.set("n", "fH", builtins.highlights, { desc = "highlights" }) + vim.keymap.set("n", "fj", builtins.jumplist, { desc = "jumplist" }) + vim.keymap.set("n", "fk", builtins.keymaps, { desc = "keymaps" }) + vim.keymap.set("n", "fl", builtins.loclist, { desc = "loclist" }) + vim.keymap.set("n", "fm", builtins.marks, { desc = "marks" }) + vim.keymap.set("n", "fM", builtins.man_pages, { desc = "man pages" }) + vim.keymap.set("n", "fo", builtins.oldfiles, { desc = "old files" }) + vim.keymap.set("n", "fp", builtins.pickers, { desc = "pickers" }) + vim.keymap.set("n", "fr", builtins.resume, { desc = "resume" }) + vim.keymap.set("n", "fR", builtins.reloader, { desc = "reloader" }) + vim.keymap.set("n", "fs", builtins.spell_suggest, { desc = "spell suggest" }) + vim.keymap.set("n", "fS", builtins.search_history, { desc = "search history" }) + vim.keymap.set("n", "ft", builtins.tags, { desc = "tags" }) + vim.keymap.set("n", "ft", builtins.colorscheme, { desc = "colorscheme" }) + vim.keymap.set("n", "fv", builtins.vim_options, { desc = "vim options" }) + vim.keymap.set("n", "f'", builtins.registers, { desc = "registers" }) + vim.keymap.set("n", "gb", builtins.git_branches, { desc = "branches" }) + vim.keymap.set("n", "gc", builtins.git_bcommits, { desc = "bcommits" }) + vim.keymap.set("n", "gC", builtins.git_commits, { desc = "commits" }) + vim.keymap.set("n", "gf", builtins.git_files, { desc = "files" }) + vim.keymap.set("n", "gt", builtins.git_status, { desc = "status" }) + vim.keymap.set("n", "gT", builtins.git_stash, { desc = "stash" }) +end -vim.keymap.set("n", "fa", builtins.autocommands, { desc = "autocommands" }) -vim.keymap.set("n", "fb", builtins.buffers, { desc = "buffers" }) -vim.keymap.set("n", "fc", builtins.commands, { desc = "commands" }) -vim.keymap.set("n", "fC", builtins.command_history, { desc = "command history" }) -vim.keymap.set("n", "fd", extensions.file_browser.file_browser, { desc = "file browser" }) -vim.keymap.set("n", "fe", builtins.diagnostics, { desc = "diagnostics" }) -vim.keymap.set("n", "ff", builtins.find_files, { desc = "find files" }) -vim.keymap.set("n", "fF", builtins.filetypes, { desc = "filetypes" }) -vim.keymap.set("n", "fg", extensions.live_grep_args.live_grep_args, { desc = "live grep" }) -vim.keymap.set("n", "fh", builtins.help_tags, { desc = "help" }) -vim.keymap.set("n", "fH", builtins.highlights, { desc = "highlights" }) -vim.keymap.set("n", "fj", builtins.jumplist, { desc = "jumplist" }) -vim.keymap.set("n", "fk", builtins.keymaps, { desc = "keymaps" }) -vim.keymap.set("n", "fl", builtins.loclist, { desc = "loclist" }) -vim.keymap.set("n", "fm", builtins.marks, { desc = "marks" }) -vim.keymap.set("n", "fM", builtins.man_pages, { desc = "man pages" }) -vim.keymap.set("n", "fo", builtins.oldfiles, { desc = "old files" }) -vim.keymap.set("n", "fp", builtins.pickers, { desc = "pickers" }) -vim.keymap.set("n", "fr", builtins.resume, { desc = "resume" }) -vim.keymap.set("n", "fR", builtins.reloader, { desc = "reloader" }) -vim.keymap.set("n", "fs", builtins.spell_suggest, { desc = "spell suggest" }) -vim.keymap.set("n", "fS", builtins.search_history, { desc = "search history" }) -vim.keymap.set("n", "ft", builtins.tags, { desc = "tags" }) -vim.keymap.set("n", "ft", builtins.colorscheme, { desc = "colorscheme" }) -vim.keymap.set("n", "fv", builtins.vim_options, { desc = "vim options" }) -vim.keymap.set("n", "f'", builtins.registers, { desc = "registers" }) -vim.keymap.set("n", "gb", builtins.git_branches, { desc = "branches" }) -vim.keymap.set("n", "gc", builtins.git_bcommits, { desc = "bcommits" }) -vim.keymap.set("n", "gC", builtins.git_commits, { desc = "commits" }) -vim.keymap.set("n", "gf", builtins.git_files, { desc = "files" }) -vim.keymap.set("n", "gt", builtins.git_status, { desc = "status" }) -vim.keymap.set("n", "gT", builtins.git_stash, { desc = "stash" }) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua b/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua index 51bfc81..d66ea9d 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua @@ -1,13 +1,17 @@ -local status_ok, tokyonight = pcall(require, "tokyonight") -if not status_ok then - vim.notify("Failed to load module 'tokyonight'", vim.log.levels.ERROR) - return +local M = { + "folke/tokyonight.nvim", +} + +function M.config() + local tokyonight = require("tokyonight") + + tokyonight.setup({ + styles = { + sidebars = "transparent", + floats = "transparent", + }, + transparent = true, + }) end -tokyonight.setup({ - styles = { - sidebars = "transparent", - floats = "transparent", - }, - transparent = true, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua b/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua index fb2e6ad..3b03e10 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua @@ -1,52 +1,64 @@ -local status_ok, treesitter = pcall(require, "nvim-treesitter.configs") -if not status_ok then - vim.notify("Failed to load module 'nvim-treesitter'", vim.log.levels.ERROR) - return -end - -treesitter.setup({ - ensure_installed = "all", - indent = { - enable = true, - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = { "markdown" }, - disable = function(_, bufnr) - -- TODO: temp solution to ts highlighting screwing up formatting - return vim.api.nvim_buf_line_count(bufnr) > 2500 or vim.bo[bufnr].filetype == "help" - end, +local M = { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufReadPost", + dependencies = { + "nvim-treesitter/playground", + "nvim-treesitter/nvim-treesitter-textobjects", + "JoosepAlviste/nvim-ts-context-commentstring", + "mfussenegger/nvim-ts-hint-textobject", }, - playground = { - enable = true, - }, - textobjects = { - select = { +} + +function M.config() + local treesitter = require("nvim-treesitter.configs") + + treesitter.setup({ + ensure_installed = "all", + indent = { + enable = true, + }, + highlight = { enable = true, - lookahead = true, - keymaps = { - ["ib"] = "@block.inner", - ["ab"] = "@block.outer", - ["ie"] = "@call.inner", - ["ae"] = "@call.outer", - ["ic"] = "@class.inner", - ["ac"] = "@class.outer", - ["i/"] = "@comment.inner", - ["a/"] = "@comment.outer", - ["ii"] = "@conditional.inner", - ["ai"] = "@conditional.outer", - ["if"] = "@function.inner", - ["af"] = "@function.outer", - ["il"] = "@loop.inner", - ["al"] = "@loop.outer", - ["ia"] = "@parameter.inner", - ["aa"] = "@parameter.outer", - ["iv"] = "@statement.inner", - ["av"] = "@statement.outer", + additional_vim_regex_highlighting = { "markdown" }, + disable = function(_, bufnr) + -- TODO: temp solution to ts highlighting screwing up formatting + return vim.api.nvim_buf_line_count(bufnr) > 2500 or vim.bo[bufnr].filetype == "help" + end, + }, + playground = { + enable = true, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["ib"] = "@block.inner", + ["ab"] = "@block.outer", + ["ie"] = "@call.inner", + ["ae"] = "@call.outer", + ["ic"] = "@class.inner", + ["ac"] = "@class.outer", + ["i/"] = "@comment.inner", + ["a/"] = "@comment.outer", + ["ii"] = "@conditional.inner", + ["ai"] = "@conditional.outer", + ["if"] = "@function.inner", + ["af"] = "@function.outer", + ["il"] = "@loop.inner", + ["al"] = "@loop.outer", + ["ia"] = "@parameter.inner", + ["aa"] = "@parameter.outer", + ["iv"] = "@statement.inner", + ["av"] = "@statement.outer", + }, }, }, - }, - context_commentstring = { - enable = true, - }, -}) + context_commentstring = { + enable = true, + }, + }) +end + +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua b/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua index e21db0d..ab697ef 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua @@ -1,11 +1,18 @@ -local status_ok, undotree = pcall(require, "undotree") -if not status_ok then - vim.notify("Failed to load module 'undotree'", vim.log.levels.ERROR) - return +local M = { + "jiaoshijie/undotree", + dependencies = { + "nvim-lua/plenary.nvim", + }, +} + +function M.config() + local undotree = require("undotree") + + undotree.setup({ + window = { + winblend = 0, + }, + }) end -undotree.setup({ - window = { - winblend = 0, - }, -}) +return M diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua b/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua index 0393924..0172046 100644 --- a/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua +++ b/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua @@ -1,19 +1,23 @@ -local status_ok, yanky = pcall(require, "yanky") -if not status_ok then - vim.notify("Failed to load module 'yanky'", vim.log.levels.ERROR) - return -end +local M = { + "gbprod/yanky.nvim", +} + +function M.config() + local yanky = require("yanky") -yanky.setup({ - highlight = { - on_put = false, - on_yank = false, - }, - preserve_cursor_position = { - enabled = false, - }, -}) + yanky.setup({ + highlight = { + on_put = false, + on_yank = false, + }, + preserve_cursor_position = { + enabled = false, + }, + }) + + local picker = require("yanky.picker") + picker.setup() + vim.keymap.set({ "n", "x" }, "", picker.select_in_history, { desc = "yank history" }) +end -local picker = require("yanky.picker") -picker.setup() -vim.keymap.set({ "n", "x" }, "", picker.select_in_history, { desc = "yank history" }) +return M -- cgit v1.2.3-70-g09d2