go-vimlparser icon indicating copy to clipboard operation
go-vimlparser copied to clipboard

Errors in parsing

Open junkblocker opened this issue 8 years ago • 6 comments

Thanks for making viml parsing super fast! I have a bug: For the following code from vim-go, the following issue with parsing is seen:

/Users/xxxxxxxx/.vim/neobundles/vim-go/autoload/go/coverage.vim:92:1: vimlparser: E171: Missing :endif:    ENDFUNCTION
" Clear clears and resets the buffer annotation matches
function! go#coverage#Clear()
  " only reset the syntax if the user has syntax enabled
  if !empty(&syntax)
    if exists("g:syntax_on") | syntax enable | endif
  endif

  if exists("s:toggle") | let s:toggle = 0 | endif

  " remove the autocmd we defined 
  if exists("#BufWinLeave#<buffer>") 
    autocmd! BufWinLeave <buffer>
  endif

  call clearmatches()
endfunction

junkblocker avatar Sep 27 '16 03:09 junkblocker

This is a vimlparser problem.

It fails to parse if 1 | syntax enable | endif. If you change syntax enable to let x = 1 or something, vimlparser can parse it, so it might be the problem of parsing syntax command with if and |.

haya14busa avatar Sep 27 '16 21:09 haya14busa

I fixed it by #21 (it's somewhat workaround though...)

haya14busa avatar Sep 27 '16 23:09 haya14busa

Thanks, @haya14busa, it does seem to cause or detect newer issues.

syn match pythonError       "[&|]\{2,}" display
.vim/syntax/python.vim:135:28: vimlparser: E492: Not an editor command: ]\{2,}" display
  syntax match qfFileName /^\zs\S[^|]\+\/\ze[^|\/]\+\/[^|\/]\+|/ conceal cchar=+
.vim/after/ftplugin/qf.vim:124:37: vimlparser: E492: Not an editor command: ]\+\/\ze[^|\/]\+\/[^|\/]\+|/ conceal cchar=+

are a couple of examples. I am doing quick tests (thanks to go-vimlparser 's speed) like so

vimlparser .vim/**/*.vim 2>&1 | grep -E ':\d+:\d+: vimlparser:' | vim -

junkblocker avatar Sep 27 '16 23:09 junkblocker

Thanks! hmm... it seems to fail to handle | in string or //.

haya14busa avatar Sep 27 '16 23:09 haya14busa

I fixed it. https://github.com/haya14busa/go-vimlparser/pull/22

Can you please update and try again?

I also runs vimlparser commands for all vim script under .vim and it worked.

haya14busa avatar Sep 28 '16 00:09 haya14busa

Thanks for the quick turnaround! Seems most of the problems are gone and only syn region is slightly broken. May I suggest running it on any vim plugin manager bundle directories you have (and try not to be sad when you see all the broken code go-vimlparser detects in so many plugins :( :) ) for more coverage? Here are some issues on some of the plugins I use:

From HybridText:

syn region txtBlock start=+^ *|+ end=+$+
.vim/neobundles/HybridText/syntax/hybrid.vim:213:34: vimlparser: E580: :endif without :if

From jedi-vim:

    syn region rstPythonRegion start=/^\v {4}/ end=/\v^( {4}|\n)@!/ contains=@rstPythonScript
.vim/neobundles/jedi-vim/autoload/jedi.vim:312:62: vimlparser: E10: \\ should be followed by /, ? or &

From vim-go a very interesting expression:

      % | " Couldn't detect gofmt error format, output errors
.vim/neobundles/vim-go/autoload/go/fmt.vim:185:9: vimlparser: E492: Not an editor command: | " Couldn't detect gofmt error format, output errors

However that runs fine in vim, just cat'ing the current source file.

There is a different issue with embedded python code but that probably should be dealt with in a separate bug.

junkblocker avatar Sep 28 '16 01:09 junkblocker