summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-17 14:59:49 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-17 15:16:28 -0700
commit8b5f4cf211ff980f796058bef0ec1696e894b033 (patch)
treeb7860b82caeacbe986cbcd4b503c7b85d76b23b5 /support
parentbc529a54b673dfe0769f6f139dc85e440b8051cf (diff)
downloadmc-8b5f4cf211ff980f796058bef0ec1696e894b033.tar.gz
Add vim support files.
Diffstat (limited to 'support')
-rw-r--r--support/vim/ftdetect/mbld.vim8
-rw-r--r--support/vim/ftdetect/myr.vim1
-rw-r--r--support/vim/indent/mbld.vim54
-rw-r--r--support/vim/indent/myr.vim74
-rw-r--r--support/vim/syntax/mbld.vim21
-rw-r--r--support/vim/syntax/myr.vim48
6 files changed, 206 insertions, 0 deletions
diff --git a/support/vim/ftdetect/mbld.vim b/support/vim/ftdetect/mbld.vim
new file mode 100644
index 0000000..3018d88
--- /dev/null
+++ b/support/vim/ftdetect/mbld.vim
@@ -0,0 +1,8 @@
+au BufRead,BufNewFile bld.proj
+ \ setlocal ft=mbld |
+ \ setlocal noet |
+ \ setlocal sw=8
+au BufRead,BufNewFile bld.sub
+ \ setlocal ft=mbld |
+ \ setlocal noet |
+ \ setlocal sw=8
diff --git a/support/vim/ftdetect/myr.vim b/support/vim/ftdetect/myr.vim
new file mode 100644
index 0000000..e7684cc
--- /dev/null
+++ b/support/vim/ftdetect/myr.vim
@@ -0,0 +1 @@
+au BufRead,BufNewFile *.myr set ft=myr
diff --git a/support/vim/indent/mbld.vim b/support/vim/indent/mbld.vim
new file mode 100644
index 0000000..acf3d5e
--- /dev/null
+++ b/support/vim/indent/mbld.vim
@@ -0,0 +1,54 @@
+" Vim Indentation file
+" Language: Myrddin
+" Maintainer: Ori Bernstein
+
+if exists("b:did_indent")
+ finish
+endif
+
+function! s:CheckMatch(line, pats)
+ for p in a:pats
+ let idx = match(a:line, p)
+ if idx >= 0
+ return 1
+ endif
+ endfor
+ return 0
+endfunction
+
+
+function! GetMbldIndent(ln)
+ let ln = a:ln
+
+ if ln == 1
+ let ind = 0
+ else
+ let i = 1
+ let prevln = ''
+ while prevln =~ '^\s*$'
+ let prevln = getline(ln - i)
+ let ind = indent(ln - i)
+ let i = i + 1
+ endwhile
+ echo "IND IS " ind
+ let curln = getline(ln)
+ let inpat = ['^\s*\<bin\>', '^\s*\<lib\>',
+ \'^\s*\<gen\>', '^\s*\<test\>',
+ \'^\s*\<man\>', '^\s*\<sub\>']
+ let level = 0
+ if s:CheckMatch(prevln, inpat)
+ let level = level + 1
+ endif
+
+ if match(curln, ';;\s*$') > 0
+ let level = level - 1
+ endif
+ echo "TABSTOP IS " &tabstop
+ let ind = ind + (level * &tabstop)
+ endif
+ return ind
+endfunction
+
+setlocal indentkeys+=,;
+setlocal indentexpr=GetMbldIndent(v:lnum)
+let b:did_indent = 1
diff --git a/support/vim/indent/myr.vim b/support/vim/indent/myr.vim
new file mode 100644
index 0000000..1cd4fa9
--- /dev/null
+++ b/support/vim/indent/myr.vim
@@ -0,0 +1,74 @@
+" Vim Indentation file
+" Language: Myrddin
+" Maintainer: Ori Bernstein
+
+if exists("b:did_indent")
+ finish
+endif
+
+function! s:CountMatches(line, pats)
+ let matches = 0
+ for p in a:pats
+ let idx = 0
+ while idx >= 0
+ let idx = match(a:line, p, idx)
+ if idx >= 0
+ let matches = matches + 1
+ let idx = idx + strlen(p)
+ endif
+ endwhile
+ endfor
+ return matches
+endfunction
+
+function! s:LineMatch(line, pats)
+ for p in a:pats
+ let pat = '^\s*'.p.'\s*$'
+ if match(a:line, pat, 0) >= 0
+ return 1
+ endif
+ endfor
+ return 0
+endfunction
+
+function! GetMyrIndent(ln)
+ let ln = a:ln
+
+ if ln == 1
+ let ind = 0
+ else
+ let i = 1
+ let prevln = ''
+ while prevln =~ '^\s*$'
+ let prevln = getline(ln - i)
+ let ind = indent(ln - i)
+
+ let i = i + 1
+ endwhile
+
+ let curln = getline(ln)
+
+ let inpat = ['\<if\>', '\<elif\>', '\<else\>',
+ \ '\<while\>','\<for\>', '\<match\>',
+ \ '\<struct\>', '\<union\>',
+ \ '{', '^\s*|', '=\s*$']
+ let outpat = ['}', ';;']
+ let outalone = ['\<else\>', '\<elif\>', '}', ';;', '|.*']
+ let width = &tabstop
+
+ let n_in = s:CountMatches(prevln, inpat)
+ let n_out = s:CountMatches(prevln, outpat)
+ if s:LineMatch(curln, outalone) != 0
+ let ind = n_in * &tabstop + ind - &tabstop
+ " avoid double-counting outdents from outalones.
+ elseif s:LineMatch(prevln, outpat) == 0
+ let ind = ind + (n_in - n_out) * &tabstop
+ endif
+ endif
+ return ind
+endfunction
+
+setlocal indentkeys+=,;\|,=elif
+setlocal indentexpr=GetMyrIndent(v:lnum)
+
+let b:did_indent = 1
diff --git a/support/vim/syntax/mbld.vim b/support/vim/syntax/mbld.vim
new file mode 100644
index 0000000..583fad4
--- /dev/null
+++ b/support/vim/syntax/mbld.vim
@@ -0,0 +1,21 @@
+" Vim Syntax file
+" Language: Myrddin Build
+" Maintainer: Ori Bernstein
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn region mbldComment start=+#+ end=+$+
+syn region mbldString start=+"+ skip=+\\"+ end=+"+ extend
+syn keyword mbldKeyword
+ \ bin
+ \ lib
+ \ gen
+ \ test
+ \ man
+ \ sub
+
+hi def link mbldComment Comment
+hi def link mbldString String
+
diff --git a/support/vim/syntax/myr.vim b/support/vim/syntax/myr.vim
new file mode 100644
index 0000000..debcf11
--- /dev/null
+++ b/support/vim/syntax/myr.vim
@@ -0,0 +1,48 @@
+" Vim Syntax file
+" Language: Myrddin
+" Maintainer: Ori Bernstein
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn region myrComment start=+/\*+ end=+\*/+
+syn match myrSpecial display contained "\\\(x\x\+\|\o\{1,3}\|u{.*}\|.\|$\)"
+syn match myrFormat display "%[sbwilpc]"
+syn region myrString start=+"+ skip=+\\"+ end=+"+ contains=myrSpecial,myrFormat extend
+syn region myrChar start=+'+ skip=+\\'+ end=+'+ contains=myrSpecial,myrFormat extend
+syn keyword myrKeyword castto
+ \ const
+ \ default
+ \ elif
+ \ else
+ \ export
+ \ extern
+ \ false
+ \ for
+ \ generic
+ \ goto
+ \ if
+ \ match
+ \ pkg
+ \ protect
+ \ sizeof
+ \ struct
+ \ trait
+ \ true
+ \ type
+ \ union
+ \ use
+ \ var
+ \ while
+
+hi def link myrComment Comment
+hi def link myrString String
+hi def link myrChar String
+hi def link myrSpecial Special
+hi def link myrFormat Special
+" Too much color makes my eyes hurt. Just highlight
+" the most important and uncommon stuff.
+"hi def link myrKeyword Keyword
+
+let b:current_syntax = "myr"