{"action":"created","issue":{"url":"https://api.github.com/repos/lervag/vimtex/issues/283","labels_url":"https://api.github.com/repos/lervag/vimtex/issues/283/labels{/name}","comments_url":"https://api.github.com/repos/lervag/vimtex/issues/283/comments","events_url":"https://api.github.com/repos/lervag/vimtex/issues/283/events","html_url":"https://github.com/lervag/vimtex/issues/283","id":118091996,"number":283,"title":"untangle fold setup","user":{"login":"Konfekt","id":7195553,"avatar_url":"https://avatars.githubusercontent.com/u/7195553?v=3","gravatar_id":"","url":"https://api.github.com/users/Konfekt","html_url":"https://github.com/Konfekt","followers_url":"https://api.github.com/users/Konfekt/followers","following_url":"https://api.github.com/users/Konfekt/following{/other_user}","gists_url":"https://api.github.com/users/Konfekt/gists{/gist_id}","starred_url":"https://api.github.com/users/Konfekt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Konfekt/subscriptions","organizations_url":"https://api.github.com/users/Konfekt/orgs","repos_url":"https://api.github.com/users/Konfekt/repos","events_url":"https://api.github.com/users/Konfekt/events{/privacy}","received_events_url":"https://api.github.com/users/Konfekt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-20T17:54:01Z","updated_at":"2015-11-20T22:15:05Z","closed_at":null,"body":"To use vimtex expression folding ideally\r\n```vim\r\nsetlocal fdm=expr\r\nsetlocal foldexpr=vimtex#fold#level(v:lnum)\r\n```\r\nshould suffice. \r\n\r\nHowever`vimtex#fold#level(v:lnum)` needs `g:vimtex_fold_enabled=1` since only then\r\n```vim\r\n    g:vimtex_fold_preamble, b:vimtex_fold_parts, g:vimtex_fold_envs.\r\n```\r\nare defined. However, `g:vimtex_fold_enabled=1` also overwrites `foldtext` and sets up `autocmd`s.\r\n\r\nSo how about defining \r\n```vim\r\n    g:vimtex_fold_preamble, b:vimtex_fold_parts, g:vimtex_fold_envs.\r\n```\r\nalways (and documenting the value of `foldexpr`)? \r\n\r\nThen `g:vimtex_fold_enabled` sets up\r\n```vim\r\n  setlocal foldmethod=expr\r\n  setlocal foldexpr=vimtex#fold#level(v:lnum)\r\n  setlocal foldtext=vimtex#fold#text()\r\n```\r\nAlso, instead of the many autocmd's, even on `CursorMove` how about simply using https://github.com/Konfekt/FastFold using less frequent autocmd's ? "},"comment":{"url":"https://api.github.com/repos/lervag/vimtex/issues/comments/158541179","html_url":"https://github.com/lervag/vimtex/issues/283#issuecomment-158541179","issue_url":"https://api.github.com/repos/lervag/vimtex/issues/283","id":158541179,"user":{"login":"lervag","id":998898,"avatar_url":"https://avatars.githubusercontent.com/u/998898?v=3","gravatar_id":"","url":"https://api.github.com/users/lervag","html_url":"https://github.com/lervag","followers_url":"https://api.github.com/users/lervag/followers","following_url":"https://api.github.com/users/lervag/following{/other_user}","gists_url":"https://api.github.com/users/lervag/gists{/gist_id}","starred_url":"https://api.github.com/users/lervag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lervag/subscriptions","organizations_url":"https://api.github.com/users/lervag/orgs","repos_url":"https://api.github.com/users/lervag/repos","events_url":"https://api.github.com/users/lervag/events{/privacy}","received_events_url":"https://api.github.com/users/lervag/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T22:15:05Z","updated_at":"2015-11-20T22:15:05Z","body":"I agree the folding options are a little bit too complex. Personally, I use the default options, which I think is similar to how FastFold functions. With `g:vimtex_fold_automatic`, we keep the `foldmethod=expr`, but toggles it when entering insert mode.\r\n\r\nThe manual (and default) mode uses a self destructive autocommand in order to update the folds when a file is loaded. Else there are no autocommands involved.\r\n\r\nI'm a bit reluctant to make vimtex fully dependent on FastFold. However, I think I could consider to remove the automatic mode, and instead make this a \"clean\" `expr` mode.\r\n\r\nRegarding the other part, I agree: the options should be defined also when the folding is disabled."}}