-
-
Notifications
You must be signed in to change notification settings - Fork 198
Plugins
- Table of Contents
- Plugin management with Lazy
- quick-scope
- vim-sandwich
- vim-easymotion
- vim-commentary
If you use lazy.nvim as your plugin manager, you can split your plugins based on when they should be loaded like so:
require("lazy").setup({
{ import = "user.plugins_notvscode", cond = (function() return not vim.g.vscode end) },
{ import = "user.plugins_always", cond = true },
{ import = "user.plugins_vscode", cond = (function() return vim.g.vscode end) },
})
Each of those directors can contain any number of specs, for example my plugins_always contains just one file
other.lua`:
return {
{ 'tpope/vim-repeat', },
{ 'tpope/vim-surround', },
}
quick-scope is a Vim plugin that provides an always-on highlight for a
unique character in every word on a line to help you use f
, F
and family.
The problem with this plugins is that it uses the default Vim highlighting groups. These highlighting groups are ignored
by vscode-neovim
. Visual Studio Code provides its own mechanism for highlighting code.
To fix this issue add the following to your init.vim
:
highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
The underline color can be changed by the guisp
tag.
vim-sandwich in much the same way as quick-scope uses highlight groups that are ignored. To fix add to your init.vim
highlight OperatorSandwichBuns guifg='#aa91a0' gui=underline ctermfg=172 cterm=underline
highlight OperatorSandwichChange guifg='#edc41f' gui=underline ctermfg='yellow' cterm=underline
highlight OperatorSandwichAdd guibg='#b1fa87' gui=none ctermbg='green' cterm=none
highlight OperatorSandwichDelete guibg='#cf5963' gui=none ctermbg='red' cterm=none
According to this thread https://github.com/vscode-neovim/vscode-neovim/issues/1353 the fork of vim-easymotion given below is no longer maintained and may not work.
EasyMotion provides a much simpler way to use some motions in vim. It
takes the <number>
out of <number>w
or <number>f{char}
by highlighting all possible choices and allowing you to
press one key to jump directly to the target.
The problem with this plugin is that it replaces your text with markers and then restores them back. It may work for Vim
but for VS Code it leads to broken text and many errors reported while you're jumping. For this reason @asvetliakov
created the special vim-easymotion fork. This version of the plugin
doesn't touch your text and instead uses VS Code's text decorations.
UPDATE 3/1/2024 It appears the original easymotion/vim-easymotion
plugin that is no longer in maintenance mode,
now works. Additionally, overwin motions now work, as demonstrated:
commentary.vim is a plugin you can use to comment stuff out.
You can use the plugin if you like it, but the behavior is already provided by VS Code so ideally you would just use
these services. vscode-neovim
has built-in commands to make it easier to do just that.
As an example, you can add the following to your init.vim
:
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
Similar to vim-commentary, gcc is comment line (accept count), e.g., entering 10gcc
comments the next 10 lines. Use gc with motion/in visual mode. VSCodeCommentary
is
just a simple function which calls editor.action.commentLine
. Thus, these commands will also work to uncomment lines.