summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2017-03-23 12:11:44 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2017-03-23 12:11:44 +0100
commit8bb259b1f6329837f471c6df2385f44fef02d2b4 (patch)
tree70d684417c7b6cc7839ea05111a51bb37d662d5e /ftplugin
parent466f20b12e5c5881af321f2f7922cce0436ba447 (diff)
downloadvim-polyglot-8bb259b1f6329837f471c6df2385f44fef02d2b4.tar.gz
vim-polyglot-8bb259b1f6329837f471c6df2385f44fef02d2b4.zip
Add mathematica support, closes #189
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/mma.vim63
1 files changed, 63 insertions, 0 deletions
diff --git a/ftplugin/mma.vim b/ftplugin/mma.vim
new file mode 100644
index 00000000..efbc8d55
--- /dev/null
+++ b/ftplugin/mma.vim
@@ -0,0 +1,63 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'mathematica') == -1
+
+"Vim filetype plugin
+" Language: Mathematica
+" Maintainer: R. Menon <rsmenon@icloud.com>
+" Last Change: Feb 26, 2013
+
+" Initialization {
+if exists("b:did_ftplugin")
+ finish
+endif
+let b:did_ftplugin = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+"}
+
+" Syntax completion function {
+if exists('&ofu')
+ setlocal omnifunc=syntaxcomplete#Complete
+ setlocal completefunc=syntaxcomplete#Complete
+endif
+"}
+
+" Main functions {
+if has('python')
+ " Random ID generator {
+ function! RandomID()
+
+"Python implementation follows; do not alter indentations/whitespace
+python << EOF
+import random, string, vim
+vim.command("let l:id = '" + (''.join(random.sample(string.ascii_uppercase + string.digits, 8))) + "'")
+EOF
+
+ return l:id
+ endfunction
+ "}
+
+ "Unit test template {
+ function! Test()
+ if exists("*strftime")
+ let l:date = strftime("%Y%m%d") . "-"
+ else
+ let l:date = ""
+ endif
+
+ let l:testid = expand("%:t") . "-" . l:date . RandomID()
+ let l:template = "Test[\rtest\r,\rresult\r,\rTestID -> \"" . l:testid . "\"\r\b]"
+ exe ":normal i" . l:template
+ endfunction
+ "}
+endif
+"}
+
+" Cleanup {
+let &cpo = s:cpo_save
+unlet s:cpo_save
+"}
+
+" vim: set foldmarker={,} foldlevel=0 foldmethod=marker:
+
+endif