Open hisbaan opened 2 years ago
Not support for now, as a workaround.
au FileType org lua require('ufo').detach()
or au FileType org UfoDetach
vim.cmd('UfoDetach')
under ~/.config/nvim/ftplugin/org.vim
or ~/.config/nvim/ftplugin/org.lua
org
buffer:
https://github.com/kevinhwang91/nvim-ufo/blob/9331576ce02b41c687309f8217eb6830e0a2ae19/doc/example.lua#L68-L73If 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 ''
from provider_selector
should disable folds but that doesn't work. Is that something that should be working.
local filetypes = { org = '' }
ufo.setup({
fold_virt_text_handler = handler,
provider_selector = function(_, ft)
return filetypes[ft] or { 'treesitter', 'indent' }
end,
})
provider_selector
return ''
only disables the providers to get folds. Disable virtual text must run UfoDetach
Edit:
Return a {}
for fold_virt_text_handler
or handler
in require('ufo').setFoldVirtTextHandler(bufnr, handler)
will only clear the color folded line.
Is this still working for others? It used to work for me, but not anymore... I need to manually do UfoDetach
once the file is opened.
It's broken after recently refactoring, I will fix it tomorrow.
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 preservim/vim-markdown
's foldmethod.
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.
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.
I have the same issue with Neo-tree.nvim
@ashb Works great for me, thanks!
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.
You might also want to disable the extra fold column by append this to callback function:
vim.wo.foldcolumn = "0"
This doesn't work for me for Neogit.
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.
It works by adding this, but then if you open another buffer which is a proper file it doesn't have folds anymore...
vim.wo.foldcolumn = "0"
Adding vim.opt_local.foldcolumn = '0'
instead actually solved it for me:
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,
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.
You might also want to disable the extra fold column by append this to callback function:
vim.wo.foldcolumn = "0"
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