This commit is contained in:
Jeff Clement 2025-03-08 20:32:06 -07:00
parent 6471e799a8
commit 931e9d4aee
Signed by: jeff
GPG key ID: 3BCB43A3F0E1D7DA
93 changed files with 6881 additions and 8 deletions

View file

@ -0,0 +1,117 @@
if exists("b:did_ftplugin")
finish
endif
let s:save_cpo = &cpo
set cpo-=C
let s:undo_ftplugin = ""
let s:browsefilter = "All Files (*.*)\t*.*\n"
let s:match_words = ""
if !exists("g:eelixir_default_subtype")
let g:eelixir_default_subtype = "html"
endif
if !exists("b:eelixir_subtype")
let s:lines = join(getline(1, 5) + [getline('$')], "\n")
let b:eelixir_subtype = matchstr(s:lines,'eelixir_subtype=\zs\w\+')
if b:eelixir_subtype == ''
let b:eelixir_subtype = matchstr(&filetype,'^eex\.\zs\w\+')
endif
if b:eelixir_subtype == ''
let b:eelixir_subtype = matchstr(&filetype,'^heex\.\zs\w\+')
endif
if b:eelixir_subtype == ''
let b:eelixir_subtype = matchstr(&filetype,'^leex\.\zs\w\+')
endif
if b:eelixir_subtype == ''
let b:eelixir_subtype = matchstr(&filetype,'^sface\.\zs\w\+')
endif
if b:eelixir_subtype == ''
let b:eelixir_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eex\|\.heex\|\.leex\|\.sface\|\.eelixir\)\+$','',''),'\.\zs\w\+$')
endif
if b:eelixir_subtype == 'ex'
let b:eelixir_subtype = 'elixir'
elseif b:eelixir_subtype == 'exs'
let b:eelixir_subtype = 'elixir'
elseif b:eelixir_subtype == 'yml'
let b:eelixir_subtype = 'yaml'
elseif b:eelixir_subtype == 'js'
let b:eelixir_subtype = 'javascript'
elseif b:eelixir_subtype == 'txt'
" Conventional; not a real file type
let b:eelixir_subtype = 'text'
elseif b:eelixir_subtype == ''
let b:eelixir_subtype = g:eelixir_default_subtype
endif
endif
if exists("b:eelixir_subtype") && b:eelixir_subtype != ''
exe "runtime! ftplugin/".b:eelixir_subtype.".vim ftplugin/".b:eelixir_subtype."_*.vim ftplugin/".b:eelixir_subtype."/*.vim"
else
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
endif
unlet! b:did_ftplugin
" Override our defaults if these were set by an included ftplugin.
if exists("b:undo_ftplugin")
let s:undo_ftplugin = b:undo_ftplugin
unlet b:undo_ftplugin
endif
if exists("b:browsefilter")
let s:browsefilter = b:browsefilter
unlet b:browsefilter
endif
if exists("b:match_words")
let s:match_words = b:match_words
unlet b:match_words
endif
runtime! ftplugin/elixir.vim ftplugin/elixir_*.vim ftplugin/elixir/*.vim
let b:did_ftplugin = 1
" Combine the new set of values with those previously included.
if exists("b:undo_ftplugin")
let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
endif
if exists ("b:browsefilter")
let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
endif
if exists("b:match_words")
let s:match_words = b:match_words . ',' . s:match_words
endif
" Load the combined list of match_words for matchit.vim
if exists("loaded_matchit")
let b:match_words = s:match_words
endif
if !exists('b:surround_45')
" When using surround `-` (ASCII 45) would provide `<% selection %>`
let b:surround_45 = "<% \r %>"
endif
if !exists('b:surround_61')
" When using surround `=` (ASCII 61) would provide `<%= selection %>`
let b:surround_61 = "<%= \r %>"
endif
if !exists('b:surround_35')
" When using surround `#` (ASCII 35) would provide `<%# selection %>`
let b:surround_35 = "<%# \r %>"
endif
if !exists('b:surround_123')
" When using surround `{` (ASCII 123) would provide `{{ selection }}`
let b:surround_123 = "{{ \r }}"
endif
if !exists('b:surround_5')
" When using surround `<C-e>` (ASCII 5 `ENQ`) would provide `<% selection %>\n<% end %>`
let b:surround_5 = "<% \r %>\n<% end %>"
endif
setlocal comments=:<%#
setlocal commentstring=<%#\ %s\ %>
let b:undo_ftplugin = "setl cms< " .
\ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
let &cpo = s:save_cpo

View file

@ -0,0 +1,52 @@
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
let b:match_words = '\:\@<!\<\%(do\|fn\)\:\@!\>' .
\ ':' .
\ '\<\%(else\|elsif\|catch\|after\|rescue\)\:\@!\>' .
\ ':' .
\ '\:\@<!\<end\>' .
\ ',{:},\[:\],(:)'
endif
setlocal shiftwidth=2 softtabstop=2 expandtab iskeyword+=!,?
setlocal comments=:#
setlocal commentstring=#\ %s
let &l:path =
\ join([
\ 'lib/**',
\ 'src/**',
\ 'test/**',
\ 'deps/**/lib/**',
\ 'deps/**/src/**',
\ &g:path
\ ], ',')
setlocal includeexpr=elixir#util#get_filename(v:fname)
setlocal suffixesadd=.ex,.exs,.eex,.heex,.leex,.sface,.erl,.xrl,.yrl,.hrl
let &l:define = 'def\(macro\|guard\|delegate\)\=p\='
silent! setlocal formatoptions-=t formatoptions+=croqlj
let b:block_begin = '\<\(do$\|fn\>\)'
let b:block_end = '\<end\>'
nnoremap <buffer> <silent> <expr> ]] ':silent keeppatterns /'.b:block_begin.'<CR>'
nnoremap <buffer> <silent> <expr> [[ ':silent keeppatterns ?'.b:block_begin.'<CR>'
nnoremap <buffer> <silent> <expr> ][ ':silent keeppatterns /'.b:block_end .'<CR>'
nnoremap <buffer> <silent> <expr> [] ':silent keeppatterns ?'.b:block_end .'<CR>'
onoremap <buffer> <silent> <expr> ]] ':silent keeppatterns /'.b:block_begin.'<CR>'
onoremap <buffer> <silent> <expr> [[ ':silent keeppatterns ?'.b:block_begin.'<CR>'
onoremap <buffer> <silent> <expr> ][ ':silent keeppatterns /'.b:block_end .'<CR>'
onoremap <buffer> <silent> <expr> [] ':silent keeppatterns ?'.b:block_end .'<CR>'
let b:undo_ftplugin = 'setlocal sw< sts< et< isk< com< cms< path< inex< sua< def< fo<'.
\ '| unlet! b:match_ignorecase b:match_words b:block_begin b:block_end'