summaryrefslogtreecommitdiff
path: root/runtime/syntax/asm.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/syntax/asm.vim')
-rw-r--r--runtime/syntax/asm.vim44
1 files changed, 35 insertions, 9 deletions
diff --git a/runtime/syntax/asm.vim b/runtime/syntax/asm.vim
index 6b8ce1ed..0ce8d239 100644
--- a/runtime/syntax/asm.vim
+++ b/runtime/syntax/asm.vim
@@ -3,7 +3,7 @@
" Maintainer: Erik Wognsen <erik.wognsen@gmail.com>
" Previous maintainer:
" Kevin Dahlhausen <kdahlhaus@yahoo.com>
-" Last Change: 2010 Apr 18
+" Last Change: 2012 Jan 5
" Thanks to Ori Avtalion for feedback on the comment markers!
@@ -15,6 +15,9 @@ elseif exists("b:current_syntax")
finish
endif
+let s:cpo_save = &cpo
+set cpo&vim
+
syn case ignore
" storage types
@@ -40,7 +43,7 @@ syn match asmIdentifier "[a-z_][a-z0-9_]*"
" Various #'s as defined by GAS ref manual sec 3.6.2.1
" Technically, the first decNumber def is actually octal,
" since the value of 0-7 octal is the same as 0-7 decimal,
-" I prefer to map it as decimal:
+" I (Kevin) prefer to map it as decimal:
syn match decNumber "0\+[1-7]\=[\t\n$,; ]"
syn match decNumber "[1-9]\d*"
syn match octNumber "0[0-7][0-7]\+"
@@ -49,14 +52,34 @@ syn match binNumber "0[bB][0-1]*"
syn keyword asmTodo contained TODO
-" GAS supports various comment markers as described here:
-" http://sourceware.org/binutils/docs-2.19/as/Comments.html
-" I have commented out the ARM comment marker "@" by default as I think more
-" people are using "@" with the .type directive. See
-" http://sourceware.org/binutils/docs-2.19/as/Type.html
+
+" GAS supports one type of multi line comments:
syn region asmComment start="/\*" end="\*/" contains=asmTodo
+
+" Line comment characters depend on the target architecture and command line
+" options and some comments may double as logical line number directives or
+" preprocessor commands. This situation is described at
+" http://sourceware.org/binutils/docs-2.22/as/Comments.html
+" Some line comment characters have other meanings for other targets. For
+" example, .type directives may use the `@' character which is also an ARM
+" comment marker.
+" As a compromise to accommodate what I arbitrarily assume to be the most
+" frequently used features of the most popular architectures (and also the
+" non-GNU assembly languages that use this syntax file because their asm files
+" are also named *.asm), the following are used as line comment characters:
syn match asmComment "[#;!|].*" contains=asmTodo
-" syn match asmComment "@.*" contains=asmTodo
+
+" Side effects of this include:
+" - When `;' is used to separate statements on the same line (many targets
+" support this), all statements except the first get highlighted as
+" comments. As a remedy, remove `;' from the above.
+" - ARM comments are not highlighted correctly. For ARM, uncomment the
+" following two lines and comment the one above.
+"syn match asmComment "@.*" contains=asmTodo
+"syn match asmComment "^#.*" contains=asmTodo
+
+" Advanced users of specific architectures will probably want to change the
+" comment highlighting or use a specific, more comprehensive syntax file.
syn match asmInclude "\.include"
syn match asmCond "\.if"
@@ -97,7 +120,7 @@ if version >= 508 || !exists("did_asm_syntax_inits")
HiLink octNumber Number
HiLink binNumber Number
- HiLink asmIdentifier Identifier
+ HiLink asmIdentifier Identifier
HiLink asmType Type
delcommand HiLink
@@ -105,4 +128,7 @@ endif
let b:current_syntax = "asm"
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
" vim: ts=8