I regularly use Vuejs and Webpack with the "@" character for file resolution, like so
import MyComponent from "@/components/MyComponent.vue";
However, I cannot use the vim gf
command to move to this file.
E447: Can't find file "/components/MyComponent.vue" in path
I have spent a couple of hours googling, messing around with the vim path and includeexpr
. I have also tried a couple of plugins, like vim-npr
or vim-gotofile
.
Has anyone encountered the same problem and found a solution?
edit
Best thing I came up with so far is this:
:set inex=substitute(v:fname,'^\\@\/','src/','')
found it in another stackoverflow thread where they where using the ~
character for this. However it doesn't work with @
. I get this error when trying to gf
E869: (NFA) Unknown operator '\@/'
My Solution
With help from @romainl I now have this set up in both after/ftplugin/vue.vim
and after/ftplugin/javascript.vim
setlocal isfname+=@-@
setlocal includeexpr=substitute(v:fname,'^@\/','src/','')
Thank you for your help!
includeexpr
" is the most important part of your question. It is missing right now.set suffixesadd=.js,.vue,.scss,.json
so that it can recognize Vue files.