2015-07-18 17:05:45 -04:00
|
|
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1
|
|
|
|
|
2013-09-12 11:31:56 -04:00
|
|
|
if (exists("b:did_ftplugin"))
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let b:did_ftplugin = 1
|
|
|
|
|
|
|
|
" Matchit support
|
|
|
|
if exists("loaded_matchit") && !exists("b:match_words")
|
|
|
|
let b:match_ignorecase = 0
|
|
|
|
|
2016-01-22 03:08:00 -05:00
|
|
|
let b:match_words = '\:\@<!\<\%(do\|fn\)\:\@!\>' .
|
2013-09-12 11:31:56 -04:00
|
|
|
\ ':' .
|
|
|
|
\ '\<\%(else\|elsif\|catch\|after\|rescue\)\:\@!\>' .
|
|
|
|
\ ':' .
|
|
|
|
\ '\:\@<!\<end\>' .
|
|
|
|
\ ',{:},\[:\],(:)'
|
|
|
|
endif
|
|
|
|
|
|
|
|
setlocal comments=:#
|
|
|
|
setlocal commentstring=#\ %s
|
2015-07-18 17:05:45 -04:00
|
|
|
|
2016-05-02 04:42:37 -04:00
|
|
|
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
|
|
|
|
|
2016-07-05 03:53:49 -04:00
|
|
|
silent! setlocal formatoptions-=t formatoptions+=croqlj
|
2016-05-02 04:42:37 -04:00
|
|
|
|
2015-07-18 17:05:45 -04:00
|
|
|
endif
|