Skip to content

Commit

Permalink
nvim: Add shroom language
Browse files Browse the repository at this point in the history
  • Loading branch information
scizzorz committed Aug 2, 2024
1 parent a6f27e1 commit ee15e25
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions nvim/ftdetect/shroom.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
au BufReadPost,FileReadPost,BufNewFile *.ms set filetype=shroom
30 changes: 30 additions & 0 deletions nvim/indent/shroom.vim
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions nvim/syntax/shroom.vim
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ee15e25

Please sign in to comment.