Konfekt/FastFold

Conflict with taglist

ktkimit opened this issue · 29 comments

When I use this with "taglist" plugin, there is a problem.

If I open "Tlist" with several files as buffers, and if I move to other buffer by typing "bp", I got sometimes an error message like:


Error detected while processing fuction 30_Tlist_Refresh[93]..30_Tlist_Window_Refresh_File[140]..30_Tlist_Create_Folds_For_File:
line 10:
E350: Cannot create fold with current 'foldmethod'
E350: Cannot create fold with current 'foldmethod'
E350: Cannot create fold with current 'foldmethod'
line 15:
E350: Cannot create fold with current 'foldmethod'


Also, in the Tlist, all the foldings are removed (setting is "foldmethod=syntax").

I will appreciate your comments.

Thank you!

Does it go away by commenting out

    if exists('##OptionSet')
      autocmd OptionSet foldmethod call s:UpdateBuf(0)
    endif

?

By default, master now disables this autocmd. Give it a try please.

I re-installed fastfold, but it still does not work.

Do you have foldmethod=syntax in your vimrc? Could you paste all settings of Fastfold and taglist? Which version of taglist is it?

I do not give any settings for Fastfold and taglist. The version of taglist is "February 26, 2013: Version 4.6" which is the latest one.

Yes, I have "foldmethod=syntax" in my vimrc.

Ok, so does it go away if the setting is removed? It's hard to pinpoint the conflicting autocmds and after all set foldmethod=global is a bad suggestion as this issue shows. It must be set for each file type.

See, the correct foldmethod for the taglist filetype is that set by taglist, manual, but somehow at some point fastfold uses the global one which is wrong as the filetype must know how to handle it.

Which setting do you mean? I have the problem when I have "foldmethod=syntax" in my vimrc.

Yes, supposedly it goes away without. Because at some point the foldmethod is set to syntax and erroneously conserved by FastFold.

And the setting is too coarse. Because many file types do not support syntax folding.

The thing is that fixing it seems impossible through FastFold other than by adding exceptions for Taglist.

Instead, the clean route is explicitely enabling foldmethod syntax for all file types you use.

If setglobal fdm=syntax must be kept, then there is now

let g:fastfold_skip_filetypes = [ 'taglist' ]

to work around this issue.

Thanks Konfekt, with the option you gave, it becomes better, but it still sometimes gives the same error ( not many as before).

With the global foldmethod syntax? Better unset it. There's a warning against it in the docs now.

If there is an error, what's the filetype like?

In my _vimrc, I have

.....
let g:fastfold_skip_filetypes = [ 'taglist' ]
....
autocmd bufnewfile,bufread .f,.f90 set foldmethod=syntax
....

When I make FORTRAN code, I use taglist with it. What do you mean by the global foldmethod syntax?

Ah, the global foldmethod is that set outside of autocmds.

You should change the autocmd to

autocmd bufnewfile,bufread *.{f,.f90} setlocal foldmethod=syntax

to make sure everything works as intended.

It looks like it works!

Thank you Konfekt, you are really helpful~

No problem! Seems the previous erroneous autocmd pattern erroneously set the foldmethod to syntax in the taglist buffers as well.

When asking for a global syntax foldmethod setting, I thought it was for all buffers. Turns out the autocmd pattern was just so that it also set the foldmethod of the taglist buffers.

I thought that it solves, but I got the same error again even if I set "autocmd bufnewfile,bufread *.{f,.f90} setlocal foldmethod=syntax"

That should read

autocmd bufnewfile,bufread *.{f,f90} setlocal foldmethod=syntax

That is, f90 instead of .f90. Are you using let g:fastfold_skip_filetypes = [ 'taglist' ] ?

I am using the correct setting:

autocmd bufnewfile,bufread *.{f,f90} setlocal foldmethod=syntax

and also using

let g:fastfold_skip_filetypes = [ 'taglist' ]

Can you post the output of :set filetype? when the error appears?

When I type it in the taglist's window it says "filetype=taglist", but when I type it in the fortran's window it says "filetype=fortran".

The error appears when I move between such two windows or when I move the other buffers by using "bn" or "bp". Also, foldings disappear in the taglist's window.

Try putting

autocmd bufnewfile,bufread *.{f,f90} setlocal foldmethod=syntax

Try putting

autocmd bufnewfile,bufread *.{f,f90} setlocal filetype fortran

into a ftdetect/fortran.vim file and

setlocal foldmethod=syntax

into ftplugin/fortran.vim

Instead of the current autocmd. Does that change anything ?

There is no such file in ftdetect folder.

I put setlocal foldmethod=syntax into ftplugin/fortran.vim, but there is no change.

Yeah, you should create it if it does not exist. Or does already recognize these file extensions as fortran files ?

Sorry for late reply. I think so. It still does not work.

Well, I think in all honesty, I probably won't resolve this. Would you mind updating taglist by

https://github.com/majutsushi/tagbar ?

The file type skipping was broken and has been fixed. If you could try again?