diff --git a/extras/hoon.vim/ftdetect/hoonfiletype.vim b/extras/hoon.vim/ftdetect/hoonfiletype.vim new file mode 100644 index 000000000..a5e92f152 --- /dev/null +++ b/extras/hoon.vim/ftdetect/hoonfiletype.vim @@ -0,0 +1,2 @@ +au BufNewfile,BufEnter *.hoon setf hoon + diff --git a/extras/hoon.vim/indent/hoon.vim b/extras/hoon.vim/indent/hoon.vim new file mode 100644 index 000000000..d642929ab --- /dev/null +++ b/extras/hoon.vim/indent/hoon.vim @@ -0,0 +1,34 @@ +" Public Domain +" Credit Goes to fode + +if exists("b:did_indent") + finish +endif + +let b:did_indent = 1 + + +setlocal indentexpr=HoonIndent(v:lnum) +setlocal nolisp +setlocal autoindent + +if exists("*HoonIndent") + finish +endif + +function! HoonIndent(lnum) + let prevlnum = prevnonblank(a:lnum-1) + if prevlnum == 0 + return 0 + endif + let prevl = substitute(getline(prevlnum),'::.*$','','') + + let ind = indent(prevlnum) + if prevl =~ '++\s*\w*\s*$' + " luslus operator + let ind += &sw + endif + + return ind +endfunction + diff --git a/extras/hoon.vim/syntax/hoon.vim b/extras/hoon.vim/syntax/hoon.vim new file mode 100644 index 000000000..29dc4565a --- /dev/null +++ b/extras/hoon.vim/syntax/hoon.vim @@ -0,0 +1,170 @@ +"hoon.vim: Hoon syntax file +"Credit goes to Fode +" +" With contributions from Philip C Monk + + +if exists("b:current_syntax") + finish +endif + +syn case match + + +" Declarations +hi def link hoonDeclaration Define +hi def link hoonSymbol Constant +hi def link hoonAtom Identifier +hi def link hoonRune Operator +hi def link hoonIdentifier Identifier +hi def link hoonBranch Conditional +hi def link hoonType Type +hi def link hoonName Constant +hi def link hoonNumber Number +hi def link hoonComment Comment +hi def link hoonTodo Todo +hi def link hoonString String + +syn match hoonDeclaration "++" nextgroup=hoonSymbolDec skipwhite +syn match hoonSymbol /%\%(\%(\%(\w\|-\)\+\)\|[|&$]\)/ +syn match hoonAtom /@\w*/ +syn match hoonName "\w*" contained +syn match hoonSymbolDec "\w*" contained contains=hoonName + +" numbers +" Numbers are in decimal, binary, hex, base32, or base64, and they must +" contain dots (optionally followed by whitespace), as in the German manner. + +syn sync linebreaks=1 +syn match hoonNumber "\d\{1,3\}\%(\.\_s\?\d\{3\}\)*" +syn match hoonNumber "0x\x\{1,4\}\%(\.\_s*\x\{4\}\)*" +syn match hoonNumber "0b[01]\{1,4\}\%(\.\_s*[01]\{4\}\)*" +syn match hoonNumber "0v[0-9a-v]\{1,4\}\%(\.\_s*[0-9a-v]\{4\}\)*" +syn match hoonNumber "0w[-~0-9a-zA-Z]\{1,4\}\%(\.\_s*[-~0-9a-zA-Z]\{4\}\)*" + +" comments + +syn region hoonComment start="::" end="$" contains=@spell,hoonTodo +syn keyword hoonTodo contained XX XXX TODO FIXME + +" strings + +syn region hoonString start=+'+ skip=+\\[\\']+ end=+'+ contains=@spell +syn region hoonString start=+"+ skip=+\\[\\"]+ end=+"+ contains=@spell + + +" match digraphs + +syn match hoonRune "||" +syn match hoonRune "|_" +syn match hoonRune "|%" +syn match hoonRune "|:" +syn match hoonRune "|\." +syn match hoonRune "|-" +syn match hoonRune "|\^" +syn match hoonRune "|+" +syn match hoonRune "|\*" +syn match hoonRune "|=" +syn match hoonRune "|?" +syn match hoonRune "%_" +syn match hoonRune "%:" +syn match hoonRune "%\." +syn match hoonRune "%\^" +syn match hoonRune "%+" +syn match hoonRune "%-" +syn match hoonRune "%\~" +syn match hoonRune "%\*" +syn match hoonRune "%=" +syn match hoonRune "\$|" +syn match hoonRune "\$_" +syn match hoonRune "\$:" +syn match hoonRune "\$%" +syn match hoonRune "\$," +syn match hoonRune "\$&" +syn match hoonRune "\$?" +syn match hoonRune ":_" +syn match hoonRune ":\~" +syn match hoonRune ":/" +syn match hoonRune ":\^" +syn match hoonRune ":+" +syn match hoonRune ":-" +syn match hoonRune ":\~" +syn match hoonRune ":\*" +syn match hoonRune "\.+" +syn match hoonRune "\.\*" +syn match hoonRune "\.=" +syn match hoonRune "\.?" +syn match hoonRune "\.\^" +syn match hoonRune "#<" +syn match hoonRune "#>" +syn match hoonRune "\^|" +syn match hoonRune "\^\." +syn match hoonRune "\^-" +syn match hoonRune "\^+" +syn match hoonRune "\^&" +syn match hoonRune "\^\~" +syn match hoonRune "\^=" +syn match hoonRune "\^?" +syn match hoonRune "\~|" +syn match hoonRune "\~\$" +syn match hoonRune "\~%" +syn match hoonRune "\~:" +syn match hoonRune "\~/" +syn match hoonRune "\~<" +syn match hoonRune "\~>" +syn match hoonRune "\~#" +syn match hoonRune "\~\^" +syn match hoonRune "\~+" +syn match hoonRune "\~&" +syn match hoonRune "\~=" +syn match hoonRune "\~!" +syn match hoonRune ";_" +syn match hoonRune ";," +syn match hoonRune ";%" +syn match hoonRune ";:" +syn match hoonRune ";\." +syn match hoonRune ";<" +syn match hoonRune ";>" +syn match hoonRune ";-" +syn match hoonRune ";+" +syn match hoonRune ";&" +syn match hoonRune ";\~" +syn match hoonRune ";;" +syn match hoonRune ";\*" +syn match hoonRune ";=" +syn match hoonRune ";?" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=|" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=\." +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=\^" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=:" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=<" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=>" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=-" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=+" +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs=\~" +syn match hoonRune "?|" +syn match hoonRune "?:" +syn match hoonRune "?\." +syn match hoonRune "?<" +syn match hoonRune "?>" +syn match hoonRune "?-" +syn match hoonRune "?\^" +syn match hoonRune "?=" +syn match hoonRune "?+" +syn match hoonRune "?&" +syn match hoonRune "?@" +syn match hoonRune "?\~" +syn match hoonRune "?!" +syn match hoonRune "!:" +syn match hoonRune "!," +syn match hoonRune "!;" +syn match hoonRune "!\^" +syn match hoonRune "!>" +syn match hoonRune "!=" + +" Not technically runes, but we highlight them like that. +syn match hoonRune "\%([^a-zA-Z]\|^\)\zs==" +syn match hoonRune "--" + +let b:current_syntax = "hoon" +