I've tried all the solutionshttps://stackoverflow.com/questions/4976776/how-to-get-path-to-the-current-vimscript-being-executed/53274039#53274039 which was posted 7 years ago and none are working for me in the current (2018) MacVim (8.1) or neovim (0.3.1). Since my question there keeps being deleted, I decided to ask in a new question.
Has something changed in Vim since the last answer 7 years ago? All of these solutions are giving me the current file's location and not the location of the script. Is SpaceVim effecting how these functions work?
This is the code I'm trying to fix:
function! TeaCodeExpand()
<<some code>>
echom fnamemodify(resolve(expand('<sfile>:p')), ':h')
<<other code>>
endfunction
I have an echom to show the path that should be the current script file, but it always returns the currently edited file. The next line is to execute an AppleScript in the directory above the vimscript file. I can hard code the path and everything works fine. But, I can't get it to work as is. The full code is here: github.com/raguay/TeaCode-Vim-Extension