vim-jp / vim-vimlparser

Vim script parser
Other
165 stars 25 forks source link

Cannot parse inline python #33

Open Kuniwak opened 7 years ago

Kuniwak commented 7 years ago

vim-vimlparse cannot parse the script, but Vim can run it well:

let s:inline_python = 'python << EOF'
exec s:inline_python
import os
EOF

And it raises the following error:

vimlparser: E492: Not an editor command: import os: line 3 col 1
mattn commented 7 years ago

This is impossible to parse.

function! s:foo()
  let let s:inline_python = 'echo "I love python"'
endfunction

let s:inline_python = 'python << EOF'
call s:foo()
exec s:inline_python
import os
EOF

In this case, import os should be parsed as VimL not python.

blueyed commented 7 years ago

But the following could be supported:

let cmd_exec = 'python3'
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'

PythonJedi << EOF
try:
    import foo
except Exception as excinfo:
    pass
EOF

From a quick look this would require "only" to handle the heredoc for user commands, which is currently done in parse_cmd_lua: https://github.com/Kuniwak/vint/blob/f78b0f034a70aa2d39130f6c5a3a21c6c61683e2/vint/_bundles/vimlparser.py#L1106