{"action":"created","issue":{"url":"https://api.github.com/repos/lervag/vimtex/issues/598","repository_url":"https://api.github.com/repos/lervag/vimtex","labels_url":"https://api.github.com/repos/lervag/vimtex/issues/598/labels{/name}","comments_url":"https://api.github.com/repos/lervag/vimtex/issues/598/comments","events_url":"https://api.github.com/repos/lervag/vimtex/issues/598/events","html_url":"https://github.com/lervag/vimtex/issues/598","id":184724892,"number":598,"title":"vimtex-indent causing slowdowns","user":{"login":"thomasteoh","id":7086928,"avatar_url":"https://avatars.githubusercontent.com/u/7086928?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasteoh","html_url":"https://github.com/thomasteoh","followers_url":"https://api.github.com/users/thomasteoh/followers","following_url":"https://api.github.com/users/thomasteoh/following{/other_user}","gists_url":"https://api.github.com/users/thomasteoh/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasteoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasteoh/subscriptions","organizations_url":"https://api.github.com/users/thomasteoh/orgs","repos_url":"https://api.github.com/users/thomasteoh/repos","events_url":"https://api.github.com/users/thomasteoh/events{/privacy}","received_events_url":"https://api.github.com/users/thomasteoh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2016-10-23T23:48:58Z","updated_at":"2016-12-15T18:22:44Z","closed_at":"2016-10-31T20:33:24Z","body":"### Explain the issue\n\nFirstly thank you for vimtex! I've been noticing for a document of mine that vimtex-indent has been causing slowdowns, locking up vim for noticeable periods\n#1. Steps to reproduce\n\nProgressive slowdown as more curly brackets are introduced. Noticeable after a few hundred. \n#2. Expected behaviour\n\nMinimal slowdowns\n#3. Observed behaviour\n\nMy log profile has the following entries:\n\n```\n\nFUNCTION  VimtexIndent()\nCalled 2 times\nTotal time:  14.537858\n Self time:   0.001414\n\ncount  total (s)   self (s)\n    2   0.007878   0.000043   let l:prev_lnum = s:get_prev_line(prevnonblank(a:lnum - 1))\n    2              0.000015   if l:prev_lnum == 0 | return indent(a:lnum) | endif\n\n                              \" Get current and previous line and remove comments\n    2              0.000062   let l:line = substitute(getline(a:lnum), '\\\\\\@<!%.*', '', '')\n    2              0.000263   let l:prev_line = substitute(getline(l:prev_lnum),   '\\\\\\@<!%.*', '', '')\n\n                              \" Check for verbatim modes\n    2   0.013373   0.000028   if s:is_verbatim(l:line, a:lnum)\n                                return empty(l:line) ? indent(l:prev_lnum) : indent(a:lnum)\n                              endif\n\n                              \" Align on ampersands\n    2              0.000025   if l:line =~# '^\\s*&' && l:prev_line =~# '\\\\\\@<!&.*'\n                                return indent(a:lnum) + match(l:prev_line, '\\\\\\@<!&') - stridx(l:line, '&')\n                              endif\n\n                              \" Use previous indentation for comments\n    2              0.000010   if l:line =~# '^\\s*%'\n                                return indent(a:lnum)\n                              endif\n\n                              \" Ensure previous line does not start with ampersand\n    2   0.007993   0.000033   let l:prev_lnum = s:get_prev_line(l:prev_lnum, 'ignore-ampersands')\n    2              0.000011   if l:prev_lnum == 0 | return 0 | endif\n    2              0.000281   let l:prev_line = substitute(getline(l:prev_lnum), '\\\\\\@<!%.*', '', '')\n\n                              \" Indent environments, delimiters, and tikz\n    2              0.000011   let l:ind = indent(l:prev_lnum)\n    2   0.000703   0.000507   let l:ind += s:indent_envs(l:line, l:prev_line)\n    2  14.506685   0.000032   let l:ind += s:indent_delims(l:line, a:lnum, l:prev_line, l:prev_lnum)\n    2   0.000483   0.000028   let l:ind += s:indent_tikz(l:prev_lnum, l:prev_line)\n    2              0.000004   return l:ind\n\n\nFUNCTION  vimtex#util#in_syntax()\nCalled 1821 times\nTotal time:  14.382734\n Self time:  14.382734\n\ncount  total (s)   self (s)\n\n                              \" Usage: vimtex#util#in_syntax(name, [line, col])\n\n                              \" Get position and correct it if necessary\n 1821              0.016471   let l:pos = a:0 > 0 ? [a:1, a:2] : [line('.'), col('.')]\n 1821              0.007665   if mode() ==# 'i'\n 1821              0.011517     let l:pos[1] -= 1\n 1821              0.003780   endif\n 1821              0.018468   call map(l:pos, 'max([v:val, 1])')\n\n                              \" Check syntax at position\n 1821             14.311981   return match(map(synstack(l:pos[0], l:pos[1]),          \"synIDattr(v:val, 'name')\"),      '^' . a:name) >= 0\n```\n\nI've noticed that disabling matching parenthesis and indentation in my .vimrc resolves much of the slowdown. \n\n```\nlet g:vimtex_motion_matchparen = 0\nlet g:vimtex_indent_enabled = 0\n```\n### Minimal vimrc file\n\n``` vim\ncall plug#begin('~/.vim/plugged')\n\n\" A modern vim plugin for editing LaTeX files.\nPlug 'lervag/vimtex'\n\n\" Add plugins to &runtimepath\ncall plug#end()\n\n\" Vimtex settings\nlet g:tex_flavor = 'latex'\nlet g:vimtex_view_method='mupdf'\n```\n"},"comment":{"url":"https://api.github.com/repos/lervag/vimtex/issues/comments/267402023","html_url":"https://github.com/lervag/vimtex/issues/598#issuecomment-267402023","issue_url":"https://api.github.com/repos/lervag/vimtex/issues/598","id":267402023,"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":"2016-12-15T18:22:44Z","updated_at":"2016-12-15T18:22:44Z","body":"I think your option 1 is the best approach. Checking the environment is cheap, or at least much cheaper (order of magnitude) than the current `s:split` method. In this case, we have two types of delimiter indentations:\r\n\r\n1. In normal text, we indent on braces. Inline math is ignored.\r\n2. In displayed math, we indent similar to how it is done now.\r\n\r\nThis change would simplify the indendation algorithm a great deal, and I think it would make things much faster. I would prefer not to add more options, so an important question is if this change would remove a feature that someone would find indispensible."}}
{"actor":{"display_login":"lervag"}}