Yank text as fenced code blocks
Find a file
2025-02-10 10:31:19 +01:00
lua/fencey refactor: Using more sane API calls 2025-02-10 10:31:19 +01:00
.gitignore initial commit 2025-02-06 01:48:39 +01:00
.stylua.toml initial commit 2025-02-06 01:48:39 +01:00
LICENSE initial commit 2025-02-06 01:48:39 +01:00
README.md feat: Config for register 2025-02-10 10:26:43 +01:00

fencey.nvim

Fencey Demo

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:

  • :FenceYank puts you into fence yank mode

I recommend keybinding this to something reasonable, see example config.

Installation

  1. Install via your favorite package manager
-- lazy.nvim
{
    'lnus/fencey.nvim',
    opts = {},
},
  1. 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 cmd and keys from 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