I want to go to a vue component file.
Vue component filenames are written in PascalCase: ExampleComponent.vue
In html (or in my case blade.php
) the ExampleComponent.vue
is instantiated
by <example-component>
(kebab-case).
When my cursor is over <example-component>
I get E447: Can't find file "container-gallery" in path
In the docs is written:
If the file can't be found, 'includeexpr' is used to
modify the name and another attempt is done.
So my Question is how do I use includeexpr
in order to change from
example-component
to
resources/js/components/ExampleComponent.vue
Further research pointed me to the substitute function:
:set includeexpr=substitute(v:fname, ..... )
but then I would need to preprocess the v:fname
variable.
A hint how to tackle that problem would be highly appreciated.
path
includesresources/js/components
andsuffixesadd
includes.vue
; thenincludeexpr
only has to changeexample-component
toExampleComponent
. This might be doable as a simple substitute; if not, you might be able to grab some code from tpope/abolish (the coercion mappings do similar transformations)path
and thesuffixesadd
and it works forExampleComponent
. Now in order to transform kebab-case to PascalCase I used regex.echo substitute('kebab-case','\(\w\+\)\(\-\)\(\w\+\)','\u\1\u\3','')
prints KebabCase. Butsetlocal includeexpr=substitute(v:fname,'\(\w\+\)\(\-\)\(\w\+\)','\u\1\u\3','')
does not work. what am I missing?