inline-fold.nvim
is a Neovim plugin inspired by the vscode plugin inline-fold
. It provides a convenient way to define patterns in files that get concealed inline. This can be used for many things for example for CSS classes in HTML files especially with TailwindCSS
Note: It doesn't work for multiline patterns.
Use your preferred plugin manager to install inline-fold.nvim
.
{
"malbertzard/inline-fold.nvim",
opts = {
defaultPlaceholder = "…",
queries = {
-- Some examples you can use
html = {
{ pattern = 'class="([^"]*)"', placeholder = "@" }, -- classes in html
{ pattern = 'href="(.-)"' }, -- hrefs in html
{ pattern = 'src="(.-)"' }, -- HTML img src attribute
}
},
}
}
Once installed, the plugin provides the following functionality:
InlineFoldToggle
: Toggles the folding of the content within CSS class attributes.InlineFoldToggle
via autocmd
Add the following snippet to your configurations to call InlineFoldToggle
automatically based on filename patterns.
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, {
pattern = { '*.html', '*.tsx' },
callback = function(_)
if not require('inline-fold.module').isHidden then
vim.cmd('InlineFoldToggle')
end
end,
})
This project is licensed under the MIT License.