Skip to content

Commit

Permalink
Add syntax highlighting support for nvim/vim
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcampanella committed Feb 24, 2024
1 parent a4f90a2 commit 3afc4f4
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions editor/rorth.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
" Vim syntax file
" Language: Rorth

" Usage Instructions
" Put this file in .vim/syntax/rorth.vim
" and add in your .vimrc file the next line:
" autocmd BufRead,BufNewFile *.rorth set filetype=rorth

if exists("b:current_syntax")
finish
endif

set iskeyword=a-z,A-Z,-,*,_,!,@
syntax keyword rorthTodos TODO XXX FIXME NOTE

" Language keywords
syntax keyword rorthKeywords if else while do include memory fn const end assert

" Comments
syntax region rorthCommentLine start="//" end="$" contains=rorthTodos

" String literals
syntax region rorthString start=/\v"/ skip=/\v\\./ end=/\v"/ contains=rorthEscapes

" Char literals
syntax region rorthChar start=/\v'/ skip=/\v\\./ end=/\v'/ contains=rorthEscapes

" Escape literals \n, \r, ....
syntax match rorthEscapes display contained "\\[nr\"']"

" Number literals
syntax region rorthNumber start=/\s\d/ skip=/\d/ end=/\s/

" Type names the compiler recognizes
syntax keyword rorthTypeNames addr int ptr bool
" Set highlights
highlight default link rorthTodos Todo
highlight default link rorthKeywords Keyword
highlight default link rorthCommentLine Comment
highlight default link rorthString String
highlight default link rorthNumber Number
highlight default link rorthTypeNames Type
highlight default link rorthChar Character
highlight default link rorthEscapes SpecialChar

let b:current_syntax = "rorth"

0 comments on commit 3afc4f4

Please sign in to comment.