diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-14 13:17:26 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-14 13:17:26 +0200 |
commit | 14dc82fc4e6c0c08078f97a24a6c1639c1cc5113 (patch) | |
tree | dea8d2398a9377a0eee7786776e3cd420ce1ee89 /autoload/ecrystal.vim | |
parent | e86e0ad36ef9501acbc3e8c63a1d4fab104e47cb (diff) | |
download | vim-polyglot-14dc82fc4e6c0c08078f97a24a6c1639c1cc5113.tar.gz vim-polyglot-14dc82fc4e6c0c08078f97a24a6c1639c1cc5113.zip |
Update
Diffstat (limited to 'autoload/ecrystal.vim')
-rw-r--r-- | autoload/ecrystal.vim | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/autoload/ecrystal.vim b/autoload/ecrystal.vim new file mode 100644 index 00000000..1a00b894 --- /dev/null +++ b/autoload/ecrystal.vim @@ -0,0 +1,34 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 + +let s:ecrystal_extensions = { + \ 'cr': 'crystal', + \ 'yml': 'yaml', + \ 'js': 'javascript', + \ 'txt': 'text', + \ 'md': 'markdown' + \ } + +if exists('g:ecrystal_extensions') + call extend(s:ecrystal_extensions, g:ecrystal_extensions, 'force') +endif + +function! ecrystal#SetSubtype() abort + if exists('b:ecrystal_subtype') + return + endif + + let b:ecrystal_subtype = matchstr(substitute(expand('%:t'), '\c\%(\.ecr\)\+$', '', ''), '\.\zs\w\+\%(\ze+\w\+\)\=$') + + let b:ecrystal_subtype = get(s:ecrystal_extensions, b:ecrystal_subtype, b:ecrystal_subtype) + + if b:ecrystal_subtype ==# '' + let b:ecrystal_subtype = get(g:, 'ecrystal_default_subtype', 'html') + endif + + if b:ecrystal_subtype !=# '' + exec 'setlocal filetype=ecrystal.' . b:ecrystal_subtype + exec 'setlocal syntax=ecrystal.' . b:ecrystal_subtype + endif +endfunction + +endif |