From 1391ca7ff153636476bae6ffbf16aec076e2d191 Mon Sep 17 00:00:00 2001 From: jdhao Date: Sun, 27 Aug 2023 23:13:42 +0200 Subject: [PATCH] feat: switch from packer.nvim to lazy.nvim --- README.md | 2 +- autoload/utils.vim | 4 +- core/plugins.vim | 10 +- docs/README.md | 20 +- docs/nvim_setup_linux.sh | 8 +- lazy-lock.json | 88 ++++ lua/colorschemes.lua | 10 - lua/config/lsp.lua | 2 +- lua/config/nvim-tree.lua | 2 +- lua/plugins.lua | 857 +++++++++++++++++++++------------------ 10 files changed, 573 insertions(+), 430 deletions(-) create mode 100644 lazy-lock.json diff --git a/README.md b/README.md index 1ccc387..3f9c096 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ and how to set up on different platforms (Linux, macOS, and Windows). # Features # -+ Plugin management via [Packer.nvim](https://github.com/wbthomason/packer.nvim). ++ Plugin management via [Lazy.nvim](https://github.com/folke/lazy.nvim). + Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp). + Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig). + Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive). diff --git a/autoload/utils.vim b/autoload/utils.vim index b09b55d..9b4bb90 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -141,9 +141,7 @@ function! utils#Inside_git_repo() abort if match(res, 'true') == -1 return v:false else - " Manually trigger a special user autocmd InGitRepo (to use it for - " lazyloading of fugitive by packer.nvim). - " See also https://github.com/wbthomason/packer.nvim/discussions/534. + " Manually trigger a special user autocmd InGitRepo (used lazyloading. doautocmd User InGitRepo return v:true endif diff --git a/core/plugins.vim b/core/plugins.vim index 64d1b29..b3bc237 100644 --- a/core/plugins.vim +++ b/core/plugins.vim @@ -7,10 +7,10 @@ lua require('plugins') " To use these shortcuts: first activate command line with `:`, then input the " short alias, e.g., `pi`, then press , the alias will be expanded to " the full command automatically. -call utils#Cabbrev('pi', 'PackerInstall') -call utils#Cabbrev('pud', 'PackerUpdate') -call utils#Cabbrev('pc', 'PackerClean') -call utils#Cabbrev('ps', 'PackerSync') +call utils#Cabbrev('pi', 'Lazy install') +call utils#Cabbrev('pud', 'Lazy update') +call utils#Cabbrev('pc', 'Lazy clean') +call utils#Cabbrev('ps', 'Lazy sync') """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " configurations for vim script plugin " @@ -401,7 +401,7 @@ function! s:wilder_init() abort \ 'apply_incsearch_fix': 0, \ })) catch /^Vim\%((\a\+)\)\=:E117/ - echohl Error |echomsg "Wilder.nvim missing: run :PackerSync to fix."|echohl None + echohl Error |echomsg "Wilder.nvim missing"| echohl None endtry endfunction diff --git a/docs/README.md b/docs/README.md index ae25d4f..774d919 100644 --- a/docs/README.md +++ b/docs/README.md @@ -111,7 +111,7 @@ vim-language-server is installed in the same directory as the node executable. ### Git -Git is required by plugin manager [packer.nvim](https://github.com/wbthomason/packer.nvim) and other git-related plugins. +Git is required by plugin manager [lazy.nvim](https://github.com/folke/lazy.nvim) and other git-related plugins. For Linux and macOS, Git is usually pre-installed. The version of Git on the Linux system may be too old so that plugins may break. @@ -201,22 +201,6 @@ After installing Nvim, we need to set the path to nvim correctly. After installing nvim and all the dependencies, we will install plugin managers and set up this config. -### Install plugin manager packer.nvim - -I use packer.nvim to manage my plugins. We need to install packer.nvim on our system first. - -For Windows, if curl is installed, run the following command (on PowerShell): - -``` -git clone --depth=1 https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\opt\packer.nvim" -``` - -For macOS and Linux, run the following command: - -```bash -git clone --depth=1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim -``` - ### How to install this configuration On Linux and macOS, the directory is `~/.config/nvim`. @@ -228,7 +212,7 @@ then go to this directory, and run the following command: git clone --depth=1 https://github.com/jdhao/nvim-config.git . ``` -After that, when we first open nvim, run command `:PackerSync` to install all the plugins. +After that, when we first open nvim, all the plugins will be installed automatically. Since I use quite a lot of plugins (more than 60), it may take some time to install all of them. [^1]: Use `echo %userprofile%` to see where your `$HOME` is. diff --git a/docs/nvim_setup_linux.sh b/docs/nvim_setup_linux.sh index 2a72890..ed207a4 100755 --- a/docs/nvim_setup_linux.sh +++ b/docs/nvim_setup_linux.sh @@ -252,13 +252,7 @@ fi git clone --depth=1 https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR" -echo "Installing packer.nvim" -if [[ ! -d ~/.local/share/nvim/site/pack/packer/opt/packer.nvim ]]; then - git clone --depth=1 https://github.com/wbthomason/packer.nvim \ - ~/.local/share/nvim/site/pack/packer/opt/packer.nvim -fi - echo "Installing nvim plugins, please wait" -"$NVIM_DIR/bin/nvim" -c "autocmd User PackerComplete quitall" -c "PackerSync" +"$NVIM_DIR/bin/nvim" -c "autocmd User LazyInstall quitall" -c "lua require('lazy').install()" echo "Finished installing Nvim and its dependencies!" diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..e08597d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,88 @@ +{ + "LeaderF": { "branch": "master", "commit": "3ded37f92807d8c6ad831d5af2c4ff22bfd32fc8" }, + "asyncrun.vim": { "branch": "master", "commit": "42385d54b8546c163b946fd50eed2103ef7993c9" }, + "better-escape.vim": { "branch": "master", "commit": "6b16a45a839727977277f6ab11bded63e9ed86bb" }, + "bufferline.nvim": { "branch": "main", "commit": "417b303328118b6d836ae330142e88771c48a8a3" }, + "catppuccin": { "branch": "main", "commit": "2e3e5ebcdc24ef0d5b14a0a999dbbe7936512c46" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-nvim-ultisnips": { "branch": "main", "commit": "24bca5c3e137b28cd87442d4fc51a2b312dd99cc" }, + "cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "committia.vim": { "branch": "master", "commit": "0b4df1a7f48ffbc23b009bd14d58ee1be541917c" }, + "dashboard-nvim": { "branch": "master", "commit": "9134d7befd50ff920ede5b0f7d6c3dbb9f7c0ecb" }, + "delimitMate": { "branch": "master", "commit": "537a1da0fa5eeb88640425c37e545af933c56e1b" }, + "dressing.nvim": { "branch": "master", "commit": "c7b035de7f91bb6b62b4308f105c56d1a968b8c5" }, + "edge": { "branch": "master", "commit": "a4fd4f458331d42677d992f428235c491b2016aa" }, + "emmylua-nvim": { "branch": "master", "commit": "60178ca58f75f5ea68a20205895ea50f5593f205" }, + "everforest": { "branch": "master", "commit": "83b666410d7ae0eccf96dbbe3b4b6ac5b8172d38" }, + "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "firenvim": { "branch": "master", "commit": "138424db463e6c0e862a05166a4ccc781cd7c19d" }, + "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, + "gitsigns.nvim": { "branch": "main", "commit": "d8590288417fef2430f85bc8b312fae8b1cf2c40" }, + "gruvbox-material": { "branch": "master", "commit": "b5f8c6a6c1cda630c53b061b765068a0898d47a3" }, + "hop.nvim": { "branch": "master", "commit": "03f0434869f1f38868618198b5f4f2ab6d39aef2" }, + "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, + "kanagawa.nvim": { "branch": "master", "commit": "0a24e504a3a278849ad0aef31cd6dd24c73ca3db" }, + "lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" }, + "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, + "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, + "material.nvim": { "branch": "main", "commit": "1ecaa2d065a1ea308bd7702a77c2bf35ede8f536" }, + "monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" }, + "neoformat": { "branch": "master", "commit": "0c285d7a7c06a6ee88db70871a274797693fce42" }, + "nightfox.nvim": { "branch": "main", "commit": "a48f6d9a0273101df76eb25d2f5477baa277f935" }, + "nord.nvim": { "branch": "master", "commit": "fab04b2dd4b64f4b1763b9250a8824d0b5194b8f" }, + "nvim-bqf": { "branch": "main", "commit": "c920a55c6153766bd909e474b7feffa9739f07e8" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, + "nvim-hlslens": { "branch": "main", "commit": "f0281591a59e95400babf61a96e59ba20e5c9533" }, + "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, + "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, + "nvim-tree.lua": { "branch": "master", "commit": "00741206c2df9c4b538055def19b99790f0c95c8" }, + "nvim-treesitter": { "branch": "master", "commit": "08c830f625eb93db9c89c5e946e8eea7111bd568" }, + "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, + "onedark.nvim": { "branch": "master", "commit": "7bd3558c17045b95c961d28861c1b3bd9bdc992a" }, + "onedarkpro.nvim": { "branch": "main", "commit": "c81dff789f7623c431d1f43cf334237e52bbfd61" }, + "open-browser.vim": { "branch": "master", "commit": "7d4c1d8198e889d513a030b5a83faa07606bac27" }, + "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, + "rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" }, + "sonokai": { "branch": "master", "commit": "17308ee6d9c764bfc1e0fa97213e7a99701b4144" }, + "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, + "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, + "telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" }, + "telescope.nvim": { "branch": "master", "commit": "207285ccec21b69996a4d3bcfa59df35d48610e8" }, + "ultisnips": { "branch": "master", "commit": "24a3ebb36687b6d59a19d63173713575b486d739" }, + "unicode.vim": { "branch": "master", "commit": "c8aa12b1e2e1b6254885b12bdb239ce6c885fdb1" }, + "vim-auto-save": { "branch": "master", "commit": "2e3e54ea4c0fc946c21b0a4ee4c1c295ba736ee8" }, + "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, + "vim-conflicted": { "branch": "master", "commit": "068c320796f807ac4961618e3e62316773803996" }, + "vim-eunuch": { "branch": "master", "commit": "67f3dd32b4dcd1c427085f42ff5f29c7adc645c6" }, + "vim-flog": { "branch": "master", "commit": "2cfa2e9d67a06a75d3d4e965c6bad558ff41e488" }, + "vim-fugitive": { "branch": "master", "commit": "572c8510123cbde02e8a1dafcd376c98e1e13f43" }, + "vim-grammarous": { "branch": "master", "commit": "db46357465ce587d5325e816235b5e92415f8c05" }, + "vim-highlighturl": { "branch": "master", "commit": "012fee983e03913db6ba6393307eac434999b896" }, + "vim-indent-object": { "branch": "master", "commit": "5c5b24c959478929b54a9e831a8e2e651a465965" }, + "vim-markdown": { "branch": "master", "commit": "cc82d88e2a791f54d2b6e2b26e41f743351ac947" }, + "vim-markdownfootnotes": { "branch": "master", "commit": "2b288149f48cfaf7465d25bb094ed62898f5e5b0" }, + "vim-matchup": { "branch": "master", "commit": "582cbc8c2dc311deb7a03f7d505d52544c36d4b6" }, + "vim-mundo": { "branch": "master", "commit": "b53d35fb5ca9923302b9ef29e618ab2db4cc675e" }, + "vim-obsession": { "branch": "master", "commit": "fe9d3e1a9a50171e7d316a52e1e56d868e4c1fe5" }, + "vim-python-pep8-indent": { "branch": "master", "commit": "60ba5e11a61618c0344e2db190210145083c91f8" }, + "vim-pythonsense": { "branch": "master", "commit": "9200a57629c904ed2ab8c9b2e8c5649d311794ba" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-sandwich": { "branch": "master", "commit": "c5a2cc438ce6ea2005c556dc833732aa53cae21a" }, + "vim-scriptease": { "branch": "master", "commit": "18511d389675d773994215ddb572ccdc2b72f52b" }, + "vim-snippets": { "branch": "master", "commit": "d37486881a0a771b844a235bc3e025046088690d" }, + "vim-swap": { "branch": "master", "commit": "9358bfdc5e377aa13e7c2c2dd8699ba32b0dcf83" }, + "vim-tmux": { "branch": "master", "commit": "cfe76281efc29890548cf9eedd42ad51c7a1faf0" }, + "vim-toml": { "branch": "main", "commit": "d36caa6b1cf508a4df1c691f915572fc02143258" }, + "vim-xkbswitch": { "branch": "master", "commit": "42b55bfec8f6dbd715135ce582a6f769831face1" }, + "vimtex": { "branch": "master", "commit": "534fd725f2475a9083b032e402c7e73b8a3fc6bb" }, + "vista.vim": { "branch": "master", "commit": "f925e481bba7cd5451fb8bca9a6ecfc2bf1f2858" }, + "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, + "whitespace.nvim": { "branch": "master", "commit": "f0fc9e9c4ce3f7d2166e9e5a069b64b9ca4a3f15" }, + "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }, + "yanky.nvim": { "branch": "main", "commit": "95c2f006ea6eaed2b2d8b8b4943b8fcf13faf03f" }, + "zen-mode.nvim": { "branch": "main", "commit": "68f554702de63f4b7b6b6d4bcb10178f41a0acc7" } +} \ No newline at end of file diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua index 46545b3..1395501 100644 --- a/lua/colorschemes.lua +++ b/lua/colorschemes.lua @@ -129,16 +129,6 @@ M.rand_colorscheme = function() return end - -- Load the colorscheme, because all the colorschemes are declared as opt plugins, so the colorscheme isn't loaded yet. - local status = utils.add_pack(M.colorscheme2dir[colorscheme]) - - if not status then - local msg = string.format("Colorscheme %s is not installed. Run PackerSync to install.", colorscheme) - vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" }) - - return - end - -- Load the colorscheme and its settings M[colorscheme]() diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index a3c5595..7c6fb79 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -234,7 +234,7 @@ if utils.executable("lua-language-server") then -- see also https://github.com/LuaLS/lua-language-server/wiki/Libraries#link-to-workspace . -- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua . library = { - fn.stdpath("data") .. "/site/pack/packer/opt/emmylua-nvim", + fn.stdpath("data") .. "/lazy/emmylua-nvim", fn.stdpath("config"), }, maxPreload = 2000, diff --git a/lua/config/nvim-tree.lua b/lua/config/nvim-tree.lua index 83e93c1..8dd4985 100644 --- a/lua/config/nvim-tree.lua +++ b/lua/config/nvim-tree.lua @@ -79,7 +79,7 @@ nvim_tree.setup { enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" }, buftype = { "nofile", "terminal", "help" }, }, }, diff --git a/lua/plugins.lua b/lua/plugins.lua index 1171295..e728510 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,396 +1,485 @@ -local api = vim.api -local fn = vim.fn - local utils = require("utils") --- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory. -vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer" +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" ---- Install packer if it has not been installed. ---- Return: ---- true: if this is a fresh install of packer ---- false: if packer has been installed -local function packer_ensure_install() - -- Where to install packer.nvim -- the package manager (we make it opt) - local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim" - - if fn.glob(packer_dir) ~= "" then - return false - end - - -- Auto-install packer in case it hasn't been installed. - vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {}) - - local packer_repo = "https://github.com/wbthomason/packer.nvim" - local install_cmd = string.format("!git clone --depth=1 %s %s", packer_repo, packer_dir) - vim.cmd(install_cmd) - - return true +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + } end - -local fresh_install = packer_ensure_install() - --- Load packer.nvim -vim.cmd("packadd packer.nvim") - -local packer = require("packer") -local packer_util = require("packer.util") +vim.opt.rtp:prepend(lazypath) -- check if firenvim is active local firenvim_not_active = function() return not vim.g.started_by_firenvim end -packer.startup { - function(use) - use { "wbthomason/packer.nvim", opt = true } - - use { "onsails/lspkind-nvim", event = "VimEnter" } - -- auto-completion engine - use { "hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]] } - - -- nvim-cmp completion sources - use { "hrsh7th/cmp-nvim-lsp", after = "nvim-cmp" } - use { "hrsh7th/cmp-path", after = "nvim-cmp" } - use { "hrsh7th/cmp-buffer", after = "nvim-cmp" } - use { "hrsh7th/cmp-omni", after = "nvim-cmp" } - use { "quangnguyen30192/cmp-nvim-ultisnips", after = { "nvim-cmp", "ultisnips" } } - if vim.g.is_mac then - use { "hrsh7th/cmp-emoji", after = "nvim-cmp" } - end - - -- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp). - use { "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] } - - if vim.g.is_mac then - use { - "nvim-treesitter/nvim-treesitter", - event = "BufEnter", - run = ":TSUpdate", - config = [[require('config.treesitter')]], - } - end - - -- Python indent (follows the PEP8 style) - use { "Vimjas/vim-python-pep8-indent", ft = { "python" } } - - -- Python-related text object - use { "jeetsukumaran/vim-pythonsense", ft = { "python" } } - - use { "machakann/vim-swap", event = "VimEnter" } - - -- IDE for Lisp - if utils.executable("sbcl") then - -- use 'kovisoft/slimv' - use { "vlime/vlime", rtp = "vim/", ft = { "lisp" } } - end - - -- Super fast buffer jump - use { - "phaazon/hop.nvim", - event = "VimEnter", - config = function() - vim.defer_fn(function() - require("config.nvim_hop") - end, 2000) - end, - } - - -- Show match number and index for searching - use { - "kevinhwang91/nvim-hlslens", - branch = "main", - keys = { { "n", "*" }, { "n", "#" }, { "n", "n" }, { "n", "N" } }, - config = [[require('config.hlslens')]], - } - - -- File search, tag search and more - if vim.g.is_win then - use { "Yggdroot/LeaderF", cmd = "Leaderf" } - else - use { "Yggdroot/LeaderF", cmd = "Leaderf", run = ":LeaderfInstallCExtension" } - end - - use { - "nvim-telescope/telescope.nvim", - cmd = "Telescope", - requires = { { "nvim-lua/plenary.nvim" } }, - } - -- search emoji and other symbols - use { "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" } - - -- A list of colorscheme plugin you may want to try. Find what suits you. - use { "navarasu/onedark.nvim", opt = true } - use { "sainnhe/edge", opt = true } - use { "sainnhe/sonokai", opt = true } - use { "sainnhe/gruvbox-material", opt = true } - use { "shaunsingh/nord.nvim", opt = true } - use { "sainnhe/everforest", opt = true } - use { "EdenEast/nightfox.nvim", opt = true } - use { "rebelot/kanagawa.nvim", opt = true } - use { "catppuccin/nvim", as = "catppuccin", opt = true } - use({ "rose-pine/neovim", as = 'rose-pine', opt = true }) - use { "olimorris/onedarkpro.nvim", opt = true } - use { "tanvirtin/monokai.nvim", opt = true } - use { "marko-cerovac/material.nvim", opt = true } - - use { "nvim-tree/nvim-web-devicons", event = "VimEnter" } - - use { - "nvim-lualine/lualine.nvim", - event = "VimEnter", - cond = firenvim_not_active, - config = [[require('config.statusline')]], - } - - use { "akinsho/bufferline.nvim", event = "VimEnter", - cond = firenvim_not_active, - config = [[require('config.bufferline')]] } - - -- fancy start screen - use { "nvimdev/dashboard-nvim", event = "VimEnter", - cond = firenvim_not_active, - config = [[require('config.dashboard-nvim')]] - } - - use { - "lukas-reineke/indent-blankline.nvim", - event = "VimEnter", - config = [[require('config.indent-blankline')]], - } - - -- Highlight URLs inside vim - use { "itchyny/vim-highlighturl", event = "VimEnter" } - - -- notification plugin - use { - "rcarriga/nvim-notify", - event = "BufEnter", - config = function() - vim.defer_fn(function() - require("config.nvim-notify") - end, 2000) - end, - } - - -- For Windows and Mac, we can open an URL in the browser. For Linux, it may - -- not be possible since we maybe in a server which disables GUI. - if vim.g.is_win or vim.g.is_mac then - -- open URL in browser - use { "tyru/open-browser.vim", event = "VimEnter" } - end - - -- Only install these plugins if ctags are installed on the system - if utils.executable("ctags") then - -- show file tags in vim window - use { "liuchengxu/vista.vim", cmd = "Vista" } - end - - -- Snippet engine and snippet template - use { "SirVer/ultisnips", event = "InsertEnter" } - use { "honza/vim-snippets", after = "ultisnips" } - - -- Automatic insertion and deletion of a pair of characters - use { "Raimondi/delimitMate", event = "InsertEnter" } - - -- Comment plugin - use { "tpope/vim-commentary", event = "VimEnter" } - - -- Multiple cursor plugin like Sublime Text? - -- use 'mg979/vim-visual-multi' - - -- Autosave files on certain events - use { "907th/vim-auto-save", event = "InsertEnter" } - - -- Show undo history visually - use { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } } - - -- better UI for some nvim actions - use {'stevearc/dressing.nvim'} - - -- Manage your yank history - use({ - "gbprod/yanky.nvim", - config = [[require('config.yanky')]] - }) - - -- Handy unix command inside Vim (Rename, Move etc.) - use { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } } - - -- Repeat vim motions - use { "tpope/vim-repeat", event = "VimEnter" } - - use { "nvim-zh/better-escape.vim", event = { "InsertEnter" } } - - if vim.g.is_mac and utils.executable('xkbswitch') then - use { "lyokha/vim-xkbswitch", event = { "InsertEnter" } } - elseif vim.g.is_win then - use { "Neur1n/neuims", event = { "InsertEnter" } } - end - - -- Auto format tools - use { "sbdchd/neoformat", cmd = { "Neoformat" } } - - -- Git command inside vim - use { "tpope/vim-fugitive", event = "User InGitRepo", config = [[require('config.fugitive')]] } - - -- Better git log display - use { "rbong/vim-flog", requires = "tpope/vim-fugitive", cmd = { "Flog" } } - - use { "christoomey/vim-conflicted", requires = "tpope/vim-fugitive", cmd = { "Conflicted" } } - - use { - "ruifm/gitlinker.nvim", - requires = "nvim-lua/plenary.nvim", - event = "User InGitRepo", - config = [[require('config.git-linker')]], - } - - -- Show git change (change, delete, add) signs in vim sign column - use { "lewis6991/gitsigns.nvim", config = [[require('config.gitsigns')]] } - - -- Better git commit experience - use { "rhysd/committia.vim", opt = true, setup = [[vim.cmd('packadd committia.vim')]] } - - use { "kevinhwang91/nvim-bqf", ft = "qf", config = [[require('config.bqf')]] } - - -- Another markdown plugin - use { "preservim/vim-markdown", ft = { "markdown" } } - - -- Faster footnote generation - use { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } } - - -- Vim tabular plugin for manipulate tabular, required by markdown plugins - use { "godlygeek/tabular", cmd = { "Tabularize" } } - - -- Markdown previewing (only for Mac and Windows) - if vim.g.is_win or vim.g.is_mac then - use { - "iamcco/markdown-preview.nvim", - run = "cd app && npm install", - ft = { "markdown" }, - } - end - - use { "folke/zen-mode.nvim", cmd = "ZenMode", config = [[require('config.zen-mode')]] } - - if vim.g.is_mac then - use { "rhysd/vim-grammarous", ft = { "markdown" } } - end - - use { "chrisbra/unicode.vim", event = "VimEnter" } - - -- Additional powerful text object for vim, this plugin should be studied - -- carefully to use its full power - use { "wellle/targets.vim", event = "VimEnter" } - - -- Plugin to manipulate character pairs quickly - use { "machakann/vim-sandwich", event = "VimEnter" } - - -- Add indent object for vim (useful for languages like Python) - use { "michaeljsmith/vim-indent-object", event = "VimEnter" } - - -- Only use these plugin on Windows and Mac and when LaTeX is installed - if utils.executable("latex") then - use { "lervag/vimtex", ft = { "tex" } } - end - - -- Since tmux is only available on Linux and Mac, we only enable these plugins - -- for Linux and Mac - if utils.executable("tmux") then - -- .tmux.conf syntax highlighting and setting check - use { "tmux-plugins/vim-tmux", ft = { "tmux" } } - end - - -- Modern matchit implementation - use { "andymass/vim-matchup", event = "VimEnter" } - - use { "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } } - - -- Asynchronous command execution - use { "skywind3000/asyncrun.vim", opt = true, cmd = { "AsyncRun" } } - - use { "cespare/vim-toml", ft = { "toml" }, branch = "main" } - - -- Edit text area in browser using nvim - if vim.g.is_win or vim.g.is_mac then - use { - "glacambre/firenvim", - run = function() - fn["firenvim#install"](0) - end, - opt = true, - setup = [[vim.cmd('packadd firenvim')]], - } - end - - -- Debugger plugin - if vim.g.is_win or vim.g.is_linux then - use { "sakhnik/nvim-gdb", run = { "bash install.sh" }, opt = true, setup = [[vim.cmd('packadd nvim-gdb')]] } - end - - -- Session management plugin - use { "tpope/vim-obsession", cmd = "Obsession" } - - if vim.g.is_linux then - use { "ojroques/vim-oscyank", cmd = { "OSCYank", "OSCYankReg" } } - end - - -- The missing auto-completion for cmdline! - use { "gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]] } - - -- showing keybindings - use { - "folke/which-key.nvim", - event = "VimEnter", - config = function() - vim.defer_fn(function() - require("config.which-key") - end, 2000) - end, - } - - -- show and trim trailing whitespaces - use { "jdhao/whitespace.nvim", event = "VimEnter" } - - -- file explorer - use { - "nvim-tree/nvim-tree.lua", - requires = { "nvim-tree/nvim-web-devicons" }, - config = [[require('config.nvim-tree')]], - } - - use { "ii14/emmylua-nvim", ft = "lua" } - - use { "j-hui/fidget.nvim", after = "nvim-lspconfig", tag = "legacy", config = [[require('config.fidget-nvim')]] } - end, - config = { - max_jobs = 16, - compile_path = packer_util.join_paths(fn.stdpath("data"), "site", "lua", "packer_compiled.lua"), +require("lazy").setup { + { "onsails/lspkind-nvim", lazy = true }, + -- auto-completion engine + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-omni", + "hrsh7th/cmp-emoji", + "quangnguyen30192/cmp-nvim-ultisnips", + }, + config = function() + require("config.nvim-cmp") + end, + }, + + -- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp). + { + "neovim/nvim-lspconfig", + config = function() + require("config.lsp") + end, + }, + + { + "nvim-treesitter/nvim-treesitter", + enabled = function() + if vim.g.is_mac then + return true + end + return false + end, + event = "BufEnter", + build = ":TSUpdate", + config = function() + require("config.treesitter") + end, + }, + + -- Python indent (follows the PEP8 style) + { "Vimjas/vim-python-pep8-indent", ft = { "python" } }, + + -- Python-related text object + { "jeetsukumaran/vim-pythonsense", ft = { "python" } }, + + { "machakann/vim-swap", event = "VimEnter" }, + + -- IDE for Lisp + -- 'kovisoft/slimv' + { + "vlime/vlime", + enabled = function() + if utils.executable("sbcl") then + return true + end + return false + end, + config = function(plugin) + vim.opt.rtp:append(plugin.dir .. "/vim") + end, + ft = { "lisp" }, + }, + + -- Super fast buffer jump + { + "phaazon/hop.nvim", + event = "VimEnter", + config = function() + vim.defer_fn(function() + require("config.nvim_hop") + end, 2000) + end, + }, + + -- Show match number and index for searching + { + "kevinhwang91/nvim-hlslens", + branch = "main", + keys = { "*", "#", "n", "N" }, + config = function() + require("config.hlslens") + end, + }, + { + "Yggdroot/LeaderF", + cmd = "Leaderf", + build = function() + if not vim.g.is_win then + vim.cmd(":LeaderfInstallCExtension") + end + end, + }, + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + dependencies = { + "nvim-telescope/telescope-symbols.nvim", + }, + }, + + -- A list of colorscheme plugin you may want to try. Find what suits you. + { "navarasu/onedark.nvim" }, + { "sainnhe/edge" }, + { "sainnhe/sonokai" }, + { "sainnhe/gruvbox-material" }, + { "shaunsingh/nord.nvim" }, + { "sainnhe/everforest" }, + { "EdenEast/nightfox.nvim" }, + { "rebelot/kanagawa.nvim" }, + { "catppuccin/nvim", name = "catppuccin" }, + { "rose-pine/neovim", name = "rose-pine" }, + { "olimorris/onedarkpro.nvim" }, + { "tanvirtin/monokai.nvim" }, + { "marko-cerovac/material.nvim" }, + + { "nvim-tree/nvim-web-devicons", event = "VimEnter" }, + + { + "nvim-lualine/lualine.nvim", + event = "VimEnter", + cond = firenvim_not_active, + config = function() + require("config.statusline") + end, + }, + + { + "akinsho/bufferline.nvim", + event = "VimEnter", + cond = firenvim_not_active, + config = function() + require("config.bufferline") + end, + }, + + -- fancy start screen + { + "nvimdev/dashboard-nvim", + event = "VimEnter", + cond = firenvim_not_active, + config = function() + require("config.dashboard-nvim") + end, + }, + + { + "lukas-reineke/indent-blankline.nvim", + event = "VimEnter", + config = function() + require("config.indent-blankline") + end, + }, + + -- Highlight URLs inside vim + { "itchyny/vim-highlighturl", event = "VimEnter" }, + + -- notification plugin + { + "rcarriga/nvim-notify", + event = "BufEnter", + config = function() + vim.defer_fn(function() + require("config.nvim-notify") + end, 2000) + end, + }, + + -- For Windows and Mac, we can open an URL in the browser. For Linux, it may + -- not be possible since we maybe in a server which disables GUI. + { + "tyru/open-browser.vim", + enabled = function() + if vim.g.is_win or vim.g.is_mac then + return true + else + return false + end + end, + event = "VimEnter", + }, + + -- Only install these plugins if ctags are installed on the system + -- show file tags in vim window + { + "liuchengxu/vista.vim", + enabled = function() + if utils.executable("ctags") then + return true + else + return false + end + end, + cmd = "Vista", + }, + + -- Snippet engine and snippet template + { "SirVer/ultisnips", dependencies = { + "honza/vim-snippets", + }, event = "InsertEnter" }, + + -- Automatic insertion and deletion of a pair of characters + { "Raimondi/delimitMate", event = "InsertEnter" }, + + -- Comment plugin + { "tpope/vim-commentary", event = "VimEnter" }, + + -- Multiple cursor plugin like Sublime Text? + -- 'mg979/vim-visual-multi' + + -- Autosave files on certain events + { "907th/vim-auto-save", event = "InsertEnter" }, + + -- Show undo history visually + { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } }, + + -- better UI for some nvim actions + { "stevearc/dressing.nvim" }, + + -- Manage your yank history + { + "gbprod/yanky.nvim", + config = function() + require("config.yanky") + end, + }, + + -- Handy unix command inside Vim (Rename, Move etc.) + { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }, + + -- Repeat vim motions + { "tpope/vim-repeat", event = "VimEnter" }, + + { "nvim-zh/better-escape.vim", event = { "InsertEnter" } }, + + { + "lyokha/vim-xkbswitch", + enabled = function() + if vim.g.is_mac and utils.executable("xkbswitch") then + return true + end + return false + end, + event = { "InsertEnter" }, + }, + + { + "Neur1n/neuims", + enabled = function() + if vim.g.is_win then + return true + end + return false + end, + event = { "InsertEnter" }, + }, + + -- Auto format tools + { "sbdchd/neoformat", cmd = { "Neoformat" } }, + + -- Git command inside vim + { + "tpope/vim-fugitive", + event = "User InGitRepo", + config = function() + require("config.fugitive") + end, + }, + + -- Better git log display + { "rbong/vim-flog", cmd = { "Flog" } }, + { "christoomey/vim-conflicted", cmd = { "Conflicted" } }, + { + "ruifm/gitlinker.nvim", + event = "User InGitRepo", + config = function() + require("config.git-linker") + end, + }, + + -- Show git change (change, delete, add) signs in vim sign column + { + "lewis6991/gitsigns.nvim", + config = function() + require("config.gitsigns") + end, + }, + + -- Better git commit experience + { "rhysd/committia.vim", lazy = true }, + { + "kevinhwang91/nvim-bqf", + ft = "qf", + config = function() + require("config.bqf") + end, + }, + + -- Another markdown plugin + { "preservim/vim-markdown", ft = { "markdown" } }, + + -- Faster footnote generation + { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } }, + + -- Vim tabular plugin for manipulate tabular, required by markdown plugins + { "godlygeek/tabular", cmd = { "Tabularize" } }, + + -- Markdown previewing (only for Mac and Windows) + { + "iamcco/markdown-preview.nvim", + enabled = function() + if vim.g.is_win or vim.g.is_mac then + return true + end + return false + end, + build = "cd app && npm install", + ft = { "markdown" }, + }, + + { + "folke/zen-mode.nvim", + cmd = "ZenMode", + config = function() + require("config.zen-mode") + end, + }, + + { + "rhysd/vim-grammarous", + enabled = function() + if vim.g.is_mac then + return true + end + return false + end, + ft = { "markdown" }, + }, + + { "chrisbra/unicode.vim", event = "VimEnter" }, + + -- Additional powerful text object for vim, this plugin should be studied + -- carefully to use its full power + { "wellle/targets.vim", event = "VimEnter" }, + + -- Plugin to manipulate character pairs quickly + { "machakann/vim-sandwich", event = "VimEnter" }, + + -- Add indent object for vim (useful for languages like Python) + { "michaeljsmith/vim-indent-object", event = "VimEnter" }, + + -- Only use these plugin on Windows and Mac and when LaTeX is installed + { + "lervag/vimtex", + enabled = function() + if utils.executable("latex") then + return true + end + return false + end, + ft = { "tex" }, + }, + + -- Since tmux is only available on Linux and Mac, we only enable these plugins + -- for Linux and Mac + -- .tmux.conf syntax highlighting and setting check + { + "tmux-plugins/vim-tmux", + enabled = function() + if utils.executable("tmux") then + return true + end + return false + end, + ft = { "tmux" }, + }, + + -- Modern matchit implementation + { "andymass/vim-matchup", event = "VimEnter" }, + { "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } }, + + -- Asynchronous command execution + { "skywind3000/asyncrun.vim", lazy = true, cmd = { "AsyncRun" } }, + { "cespare/vim-toml", ft = { "toml" }, branch = "main" }, + + -- Edit text area in browser using nvim + { + "glacambre/firenvim", + enabled = function() + if vim.g.is_win or vim.g.is_mac then + return true + end + return false + end, + build = function() + vim.fn["firenvim#install"](0) + end, + lazy = true, + }, + + -- Debugger plugin + { + "sakhnik/nvim-gdb", + enabled = function() + if vim.g.is_win or vim.g.is_linux then + return true + end + return false + end, + build = { "bash install.sh" }, + lazy = true, + }, + + -- Session management plugin + { "tpope/vim-obsession", cmd = "Obsession" }, + + { + "ojroques/vim-oscyank", + enabled = function() + if vim.g.is_linux then + return true + end + return false + end, + cmd = { "OSCYank", "OSCYankReg" }, + }, + + -- The missing auto-completion for cmdline! + { "gelguy/wilder.nvim" }, + + -- showing keybindings + { + "folke/which-key.nvim", + event = "VimEnter", + config = function() + vim.defer_fn(function() + require("config.which-key") + end, 2000) + end, + }, + + -- show and trim trailing whitespaces + { "jdhao/whitespace.nvim", event = "VimEnter" }, + + -- file explorer + { + "nvim-tree/nvim-tree.lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("config.nvim-tree") + end, + }, + + { "ii14/emmylua-nvim", ft = "lua" }, + { + "j-hui/fidget.nvim", + tag = "legacy", + config = function() + require("config.fidget-nvim") + end, }, } - --- For fresh install, we need to install plugins. Otherwise, we just need to require `packer_compiled.lua`. -if fresh_install then - -- We run packer.sync() here, because only after packer.startup, can we know which plugins to install. - -- So plugin installation should be done after the startup process. - packer.sync() -else - local status, _ = pcall(require, "packer_compiled") - if not status then - local msg = "File packer_compiled.lua not found: run PackerSync to fix!" - vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" }) - end -end - --- Auto-generate packer_compiled.lua file -api.nvim_create_autocmd({ "BufWritePost" }, { - pattern = "*/nvim/lua/plugins.lua", - group = api.nvim_create_augroup("packer_auto_compile", { clear = true }), - callback = function(ctx) - local cmd = "source " .. ctx.file - vim.cmd(cmd) - vim.cmd("PackerCompile") - vim.notify("PackerCompile done!", vim.log.levels.INFO, { title = "Nvim-config" }) - end, -})