summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2016-05-02 10:49:45 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2016-05-02 10:49:45 +0200
commitc200e7a0c587f70611b8dd702d0c3b378676a39a (patch)
tree960c7c88f634854cf3488d6d18ce42344875f8ef /ftplugin
parent5529a5e8e21e4577e4cd3551f2cbad59b5b406e8 (diff)
downloadvim-polyglot-c200e7a0c587f70611b8dd702d0c3b378676a39a.tar.gz
vim-polyglot-c200e7a0c587f70611b8dd702d0c3b378676a39a.zip
Add crystal syntax, closes #118
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/crystal.vim60
1 files changed, 60 insertions, 0 deletions
diff --git a/ftplugin/crystal.vim b/ftplugin/crystal.vim
new file mode 100644
index 00000000..f990a8da
--- /dev/null
+++ b/ftplugin/crystal.vim
@@ -0,0 +1,60 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1
+
+if exists('b:did_ftplugin')
+ finish
+endif
+let b:did_ftplugin = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+if exists('loaded_matchit') && !exists('b:match_words')
+ let b:match_ignorecase = 0
+
+ let b:match_words =
+ \ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|struct\|lib\|macro\|ifdef\|def\|fun\|begin\)\>=\@!' .
+ \ ':' .
+ \ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
+ \ ':' .
+ \ '\<end\>' .
+ \ ',{:},\[:\],(:)'
+
+ let b:match_skip =
+ \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
+ \ "\\<crystal\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
+ \ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
+ \ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
+ \ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
+ \ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
+endif
+
+setlocal comments=:#
+setlocal commentstring=#\ %s
+setlocal suffixesadd=.cr
+
+" Set format for quickfix window
+setlocal errorformat=
+ \%ESyntax\ error\ in\ line\ %l:\ %m,
+ \%ESyntax\ error\ in\ %f:%l:\ %m,
+ \%EError\ in\ %f:%l:\ %m,
+ \%C%p^,
+ \%-C%.%#
+
+if get(g:, 'crystal_define_mappings', 1)
+ nmap <buffer>gd <Plug>(crystal-jump-to-definition)
+ nmap <buffer>gc <Plug>(crystal-show-context)
+ nmap <buffer>gss <Plug>(crystal-spec-switch)
+ nmap <buffer>gsa <Plug>(crystal-spec-run-all)
+ nmap <buffer>gsc <Plug>(crystal-spec-run-current)
+endif
+
+if &l:ofu ==# ''
+ setlocal omnifunc=crystal_lang#complete
+endif
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim: nowrap sw=2 sts=2 ts=8:
+
+endif