diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2016-05-02 10:42:37 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2016-05-02 10:42:37 +0200 |
commit | 5dd1a7e83966c92d220073185f1738dfe441f59e (patch) | |
tree | 9c4bee389a51a9bb111dcc894c9db0f6d1809d81 /ftplugin/elixir.vim | |
parent | bc098370c1bb81840734f5764f431dee270e75ce (diff) | |
download | vim-polyglot-5dd1a7e83966c92d220073185f1738dfe441f59e.tar.gz vim-polyglot-5dd1a7e83966c92d220073185f1738dfe441f59e.zip |
Update
Diffstat (limited to 'ftplugin/elixir.vim')
-rw-r--r-- | ftplugin/elixir.vim | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/ftplugin/elixir.vim b/ftplugin/elixir.vim index 04388efd..225e2772 100644 --- a/ftplugin/elixir.vim +++ b/ftplugin/elixir.vim @@ -5,7 +5,6 @@ if (exists("b:did_ftplugin")) endif let b:did_ftplugin = 1 - " Matchit support if exists("loaded_matchit") && !exists("b:match_words") let b:match_ignorecase = 0 @@ -21,4 +20,42 @@ endif setlocal comments=:# setlocal commentstring=#\ %s +function! GetElixirFilename(word) + let word = a:word + + " get first thing that starts uppercase, until the first space or end of line + let word = substitute(word,'^\s*\(\u[^ ]\+\).*$','\1','g') + + " remove any trailing characters that don't look like a nested module + let word = substitute(word,'\.\U.*$','','g') + + " replace module dots with slash + let word = substitute(word,'\.','/','g') + + " remove any special chars + let word = substitute(word,'[^A-z0-9-_/]','','g') + + " convert to snake_case + let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') + let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') + let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g') + let word = substitute(word,'-','_','g') + let word = tolower(word) + + return word +endfunction + +let &l:path = + \ join([ + \ getcwd().'/lib', + \ getcwd().'/src', + \ getcwd().'/deps/**/lib', + \ getcwd().'/deps/**/src', + \ &g:path + \ ], ',') +setlocal includeexpr=GetElixirFilename(v:fname) +setlocal suffixesadd=.ex,.exs,.eex,.erl,.yrl,.hrl + +setlocal formatoptions-=t formatoptions+=croqlj + endif |