Closed wintermute-cell closed 2 years ago
This appears to be a bug in Telescope: https://github.com/nvim-telescope/telescope.nvim/issues/1277.
As a temporary workaround, maybe you could add an autocommand that updates folds after the file is loaded:
autocmd BufRead *.py normal zx
or perhaps
autocmd FileType python normal zx
I don't use nvim, nor am I familiar with Telescope, so it's not easy for me to test this myself, but something like that may help if you can't live with typing zx
manually.
Knowing that's an active bug with telescope is answer enough for me! Thank you for finding the telescope issue that i apparently couldn't find, and I'll try out your temporary solution asap.
autocmd BufRead *.py normal zx zR
works perfectly, opening the file with all folds open. Thanks again!
telescope.setup({
pickers = {
find_files = {
hidden = true,
attach_mappings = function(_)
action_set.select:enhance({
post = function()
vim.cmd(":normal! zx")
end,
})
return true
end,
},
},
...
@danielnehrig your solution, unfortunately, does not work.
The solution I use:
autocmd BufRead * autocmd BufWinEnter * ++once normal! zx
or the same but with new autocmd API:
vim.api.nvim_create_autocmd('BufRead', {
callback = function()
vim.api.nvim_create_autocmd('BufWinEnter', {
once = true,
command = 'normal! zx'
})
end
})
BufWinEnter
needed to take into account the modeline settings.
And why it not used alone but after BufRead
, because BufWinEnter
need to be executed only once for each buffer.
Setup
I'm running nvim v0.6.0.
The following values are inspected to be set correctly:
filetype=python
foldexpr=SimpylFold#FoldExpr(v:lnum)
foldmethod=expr
:scriptnames
contains (among unrelated others):I have done no SimpylFold related configuration (not necessary afaik?).
Problem
When opening a .py file in nvim, and trying to toggle a fold with
za
(or usingzo
,zc
, etc..), no folding occurs, but nvim prints the errorE490: No fold found
. After usingzx
, all possible folds become folded, except the one where the cursor is located at. After this, folding withza
works as intended.EDIT: (I'm dumb not to test this earlier) The issue only occurs when opening a file through telescope (https://github.com/nvim-telescope/telescope.nvim). What could be going wrong here?