Initial check-in of vim syntax highlighting
This commit is contained in:
2
contrib/vim/ftdetect/chaiscript.vim
Normal file
2
contrib/vim/ftdetect/chaiscript.vim
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
au BufRead,BufNewFile *.chai set filetype=chaiscript
|
||||||
|
|
56
contrib/vim/indent/chaiscript.vim
Normal file
56
contrib/vim/indent/chaiscript.vim
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Minnow
|
||||||
|
" Maintainer: Jason Turner <jason 'at' emptycrate.com>
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal indentexpr=GetMinnowIndent()
|
||||||
|
|
||||||
|
" To make Vim call GetMinnowIndent() when it finds '\s*end'
|
||||||
|
" on the current line ('else' is default and includes 'elseif').
|
||||||
|
setlocal indentkeys+=0=end
|
||||||
|
|
||||||
|
setlocal autoindent
|
||||||
|
|
||||||
|
" Only define the function once.
|
||||||
|
if exists("*GetMinnowIndent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! GetMinnowIndent()
|
||||||
|
" Find a non-blank line above the current line.
|
||||||
|
let lnum = prevnonblank(v:lnum - 1)
|
||||||
|
|
||||||
|
" Hit the start of the file, use zero indent.
|
||||||
|
if lnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Add a 'shiftwidth' after lines that start a block:
|
||||||
|
" 'function', 'if', 'for', 'while', 'repeat', 'else', 'elseif', '{'
|
||||||
|
let ind = indent(lnum)
|
||||||
|
let flag = 0
|
||||||
|
let prevline = getline(lnum)
|
||||||
|
if prevline =~ '^.*{.*'
|
||||||
|
let ind = ind + &shiftwidth
|
||||||
|
let flag = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Subtract a 'shiftwidth' after lines ending with
|
||||||
|
" 'end' when they begin with 'while', 'if', 'for', etc. too.
|
||||||
|
if flag == 1 && prevline =~ '.*{.*}.*'
|
||||||
|
let ind = ind - &shiftwidth
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Subtract a 'shiftwidth' on end, else (and elseif), until and '}'
|
||||||
|
" This is the part that requires 'indentkeys'.
|
||||||
|
if getline(v:lnum) =~ '^\s*\%(}\)'
|
||||||
|
let ind = ind - &shiftwidth
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ind
|
||||||
|
endfunction
|
73
contrib/vim/syntax/chaiscript.vim
Normal file
73
contrib/vim/syntax/chaiscript.vim
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: ChaiScript
|
||||||
|
" Maintainer: Jason Turner <jason 'at' emptycrate com>
|
||||||
|
|
||||||
|
syn case match
|
||||||
|
|
||||||
|
" syncing method
|
||||||
|
syn sync fromstart
|
||||||
|
|
||||||
|
" Strings
|
||||||
|
syn region chaiscriptString start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=chaiscriptSpecial,@Spell
|
||||||
|
|
||||||
|
|
||||||
|
" integer number
|
||||||
|
syn match chaiscriptNumber "\<\d\+\>"
|
||||||
|
" floating point number, with dot, optional exponent
|
||||||
|
syn match chaiscriptFloat "\<\d\+\.\d*\%(e[-+]\=\d\+\)\=\>"
|
||||||
|
" floating point number, starting with a dot, optional exponent
|
||||||
|
syn match chaiscriptFloat "\.\d\+\%(e[-+]\=\d\+\)\=\>"
|
||||||
|
" floating point number, without dot, with exponent
|
||||||
|
syn match chaiscriptFloat "\<\d\+e[-+]\=\d\+\>"
|
||||||
|
|
||||||
|
syn match chaiscriptNumber "\<0x\x\+\>"
|
||||||
|
|
||||||
|
syn keyword chaiscriptCond if else
|
||||||
|
|
||||||
|
syn keyword chaiscriptRepeat while for do
|
||||||
|
syn keyword chaiscriptStatement break continue return
|
||||||
|
|
||||||
|
syn keyword chaiscriptExceptions try catch throw
|
||||||
|
|
||||||
|
"Keyword
|
||||||
|
syn keyword chaiscriptKeyword def true false attr
|
||||||
|
|
||||||
|
syn keyword chaiscriptType fun var
|
||||||
|
|
||||||
|
"Built in funcs
|
||||||
|
syn keyword chaiscriptFunc eval
|
||||||
|
|
||||||
|
"Let's treat all backtick operator function lookups as built in too
|
||||||
|
syn match chaiscriptFunc "`.*`"
|
||||||
|
|
||||||
|
" Comments
|
||||||
|
syn match chaiscriptComment "//.*$" contains=@Spell
|
||||||
|
syn region chaiscriptComment matchgroup=chaiscriptComment start="/\*" end="\*/" contains=@Spell
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
command -nargs=+ HiLink hi def link <args>
|
||||||
|
|
||||||
|
HiLink chaiscriptExceptions Exception
|
||||||
|
HiLink chaiscriptKeyword Keyword
|
||||||
|
HiLink chaiscriptStatement Statement
|
||||||
|
HiLink chaiscriptRepeat Repeat
|
||||||
|
HiLink chaiscriptString String
|
||||||
|
HiLink chaiscriptNumber Number
|
||||||
|
HiLink chaiscriptFloat Float
|
||||||
|
HiLink chaiscriptOperator Operator
|
||||||
|
HiLink chaiscriptConstant Constant
|
||||||
|
HiLink chaiscriptCond Conditional
|
||||||
|
HiLink chaiscriptFunction Function
|
||||||
|
HiLink chaiscriptComment Comment
|
||||||
|
HiLink chaiscriptTodo Todo
|
||||||
|
HiLink chaiscriptError Error
|
||||||
|
HiLink chaiscriptSpecial SpecialChar
|
||||||
|
HiLink chaiscriptFunc Identifier
|
||||||
|
HiLink chaiscriptType Type
|
||||||
|
|
||||||
|
delcommand HiLink
|
||||||
|
|
||||||
|
let b:current_syntax = "chaiscript"
|
||||||
|
|
||||||
|
" vim: nowrap sw=2 sts=2 ts=8 noet ff=unix:
|
Reference in New Issue
Block a user