From c005df528fb39d882f9cd14432a16585222750ab Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 16 Mar 2022 09:42:40 +0100 Subject: [PATCH] Add dis syntax --- ftdetect/dis.vim | 1 + ftplugin/dis.vim | 6 +++ syntax/dis.vim | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 ftdetect/dis.vim create mode 100644 ftplugin/dis.vim create mode 100644 syntax/dis.vim diff --git a/ftdetect/dis.vim b/ftdetect/dis.vim new file mode 100644 index 0000000..1d3f669 --- /dev/null +++ b/ftdetect/dis.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.dis* set filetype=dis diff --git a/ftplugin/dis.vim b/ftplugin/dis.vim new file mode 100644 index 0000000..0ae4f60 --- /dev/null +++ b/ftplugin/dis.vim @@ -0,0 +1,6 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin=1 + +set ts=4 diff --git a/syntax/dis.vim b/syntax/dis.vim new file mode 100644 index 0000000..19446d5 --- /dev/null +++ b/syntax/dis.vim @@ -0,0 +1,116 @@ +" Vim syntax file +" Language: x86/x64 GNU Disassembler (objdump -d -Mintel) +" Maintainer: @shiracamus +" Last Change: 2013 Dec 30 + +" For version 5.x: Clear all syntax items +" For version 6.0 and later: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +syn case ignore + +syn match disOffset "[+-]" +syn match disNumber "[+-]\?\<0x[0-9a-f]\+\>" contains=disOffset +syn match disNumber "[+-]\?\<[0-9a-f]\+\>" contains=disOffset + +syn match disRegister "\<[re]\?[abcd][xhl]\>" +syn match disRegister "\<[re]\?[sd]il\?\>" +syn match disRegister "\<[re]\?[sbi]pl\?\>" +syn match disRegister "\" +syn match disRegister "[^\t]\<[cdefgs]s\>"hs=s+1 + +syn match disAt "@" +syn match disSection " \.[a-z][a-z_\.-]*:"he=e-1 +syn match disSection "@[a-z0-9_][a-z0-9_-]\+"hs=s+1 contains=disAt,disNumber + +syn match disLabel "<[a-z0-9_.][a-z0-9_.@+-]\+>"hs=s+1,he=e-1 contains=disNumber,disSection +syn match disHexDump ":\t\([0-9a-f][0-9a-f][ \t]\)\+"hs=s+1 + +syn match disError "" +syn match disError "(bad)" + +syn keyword disTodo contained TODO + +syn region disComment start="/\*" end="\*/" contains=disTodo +syn match disComment "[#;!|].*" contains=disLabel,disTodo +syn match disStatement "//.*" contains=cStatement + +syn match disSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" +syn region disString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=disSpecial +syn region disString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=disSpecial + +syn match disFormat ": \+file format " +syn match disTitle "^[^ ]\+: \+file format .*$" contains=disFormat + +syn match disMacro "FWORD" +syn match disMacro "QWORD" +syn match disMacro "DWORD" +syn match disMacro "BYTE" +syn match disMacro "PTR" + +syn match disData ".word" +syn match disData ".short" +syn match disData ".byte" + +" Opecode matched disNumber +syn match disOpecode "\= 508 || !exists("did_dis_syntax_inits") + if version < 508 + let did_dis_syntax_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + " The default methods for highlighting. Can be overridden later + " Comment + HiLink disComment Comment + " Constant: String, Character, Number, Boolean, Float + HiLink disNumber Number + HiLink disString String + " Identifier: Function + HiLink disHexDump Identifier + " Statement: Conditional, Repeat, Label, Operator, Keyword, Exception + HiLink disStatement Statement + HiLink disLabel Label + " PreProc: Include, Define, Macro, PreCondit + HiLink disData Define + HiLink disMacro Macro + " Type: StorageClass, Structure, Typedef + HiLink disRegister StorageClass + HiLink disTitle Typedef + " Special: SpecialChar, Tag, Delimiter, SpecialComment, Debug + HiLink disSpecial SpecialChar + HiLink disSection Special + " Underlined + " Ignore + " Error + HiLink disError Error + " Todo + HiLink disTodo Todo + + delcommand HiLink +endif + +let b:current_syntax = "dis" + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: ts=8 sts=4 sw=2 -- 2.39.5