Skip to content

Commit bd66ed1

Browse files
author
Patrick Oscity
committed
Enable "gf" for jumping to a module
1 parent 62711e5 commit bd66ed1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

ftplugin/elixir.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,39 @@ endif
1818

1919
setlocal comments=:#
2020
setlocal commentstring=#\ %s
21+
22+
function! GetElixirFilename(word)
23+
let word = a:word
24+
25+
" get first thing that starts uppercase, until the first space or end of line
26+
let word = substitute(word,'^\s*\(\u[^ ]\+\).*$','\1','g')
27+
28+
" remove any trailing characters that don't look like a nested module
29+
let word = substitute(word,'\.\U.*$','','g')
30+
31+
" replace module dots with slash
32+
let word = substitute(word,'\.','/','g')
33+
34+
" remove any special chars
35+
let word = substitute(word,'[^A-z0-9-_/]','','g')
36+
37+
" convert to snake_case
38+
let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g')
39+
let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g')
40+
let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g')
41+
let word = substitute(word,'-','_','g')
42+
let word = tolower(word)
43+
44+
return word
45+
endfunction
46+
47+
let &l:path =
48+
\ join([
49+
\ getcwd().'/lib',
50+
\ getcwd().'/src',
51+
\ getcwd().'/deps/**/lib',
52+
\ getcwd().'/deps/**/src',
53+
\ &g:path
54+
\ ], ',')
55+
setlocal includeexpr=GetElixirFilename(v:fname)
56+
setlocal suffixesadd=.ex,.exs,.eex,.erl,.yrl,.hrl

0 commit comments

Comments
 (0)