- Yank text as a code block
- Do it again, if you want to
Couldn't this just have been a gist with an autocommand?!
Yes, but this is cooler.
Feel free to repurpose the code as an autocommand if you want, but I have added some niceties that make this easier to use.
fencey.nvim provides one command:
:FenceYankputs you into fence yank mode
I recommend keybinding this to something reasonable, see example config.
- Install via your favorite package manager
-- lazy.nvim
{
'lnus/fencey.nvim',
opts = {},
},- Setup the plugin in your
init.lua
NOT needed with lazy.nvim if opts is set, like above
require('fencey').setup()The default configuration is very barebones.
{
verbose = false, -- Log more often
register = '+', -- Which register to store yank in
virtual_text = {
content = '[FY]', -- Virtual text content
hl_group = 'DiagnosticVirtualTextInfo', -- Which highlight group to use
},
}Make sure to understand
cmdandkeysfrom lazy.nvim
With lazy.nvim a config might look like this:
{
'lnus/fencey.nvim',
opts = {
verbose = false,
register = '+',
virtual_text = {
content = '[FenceY]',
hl_group = 'Comment',
},
},
cmd = { 'FenceYank' },
keys = {
{ '<leader>fy', '<cmd>FenceYank<cr>', desc = '[F]ence [Y]ank' },
},
},Or a more explicit, not lazy loaded configuration:
{
'lnus/fencey.nvim',
config = function()
vim.api.nvim_set_hl(0, 'AwesomeHighlight', { fg = '#FF0FF0', italic = true })
vim.keymap.set('n', '<leader>yf', '<cmd>FenceYank<cr>', { desc = '[Y]ank [F]ence' })
require('fencey').setup {
verbose = false,
register = '+',
virtual_text = {
content = '[Yanking Fence]',
hl_group = 'AwesomeHighlight',
},
}
end,
},MIT
