File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import mymodule
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+
4+ sys .path .append ('../src/' )
5+
6+ import calculator
17import vim
28
39def foo ():
@@ -6,7 +12,7 @@ def foo():
612 return "Hello World!\n \n "
713
814def bar (x , y ):
9- return str (int (x ) + int (y ))
15+ return calculator . sum (int (x ), int (y ))
1016
1117def none ():
1218 print ('ok' )
Original file line number Diff line number Diff line change 11" myplugin.vim
22
3- let current_dir = expand (' <sfile>:p:h' )
4- let relative_path = ' ../python'
5- let g: myplugin_python_dir = resolve (current_dir . ' /' . relative_path)
6- set rtp += myplugin_python_dir
3+ let current_dir = expand (' <sfile>:p:h/' )
74
5+ let g: include_path = resolve (current_dir . ' /' . ' ../include' )
6+ let g: src_path = resolve (current_dir . ' /' . ' ../src' )
87
9- function ! CallPythonFunction (command_name, module_name, ... )
10- python3 << EOF
8+ let $PYTHONPATH = expand (" %:p:h" ) . " :" . $PYTHONPATH
9+
10+ python3 << EOF
1111import sys
12- sys.path .append (vim .eval (' g:myplugin_python_dir' ))
12+
13+ sys.path .append (vim .eval (' g:include_path' ))
14+ sys.path .append (vim .eval (' g:src_path' ))
1315
1416import vim
17+ EOF
1518
19+ function ! CallPythonFunction (command_name, module_name, ... )
20+ python3 << EOF
1621# Get the function name and arguments from Vim script
1722args = vim .eval (' a:000' )
1823
@@ -39,12 +44,11 @@ endfunction
3944
4045function ! CreatePythonCommands ()
4146 python3 << EOF
42- import vim
4347import os
4448import importlib.util
4549
4650# Get the Python directory from Vim script
47- python_dir = vim .eval (' g:myplugin_python_dir ' )
51+ python_dir = vim .eval (' g:include_path ' )
4852
4953# Find all Python modules in the directory
5054modules = [f for f in os.listdir (python_dir) if f .endswith (' .py' ) and not f .startswith (' __' )]
Original file line number Diff line number Diff line change 1+ import calculator
Original file line number Diff line number Diff line change 1+ def sum (x : int , y : int ):
2+ return x + y
You can’t perform that action at this time.
0 commit comments