From af6f94cbdc25b154a331b689103c79f6f60a04cc Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 20 Dec 2022 18:38:23 +0100 Subject: [PATCH] feat: migrate to lazy.nvim --- configs/lazygit/state.yml | 4 +- configs/nvim/init.lua | 5 +- configs/nvim/lazy-lock.json | 58 ++++++ configs/nvim/lua/configs/autocomplete.lua | 9 +- configs/nvim/lua/configs/dashboard.lua | 26 ++- configs/nvim/lua/configs/lsp.lua | 3 +- configs/nvim/lua/configs/lualine.lua | 2 +- configs/nvim/lua/configs/snippets.lua | 12 ++ configs/nvim/lua/configs/telescope.lua | 2 +- configs/nvim/lua/core/bootstrap.lua | 12 ++ configs/nvim/lua/core/plugins.lua | 209 +++++++++------------- 11 files changed, 205 insertions(+), 137 deletions(-) create mode 100644 configs/nvim/lazy-lock.json create mode 100644 configs/nvim/lua/core/bootstrap.lua diff --git a/configs/lazygit/state.yml b/configs/lazygit/state.yml index e2f04f8..18d6447 100644 --- a/configs/lazygit/state.yml +++ b/configs/lazygit/state.yml @@ -1,12 +1,12 @@ lastupdatecheck: 0 recentrepos: - /home/max/.dotfiles +- /home/max/Projects/silvester - /home/max/Projects/ruumio/feat-api +- /home/max/Projects/ruumio/main - /home/max/Projects/nx-test - /home/max/Projects/ruumio/new-api-stack - /home/max/Projects/ruumio/nx-test -- /home/max/Projects/silvester -- /home/max/Projects/ruumio/main - /home/max/Projects/ruumio/feat-prejoin-avatar-soon - /home/max/Projects/ruumio/feat-wavy-bg - /home/max/Projects/ruumio/feat-3d-poi diff --git a/configs/nvim/init.lua b/configs/nvim/init.lua index 120b13e..de6d8b2 100644 --- a/configs/nvim/init.lua +++ b/configs/nvim/init.lua @@ -1,4 +1,7 @@ -pcall(require, "impatient") +-- pcall(require, "impatient") +-- +-- +require("core.bootstrap") require("core.plugins") diff --git a/configs/nvim/lazy-lock.json b/configs/nvim/lazy-lock.json new file mode 100644 index 0000000..2404046 --- /dev/null +++ b/configs/nvim/lazy-lock.json @@ -0,0 +1,58 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "5f01c1a89adafc52bf34e3bf690f80d9d726715d" }, + "LuaSnip": { "branch": "master", "commit": "8b25e74761eead3dc47ce04b5e017fd23da7ad7e" }, + "alpha-nvim": { "branch": "main", "commit": "21a0f2520ad3a7c32c0822f943368dc063a569fb" }, + "autolist.nvim": { "branch": "main", "commit": "aaadfa9a0d4de1c7628eb3cb7ee811dc94872ef8" }, + "boole.nvim": { "branch": "main", "commit": "d059fd7da634aaaabddbb280709f92effd9f2dba" }, + "catppuccin": { "branch": "main", "commit": "55f43a952856bc0029e6cef066297c6cfab3451d" }, + "cmp-calc": { "branch": "main", "commit": "50792f34a628ea6eb31d2c90e8df174671e4e7a0" }, + "cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-nvim-lua": { "branch": "main", "commit": "d276254e7198ab7d00f117e88e223b4bd8c02d21" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "copilot-cmp": { "branch": "master", "commit": "84d5a0e8e4d1638e7554899cb7b642fa24cf463f" }, + "copilot.lua": { "branch": "master", "commit": "81eb5d1bc2eddad5ff0b4e3c1c4be5c09bdfaa63" }, + "editorconfig-vim": { "branch": "master", "commit": "30ddc057f71287c3ac2beca876e7ae6d5abe26a0" }, + "friendly-snippets": { "branch": "main", "commit": "1a6a02350568d6830bcfa167c72f9b6e75e454ae" }, + "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, + "fzf": { "branch": "master", "commit": "6d14573fd038e9b9789e1250fb194b67ff2e2d06" }, + "git-conflict.nvim": { "branch": "main", "commit": "77faa75c09a6af88e7b54d8d456327e06611f7ea" }, + "git-worktree.nvim": { "branch": "master", "commit": "d7f4e2584e81670154f07ca9fa5dd791d9c1b458" }, + "gitsigns.nvim": { "branch": "main", "commit": "2ab3bdf0a40bab53033048c6be75bda86316b55d" }, + "harpoon": { "branch": "master", "commit": "21d0d1bfa3000e4384740bfaefa0ebc51c773786" }, + "lazy.nvim": { "branch": "main", "commit": "2927b0597e1860ec3eb87d354018dc3e1d1b55e0" }, + "leap.nvim": { "branch": "main", "commit": "a5c9504290832e6bdbbb6265fd1ff02fc6485d20" }, + "lsp_lines.nvim": { "branch": "main", "commit": "ec98b45c8280e5ef8c84028d4f38aa447276c002" }, + "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lspsaga.nvim": { "branch": "main", "commit": "b7b4777369b441341b2dcd45c738ea4167c11c9e" }, + "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, + "lualine.nvim": { "branch": "master", "commit": "bfa0d99ba6f98d077dd91779841f1c88b7b5c165" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "5bea0e851b8f48479d2cb927cd26733b4058b2b3" }, + "mason.nvim": { "branch": "main", "commit": "dd04b4105e84620685c37efb6ca935d282e11465" }, + "neotest": { "branch": "master", "commit": "de2f68fb13a05c361e0c096e167f7f79712f3a5c" }, + "null-ls.nvim": { "branch": "main", "commit": "db1c7cb5f6d6f6036b7f8433bb3cfcbe985cb3d1" }, + "nvim-autopairs": { "branch": "master", "commit": "b5994e6547d64f781cfca853a1aa6174d238fe0e" }, + "nvim-cmp": { "branch": "main", "commit": "8868cf9a09e5f3c2612a22ccb82dcc6d9f0d0d35" }, + "nvim-dap": { "branch": "master", "commit": "284c754f60f6ef15ecdd071524b945cb2fffbbb9" }, + "nvim-dap-ui": { "branch": "master", "commit": "54365d2eb4cb9cfab0371306c6a76c913c5a67e3" }, + "nvim-dap-vscode-js": { "branch": "main", "commit": "e7c05495934a658c8aa10afd995dacd796f76091" }, + "nvim-lspconfig": { "branch": "master", "commit": "d597b0f3605f43526f1b6948c6d7ca2919ea32ac" }, + "nvim-notify": { "branch": "master", "commit": "b005821516f1f37801a73067afd1cef2dbc4dfe8" }, + "nvim-scrollbar": { "branch": "main", "commit": "f45aecbba9c402282dfc99721e0ad4c08710907c" }, + "nvim-toggleterm.lua": { "branch": "main", "commit": "b02a1674bd0010d7982b056fd3df4f717ff8a57a" }, + "nvim-tree.lua": { "branch": "master", "commit": "e14c2895b4f36a22001f7773244041c173dcf867" }, + "nvim-treesitter": { "branch": "master", "commit": "eedb7b9c69b13afe86461b0742266bb62b811ece" }, + "nvim-web-devicons": { "branch": "master", "commit": "05e1072f63f6c194ac6e867b567e6b437d3d4622" }, + "plenary.nvim": { "branch": "master", "commit": "4b7e52044bbb84242158d977a50c4cbcd85070c7" }, + "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "projections.nvim": { "branch": "main", "commit": "7aecd9d9d516e7db92d2294c4b331c31f578bf86" }, + "sniprun": { "branch": "master", "commit": "c37086a0d12b2053bf147c2f4643c0c92318c0c2" }, + "telescope.nvim": { "branch": "master", "commit": "cabf991b1d3996fa6f3232327fc649bbdf676496" }, + "translate.nvim": { "branch": "main", "commit": "7b2fd50c21ecfe536d572d62dcd3fa83acad3743" }, + "trouble.nvim": { "branch": "main", "commit": "897542f90050c3230856bc6e45de58b94c700bbf" }, + "vim-dadbod": { "branch": "master", "commit": "34151ccce9f5ff16229b8e482a97e46997914cb3" }, + "vim-dadbod-ui": { "branch": "master", "commit": "6a2b841d2f0b82386c637ce4e9954ae12c7eaee8" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" } +} \ No newline at end of file diff --git a/configs/nvim/lua/configs/autocomplete.lua b/configs/nvim/lua/configs/autocomplete.lua index 43dd6b1..e58744e 100644 --- a/configs/nvim/lua/configs/autocomplete.lua +++ b/configs/nvim/lua/configs/autocomplete.lua @@ -5,6 +5,11 @@ local lspkind = require("lspkind") local cmp = require("cmp") local cmp_autopairs = require("nvim-autopairs.completion.cmp") +local capabilities = require("cmp_nvim_lsp").default_capabilities() +require("lspconfig").html.setup({ + capabilities = capabilities, +}) + require("nvim-autopairs").setup() require("copilot").setup() require("copilot_cmp").setup({ @@ -49,7 +54,7 @@ cmp.setup({ }, formatting = { format = lspkind.cmp_format({ - mode = "symbol", + mode = "symbol_text", max_width = 50, symbol_map = { Copilot = "" }, }), @@ -61,7 +66,7 @@ cmp.setup({ { name = "luasnip" }, { name = "emoji" }, { name = "path" }, - -- { name = "buffer" }, + { name = "buffer" }, { name = "calc" }, }, }) diff --git a/configs/nvim/lua/configs/dashboard.lua b/configs/nvim/lua/configs/dashboard.lua index c38095f..694e332 100644 --- a/configs/nvim/lua/configs/dashboard.lua +++ b/configs/nvim/lua/configs/dashboard.lua @@ -29,7 +29,7 @@ dashboard.section.buttons.val = { dashboard.button("v", " Neovim Settings ", ":set laststatus=3 | e ~/.config/nvim/init.lua "), dashboard.button("b", "⟳ Recent Files", ":Telescope oldfiles"), dashboard.button("s", " Shell Configuration", ":set laststatus=3 | e ~/.config/zsh/.zshrc "), - dashboard.button("u", " Update Nvim Plugins", ":PackerUpdate "), + dashboard.button("u", " Update Nvim Plugins", ":Lazy update "), dashboard.button("q", " Quit Neovim", ":qa"), } @@ -43,6 +43,30 @@ dashboard.section.header.val = { [[╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝]], } +dashboard.section.header.val = { + [[ __ ]], + [[ /\ \ ]], + [[ / /\ \ ]], + [[/ /__\ \ ]], + [[\/____\/ ]], +} + +dashboard.section.header.val = { + [[ ____]], + [[ /\ \]], + [[ / \ \]], + [[ / \ \]], + [[ / \ \]], + [[ / /\ \ \]], + [[ / / \ \ \]], + [[ / / \ \ \]], + [[ / / / \ \ \]], + [[ / / / \ \ \]], + [[ / / /---------' \]], + [[/ / /_______________\]], + [[\ / /]], + [[ \/_____________________/ ]], +} -- Layout For Luavim ascii art dashboard.config.layout = { { type = "padding", val = 5 }, diff --git a/configs/nvim/lua/configs/lsp.lua b/configs/nvim/lua/configs/lsp.lua index 450f5df..59fcb9e 100644 --- a/configs/nvim/lua/configs/lsp.lua +++ b/configs/nvim/lua/configs/lsp.lua @@ -6,7 +6,8 @@ require("null-ls").setup({ sources = { require("null-ls").builtins.formatting.stylua, require("null-ls").builtins.diagnostics.eslint, - require("null-ls").builtins.completion.spell, + require("null-ls").builtins.code_actions.eslint_d, + -- require("null-ls").builtins.completion.spell, }, }) diff --git a/configs/nvim/lua/configs/lualine.lua b/configs/nvim/lua/configs/lualine.lua index fdfe948..754aec9 100644 --- a/configs/nvim/lua/configs/lualine.lua +++ b/configs/nvim/lua/configs/lualine.lua @@ -160,7 +160,7 @@ ins_left({ spinner = { pre = "", post = "" }, message = { commenced = "In Progress", completed = "Completed" }, }, - display_components = { "lsp_client_name", "spinner", { "title", "percentage", "message" } }, + display_components = { "lsp_client_name", "spinner", "percentage" }, timer = { progress_enddelay = 500, spinner = 1000, lsp_client_name_enddelay = 1000 }, spinner_symbols = { "🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 " }, }) diff --git a/configs/nvim/lua/configs/snippets.lua b/configs/nvim/lua/configs/snippets.lua index aa78673..3414912 100644 --- a/configs/nvim/lua/configs/snippets.lua +++ b/configs/nvim/lua/configs/snippets.lua @@ -41,6 +41,12 @@ ls.add_snippets("all", { }), }) +local debugJSON = s("pcs", { + t("
{JSON.stringify("),
+  i(0),
+  t("null, 2)}
"), +}) + ls.add_snippets("svelte", { s("slt", { t({ '" }), }), + debugJSON, +}) + +ls.add_snippets("typescriptreact", { + debugJSON, }) ls.add_snippets("typescript", { + debugJSON, s("sget", { t('export const GET: import("./$types").RequestHandler = async function get({'), i(1, "params"), diff --git a/configs/nvim/lua/configs/telescope.lua b/configs/nvim/lua/configs/telescope.lua index d30779a..133615c 100644 --- a/configs/nvim/lua/configs/telescope.lua +++ b/configs/nvim/lua/configs/telescope.lua @@ -63,7 +63,7 @@ local default = { telescope.setup(default) -- telescope.load_extension("themes"); -- -telescope.load_extension("harpoon") +-- telescope.load_extension("harpoon") telescope.load_extension("projections") telescope.load_extension("git_worktree") telescope.load_extension("notify") diff --git a/configs/nvim/lua/core/bootstrap.lua b/configs/nvim/lua/core/bootstrap.lua new file mode 100644 index 0000000..80556b3 --- /dev/null +++ b/configs/nvim/lua/core/bootstrap.lua @@ -0,0 +1,12 @@ +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) diff --git a/configs/nvim/lua/core/plugins.lua b/configs/nvim/lua/core/plugins.lua index d49b581..3126d41 100644 --- a/configs/nvim/lua/core/plugins.lua +++ b/configs/nvim/lua/core/plugins.lua @@ -1,145 +1,114 @@ -local fn = vim.fn -local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" -local packer_bootstrap = false -if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = true - fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) - vim.cmd("packadd packer.nvim") -end - -local packer = require("packer") -packer.init({ - display = { - open_fn = function() - return require("packer.util").float({ border = "rounded" }) - end, - }, -}) - -return packer.startup(function(use) - -- Let packer manage itself - use("wbthomason/packer.nvim") - - -- General Helper Functions - use("lewis6991/impatient.nvim") - use("nvim-lua/plenary.nvim") +local plugins = { + "nvim-lua/plenary.nvim", --------------------- -- Theming Section -- --------------------- - use("rktjmp/fwatch.nvim") -- Used to check dark/light theme - use({ "catppuccin/nvim", as = "catppuccin" }) - -- use 'folke/tokyonight.nvim' - use("nvim-lualine/lualine.nvim") + "rktjmp/fwatch.nvim", -- d to check dark/light theme + { "catppuccin/nvim", name = "catppuccin" }, + + "nvim-lualine/lualine.nvim", -------------------- -- Layout Plugins -- -------------------- - use({ + { "petertriho/nvim-scrollbar", config = function() require("configs.scrollbar") end, - }) - use({ + }, + { "lewis6991/gitsigns.nvim", config = function() require("gitsigns").setup() end, - }) - use("akinsho/nvim-toggleterm.lua") - use({ + }, + "akinsho/nvim-toggleterm.lua", + { "akinsho/git-conflict.nvim", - tag = "*", config = function() - require("git-conflict").setup() + -- require("git-conflict").setup() end, - }) - - use({ + }, + { "rcarriga/nvim-notify", config = function() require("configs.notify") end, event = "VimEnter", - }) - - use({ + }, + { "kyazdani42/nvim-tree.lua", - requires = { "kyazdani42/nvim-web-devicons" }, + cmd = "NvimTreeToggle", + dependencies = { "kyazdani42/nvim-web-devicons" }, config = function() require("configs.tree") end, - }) - use("nvim-lua/popup.nvim") - use("goolord/alpha-nvim") -- startup screen - use({ + }, + "nvim-lua/popup.nvim", + "goolord/alpha-nvim", -- startup screen + { "numToStr/Comment.nvim", event = "BufReadPre", config = function() require("Comment").setup() end, - }) - use("glepnir/lspsaga.nvim") -- better windows for lsp replace, goto definition etc... - + }, + "glepnir/lspsaga.nvim", -- better windows for lsp replace, goto definition etc... --------------------- -- Code Navigation -- --------------------- - - use("junegunn/fzf") - use({ + "junegunn/fzf", + { "ggandor/leap.nvim", config = function() local leap = require("leap") leap.add_default_mappings() leap.setup({}) end, - }) - use({ + }, + { "nvim-telescope/telescope.nvim", config = function() require("configs.telescope") end, - }) - use("ThePrimeagen/harpoon") - + }, + -- "ThePrimeagen/harpoon", --------------- -- Lsp Setup -- --------------- - - use("arkav/lualine-lsp-progress") - use("neovim/nvim-lspconfig") - use("williamboman/mason.nvim") - use("williamboman/mason-lspconfig.nvim") - use("jose-elias-alvarez/null-ls.nvim") - use("folke/lsp-colors.nvim") - use({ + "arkav/lualine-lsp-progress", + "neovim/nvim-lspconfig", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "jose-elias-alvarez/null-ls.nvim", + -- "folke/lsp-colors.nvim", + { "folke/trouble.nvim", event = "BufRead", requires = "kyazdani42/nvim-web-devicons", config = function() require("trouble").setup({}) end, - }) - use("onsails/lspkind.nvim") - use({ - "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + }, + "onsails/lspkind.nvim", + { + url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim", event = "BufReadPre", config = function() require("lsp_lines").setup() end, - }) - + }, ------------------- -- Autocomplete -- ------------------- - - use("tpope/vim-surround") - use({ + "tpope/vim-surround", + { "hrsh7th/nvim-cmp", - requires = { + dependencies = { "rafamadriz/friendly-snippets", "saadparwaiz1/cmp_luasnip", "L3MON4D3/LuaSnip", @@ -147,52 +116,39 @@ return packer.startup(function(use) "zbirenbaum/copilot.lua", "zbirenbaum/copilot-cmp", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-calc", + "hrsh7th/cmp-emoji", }, - event = { "BufReadPre", "CmdlineChanged" }, + event = "InsertEnter", config = function() vim.schedule(function() require("configs.autocomplete") require("configs.snippets") end) end, - }) - - use({ - "hrsh7th/cmp-nvim-lsp", - after = "nvim-cmp", - config = function() - local capabilities = require("cmp_nvim_lsp").default_capabilities() - require("lspconfig").html.setup({ - capabilities = capabilities, - }) - end, - }) - use({ "hrsh7th/cmp-cmdline", after = "nvim-cmp" }) - use({ "hrsh7th/cmp-path", after = "nvim-cmp" }) - use({ "hrsh7th/cmp-nvim-lua", after = "nvim-cmp" }) - use({ "hrsh7th/cmp-calc", after = "nvim-cmp" }) - use({ "hrsh7th/cmp-emoji", after = "nvim-cmp" }) - - use({ - "https://github.com/nat-418/boole.nvim", + }, + { + "nat-418/boole.nvim", event = "BufReadPre", config = function() require("boole").setup() end, - }) - use({ + }, + { "gaoDean/autolist.nvim", event = "BufReadPre", config = function() require("autolist").setup({}) end, - }) - + }, ------------------------- -- Syntax Highlighting -- ------------------------- - - use({ + { "nvim-treesitter/nvim-treesitter", event = "BufReadPost", requires = { @@ -202,46 +158,43 @@ return packer.startup(function(use) require("configs.treesitter") end, run = ":TSUpdate", - }) - + }, -------------------- -- IDE Type Stuff -- -------------------- - use({ + { "ThePrimeagen/git-worktree.nvim", config = function() require("git-worktree").setup() end, - }) - use({ + }, + { "GnikDroy/projections.nvim", config = function() require("configs.sessions") end, - }) - + }, -- Dap Debugger -- Have not yet been able to set this up - use({ "mfussenegger/nvim-dap" }) - use({ "rcarriga/nvim-dap-ui" }) - use({ "mxsdev/nvim-dap-vscode-js", requires = { "mfussenegger/nvim-dap" } }) - - use("editorconfig/editorconfig-vim") - use({ + "mfussenegger/nvim-dap", + "rcarriga/nvim-dap-ui", + { "mxsdev/nvim-dap-vscode-js", requires = { "mfussenegger/nvim-dap" } }, + "editorconfig/editorconfig-vim", + { "michaelb/sniprun", event = "BufReadPost", config = function() require("configs.sniprun") end, run = "bash ./install.sh", - }) - use({ + }, + { "uga-rosa/translate.nvim", event = "InsertEnter", config = function() require("translate").setup({ default = { output = "replace" } }) end, - }) - use({ + }, + { "nvim-neotest/neotest", cmd = "NeoTest", config = function() @@ -252,12 +205,12 @@ return packer.startup(function(use) "KaiSpencer/neotest-vitest", "antoinemadec/FixCursorHold.nvim", }, - }) + }, - use("tpope/vim-dadbod") - use("kristijanhusak/vim-dadbod-ui") + "tpope/vim-dadbod", + "kristijanhusak/vim-dadbod-ui", +} - if packer_bootstrap then - packer.sync() - end -end) +local opts = { defaults = { lazy = true } } + +require("lazy").setup(plugins, opts)