mirror of
https://github.com/lnus/fencey.nvim.git
synced 2026-06-19 00:01:10 -06:00
Yank text as fenced code blocks
- Lua 100%
| lua/fencey | ||
| .gitignore | ||
| .stylua.toml | ||
| LICENSE | ||
| README.md | ||
fencey.nvim
Features
- 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.
Usage
fencey.nvim provides one command:
:FenceYankputs you into fence yank mode
I recommend keybinding this to something reasonable, see example config.
Installation
- 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()
Configuration
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
},
}
Example configuration
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,
},
License
MIT