Стоит отметить, что вышеуказанное решение будет работать только вне функции.
Это не даст желаемого результата:
function! MyFunction()
let s:current_file=expand('<sfile>:p:h')
echom s:current_file
endfunction
Но это будет:
let s:current_file=expand('<sfile>')
function! MyFunction()
echom s:current_file
endfunction
Вот полное решение оригинального вопроса ОП:
let s:path = expand('<sfile>:p:h')
function! MyPythonFunction()
import sys
import os
script_path = vim.eval('s:path')
lib_path = os.path.join(script_path, '.')
sys.path.insert(0, lib_path)
import vim
import plugin_helpers
plugin_helpers.do_some_cool_stuff_here()
vim.command("badd %(result)s" % {'result':plugin_helpers.get_result()})
EOF
endfunction