[vim] Hare vim plugin
git clone https://git.torresjrjr.com/hare.vim.git
Log | Files | Refs | README | LICENSE

commit e9343e14e3e0f5f2e2c8501f40bfca970485d1d7
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed,  6 May 2020 22:55:59 -0400

Initial commit

AREADME.md | 3+++
Aftdetect/hare.vim | 1+
Aftplugin/hare.vim | 17+++++++++++++++++
Asyntax/hare.vim | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,3 @@ +# hare.vim + +Vim plugin for Hare programming. diff --git a/ftdetect/hare.vim b/ftdetect/hare.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.ha set filetype=hare diff --git a/ftplugin/hare.vim b/ftplugin/hare.vim @@ -0,0 +1,17 @@ +" Hare filetype plugin +" Maintainer: Drew DeVault <sir@cmpwn.com> +" Last Updated: 2020-05-06 + +" Only do this when not done yet for this buffer +if exists('b:did_ftplugin') + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +setlocal noexpandtab +setlocal tabstop=8 +setlocal shiftwidth=0 +setlocal softtabstop=0 +setlocal textwidth=80 diff --git a/syntax/hare.vim b/syntax/hare.vim @@ -0,0 +1,75 @@ +" Vim syntax file +" Language: Hare + +" TODO: +" Highlight ... in [x, y, z...] + +if exists("b:current_syntax") + finish +endif + +syn keyword hareKeyword let const fn def return static export +syn keyword hareRepeat for while +syn keyword hareConditional if else match switch +syn keyword hareBuiltin len offset free alloc assert +" TODO: highlight size correctly both as keyword and type +syn match harePreProc "^use .*;" +syn match harePreProc "@[a-z]*" +" TODO: This doesn't seem to work: +syn match hareOperator "\.\." "\.\.\." + +syn region hareString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+ + +"adapted from c.vim +"integer number, or floating point number without a dot and with "f". +syn case ignore +syn match hareNumbers display transparent "\<\d\|\.\d" contains=hareNumber,hareFloat,hareOctalError,hareOctal +" Same, but without octal error (for comments) +syn match hareNumbersCom display contained transparent "\<\d\|\.\d" contains=hareNumber,hareFloat,hareOctal +syn match hareNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" +"hex number +syn match hareNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" +" Flag the first zero of an octal number as something special +syn match hareOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=hareOctalZero +syn match hareOctalZero display contained "\<0" +syn match hareFloat display contained "\d\+f" +"floating point number, with dot, optional exponent +syn match hareFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" +"floating point number, starting with a dot, optional exponent +syn match hareFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" +"floating point number, without dot, with exponent +syn match hareFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" + +syn keyword hareTodo contained TODO FIXME XXX +syn region hareComment start="/\*" end="\*/" contains=hareTodo + +syn keyword hareType u8 u16 u32 u64 i8 i16 i32 i64 +syn keyword hareType uint int +syn keyword hareType uintptr +syn keyword hareType size +syn keyword hareType f32 f64 +syn keyword hareType bool +syn keyword hareType char str +syn keyword hareType void +syn keyword hareType struct union +syn keyword hareType nullable +syn keyword hareNull null +syn keyword hareBoolean true false + +hi def link hareBoolean Boolean +hi def link hareComment Comment +hi def link hareConditional Conditional +hi def link hareFloat Number +hi def link hareKeyword Keyword +hi def link hareNumber Number +hi def link hareNull Constant +hi def link hareOctal Number +hi def link hareOperator Keyword +hi def link harePreProc PreProc +hi def link hareRepeat Repeat +hi def link hareString String +hi def link hareTodo Todo +hi def link hareType Type +hi def link hareBuiltin Keyword + +hi hareKeyword ctermbg=NONE ctermfg=darkcyan