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

Cannot parse inline python

Open Kuniwak opened this issue 8 years ago • 2 comments

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

Kuniwak avatar Dec 07 '16 01:12 Kuniwak

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.

mattn avatar May 25 '17 17:05 mattn

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

blueyed avatar Aug 06 '17 19:08 blueyed