diff --git a/nvim/ftdetect/shroom.vim b/nvim/ftdetect/shroom.vim new file mode 100644 index 0000000..4d2423a --- /dev/null +++ b/nvim/ftdetect/shroom.vim @@ -0,0 +1 @@ +au BufReadPost,FileReadPost,BufNewFile *.ms set filetype=shroom diff --git a/nvim/indent/shroom.vim b/nvim/indent/shroom.vim new file mode 100644 index 0000000..3071d4f --- /dev/null +++ b/nvim/indent/shroom.vim @@ -0,0 +1,30 @@ +setlocal nolisp +setlocal autoindent +setlocal indentkeys+=<:>,0=},0=) +setlocal indentexpr=ShroomIndent(v:lnum) + +function! ShroomIndent(lnum) abort + let l:prevlnum = prevnonblank(a:lnum-1) + if l:prevlnum == 0 + return 0 + endif + + " strip comments from EOL + let l:prevl = substitute(getline(l:prevlnum), '\(//\|#\).*$', '', '') + let l:thisl = substitute(getline(a:lnum), '\(//\|#\).*$', '', '') + let l:previ = indent(l:prevlnum) + + let l:ind = l:previ + + if l:prevl =~ '{\s*$' + " previous line opened a block + let l:ind += shiftwidth() + endif + + if l:thisl =~ '^\s*}' + " this line closed a block + let l:ind -= shiftwidth() + endif + + return l:ind +endfunction diff --git a/nvim/syntax/shroom.vim b/nvim/syntax/shroom.vim new file mode 100644 index 0000000..7f1a747 --- /dev/null +++ b/nvim/syntax/shroom.vim @@ -0,0 +1,54 @@ +if exists("b:current_syntax") + finish +endif + +syn keyword shroomEvent onChoice onPrepare onDiscard onModPower onModStamina onUseStamina onGather onPlay onSummon onDie onEmpty onStart onMorning onTurn onNight onFinish + +syn keyword shroomKeyword if elif else return +syn keyword shroomKeyword has and or space + +syn keyword shroomFunction activate event setPower setStamina setTraits modPower modStamina forceModPower forceModStamina useStamina summon + +syn keyword shroomVariable critter area amount source played target discarded first second none trait from to name value credit at pow stam name + +syn match shroomSymbol "\v\(" +syn match shroomSymbol "\v\)" +syn match shroomSymbol "\v\{" +syn match shroomSymbol "\v\}" +syn match shroomSymbol "\v\=" +syn match shroomSymbol "\v\." +syn match shroomSymbol "\v\," +" syn match shroomSymbol "\v\:\=" + +syn match shroomOperator "\v\+" +syn match shroomOperator "\v\/" +syn match shroomOperator "\v\-" +syn match shroomOperator "\v\*" + +syn region shroomString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ keepend + +syn match shroomNumber "\v\-?[0-9]+" + +syn match shroomComment1 "#.*$" display +syn match shroomComment2 "\/\/.*$" display + +" hi link shroomBad DiagnosticWarn +hi link shroomSymbol Operator +" hi link shroomOperator Operator +hi link shroomEvent Identifier +hi link shroomFunction Special +hi link shroomString String +hi link shroomNumber Number +hi link shroomVariable Operator +hi link shroomKeyword Keyword +hi link shroomComment1 Comment +hi link shroomComment2 Comment +" hi link shroomType Type +" hi link shroomGeneric Identifier +" PreProc +" Boolean +" String +" Number +" Number +" Comment +" not used PreProc