From e3568cb593219724046c5291cd0c41e15ebb8c58 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 6 Jan 2016 03:49:39 -0800 Subject: [PATCH] syntax highlighting stuff --- vim/autoload/SyntaxAttr.vim | 65 ++++++++++ vim/colors/property2.vim | 162 ++++++++++++++++++++++++ vim/syntax/lips.vim | 239 ++++++++++++++++++++++++++++++++++++ 3 files changed, 466 insertions(+) create mode 100644 vim/autoload/SyntaxAttr.vim create mode 100644 vim/colors/property2.vim create mode 100644 vim/syntax/lips.vim diff --git a/vim/autoload/SyntaxAttr.vim b/vim/autoload/SyntaxAttr.vim new file mode 100644 index 0000000..81a8b0b --- /dev/null +++ b/vim/autoload/SyntaxAttr.vim @@ -0,0 +1,65 @@ +" EXAMPLE SETUP +" +" Show the syntax group name of the item under cursor. +" map -a :call SyntaxAttr() + +function! SyntaxAttr() + let synid = "" + let guifg = "" + let guibg = "" + let gui = "" + + let id1 = synID(line("."), col("."), 1) + let tid1 = synIDtrans(id1) + + if synIDattr(id1, "name") != "" + let synid = "group: " . synIDattr(id1, "name") + if (tid1 != id1) + let synid = synid . '->' . synIDattr(tid1, "name") + endif + let id0 = synID(line("."), col("."), 0) + if (synIDattr(id1, "name") != synIDattr(id0, "name")) + let synid = synid . " (" . synIDattr(id0, "name") + let tid0 = synIDtrans(id0) + if (tid0 != id0) + let synid = synid . '->' . synIDattr(tid0, "name") + endif + let synid = synid . ")" + endif + endif + + " Use the translated id for all the color & attribute lookups; the linked id yields blank values. + if (synIDattr(tid1, "fg") != "" ) + let guifg = " guifg=" . synIDattr(tid1, "fg") . "(" . synIDattr(tid1, "fg#") . ")" + endif + if (synIDattr(tid1, "bg") != "" ) + let guibg = " guibg=" . synIDattr(tid1, "bg") . "(" . synIDattr(tid1, "bg#") . ")" + endif + if (synIDattr(tid1, "bold" )) + let gui = gui . ",bold" + endif + if (synIDattr(tid1, "italic" )) + let gui = gui . ",italic" + endif + if (synIDattr(tid1, "reverse" )) + let gui = gui . ",reverse" + endif + if (synIDattr(tid1, "inverse" )) + let gui = gui . ",inverse" + endif + if (synIDattr(tid1, "underline")) + let gui = gui . ",underline" + endif + if (gui != "" ) + let gui = substitute(gui, "^,", " gui=", "") + endif + + echohl MoreMsg + let message = synid . guifg . guibg . gui + if message == "" + echohl WarningMsg + let message = "" + endif + echo message + echohl None +endfunction diff --git a/vim/colors/property2.vim b/vim/colors/property2.vim new file mode 100644 index 0000000..1b953fc --- /dev/null +++ b/vim/colors/property2.vim @@ -0,0 +1,162 @@ +" Property +" a vim color scheme by @notwa +" loosely based on Clearance by Chris Seelus (@ceelus) +" built upon the Tomorrow scheme's functionality + +" other sources of inspiration: +" colorful +" redblack + +" basically i split styling into: +" built-in things you'd pass arguments to +" built-in things you wouldn't that moreso construct the language (if, else) +" built-in things you shouldn't use as variable names + +" hi \([A-Za-z]\+\) \+guifg=\([^ ]\+\) \+guibg=\([^ ]\+\) \+gui=\(\w\+\) + +let s:foreground = "D6DBD5" +let s:background = "202121" + +let s:white = "F9FAF7" + +let s:backgrounder = "292B2C" +let s:line_number = "484E52" +let s:comment = "80908C" + +let s:selection = "393C41" + +" not including C chars ('x' syntax) +let s:string = "BEE563" +let s:stringer = "2A3026" + +" sometimes true and false too, depending on the language +let s:number = "FA7A76" + +" a language constructor +" maybe not true-blue enough? +" maybe use pure (bold) white instead, and use this elsewhere +let s:language = "7DB8E8" + +" don't overwrite me! +let s:function = "64CCC5" " old seaweed color +" needs a tad more saturation and brightness? +let s:function = "5A7FD6" + +" TODO: () colors, [] colors, {} colors (background for braces?) + +hi clear +if exists("syntax_on") | syntax reset | endif +set background=dark + +let g:colors_name = "property2" + +" Sets the highlighting for the given group +fu! X(group, fg, bg, attr) + let l:fg=a:fg + let l:bg=a:bg + if a:fg != "" && a:fg != "NONE" | let l:fg="#".l:fg | endif + if a:bg != "" && a:bg != "NONE" | let l:bg="#".l:bg | endif + if a:fg != "" | exec "hi! ".a:group." guifg=".l:fg | endif + if a:bg != "" | exec "hi! ".a:group." guibg=".l:bg | endif + if a:attr != "" | exec "hi! ".a:group." gui=".a:attr | endif +endfun + +" Interface + +call X("Normal", s:foreground, s:background, "") +call X("LineNr", s:line_number, "", "") +call X("NonText", s:foreground, "", "") +call X("SpecialKey", s:line_number, "", "") +call X("Search", "NONE", s:backgrounder, "underline") +call X("TabLine", s:foreground, "", "") +call X("TabLineFill", s:foreground, "", "") +"call X("StatusLine", s:foreground, "", "") +"call X("StatusLineNC", s:foreground, "", "") +call X("VertSplit", s:foreground, "", "") +call X("Visual", s:foreground, s:selection, "") +call X("Directory", s:foreground, "", "") +call X("ModeMsg", s:foreground, "", "") +call X("MoreMsg", s:foreground, "", "") +call X("Question", s:foreground, "", "") +call X("WarningMsg", s:foreground, "", "") +call X("MatchParen", s:foreground, "", "") +call X("Folded", s:foreground, "", "") +call X("FoldColumn", s:foreground, "", "") +call X("CursorLine", s:foreground, "", "") +call X("CursorColumn", s:foreground, "", "") +call X("PMenu", s:foreground, "", "") +call X("PMenuSel", s:foreground, "", "") +call X("SignColumn", s:foreground, "", "") +call X("ColorColumn", "", s:backgrounder, "") + +" Syntax highlighting + +call X("Todo", s:white, s:background, "bold,italic") +call X("Title", s:foreground, "", "") +call X("Identifier", s:language, "", "") +call X("Structure", s:language, "", "") +call X("Constant", s:number, "", "") +call X("Special", s:white, "", "bold") +call X("Operator", s:foreground, "", "") +call X("Delimiter", s:foreground, "", "") + +call X("Comment", s:comment, "", "italic") +call X("Function", s:function, "", "NONE") +call X("Statement", s:white, "", "bold") +call X("Repeat", s:language, "", "bold") +call X("Keyword", s:language, "", "NONE") +call X("Conditional", s:language, "", "NONE") +call X("String", s:string, s:stringer, "") +call X("Type", s:function, "", "NONE") " not too bad as s:number +call X("PreProc", s:foreground, "", "NONE") +call X("Define", s:function, "", "NONE") +call X("Include", s:foreground, "", "NONE") +call X("Number", s:number, "", "") + +hi link vimCommand Keyword +hi link vimCommentString Comment +hi link vimFuncVar Normal +hi link vimVar Normal + +hi link pythonBoolean Constant +hi link pythonBuiltin Function +hi link pythonBuiltinFunc Function +hi link pythonConditional Structure +hi link pythonException Structure +hi link pythonImport Function +hi link pythonInclude Function +hi link pythonOperator Structure +hi link pythonRepeat Structure +hi link pythonRun Comment +hi link pythonStatement Structure + +" FIXME: escapes shouldn't override string background +hi link luaCond Structure +hi link luaCondElseif Structure +hi link luaCondEnd Structure +hi link luaCondStart Structure +hi link luaFunc Function +hi link luaFunction Function +hi link luaRepeat Structure +hi link luaStatement Structure + +"hi link Operator Normal +"hi link Character Constant +"hi link Boolean Constant +"hi link Float Number +"hi link Repeat Statement +"hi link Label Statement +"hi link Exception Statement +"hi link Include PreProc +"hi link Define PreProc +"hi link Macro PreProc +"hi link PreCondit PreProc +"hi link StorageClass Type +"hi link Structure Type +"hi link Typedef Type +"hi link Tag Special +"hi link SpecialChar Special +"hi link SpecialComment Special +"hi link Debug Special + +delf X diff --git a/vim/syntax/lips.vim b/vim/syntax/lips.vim new file mode 100644 index 0000000..1f0d874 --- /dev/null +++ b/vim/syntax/lips.vim @@ -0,0 +1,239 @@ +" Vim syn file +" Language: lips assembly +" Maintainer: notwa +" Last Change: 2016-01-05 + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn case ignore + +syn region lipsString start=/"/ skip=/\\"/ end=/"/ +syn region asmComment start="/\*" end="\*/" +syn match lipsComment /\(\/\/\|;\).*/ + +syn match lipsNumber /\<[+-]\?\d\+\>/ " Decimal numbers +syn match lipsNumber /\<[+-]\?0x[0-9a-f]\+\>/ " Hex numbers +syn match lipsNumber /\<[+-]\?0[0-7]\+\>/ " Octal numbers + +syn match lipsColon /:/ contained +syn match lipsLabel /[a-z_][a-z0-9_]*:/ contains=lipsColon +syn match lipsLabel /[+-]:/ contains=lipsColon +syn match lipsDefine /\[[a-z0-9_]\+\]:/ contains=lipsColon +syn match lipsDefine /@[a-z0-9_]\+/ + +" Registers +syn keyword lipsRegister r0 +syn keyword lipsRegister v0 v1 +syn keyword lipsRegister a0 a1 a2 a3 +syn keyword lipsRegister t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 +syn keyword lipsRegister s0 s1 s2 s3 s4 s5 s6 s7 +syn keyword lipsRegister k0 k1 +syn keyword lipsRegister gp sp fp +syn keyword lipsRegister ra + +" Register aliases +syn keyword lipsRegister zero +syn keyword lipsRegister s8 + +" Coprocessor 0 registers +syn keyword lipsRegister index random entrylo0 entrylo1 +syn keyword lipsRegister context pagemask wired reserved0 +syn keyword lipsRegister badvaddr count entryhi compare +syn keyword lipsRegister status cause epc previd +syn keyword lipsRegister config lladdr watchlo watchhi +syn keyword lipsRegister xcontext reserved1 reserved2 reserved3 +syn keyword lipsRegister reserved4 reserved5 perr cacheerr +syn keyword lipsRegister taglo taghi errorepc reserved6 + +" Register numeric aliases and FPU registers +let i = 0 +while i < 32 + execute 'syn keyword lipsRegister r'.i + execute 'syn keyword lipsRegister f'.i + let i = i + 1 +endwhile + +" Directives +syn match lipsDirective "\.align\>" +syn match lipsDirective "\.skip\>" +syn match lipsDirective "\.ascii\>" +syn match lipsDirective "\.asciiz\>" +syn match lipsDirective "\.byte\>" +syn match lipsDirective "\.halfword\>" +syn match lipsDirective "\.word\>" +syn match lipsDirective "\.float\>" +syn match lipsDirective "\.hex\>" +syn match lipsDirective "\.inc\>" +syn match lipsDirective "\.incasm\>" +syn match lipsDirective "\.include\>" +syn match lipsDirective "\.incbin\>" +syn match lipsDirective "\.org\>" + +" Instructions + +syn keyword lipsInstruction LB LBU +syn keyword lipsInstruction LD +syn keyword lipsInstruction LDL LDR +syn keyword lipsInstruction LH LHU +syn keyword lipsInstruction LL LLD +syn keyword lipsInstruction LUI +syn keyword lipsInstruction LW LWU +syn keyword lipsInstruction LWL LWR + +syn keyword lipsInstruction SB +syn keyword lipsInstruction SC SCD +syn keyword lipsInstruction SD +syn keyword lipsInstruction SDL SDR +syn keyword lipsInstruction SH +syn keyword lipsInstruction SW +syn keyword lipsInstruction SWL SWR + +syn keyword lipsInstruction ADD ADDI ADDIU ADDU +syn keyword lipsInstruction AND ANDI +syn keyword lipsInstruction MULT MULTU +syn keyword lipsInstruction NOR +syn keyword lipsInstruction OR ORI +syn keyword lipsInstruction SLL SLLV +syn keyword lipsInstruction SRA SRAV +syn keyword lipsInstruction SRL SRLV +syn keyword lipsInstruction SUB SUBU +syn keyword lipsInstruction XOR XORI + +syn keyword lipsInstruction DADD DADDI DADDIU DADDU +syn keyword lipsInstruction DDIV DDIVU +syn keyword lipsInstruction DIV DIVU +syn keyword lipsInstruction DMULT DMULTU +syn keyword lipsInstruction DSLL DSLL32 DSLLV +syn keyword lipsInstruction DSRA DSRA32 DSRAV +syn keyword lipsInstruction DSRL DSRL32 DSRLV +syn keyword lipsInstruction DSUB DSUBU + +syn keyword lipsInstruction J JR +syn keyword lipsInstruction JAL JALR + +syn keyword lipsInstruction SLT SLTI SLTIU SLTU + +syn keyword lipsInstruction BEQ BEQL +syn keyword lipsInstruction BGEZ BGEZAL BGEZALL BGEZL +syn keyword lipsInstruction BGTZ BGTZL +syn keyword lipsInstruction BLEZ BLEZL +syn keyword lipsInstruction BLTZ BLTZAL BLTZALL BLTZL +syn keyword lipsInstruction BNE BNEL + +" Coprocessor-related instructions, etc. + +syn keyword lipsInstruction BC1F BC1FL +syn keyword lipsInstruction BC1T BC1TL + +syn keyword lipsInstruction CFC1 CTC1 +syn keyword lipsInstruction DMFC1 DMTC1 +syn keyword lipsInstruction LDC1 LWC1 +syn keyword lipsInstruction MFC0 MTC0 +syn keyword lipsInstruction MFC1 MTC1 +syn keyword lipsInstruction MFHI MFLO +syn keyword lipsInstruction MTHI MTLO +syn keyword lipsInstruction SDC1 SWC1 + +syn keyword lipsInstruction BREAK +syn keyword lipsInstruction CACHE +syn keyword lipsInstruction ERET +syn keyword lipsInstruction SYNC +syn keyword lipsInstruction SYSCALL + +syn keyword lipsInstruction TEQ TEQI +syn keyword lipsInstruction TGE TGEI TGEIU TGEU +syn keyword lipsInstruction TLBP TLBR +syn keyword lipsInstruction TLBWI TLBWR +syn keyword lipsInstruction TLT TLTI TLTIU TLTU +syn keyword lipsInstruction TNE TNEI + +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ + +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ + +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ + +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ +syn match lipsInstruction /\/ + +" Pseudo-instructions + +syn keyword lipsInstruction B BAL +syn keyword lipsInstruction BEQZ BNEZ +syn keyword lipsInstruction CL +syn keyword lipsInstruction MOV +syn keyword lipsInstruction NEG +syn keyword lipsInstruction NOP +syn keyword lipsInstruction NOT +syn keyword lipsInstruction SUBI SUBIU + +syn keyword lipsInstruction LI LA + +syn keyword lipsInstruction PUSH +syn keyword lipsInstruction POP JPOP + +syn keyword lipsInstruction ABS +syn keyword lipsInstruction MUL +syn keyword lipsInstruction REM +syn keyword lipsInstruction NAND NANDI +syn keyword lipsInstruction NORI +syn keyword lipsInstruction ROL ROR + +syn keyword lipsInstruction SEQ SEQI SEQIU SEQU +syn keyword lipsInstruction SGE SGEI SGEIU SGEU +syn keyword lipsInstruction SGT SGTI SGTIU SGTU +syn keyword lipsInstruction SLE SLEI SLEIU SLEU +syn keyword lipsInstruction SNE SNEI SNEIU SNEU + +syn keyword lipsInstruction BEQI +syn keyword lipsInstruction BNEI +syn keyword lipsInstruction BGE BGEI +syn keyword lipsInstruction BLE BLEI +syn keyword lipsInstruction BLT BLTI +syn keyword lipsInstruction BGT BGTI + +hi def link lipsComment Comment +hi def link lipsNumber Number +hi def link lipsString String +hi def link lipsLabel Type +hi def link lipsRegister Identifier +hi def link lipsDirective Special +hi def link lipsInstruction Statement +hi def link lipsDefine Define + +let b:current_syntax = "lips"