I am trying to write some tests for a ftplugin
but I am encountering some issues. The following is the plugin structure:
.
├── ftplugin
│ └── python.vim
├── lib
│ └── myfunctions.vim
├── plugin
│ └── myplugin.vim
├── test_script.vim
└── testfile.py
The content of the files is as follows:
./ftplugin/python.vim
vim9script
b:foo = 'Success!'
./lib/myfunctions.vim
vim9script
export def MyFunction()
if !empty(getbufvar('%', "foo"))
echom b:foo
else
echom 'This does not seem a python file.'
endif
enddef
./plugin/myplugin.vim
vim9script
import autoload "../lib/myfunctions.vim"
command! MyCommand myfunctions.MyFunction()
testfile.py
a = 3
b = 2
c = a + b
and finally test_script.vim
vim9script
filetype plugin indent on
import "./plugin/myplugin.vim"
var filename = 'testfile.py'
exe $"edit {filename}"
exe $'buffer {filename}'
MyCommand
The above example is reproducible.
If I open Vim and source test_script.vim
from the current directory, I get the message 'This does not seem a python file.'
whereas I would like to have 'Success'
due to the fact I wish the local ftplugin
to be considered as a "standard" ftplugin
folder.
How shall I change test_script.vim
to get the wanted result?
Note: something similar was poorly asked in What options shall be set for loading ftplugins? but for some reason SO won't allow to delete such a question.