|
18 | 18 |
|
19 | 19 | setlocal comments=:#
|
20 | 20 | 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