-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable UFO in certain buffer types #33
Comments
Not support for now, as a workaround.
If there're many buffers that want to detach ufo, ufo will add an option to be convenient for the users. Leave this issue for others. |
@kevinhwang91 the README makes it sound like returning local filetypes = { org = '' }
ufo.setup({
fold_virt_text_handler = handler,
provider_selector = function(_, ft)
return filetypes[ft] or { 'treesitter', 'indent' }
end,
}) |
Edit: |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Another case where this might be useful: When working with buffers that aren't even files, like opened preview windows like popups, etc. I get UFO folding indicators in symbols-outline, for example. |
local ft = {
vim = "indent",
python = { "indent" },
}
local ignored_filetypes = { "markdown", "git", "NeogitStatus" }
for _, key in ipairs(ignored_filetypes) do
ignored_filetypes[key] = true
ft[key] = ""
end
require('ufo').setup({
-- ...
}) Inserting ignored filetypes from a dedicated list is what I do, to then reuse them in the keymaps. E.g., allows to keep ufos foldstyle for markdown but use nx.au({
"BufEnter",
callback = function()
if ignored_filetypes[vim.bo.ft] or vim.bo.bt ~= "" then return end -- <--
nx.map({
{ "zR", ufo.openAllFolds },
{ "zM", ufo.closeAllFolds },
{ "zr", ufo.openFoldsExceptKinds },
{ "zm", ufo.closeFoldsWith },
{
"K",
function()
local winid = ufo.peekFoldedLinesUnderCursor()
if not winid then vim.lsp.buf.hover() end
end,
},
}, { buffer = true })
end,
}) |
would love to disable ufo on all neogit* buffers |
My approach (I just wanted to turn off folding altogether, rather than disabling UFO specifically): vim.api.nvim_create_autocmd("FileType", {
pattern = { "nvcheatsheet", "neo-tree" },
callback = function()
require("ufo").detach()
vim.opt_local.foldenable = false
end
}) Edit: seems that due to UFO's events you also need to do a detach to make it work. |
I have the same issue with Neo-tree.nvim |
@ashb Works great for me, thanks! |
You might also want to disable the extra fold column by append this to callback function:
|
This doesn't work for me for Neogit.
It works by adding this, but then if you open another buffer which is a proper file it doesn't have folds anymore...
Adding vim.api.nvim_create_autocmd('FileType', {
pattern = { 'NeogitStatus' },
callback = function()
require('ufo').detach()
vim.opt_local.foldenable = false
vim.opt_local.foldcolumn = '0'
end,
})
end, |
With statuscol, you must also set the ft_ignore option. require('statuscol').setup {
ft_ignore = { 'neo-tree' },
...
} |
Feature description
Using something like a
disabled
table in the configuration function, one should be able to disable nvim-ufo in certain buffer types. An example of where this is useful is.org
documents. Thenvim-orgmode/orgmode
plugin has built in fold support, but nvim-ufo overrides that with incorrect behaviour (intent based). The ability to disable it in certain buffer types would allow for the best of both worlds.One distinction is that when switching to another buffer of a different type, nvim-ufo should be able to work again.
Describe the solution you'd like
Something similar to how LSP servers handle enabling and disabling filetypes would be best. An example configuration would be something like:
Additional context
No response
The text was updated successfully, but these errors were encountered: