From 53c029d76b75ccf1010720009b4a68c5b9e4ba70 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 6 Apr 2023 03:03:32 +0900 Subject: neovim: migrate package manager from packer.nvim to lazy.nvim --- .config/nvim/lua/vimrc/plugins.lua | 422 ++++++++++++++----------------------- 1 file changed, 161 insertions(+), 261 deletions(-) (limited to '.config/nvim/lua/vimrc/plugins.lua') diff --git a/.config/nvim/lua/vimrc/plugins.lua b/.config/nvim/lua/vimrc/plugins.lua index 25baa9c..e7c3d1b 100644 --- a/.config/nvim/lua/vimrc/plugins.lua +++ b/.config/nvim/lua/vimrc/plugins.lua @@ -1,22 +1,13 @@ -vim.cmd.packadd('packer.nvim') -local packer = require('packer') - --- Plugins {{{1 -packer.startup(function(use) - -- Plugin management {{{2 - use { - 'wbthomason/packer.nvim', - opt = true, - } - -- Libraries {{{2 +return { + -- Libraries {{{1 -- telescope.nvim depends on it. - use { + { 'nvim-lua/plenary.nvim', - } - -- Text editing {{{2 - -- IME {{{3 + }, + -- Text editing {{{1 + -- IME {{{2 -- SKK (Simple Kana to Kanji conversion program) for Vim. - use { + { 'vim-skk/eskk.vim', config = function() local my_env = require('vimrc.my_env') @@ -100,33 +91,26 @@ packer.startup(function(use) autocmd Vimrc User eskk-initialize-post call My_eskk_initialize_post() ]=]) end, - } - -- Operators {{{3 + }, + -- Operators {{{2 -- Support for user-defined operators. - use { + { 'kana/vim-operator-user', - } + }, -- Extract expression and make assingment statement. - use { + { 'tek/vim-operator-assign', - } + }, -- Replace text without updating registers. - use { + { 'kana/vim-operator-replace', - opt = true, + lazy = true, keys = { - {'n', '(operator-replace)'}, - {'o', '(operator-replace)'}, - {'x', '(operator-replace)'}, + {'', '(operator-replace)', mode = {'n', 'o', 'x'}}, }, - setup = function() - vim.keymap.set('n', '', '(operator-replace)') - vim.keymap.set('o', '', '(operator-replace)') - vim.keymap.set('x', '', '(operator-replace)') - end, - } + }, -- Super surround. - use { + { 'machakann/vim-sandwich', config = function() vim.fn['operator#sandwich#set']('add', 'all', 'highlight', 2) @@ -152,21 +136,11 @@ packer.startup(function(use) vim.g['sandwich#recipes'] = rs end end, - } - -- Non-operators {{{3 + }, + -- Non-operators {{{2 -- Comment out. - use { + { 'numToStr/Comment.nvim', - opt = true, - keys = { - {'n', 'm//'}, - {'n', 'm??'}, - {'n', 'm/'}, {'x', 'm/'}, - {'n', 'm?'}, {'x', 'm?'}, - {'n', 'm/O'}, - {'n', 'm/o'}, - {'n', 'm/A'}, - }, config = function() require('Comment').setup { toggler = { @@ -184,126 +158,93 @@ packer.startup(function(use) }, } end, - } + }, -- Align text. - use { + { 'junegunn/vim-easy-align', - opt = true, + lazy = true, cmd = {'EasyAlign'}, keys = { - {'n', '(EasyAlign)'}, - {'x', '(EasyAlign)'}, + {'=', '(EasyAlign)', mode = {'n', 'x'}}, }, - setup = function() - vim.keymap.set('n', '=', '(EasyAlign)') - vim.keymap.set('x', '=', '(EasyAlign)') - end, - } - -- Text objects {{{2 + }, + -- Text objects {{{1 -- Support for user-defined text objects. - use { + { 'kana/vim-textobj-user', - } + priority = 100, + }, -- Text object for blockwise. - use { + { 'osyo-manga/vim-textobj-blockwise', - } + }, -- Text object for comment. - use { + { 'thinca/vim-textobj-comment', - } + }, -- Text object for indent. - use { + { 'kana/vim-textobj-indent', - } + }, -- Text object for line. - use { + { 'kana/vim-textobj-line', - } + }, -- Text object for parameter. - use { + { 'sgur/vim-textobj-parameter', - } + }, -- Text object for space. - use { + { 'saihoooooooo/vim-textobj-space', - opt = true, + lazy = true, keys = { - {'o', 'a'}, {'x', 'a'}, - {'o', 'i'}, {'x', 'i'}, + {'a', '(textobj-space-a)', mode = {'o', 'x'}}, + {'i', '(textobj-space-i)', mode = {'o', 'x'}}, }, - setup = function() + init = function() vim.g.textobj_space_no_default_key_mappings = true end, - config = function() - vim.keymap.set('o', 'a', '(textobj-space-a)') - vim.keymap.set('x', 'a', '(textobj-space-a)') - vim.keymap.set('o', 'i', '(textobj-space-i)') - vim.keymap.set('x', 'i', '(textobj-space-i)') - end, - } + }, -- Text object for syntax. - use { + { 'kana/vim-textobj-syntax', - } + }, -- Text object for URL. - use { + { 'mattn/vim-textobj-url', - } + }, -- Text object for words in words. - use { + { 'h1mesuke/textobj-wiw', - opt = true, + lazy = true, keys = { - {'n', ''}, {'o', ''}, {'x', ''}, - {'n', 'g'}, {'o', 'g'}, {'x', 'g'}, - {'n', ''}, {'o', ''}, {'x', ''}, - {'n', 'g'}, {'o', 'g'}, {'x', 'g'}, - {'o', 'a'}, {'x', 'a'}, - {'o', 'i'}, {'x', 'i'}, + {'', '(textobj-wiw-n)', mode = {'n', 'o', 'x'}}, + {'g', '(textobj-wiw-p)', mode = {'n', 'o', 'x'}}, + {'', '(textobj-wiw-N)', mode = {'n', 'o', 'x'}}, + {'g', '(textobj-wiw-P)', mode = {'n', 'o', 'x'}}, + {'a', '(textobj-wiw-a)', mode = {'o', 'x'}}, + {'i', '(textobj-wiw-i)', mode = {'o', 'x'}}, }, - setup = function() + init = function() vim.g.textobj_wiw_no_default_key_mappings = true end, - config = function() - vim.keymap.set('n', '', '(textobj-wiw-n)') - vim.keymap.set('o', '', '(textobj-wiw-n)') - vim.keymap.set('x', '', '(textobj-wiw-n)') - vim.keymap.set('n', 'g', '(textobj-wiw-p)') - vim.keymap.set('o', 'g', '(textobj-wiw-p)') - vim.keymap.set('x', 'g', '(textobj-wiw-p)') - vim.keymap.set('n', '', '(textobj-wiw-N)') - vim.keymap.set('o', '', '(textobj-wiw-N)') - vim.keymap.set('x', '', '(textobj-wiw-N)') - vim.keymap.set('n', 'g', '(textobj-wiw-P)') - vim.keymap.set('o', 'g', '(textobj-wiw-P)') - vim.keymap.set('x', 'g', '(textobj-wiw-P)') - - vim.keymap.set('o', 'a', '(textobj-wiw-a)') - vim.keymap.set('x', 'a', '(textobj-wiw-a)') - vim.keymap.set('o', 'i', '(textobj-wiw-i)') - vim.keymap.set('x', 'i', '(textobj-wiw-i)') - end, - } - -- Search {{{2 + }, + -- Search {{{1 -- Extend * and #. - use { + { 'haya14busa/vim-asterisk', - opt = true, + lazy = true, keys = { - {'n', '(asterisk-z*)'}, {'x', '(asterisk-z*)'}, - {'n', '(asterisk-gz*)'}, {'x', '(asterisk-gz*)'}, + {'*', '(asterisk-z*)', mode = {'n', 'x'}}, + {'g*', '(asterisk-gz*)', mode = {'n', 'x'}}, }, - setup = function() - vim.keymap.set({'n', 'x'}, '*', '(asterisk-z*)') - vim.keymap.set({'n', 'x'}, 'g*', '(asterisk-gz*)') - end, - } + }, -- NOTE: it is a fork version of jremmen/vim-ripgrep -- Integration with ripgrep, fast alternative of grep command. - use { + { 'nsfisis/vim-ripgrep', - opt = true, + lazy = true, cmd = {'Rg', 'RG'}, config = function() -- Workaround: do not open quickfix window. @@ -322,10 +263,10 @@ packer.startup(function(use) } ) end, - } - -- Files {{{2 + }, + -- Files {{{1 -- Switch to related files. - use { + { 'kana/vim-altr', config = function() -- C/C++ @@ -336,11 +277,11 @@ packer.startup(function(use) -- Go to File Alternative vim.keymap.set('n', 'gfa', '(altr-forward)') end, - } + }, -- Full-featured filer. - use { + { 'lambdalisue/fern.vim', - opt = true, + lazy = true, cmd = {'Fern'}, config = function() local vimrc = require('vimrc') @@ -354,28 +295,28 @@ packer.startup(function(use) end, }) end, - } + }, -- Fern plugin: hijack Netrw. - use { + { 'lambdalisue/fern-hijack.vim', - } - -- Appearance {{{2 + }, + -- Appearance {{{1 -- Show highlight. - use { + { 'cocopon/colorswatch.vim', - opt = true, + lazy = true, cmd = {'ColorSwatchGenerate'}, - } + }, -- Makes folding text cool. - use { + { 'LeafCage/foldCC.vim', config = function() vim.o.foldtext = 'FoldCCtext()' vim.g.foldCCtext_head = 'repeat(">", v:foldlevel) . " "' end, - } + }, -- Show indentation guide. - use { + { 'lukas-reineke/indent-blankline.nvim', config = function() require("indent_blankline").setup { @@ -383,15 +324,15 @@ packer.startup(function(use) show_first_indent_level = false, } end, - } + }, -- Highlight matched parentheses. - use { + { 'itchyny/vim-parenmatch', - } + }, -- Tree-sitter integration. - use { + { 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdateSync', + build = ':TSUpdateSync', config = function() require('nvim-treesitter.configs').setup { ensure_installed = 'all', @@ -419,13 +360,13 @@ packer.startup(function(use) }, } end, - } + }, -- Tree-sitter debugging. - use { + { 'nvim-treesitter/playground', - } + }, -- Highlight specified words. - use { + { 't9md/vim-quickhl', config = function() -- TODO: CUI @@ -446,15 +387,15 @@ packer.startup(function(use) vim.keymap.set('x', '"', '(quickhl-manual-this)') vim.keymap.set('n', '', ':nohlsearch QuickhlManualReset', { silent=true }) end, - } + }, -- Yet another tree-sitter indentation. -- TODO: uninstall it once the official nvim-treesitter provides sane indentation. - use { + { 'yioneko/nvim-yati', - } - -- Filetypes {{{2 + }, + -- Filetypes {{{1 -- Faster replacement for bundled filetype.vim - use { + { 'nathom/filetype.nvim', config = function() require('filetype').setup({ @@ -467,9 +408,9 @@ packer.startup(function(use) }, }) end, - } + }, -- C/C++ - use { + { 'rhysd/vim-clang-format', config = function() local vimrc = require('vimrc') @@ -481,13 +422,13 @@ packer.startup(function(use) command = 'ClangFormatAutoDisable', }) end, - } + }, -- HTML/CSS - use { + { 'mattn/emmet-vim', - opt = true, + lazy = true, cmd = {'EmmetInstall'}, - setup = function() + init = function() local vimrc = require('vimrc') vim.g.user_emmet_install_global = false @@ -496,23 +437,23 @@ packer.startup(function(use) command = 'EmmetInstall', }) end, - } + }, -- Rust - use { + { 'rust-lang/rust.vim', config = function() vim.g.rustfmt_autosave = true end, - } - -- QoL {{{2 + }, + -- QoL {{{1 -- Capture the output of a command. - use { + { 'tyru/capture.vim', - opt = true, + lazy = true, cmd = {'Capture'}, - } + }, -- Write git commit message. - use { + { 'rhysd/committia.vim', config = function() vim.g.committia_hooks = { @@ -521,23 +462,26 @@ packer.startup(function(use) end, } end, - } + }, -- Neovim clone of EasyMotion - use { + { 'phaazon/hop.nvim', branch = 'v2', -- Hop.nvim's README recommends this. - opt = true, + lazy = true, keys = { - {'n', '(hop-f)'}, {'o', '(hop-f)'}, - {'x', '(hop-f)'}, {'n', '(hop-F)'}, - {'o', '(hop-F)'}, {'x', '(hop-F)'}, - {'o', '(hop-t)'}, {'x', '(hop-t)'}, - {'o', '(hop-T)'}, {'x', '(hop-T)'}, - {'n', '(hop-s2)'}, {'o', '(hop-s2)'}, {'x', '(hop-s2)'}, - {'n', '(hop-n)'}, {'o', '(hop-n)'}, {'x', '(hop-n)'}, - {'n', '(hop-N)'}, {'o', '(hop-N)'}, {'x', '(hop-N)'}, - {'n', '(hop-j)'}, {'o', '(hop-j)'}, {'x', '(hop-j)'}, - {'n', '(hop-k)'}, {'o', '(hop-k)'}, {'x', '(hop-k)'}, + {'f', '(hop-f)', mode = {'n', 'o', 'x'}}, + {'F', '(hop-F)', mode = {'n', 'o', 'x'}}, + {'t', '(hop-t)', mode = {'o', 'x'}}, + {'T', '(hop-T)', mode = {'o', 'x'}}, + -- Note: Don't use the following key sequences! They are used by 'vim-sandwich'. + -- * sa + -- * sd + -- * sr + {'ss', '(hop-s2)', mode = {'n', 'o', 'x'}}, + {'sn', '(hop-n)', mode = {'n', 'o', 'x'}}, + {'sN', '(hop-N)', mode = {'n', 'o', 'x'}}, + {'sj', '(hop-j)', mode = {'n', 'o', 'x'}}, + {'sk', '(hop-k)', mode = {'n', 'o', 'x'}}, }, config = function() require('hop').setup { @@ -587,45 +531,13 @@ packer.startup(function(use) vim.keymap.set('', '(hop-j)', function() hop_jk({ direction = AFTER_CURSOR }) end, { silent = true }) vim.keymap.set('', '(hop-k)', function() hop_jk({ direction = BEFORE_CURSOR }) end, { silent = true }) end, - setup = function() - vim.keymap.set('n', 'f', '(hop-f)') - vim.keymap.set('o', 'f', '(hop-f)') - vim.keymap.set('x', 'f', '(hop-f)') - vim.keymap.set('n', 'F', '(hop-F)') - vim.keymap.set('o', 'F', '(hop-F)') - vim.keymap.set('x', 'F', '(hop-F)') - vim.keymap.set('o', 't', '(hop-t)') - vim.keymap.set('x', 't', '(hop-t)') - vim.keymap.set('o', 'T', '(hop-T)') - vim.keymap.set('x', 'T', '(hop-T)') - - -- Note: Don't use the following key sequences! They are used by 'vim-sandwich'. - -- * sa - -- * sd - -- * sr - vim.keymap.set('n', 'ss', '(hop-s2)') - vim.keymap.set('o', 'ss', '(hop-s2)') - vim.keymap.set('x', 'ss', '(hop-s2)') - vim.keymap.set('n', 'sn', '(hop-n)') - vim.keymap.set('o', 'sn', '(hop-n)') - vim.keymap.set('x', 'sn', '(hop-n)') - vim.keymap.set('n', 'sN', '(hop-N)') - vim.keymap.set('o', 'sN', '(hop-N)') - vim.keymap.set('x', 'sN', '(hop-N)') - vim.keymap.set('n', 'sj', '(hop-j)') - vim.keymap.set('o', 'sj', '(hop-j)') - vim.keymap.set('x', 'sj', '(hop-j)') - vim.keymap.set('n', 'sk', '(hop-k)') - vim.keymap.set('o', 'sk', '(hop-k)') - vim.keymap.set('x', 'sk', '(hop-k)') - end, - } + }, -- Integration with EditorConfig (https://editorconfig.org) - use { + { 'editorconfig/editorconfig-vim', - } + }, -- Extend J. - use { + { 'osyo-manga/vim-jplus', config = function() vim.g['jplus#input_config'] = { @@ -644,31 +556,31 @@ packer.startup(function(use) vim.keymap.set('n', 'gJ', '(jplus-input)') vim.keymap.set('x', 'gJ', '(jplus-input)') end, - } + }, -- Improve behaviors of I, A and gI in Blockwise-Visual mode. - use { + { 'kana/vim-niceblock', config = function() vim.keymap.set('x', 'I', '(niceblock-I)') vim.keymap.set('x', 'gI', '(niceblock-gI)') vim.keymap.set('x', 'A', '(niceblock-A)') end, - } + }, -- Edit QuickFix freely. - use { + { 'itchyny/vim-qfedit', - } + }, -- Edit QuickFix and reflect to original buffers. - use { + { 'thinca/vim-qfreplace', - opt = true, + lazy = true, cmd = {'Qfreplace'}, config = function() vim.keymap.set('n', 'br', ':Qfreplace SmartOpen', { silent=true }) end, - } + }, -- Run anything. - use { + { 'thinca/vim-quickrun', config = function() vim.g.quickrun_config = { @@ -689,9 +601,9 @@ packer.startup(function(use) vim.keymap.set('n', 'BB', '(quickrun)') vim.keymap.set('x', 'BB', '(quickrun)') end, - } + }, -- Extend dot-repeat. - use { + { 'tpope/vim-repeat', config = function() vim.keymap.set('n', 'U', '(RepeatRedo)') @@ -699,76 +611,70 @@ packer.startup(function(use) -- repeat#setreg() does nothing here. vim.fn['repeat#setreg']('', '') end, - } + }, -- Introduce user-defined mode. - use { + { 'kana/vim-submode', config = function() - -- Global settings {{{3 + -- Global settings {{{2 vim.g.submode_always_show_submode = true vim.g.submode_keyseqs_to_leave = {'', ''} vim.g.submode_keep_leaving_key = true - -- yankround {{{3 + -- yankround {{{2 vim.fn['submode#enter_with']('YankRound', 'nv', 'rs', 'gp', '(yankround-p)') vim.fn['submode#enter_with']('YankRound', 'nv', 'rs', 'gP', '(yankround-P)') vim.fn['submode#map']('YankRound', 'nv', 'rs', 'p', '(yankround-prev)') vim.fn['submode#map']('YankRound', 'nv', 'rs', 'P', '(yankround-next)') - -- swap {{{3 + -- swap {{{2 vim.fn['submode#enter_with']('Swap', 'n', 'rs', 'g>', '(swap-next)') vim.fn['submode#map']('Swap', 'n', 'rs', '<', '(swap-prev)') vim.fn['submode#enter_with']('Swap', 'n', 'rs', 'g<', '(swap-prev)') vim.fn['submode#map']('Swap', 'n', 'rs', '>', '(swap-next)') - -- TODO - if packer_plugins['vim-swap'] and not packer_plugins['vim-swap'].loaded then - vim.cmd.packadd('vim-swap') - end - - -- Resizing a window (height) {{{3 + -- Resizing a window (height) {{{2 vim.fn['submode#enter_with']('WinResizeH', 'n', 's', 'trh') vim.fn['submode#enter_with']('WinResizeH', 'n', 's', 'trh') vim.fn['submode#map']('WinResizeH', 'n', 's', '+', '+') vim.fn['submode#map']('WinResizeH', 'n', 's', '-', '-') - -- Resizing a window (width) {{{3 + -- Resizing a window (width) {{{2 vim.fn['submode#enter_with']('WinResizeW', 'n', 's', 'trw') vim.fn['submode#enter_with']('WinResizeW', 'n', 's', 'trw') vim.fn['submode#map']('WinResizeW', 'n', 's', '+', '>') vim.fn['submode#map']('WinResizeW', 'n', 's', '-', '') - -- Super undo/redo {{{3 + -- Super undo/redo {{{2 vim.fn['submode#enter_with']('Undo/Redo', 'n', 's', 'gu', 'g-') vim.fn['submode#map']('Undo/Redo', 'n', 's', 'u', 'g-') vim.fn['submode#enter_with']('Undo/Redo', 'n', 's', 'gU', 'g+') vim.fn['submode#map']('Undo/Redo', 'n', 's', 'U', 'g+') -- }}} end, - } + }, -- Swap arguments. - use { + { 'machakann/vim-swap', - opt = true, - setup = function() + init = function() vim.g.swap_no_default_key_mappings = true end, - } + }, -- Fuzzy finder. - use { + { 'nvim-telescope/telescope.nvim', - } + }, -- Adjust window size. - use { + { 'rhysd/vim-window-adjuster', config = function() vim.keymap.set('n', 'tRw', 'AdjustScreenWidth') vim.keymap.set('n', 'tRh', 'AdjustScreenHeight') vim.keymap.set('n', 'tRr', ':AdjustScreenWidth AdjustScreenHeight', { silent=true }) end, - } + }, -- Remember yank history and paste them. - use { + { 'LeafCage/yankround.vim', config = function() local my_env = require('vimrc.my_env') @@ -776,12 +682,6 @@ packer.startup(function(use) vim.g.yankround_dir = my_env.yankround_dir vim.g.yankround_use_region_hl = true end, - } + }, -- }}} -end) --- }}} - -return { - compile = packer.compile, - sync = packer.sync, } -- cgit v1.2.3-70-g09d2