diff options
Diffstat (limited to 'home/.config/nvim')
-rw-r--r-- | home/.config/nvim/autoload/man.vim | 412 | ||||
-rw-r--r-- | home/.config/nvim/colors/trivial.vim | 65 | ||||
-rw-r--r-- | home/.config/nvim/ftdetect/mdoc.vim | 1 | ||||
-rw-r--r-- | home/.config/nvim/init.vim | 34 | ||||
-rw-r--r-- | home/.config/nvim/syntax/mdoc.vim | 12 | ||||
-rw-r--r-- | home/.config/nvim/syntax/nasm.vim | 527 |
6 files changed, 1051 insertions, 0 deletions
diff --git a/home/.config/nvim/autoload/man.vim b/home/.config/nvim/autoload/man.vim new file mode 100644 index 00000000..c6f49339 --- /dev/null +++ b/home/.config/nvim/autoload/man.vim @@ -0,0 +1,412 @@ +" Maintainer: Anmol Sethi <anmol@aubble.com> + +if exists('s:loaded_man') + finish +endif +let s:loaded_man = 1 + +let s:find_arg = '-w' +let s:localfile_arg = v:true " Always use -l if possible. #6683 +let s:section_arg = '-s' + +function! s:init_section_flag() + call system(['env', 'MANPAGER=cat', 'man', s:section_arg, '1', 'man']) + if v:shell_error + let s:section_arg = '-S' + endif +endfunction + +function! s:init() abort + call s:init_section_flag() + " TODO(nhooyr): Does `man -l` on SunOS list searched directories? + try + if !has('win32') && $OSTYPE !~? 'cygwin\|linux' && system('uname -s') =~? 'SunOS' && system('uname -r') =~# '^5' + let s:find_arg = '-l' + endif + " Check for -l support. + call s:get_page(s:get_path('', 'man')) + catch /E145:/ + " Ignore the error in restricted mode + catch /command error .*/ + let s:localfile_arg = v:false + endtry +endfunction + +function! man#open_page(count, count1, mods, ...) abort + if a:0 > 2 + call s:error('too many arguments') + return + elseif a:0 == 0 + let ref = &filetype ==# 'man' ? expand('<cWORD>') : expand('<cword>') + if empty(ref) + call s:error('no identifier under cursor') + return + endif + elseif a:0 ==# 1 + let ref = a:1 + else + " Combine the name and sect into a manpage reference so that all + " verification/extraction can be kept in a single function. + " If a:2 is a reference as well, that is fine because it is the only + " reference that will match. + let ref = a:2.'('.a:1.')' + endif + try + let [sect, name] = man#extract_sect_and_name_ref(ref) + if a:count ==# a:count1 + " v:count defaults to 0 which is a valid section, and v:count1 defaults to + " 1, also a valid section. If they are equal, count explicitly set. + let sect = string(a:count) + endif + let [sect, name, path] = s:verify_exists(sect, name) + catch + call s:error(v:exception) + return + endtry + + call s:push_tag() + let bufname = 'man://'.name.(empty(sect)?'':'('.sect.')') + + try + set eventignore+=BufReadCmd + if a:mods !~# 'tab' && s:find_man() + execute 'silent keepalt edit' fnameescape(bufname) + else + execute 'silent keepalt' a:mods 'split' fnameescape(bufname) + endif + finally + set eventignore-=BufReadCmd + endtry + + try + let page = s:get_page(path) + catch + if a:mods =~# 'tab' || !s:find_man() + " a new window was opened + close + endif + call s:error(v:exception) + return + endtry + + let b:man_sect = sect + call s:put_page(page) +endfunction + +function! man#read_page(ref) abort + try + let [sect, name] = man#extract_sect_and_name_ref(a:ref) + let [sect, name, path] = s:verify_exists(sect, name) + let page = s:get_page(path) + catch + call s:error(v:exception) + return + endtry + let b:man_sect = sect + call s:put_page(page) +endfunction + +" Handler for s:system() function. +function! s:system_handler(jobid, data, event) dict abort + if a:event is# 'stdout' || a:event is# 'stderr' + let self[a:event] .= join(a:data, "\n") + else + let self.exit_code = a:data + endif +endfunction + +" Run a system command and timeout after 30 seconds. +function! s:system(cmd, ...) abort + let opts = { + \ 'stdout': '', + \ 'stderr': '', + \ 'exit_code': 0, + \ 'on_stdout': function('s:system_handler'), + \ 'on_stderr': function('s:system_handler'), + \ 'on_exit': function('s:system_handler'), + \ } + let jobid = jobstart(a:cmd, opts) + + if jobid < 1 + throw printf('command error %d: %s', jobid, join(a:cmd)) + endif + + let res = jobwait([jobid], 30000) + if res[0] == -1 + try + call jobstop(jobid) + throw printf('command timed out: %s', join(a:cmd)) + catch /^Vim(call):E900:/ + endtry + elseif res[0] == -2 + throw printf('command interrupted: %s', join(a:cmd)) + endif + if opts.exit_code != 0 + throw printf("command error (%d) %s: %s", jobid, join(a:cmd), substitute(opts.stderr, '\_s\+$', '', &gdefault ? '' : 'g')) + endif + + return opts.stdout +endfunction + +function! s:get_page(path) abort + " Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065). + " We use soft wrap: ftplugin/man.vim sets wrap/breakindent/…. + let manwidth = 999 + if exists('g:man_hard_wrap') + " Respect $MANWIDTH or default to window width. + let manwidth = empty($MANWIDTH) ? winwidth(0) : $MANWIDTH + endif + " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). + " http://comments.gmane.org/gmane.editors.vim.devel/29085 + " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. + let cmd = ['env', 'MANPAGER=cat', 'MANWIDTH='.manwidth, 'MAN_KEEP_FORMATTING=1', 'man'] + return s:system(cmd + (s:localfile_arg ? ['-l', a:path] : [a:path])) +endfunction + +function! s:put_page(page) abort + setlocal modifiable + setlocal noreadonly + silent keepjumps %delete _ + silent put =a:page + while getline(1) =~# '^\s*$' + silent keepjumps 1delete _ + endwhile + " XXX: nroff justifies text by filling it with whitespace. That interacts + " badly with our use of $MANWIDTH=999. Hack around this by using a fixed + " size for those whitespace regions. + silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g + 1 + lua require("man").highlight_man_page() + setlocal filetype=man +endfunction + +function! man#show_toc() abort + let bufname = bufname('%') + let info = getloclist(0, {'winid': 1}) + if !empty(info) && getwinvar(info.winid, 'qf_toc') ==# bufname + lopen + return + endif + + let toc = [] + let lnum = 2 + let last_line = line('$') - 1 + while lnum && lnum < last_line + let text = getline(lnum) + if text =~# '^\%( \{3\}\)\=\S.*$' + call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, 'text': text}) + endif + let lnum = nextnonblank(lnum + 1) + endwhile + + call setloclist(0, toc, ' ') + call setloclist(0, [], 'a', {'title': 'Man TOC'}) + lopen + let w:qf_toc = bufname +endfunction + +" attempt to extract the name and sect out of 'name(sect)' +" otherwise just return the largest string of valid characters in ref +function! man#extract_sect_and_name_ref(ref) abort + if a:ref[0] ==# '-' " try ':Man -pandoc' with this disabled. + throw 'manpage name cannot start with ''-''' + endif + let ref = matchstr(a:ref, '[^()]\+([^()]\+)') + if empty(ref) + let name = matchstr(a:ref, '[^()]\+') + if empty(name) + throw 'manpage reference cannot contain only parentheses' + endif + return [get(b:, 'man_default_sects', ''), name] + endif + let left = split(ref, '(') + " see ':Man 3X curses' on why tolower. + " TODO(nhooyr) Not sure if this is portable across OSs + " but I have not seen a single uppercase section. + return [tolower(split(left[1], ')')[0]), left[0]] +endfunction + +function! s:get_path(sect, name) abort + " Some man implementations (OpenBSD) return all available paths from the + " search command, so we get() the first one. #8341 + if empty(a:sect) + return substitute(get(split(s:system(['man', s:find_arg, a:name])), 0, ''), '\n\+$', '', '') + endif + " '-s' flag handles: + " - tokens like 'printf(echo)' + " - sections starting with '-' + " - 3pcap section (found on macOS) + " - commas between sections (for section priority) + return substitute(get(split(s:system(['man', s:find_arg, s:section_arg, a:sect, a:name])), 0, ''), '\n\+$', '', '') +endfunction + +function! s:verify_exists(sect, name) abort + try + let path = s:get_path(a:sect, a:name) + catch /^command error (/ + try + let path = s:get_path(get(b:, 'man_default_sects', ''), a:name) + catch /^command error (/ + let path = s:get_path('', a:name) + endtry + endtry + " Extract the section from the path, because sometimes the actual section is + " more specific than what we provided to `man` (try `:Man 3 App::CLI`). + " Also on linux, name seems to be case-insensitive. So for `:Man PRIntf`, we + " still want the name of the buffer to be 'printf'. + return s:extract_sect_and_name_path(path) + [path] +endfunction + +let s:tag_stack = [] + +function! s:push_tag() abort + let s:tag_stack += [{ + \ 'buf': bufnr('%'), + \ 'lnum': line('.'), + \ 'col': col('.'), + \ }] +endfunction + +function! man#pop_tag() abort + if !empty(s:tag_stack) + let tag = remove(s:tag_stack, -1) + execute 'silent' tag['buf'].'buffer' + call cursor(tag['lnum'], tag['col']) + endif +endfunction + +" extracts the name and sect out of 'path/name.sect' +function! s:extract_sect_and_name_path(path) abort + let tail = fnamemodify(a:path, ':t') + if a:path =~# '\.\%([glx]z\|bz2\|lzma\|Z\)$' " valid extensions + let tail = fnamemodify(tail, ':r') + endif + let sect = matchstr(tail, '\.\zs[^.]\+$') + let name = matchstr(tail, '^.\+\ze\.') + return [sect, name] +endfunction + +function! s:find_man() abort + if &filetype ==# 'man' + return 1 + elseif winnr('$') ==# 1 + return 0 + endif + let thiswin = winnr() + while 1 + wincmd w + if &filetype ==# 'man' + return 1 + elseif thiswin ==# winnr() + return 0 + endif + endwhile +endfunction + +function! s:error(msg) abort + redraw + echohl ErrorMsg + echon 'man.vim: ' a:msg + echohl None +endfunction + +" see man#extract_sect_and_name_ref on why tolower(sect) +function! man#complete(arg_lead, cmd_line, cursor_pos) abort + let args = split(a:cmd_line) + let cmd_offset = index(args, 'Man') + if cmd_offset > 0 + " Prune all arguments up to :Man itself. Otherwise modifier commands like + " :tab, :vertical, etc. would lead to a wrong length. + let args = args[cmd_offset:] + endif + let l = len(args) + if l > 3 + return + elseif l ==# 1 + let name = '' + let sect = '' + elseif a:arg_lead =~# '^[^()]\+([^()]*$' + " cursor (|) is at ':Man printf(|' or ':Man 1 printf(|' + " The later is is allowed because of ':Man pri<TAB>'. + " It will offer 'priclass.d(1m)' even though section is specified as 1. + let tmp = split(a:arg_lead, '(') + let name = tmp[0] + let sect = tolower(get(tmp, 1, '')) + return s:complete(sect, '', name) + elseif args[1] !~# '^[^()]\+$' + " cursor (|) is at ':Man 3() |' or ':Man (3|' or ':Man 3() pri|' + " or ':Man 3() pri |' + return + elseif l ==# 2 + if empty(a:arg_lead) + " cursor (|) is at ':Man 1 |' + let name = '' + let sect = tolower(args[1]) + else + " cursor (|) is at ':Man pri|' + if a:arg_lead =~# '\/' + " if the name is a path, complete files + " TODO(nhooyr) why does this complete the last one automatically + return glob(a:arg_lead.'*', 0, 1) + endif + let name = a:arg_lead + let sect = '' + endif + elseif a:arg_lead !~# '^[^()]\+$' + " cursor (|) is at ':Man 3 printf |' or ':Man 3 (pr)i|' + return + else + " cursor (|) is at ':Man 3 pri|' + let name = a:arg_lead + let sect = tolower(args[1]) + endif + return s:complete(sect, sect, name) +endfunction + +function! s:complete(sect, psect, name) abort + try + let mandirs = join(split(s:system(['man', s:find_arg]), ':\|\n'), ',') + catch + call s:error(v:exception) + return + endtry + let pages = globpath(mandirs,'man?/'.a:name.'*.'.a:sect.'*', 0, 1) + " We remove duplicates in case the same manpage in different languages was found. + return uniq(sort(map(pages, 's:format_candidate(v:val, a:psect)'), 'i')) +endfunction + +function! s:format_candidate(path, psect) abort + if a:path =~# '\.\%(pdf\|in\)$' " invalid extensions + return + endif + let [sect, name] = s:extract_sect_and_name_path(a:path) + if sect ==# a:psect + return name + elseif sect =~# a:psect.'.\+$' + " We include the section if the user provided section is a prefix + " of the actual section. + return name.'('.sect.')' + endif +endfunction + +function! man#init_pager() abort + if getline(1) =~# '^\s*$' + silent keepjumps 1delete _ + else + keepjumps 1 + endif + lua require("man").highlight_man_page() + " Guess the ref from the heading (which is usually uppercase, so we cannot + " know the correct casing, cf. `man glDrawArraysInstanced`). + let ref = substitute(matchstr(getline(1), '^[^)]\+)'), ' ', '_', 'g') + try + let b:man_sect = man#extract_sect_and_name_ref(ref)[0] + catch + let b:man_sect = '' + endtry + if -1 == match(bufname('%'), 'man:\/\/') " Avoid duplicate buffers, E95. + execute 'silent file man://'.tolower(fnameescape(ref)) + endif +endfunction + +call s:init() diff --git a/home/.config/nvim/colors/trivial.vim b/home/.config/nvim/colors/trivial.vim new file mode 100644 index 00000000..3ebe8d97 --- /dev/null +++ b/home/.config/nvim/colors/trivial.vim @@ -0,0 +1,65 @@ +hi clear +syntax reset +let colors_name = 'trivial' + +hi Normal ctermbg=NONE ctermfg=NONE + +hi ColorColumn ctermbg=0 +hi EndOfBuffer ctermfg=8 +hi VertSplit cterm=NONE ctermbg=NONE ctermfg=8 +hi LineNr ctermfg=8 +hi MatchParen ctermbg=NONE ctermfg=3 +hi ModeMsg ctermfg=8 +hi MoreMsg ctermfg=2 +hi! link Question MoreMsg +hi WarningMsg ctermfg=1 +hi NonText ctermfg=8 +hi Search ctermbg=NONE ctermfg=11 +hi StatusLine cterm=NONE ctermbg=0 ctermfg=7 +hi StatusLineNC cterm=NONE ctermbg=0 ctermfg=8 +hi Folded ctermbg=0 ctermfg=8 +hi Visual cterm=inverse ctermbg=NONE +hi Title ctermfg=5 +hi Directory ctermfg=4 + +hi Comment ctermfg=4 + +hi! link Constant Normal +hi String ctermfg=6 +hi link Character String + +hi! link Identifier Normal + +hi Statement ctermfg=7 +hi link Operator Normal + +hi PreProc ctermfg=2 + +hi! link Type Normal +hi link StorageClass Statement +hi link Structure StorageClass +hi link Typedef Structure + +hi! link Special Normal +hi SpecialComment ctermfg=12 +hi SpecialKey ctermfg=5 + +hi Underlined ctermfg=NONE +hi Error ctermbg=NONE ctermfg=9 +hi SpellBad ctermbg=NONE ctermfg=1 +hi! link Todo SpecialComment + +hi cFormat ctermfg=14 + +hi diffAdded ctermfg=10 +hi diffRemoved ctermfg=9 + +hi manUnderline cterm=italic + +hi link pythonInclude Statement + +hi link rubyDefine Structure +hi link rubyStringDelimiter String +hi link rubySymbol String + +hi link rustModPath Identifier diff --git a/home/.config/nvim/ftdetect/mdoc.vim b/home/.config/nvim/ftdetect/mdoc.vim new file mode 100644 index 00000000..b845fee6 --- /dev/null +++ b/home/.config/nvim/ftdetect/mdoc.vim @@ -0,0 +1 @@ +autocmd BufRead,BufNewFile *.[1-9] set filetype=mdoc diff --git a/home/.config/nvim/init.vim b/home/.config/nvim/init.vim new file mode 100644 index 00000000..0eeae165 --- /dev/null +++ b/home/.config/nvim/init.vim @@ -0,0 +1,34 @@ +set hidden +set undofile +set shortmess=atI +set wildmode=list:longest wildignore=*.o +set splitbelow splitright +command! W w +command! Q q + +set tabstop=4 shiftwidth=4 shiftround +set smartindent cinoptions=l1(sU1m1 +set ignorecase smartcase inccommand=nosplit +nmap <leader><leader> :nohlsearch<CR> +set foldmethod=syntax foldlevel=99 foldopen-=block +let asmsyntax = "nasm" +let c_syntax_for_h = 1 +let is_posix = 1 +let man_hard_wrap = 1 + +set title laststatus=1 +set scrolloff=1 +set noruler colorcolumn=80 +set list listchars=tab:\ \ ,trail:· +colorscheme trivial + +autocmd TermOpen * setlocal statusline=%{b:term_title} +autocmd BufEnter term://* startinsert +tmap <C-w> <C-\><C-n><C-w> + +let g:clipboard = {'copy':{'+':'pbcopy'},'paste':{'+':'pbpaste'}} +nmap gp `[v`] + +nmap <leader>s vip:sort<CR> +nmap <leader>a :0/^#include <<CR>:nohlsearch<CR>O#include < +nmap <leader>l :0read ~/src/etc/agpl.c<CR>'' diff --git a/home/.config/nvim/syntax/mdoc.vim b/home/.config/nvim/syntax/mdoc.vim new file mode 100644 index 00000000..d9d587f5 --- /dev/null +++ b/home/.config/nvim/syntax/mdoc.vim @@ -0,0 +1,12 @@ +if exists("b:current_syntax") + finish +endif + +runtime! syntax/nroff.vim +unlet! b:current_syntax + +setlocal sections+=ShSs +syntax match mdocBlank /^\.$/ conceal +setlocal conceallevel=2 + +let b:current_syntax = "mdoc" diff --git a/home/.config/nvim/syntax/nasm.vim b/home/.config/nvim/syntax/nasm.vim new file mode 100644 index 00000000..7eeb9abb --- /dev/null +++ b/home/.config/nvim/syntax/nasm.vim @@ -0,0 +1,527 @@ +" Vim syntax file +" Language: NASM - The Netwide Assembler (v0.98) +" Maintainer: Andriy Sokolov <andriy145@gmail.com> +" Original Author: Manuel M.H. Stol <Manuel.Stol@allieddata.nl> +" Former Maintainer: Manuel M.H. Stol <Manuel.Stol@allieddata.nl> +" Last Change: 2012 Feb 7 +" NASM Home: http://www.nasm.us/ + + + +" Setup Syntax: +" Clear old syntax settings +if version < 600 + syn clear +elseif exists("b:current_syntax") + finish +endif +" Assembler syntax is case insensetive +syn case ignore + + + +" Vim search and movement commands on identifers +if version < 600 + " Comments at start of a line inside which to skip search for indentifiers + set comments=:; + " Identifier Keyword characters (defines \k) + set iskeyword=@,48-57,#,$,.,?,@-@,_,~ +else + " Comments at start of a line inside which to skip search for indentifiers + setlocal comments=:; + " Identifier Keyword characters (defines \k) + setlocal iskeyword=@,48-57,#,$,.,?,@-@,_,~ +endif + + + +" Comments: +syn region nasmComment start=";" keepend end="$" contains=@nasmGrpInComments +syn region nasmSpecialComment start=";\*\*\*" keepend end="$" +syn keyword nasmInCommentTodo contained TODO FIXME XXX[XXXXX] +syn cluster nasmGrpInComments contains=nasmInCommentTodo +syn cluster nasmGrpComments contains=@nasmGrpInComments,nasmComment,nasmSpecialComment + + + +" Label Identifiers: +" in NASM: 'Everything is a Label' +" Definition Label = label defined by %[i]define or %[i]assign +" Identifier Label = label defined as first non-keyword on a line or %[i]macro +syn match nasmLabelError "$\=\(\d\+\K\|[#.@]\|\$\$\k\)\k*\>" +syn match nasmLabel "\<\(\h\|[?@]\)\k*\>" +syn match nasmLabel "[\$\~]\(\h\|[?@]\)\k*\>"lc=1 +" Labels starting with one or two '.' are special +syn match nasmLocalLabel "\<\.\(\w\|[#$?@~]\)\k*\>" +syn match nasmLocalLabel "\<\$\.\(\w\|[#$?@~]\)\k*\>"ms=s+1 +if !exists("nasm_no_warn") + syn match nasmLabelWarn "\<\~\=\$\=[_.][_.\~]*\>" +endif +if exists("nasm_loose_syntax") + syn match nasmSpecialLabel "\<\.\.@\k\+\>" + syn match nasmSpecialLabel "\<\$\.\.@\k\+\>"ms=s+1 + if !exists("nasm_no_warn") + syn match nasmLabelWarn "\<\$\=\.\.@\(\d\|[#$\.~]\)\k*\>" + endif + " disallow use of nasm internal label format + syn match nasmLabelError "\<\$\=\.\.@\d\+\.\k*\>" +else + syn match nasmSpecialLabel "\<\.\.@\(\h\|[?@]\)\k*\>" + syn match nasmSpecialLabel "\<\$\.\.@\(\h\|[?@]\)\k*\>"ms=s+1 +endif +" Labels can be dereferenced with '$' to destinguish them from reserved words +syn match nasmLabelError "\<\$\K\k*\s*:" +syn match nasmLabelError "^\s*\$\K\k*\>" +syn match nasmLabelError "\<\~\s*\(\k*\s*:\|\$\=\.\k*\)" + + + +" Constants: +syn match nasmStringError +["'`]+ +syn match nasmString +\("[^"]\{-}"\|'[^']\{-}'\|`[^"]\{-}`\)+ +syn match nasmBinNumber "\<[0-1_]\+b\>" +syn match nasmBinNumber "\<\~[0-1_]\+b\>"lc=1 +syn match nasmOctNumber "\<\(\o\|_\)\+q\>" +syn match nasmOctNumber "\<\~\(\o\|_\)\+q\>"lc=1 +syn match nasmDecNumber "\<\(\d\|_\)\+\>" +syn match nasmDecNumber "\<\~\(\d\|_\)\+\>"lc=1 +syn match nasmHexNumber "\<\(\d\(\x\|_\)*h\|0x\(\x\|_\)\+\|\$\d\(\x\|_\)*\)\>" +syn match nasmHexNumber "\<\~\(\d\(\x\|_\)*h\|0x\(\x\|_\)\+\|\$\d\(\x\|_\)*\)\>"lc=1 +syn match nasmFltNumber "\<\(\d\|_\)\+\.\(\d\|_\)*\(e[+-]\=\d\+\)\=\>" +syn keyword nasmFltNumber Inf Infinity Indefinite NaN SNaN QNaN +syn match nasmNumberError "\<\~\s*\d\+\.\d*\(e[+-]\=\d\+\)\=\>" + + +" Netwide Assembler Storage Directives: +" Storage types +syn keyword nasmTypeError DF EXTRN FWORD RESF TBYTE +syn keyword nasmType FAR NEAR SHORT +syn keyword nasmType BYTE WORD DWORD QWORD DQWORD HWORD DHWORD TWORD +syn keyword nasmType CDECL FASTCALL NONE PASCAL STDCALL +syn keyword nasmStorage DB DW DD DQ DDQ DT +syn keyword nasmStorage RESB RESW RESD RESQ RESDQ REST +syn keyword nasmStorage EXTERN GLOBAL COMMON +" Structured storage types +syn match nasmTypeError "\<\(AT\|I\=\(END\)\=\(STRUCT\=\|UNION\)\|I\=END\)\>" +syn match nasmStructureLabel contained "\<\(AT\|I\=\(END\)\=\(STRUCT\=\|UNION\)\|I\=END\)\>" +" structures cannot be nested (yet) -> use: 'keepend' and 're=' +syn cluster nasmGrpCntnStruc contains=ALLBUT,@nasmGrpInComments,nasmMacroDef,@nasmGrpInMacros,@nasmGrpInPreCondits,nasmStructureDef,@nasmGrpInStrucs +syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="^\s*STRUCT\>"hs=e-5 end="^\s*ENDSTRUCT\>"re=e-9 contains=@nasmGrpCntnStruc +syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="^\s*STRUC\>"hs=e-4 end="^\s*ENDSTRUC\>"re=e-8 contains=@nasmGrpCntnStruc +syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="\<ISTRUCT\=\>" end="\<IEND\(STRUCT\=\)\=\>" contains=@nasmGrpCntnStruc,nasmInStructure +" union types are not part of nasm (yet) +"syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="^\s*UNION\>"hs=e-4 end="^\s*ENDUNION\>"re=e-8 contains=@nasmGrpCntnStruc +"syn region nasmStructureDef transparent matchgroup=nasmStructure keepend start="\<IUNION\>" end="\<IEND\(UNION\)\=\>" contains=@nasmGrpCntnStruc,nasmInStructure +syn match nasmInStructure contained "^\s*AT\>"hs=e-1 +syn cluster nasmGrpInStrucs contains=nasmStructure,nasmInStructure,nasmStructureLabel + + + +" PreProcessor Instructions: +" NAsm PreProcs start with %, but % is not a character +syn match nasmPreProcError "%{\=\(%\=\k\+\|%%\+\k*\|[+-]\=\d\+\)}\=" +if exists("nasm_loose_syntax") + syn cluster nasmGrpNxtCtx contains=nasmStructureLabel,nasmLabel,nasmLocalLabel,nasmSpecialLabel,nasmLabelError,nasmPreProcError +else + syn cluster nasmGrpNxtCtx contains=nasmStructureLabel,nasmLabel,nasmLabelError,nasmPreProcError +endif + +" Multi-line macro +syn cluster nasmGrpCntnMacro contains=ALLBUT,@nasmGrpInComments,nasmStructureDef,@nasmGrpInStrucs,nasmMacroDef,@nasmGrpPreCondits,nasmMemReference,nasmInMacPreCondit,nasmInMacStrucDef +syn region nasmMacroDef matchgroup=nasmMacro keepend start="^\s*%macro\>"hs=e-5 start="^\s*%imacro\>"hs=e-6 end="^\s*%endmacro\>"re=e-9 contains=@nasmGrpCntnMacro,nasmInMacStrucDef +if exists("nasm_loose_syntax") + syn match nasmInMacLabel contained "%\(%\k\+\>\|{%\k\+}\)" + syn match nasmInMacLabel contained "%\($\+\(\w\|[#\.?@~]\)\k*\>\|{$\+\(\w\|[#\.?@~]\)\k*}\)" + syn match nasmInMacPreProc contained "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=nasmStructureLabel,nasmLabel,nasmInMacParam,nasmLocalLabel,nasmSpecialLabel,nasmLabelError,nasmPreProcError + if !exists("nasm_no_warn") + syn match nasmInMacLblWarn contained "%\(%[$\.]\k*\>\|{%[$\.]\k*}\)" + syn match nasmInMacLblWarn contained "%\($\+\(\d\|[#\.@~]\)\k*\|{\$\+\(\d\|[#\.@~]\)\k*}\)" + hi link nasmInMacCatLabel nasmInMacLblWarn + else + hi link nasmInMacCatLabel nasmInMacLabel + endif +else + syn match nasmInMacLabel contained "%\(%\(\w\|[#?@~]\)\k*\>\|{%\(\w\|[#?@~]\)\k*}\)" + syn match nasmInMacLabel contained "%\($\+\(\h\|[?@]\)\k*\>\|{$\+\(\h\|[?@]\)\k*}\)" + hi link nasmInMacCatLabel nasmLabelError +endif +syn match nasmInMacCatLabel contained "\d\K\k*"lc=1 +syn match nasmInMacLabel contained "\d}\k\+"lc=2 +if !exists("nasm_no_warn") + syn match nasmInMacLblWarn contained "%\(\($\+\|%\)[_~][._~]*\>\|{\($\+\|%\)[_~][._~]*}\)" +endif +syn match nasmInMacPreProc contained "^\s*%pop\>"hs=e-3 +syn match nasmInMacPreProc contained "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=@nasmGrpNxtCtx +" structures cannot be nested (yet) -> use: 'keepend' and 're=' +syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="^\s*STRUCT\>"hs=e-5 end="^\s*ENDSTRUCT\>"re=e-9 contains=@nasmGrpCntnMacro +syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="^\s*STRUC\>"hs=e-4 end="^\s*ENDSTRUC\>"re=e-8 contains=@nasmGrpCntnMacro +syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="\<ISTRUCT\=\>" end="\<IEND\(STRUCT\=\)\=\>" contains=@nasmGrpCntnMacro,nasmInStructure +" union types are not part of nasm (yet) +"syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="^\s*UNION\>"hs=e-4 end="^\s*ENDUNION\>"re=e-8 contains=@nasmGrpCntnMacro +"syn region nasmInMacStrucDef contained transparent matchgroup=nasmStructure keepend start="\<IUNION\>" end="\<IEND\(UNION\)\=\>" contains=@nasmGrpCntnMacro,nasmInStructure +syn region nasmInMacPreConDef contained transparent matchgroup=nasmInMacPreCondit start="^\s*%ifnidni\>"hs=e-7 start="^\s*%if\(idni\|n\(ctx\|def\|idn\|num\|str\)\)\>"hs=e-6 start="^\s*%if\(ctx\|def\|idn\|nid\|num\|str\)\>"hs=e-5 start="^\s*%ifid\>"hs=e-4 start="^\s*%if\>"hs=e-2 end="%endif\>" contains=@nasmGrpCntnMacro,nasmInMacPreCondit,nasmInPreCondit +" Todo: allow STRUC/ISTRUC to be used inside preprocessor conditional block +syn match nasmInMacPreCondit contained transparent "ctx\s"lc=3 skipwhite nextgroup=@nasmGrpNxtCtx +syn match nasmInMacPreCondit contained "^\s*%elifctx\>"hs=e-7 skipwhite nextgroup=@nasmGrpNxtCtx +syn match nasmInMacPreCondit contained "^\s*%elifnctx\>"hs=e-8 skipwhite nextgroup=@nasmGrpNxtCtx +syn match nasmInMacParamNum contained "\<\d\+\.list\>"me=e-5 +syn match nasmInMacParamNum contained "\<\d\+\.nolist\>"me=e-7 +syn match nasmInMacDirective contained "\.\(no\)\=list\>" +syn match nasmInMacMacro contained transparent "macro\s"lc=5 skipwhite nextgroup=nasmStructureLabel +syn match nasmInMacMacro contained "^\s*%rotate\>"hs=e-6 +syn match nasmInMacParam contained "%\([+-]\=\d\+\|{[+-]\=\d\+}\)" +" nasm conditional macro operands/arguments +" Todo: check feasebility; add too nasmGrpInMacros, etc. +"syn match nasmInMacCond contained "\<\(N\=\([ABGL]E\=\|[CEOSZ]\)\|P[EO]\=\)\>" +syn cluster nasmGrpInMacros contains=nasmMacro,nasmInMacMacro,nasmInMacParam,nasmInMacParamNum,nasmInMacDirective,nasmInMacLabel,nasmInMacLblWarn,nasmInMacMemRef,nasmInMacPreConDef,nasmInMacPreCondit,nasmInMacPreProc,nasmInMacStrucDef + +" Context pre-procs that are better used inside a macro +if exists("nasm_ctx_outside_macro") + syn region nasmPreConditDef transparent matchgroup=nasmCtxPreCondit start="^\s*%ifnctx\>"hs=e-6 start="^\s*%ifctx\>"hs=e-5 end="%endif\>" contains=@nasmGrpCntnPreCon + syn match nasmCtxPreProc "^\s*%pop\>"hs=e-3 + if exists("nasm_loose_syntax") + syn match nasmCtxLocLabel "%$\+\(\w\|[#.?@~]\)\k*\>" + else + syn match nasmCtxLocLabel "%$\+\(\h\|[?@]\)\k*\>" + endif + syn match nasmCtxPreProc "^\s*%\(push\|repl\)\>"hs=e-4 skipwhite nextgroup=@nasmGrpNxtCtx + syn match nasmCtxPreCondit contained transparent "ctx\s"lc=3 skipwhite nextgroup=@nasmGrpNxtCtx + syn match nasmCtxPreCondit contained "^\s*%elifctx\>"hs=e-7 skipwhite nextgroup=@nasmGrpNxtCtx + syn match nasmCtxPreCondit contained "^\s*%elifnctx\>"hs=e-8 skipwhite nextgroup=@nasmGrpNxtCtx + if exists("nasm_no_warn") + hi link nasmCtxPreCondit nasmPreCondit + hi link nasmCtxPreProc nasmPreProc + hi link nasmCtxLocLabel nasmLocalLabel + else + hi link nasmCtxPreCondit nasmPreProcWarn + hi link nasmCtxPreProc nasmPreProcWarn + hi link nasmCtxLocLabel nasmLabelWarn + endif +endif + +" Conditional assembly +syn cluster nasmGrpCntnPreCon contains=ALLBUT,@nasmGrpInComments,@nasmGrpInMacros,@nasmGrpInStrucs +syn region nasmPreConditDef transparent matchgroup=nasmPreCondit start="^\s*%ifnidni\>"hs=e-7 start="^\s*%if\(idni\|n\(def\|idn\|num\|str\)\)\>"hs=e-6 start="^\s*%if\(def\|idn\|nid\|num\|str\)\>"hs=e-5 start="^\s*%ifid\>"hs=e-4 start="^\s*%if\>"hs=e-2 end="%endif\>" contains=@nasmGrpCntnPreCon +syn match nasmInPreCondit contained "^\s*%el\(if\|se\)\>"hs=e-4 +syn match nasmInPreCondit contained "^\s*%elifid\>"hs=e-6 +syn match nasmInPreCondit contained "^\s*%elif\(def\|idn\|nid\|num\|str\)\>"hs=e-7 +syn match nasmInPreCondit contained "^\s*%elif\(n\(def\|idn\|num\|str\)\|idni\)\>"hs=e-8 +syn match nasmInPreCondit contained "^\s*%elifnidni\>"hs=e-9 +syn cluster nasmGrpInPreCondits contains=nasmPreCondit,nasmInPreCondit,nasmCtxPreCondit +syn cluster nasmGrpPreCondits contains=nasmPreConditDef,@nasmGrpInPreCondits,nasmCtxPreProc,nasmCtxLocLabel + +" Other pre-processor statements +syn match nasmPreProc "^\s*%\(rep\|use\)\>"hs=e-3 +syn match nasmPreProc "^\s*%line\>"hs=e-4 +syn match nasmPreProc "^\s*%\(clear\|error\|fatal\)\>"hs=e-5 +syn match nasmPreProc "^\s*%\(endrep\|strlen\|substr\)\>"hs=e-6 +syn match nasmPreProc "^\s*%\(exitrep\|warning\)\>"hs=e-7 +syn match nasmDefine "^\s*%undef\>"hs=e-5 +syn match nasmDefine "^\s*%\(assign\|define\)\>"hs=e-6 +syn match nasmDefine "^\s*%i\(assign\|define\)\>"hs=e-7 +syn match nasmDefine "^\s*%unmacro\>"hs=e-7 +syn match nasmInclude "^\s*%include\>"hs=e-7 +" Todo: Treat the line tail after %fatal, %error, %warning as text + +" Multiple pre-processor instructions on single line detection (obsolete) +"syn match nasmPreProcError +^\s*\([^\t "%';][^"%';]*\|[^\t "';][^"%';]\+\)%\a\+\>+ +syn cluster nasmGrpPreProcs contains=nasmMacroDef,@nasmGrpInMacros,@nasmGrpPreCondits,nasmPreProc,nasmDefine,nasmInclude,nasmPreProcWarn,nasmPreProcError + + + +" Register Identifiers: +" Register operands: +syn match nasmGen08Register "\<[A-D][HL]\>" +syn match nasmGen16Register "\<\([A-D]X\|[DS]I\|[BS]P\)\>" +syn match nasmGen32Register "\<E\([A-D]X\|[DS]I\|[BS]P\)\>" +syn match nasmGen64Register "\<R\([A-D]X\|[DS]I\|[BS]P\|[89]\|1[0-5]\|[89][WD]\|1[0-5][WD]\)\>" +syn match nasmSegRegister "\<[C-GS]S\>" +syn match nasmSpcRegister "\<E\=IP\>" +syn match nasmFpuRegister "\<ST\o\>" +syn match nasmMmxRegister "\<MM\o\>" +syn match nasmSseRegister "\<XMM\o\>" +syn match nasmCtrlRegister "\<CR\o\>" +syn match nasmDebugRegister "\<DR\o\>" +syn match nasmTestRegister "\<TR\o\>" +syn match nasmRegisterError "\<\(CR[15-9]\|DR[4-58-9]\|TR[0-28-9]\)\>" +syn match nasmRegisterError "\<X\=MM[8-9]\>" +syn match nasmRegisterError "\<ST\((\d)\|[8-9]\>\)" +syn match nasmRegisterError "\<E\([A-D][HL]\|[C-GS]S\)\>" +" Memory reference operand (address): +syn match nasmMemRefError "[[\]]" +syn cluster nasmGrpCntnMemRef contains=ALLBUT,@nasmGrpComments,@nasmGrpPreProcs,@nasmGrpInStrucs,nasmMemReference,nasmMemRefError +syn match nasmInMacMemRef contained "\[[^;[\]]\{-}\]" contains=@nasmGrpCntnMemRef,nasmPreProcError,nasmInMacLabel,nasmInMacLblWarn,nasmInMacParam +syn match nasmMemReference "\[[^;[\]]\{-}\]" contains=@nasmGrpCntnMemRef,nasmPreProcError,nasmCtxLocLabel + + + +" Netwide Assembler Directives: +" Compilation constants +syn keyword nasmConstant __BITS__ __DATE__ __FILE__ __FORMAT__ __LINE__ +syn keyword nasmConstant __NASM_MAJOR__ __NASM_MINOR__ __NASM_VERSION__ +syn keyword nasmConstant __TIME__ +" Instruction modifiers +syn match nasmInstructnError "\<TO\>" +syn match nasmInstrModifier "\(^\|:\)\s*[C-GS]S\>"ms=e-1 +syn keyword nasmInstrModifier A16 A32 O16 O32 +syn match nasmInstrModifier "\<F\(ADD\|MUL\|\(DIV\|SUB\)R\=\)\s\+TO\>"lc=5,ms=e-1 +" the 'to' keyword is not allowed for fpu-pop instructions (yet) +"syn match nasmInstrModifier "\<F\(ADD\|MUL\|\(DIV\|SUB\)R\=\)P\s\+TO\>"lc=6,ms=e-1 +" NAsm directives +syn keyword nasmRepeat TIMES +syn keyword nasmDirective ALIGN[B] INCBIN EQU NOSPLIT SPLIT +syn keyword nasmDirective ABSOLUTE BITS SECTION SEGMENT +syn keyword nasmDirective ENDSECTION ENDSEGMENT +syn keyword nasmDirective __SECT__ +" Macro created standard directives: (requires %include) +syn case match +syn keyword nasmStdDirective ENDPROC EPILOGUE LOCALS PROC PROLOGUE USES +syn keyword nasmStdDirective ENDIF ELSE ELIF ELSIF IF +"syn keyword nasmStdDirective BREAK CASE DEFAULT ENDSWITCH SWITCH +"syn keyword nasmStdDirective CASE OF ENDCASE +syn keyword nasmStdDirective DO ENDFOR ENDWHILE FOR REPEAT UNTIL WHILE EXIT +syn case ignore +" Format specific directives: (all formats) +" (excluded: extension directives to section, global, common and extern) +syn keyword nasmFmtDirective ORG +syn keyword nasmFmtDirective EXPORT IMPORT GROUP UPPERCASE SEG WRT +syn keyword nasmFmtDirective LIBRARY +syn case match +syn keyword nasmFmtDirective _GLOBAL_OFFSET_TABLE_ __GLOBAL_OFFSET_TABLE_ +syn keyword nasmFmtDirective ..start ..got ..gotoff ..gotpc ..plt ..sym +syn case ignore + + + +" Standard Instructions: +syn match nasmInstructnError "\<\(F\=CMOV\|SET\)N\=\a\{0,2}\>" +syn keyword nasmInstructnError CMPS MOVS LCS LODS STOS XLAT +syn match nasmStdInstruction "\<MOV\>" +syn match nasmInstructnError "\<MOV\s[^,;[]*\<CS\>\s*[^:]"he=e-1 +syn match nasmStdInstruction "\<\(CMOV\|J\|SET\)\(N\=\([ABGL]E\=\|[CEOSZ]\)\|P[EO]\=\)\>" +syn match nasmStdInstruction "\<POP\>" +syn keyword nasmStdInstruction AAA AAD AAM AAS ADC ADD AND +syn keyword nasmStdInstruction BOUND BSF BSR BSWAP BT[C] BTR BTS +syn keyword nasmStdInstruction CALL CBW CDQ CLC CLD CMC CMP CMPSB CMPSD CMPSW CMPSQ +syn keyword nasmStdInstruction CMPXCHG CMPXCHG8B CPUID CWD[E] CQO +syn keyword nasmStdInstruction DAA DAS DEC DIV ENTER +syn keyword nasmStdInstruction IDIV IMUL INC INT[O] IRET[D] IRETW IRETQ +syn keyword nasmStdInstruction JCXZ JECXZ JMP +syn keyword nasmStdInstruction LAHF LDS LEA LEAVE LES LFS LGS LODSB LODSD LODSQ +syn keyword nasmStdInstruction LODSW LOOP[E] LOOPNE LOOPNZ LOOPZ LSS +syn keyword nasmStdInstruction MOVSB MOVSD MOVSW MOVSX MOVSQ MOVZX MUL NEG NOP NOT +syn keyword nasmStdInstruction OR POPA[D] POPAW POPF[D] POPFW POPFQ +syn keyword nasmStdInstruction PUSH[AD] PUSHAW PUSHF[D] PUSHFW PUSHFQ +syn keyword nasmStdInstruction RCL RCR RETF RET[N] ROL ROR +syn keyword nasmStdInstruction SAHF SAL SAR SBB SCASB SCASD SCASW +syn keyword nasmStdInstruction SHL[D] SHR[D] STC STD STOSB STOSD STOSW STOSQ SUB +syn keyword nasmStdInstruction TEST XADD XCHG XLATB XOR +syn keyword nasmStdInstruction LFENCE MFENCE SFENCE + + +" System Instructions: (usually privileged) +" Verification of pointer parameters +syn keyword nasmSysInstruction ARPL LAR LSL VERR VERW +" Addressing descriptor tables +syn keyword nasmSysInstruction LLDT SLDT LGDT SGDT +" Multitasking +syn keyword nasmSysInstruction LTR STR +" Coprocessing and Multiprocessing (requires fpu and multiple cpu's resp.) +syn keyword nasmSysInstruction CLTS LOCK WAIT +" Input and Output +syn keyword nasmInstructnError INS OUTS +syn keyword nasmSysInstruction IN INSB INSW INSD OUT OUTSB OUTSB OUTSW OUTSD +" Interrupt control +syn keyword nasmSysInstruction CLI STI LIDT SIDT +" System control +syn match nasmSysInstruction "\<MOV\s[^;]\{-}\<CR\o\>"me=s+3 +syn keyword nasmSysInstruction HLT INVD LMSW +syn keyword nasmSseInstruction PREFETCHT0 PREFETCHT1 PREFETCHT2 PREFETCHNTA +syn keyword nasmSseInstruction RSM SFENCE SMSW SYSENTER SYSEXIT UD2 WBINVD +" TLB (Translation Lookahead Buffer) testing +syn match nasmSysInstruction "\<MOV\s[^;]\{-}\<TR\o\>"me=s+3 +syn keyword nasmSysInstruction INVLPG + +" Debugging Instructions: (privileged) +syn match nasmDbgInstruction "\<MOV\s[^;]\{-}\<DR\o\>"me=s+3 +syn keyword nasmDbgInstruction INT1 INT3 RDMSR RDTSC RDPMC WRMSR + + +" Floating Point Instructions: (requires FPU) +syn match nasmFpuInstruction "\<FCMOVN\=\([AB]E\=\|[CEPUZ]\)\>" +syn keyword nasmFpuInstruction F2XM1 FABS FADD[P] FBLD FBSTP +syn keyword nasmFpuInstruction FCHS FCLEX FCOM[IP] FCOMP[P] FCOS +syn keyword nasmFpuInstruction FDECSTP FDISI FDIV[P] FDIVR[P] FENI FFREE +syn keyword nasmFpuInstruction FIADD FICOM[P] FIDIV[R] FILD +syn keyword nasmFpuInstruction FIMUL FINCSTP FINIT FIST[P] FISUB[R] +syn keyword nasmFpuInstruction FLD[1] FLDCW FLDENV FLDL2E FLDL2T FLDLG2 +syn keyword nasmFpuInstruction FLDLN2 FLDPI FLDZ FMUL[P] +syn keyword nasmFpuInstruction FNCLEX FNDISI FNENI FNINIT FNOP FNSAVE +syn keyword nasmFpuInstruction FNSTCW FNSTENV FNSTSW FNSTSW +syn keyword nasmFpuInstruction FPATAN FPREM[1] FPTAN FRNDINT FRSTOR +syn keyword nasmFpuInstruction FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT +syn keyword nasmFpuInstruction FSTCW FSTENV FST[P] FSTSW FSUB[P] FSUBR[P] +syn keyword nasmFpuInstruction FTST FUCOM[IP] FUCOMP[P] +syn keyword nasmFpuInstruction FXAM FXCH FXTRACT FYL2X FYL2XP1 + + +" Multi Media Xtension Packed Instructions: (requires MMX unit) +" Standard MMX instructions: (requires MMX1 unit) +syn match nasmInstructnError "\<P\(ADD\|SUB\)U\=S\=[DQ]\=\>" +syn match nasmInstructnError "\<PCMP\a\{0,2}[BDWQ]\=\>" +syn keyword nasmMmxInstruction EMMS MOVD MOVQ +syn keyword nasmMmxInstruction PACKSSDW PACKSSWB PACKUSWB PADDB PADDD PADDW +syn keyword nasmMmxInstruction PADDSB PADDSW PADDUSB PADDUSW PAND[N] +syn keyword nasmMmxInstruction PCMPEQB PCMPEQD PCMPEQW PCMPGTB PCMPGTD PCMPGTW +syn keyword nasmMmxInstruction PMACHRIW PMADDWD PMULHW PMULLW POR +syn keyword nasmMmxInstruction PSLLD PSLLQ PSLLW PSRAD PSRAW PSRLD PSRLQ PSRLW +syn keyword nasmMmxInstruction PSUBB PSUBD PSUBW PSUBSB PSUBSW PSUBUSB PSUBUSW +syn keyword nasmMmxInstruction PUNPCKHBW PUNPCKHDQ PUNPCKHWD +syn keyword nasmMmxInstruction PUNPCKLBW PUNPCKLDQ PUNPCKLWD PXOR +" Extended MMX instructions: (requires MMX2/SSE unit) +syn keyword nasmMmxInstruction MASKMOVQ MOVNTQ +syn keyword nasmMmxInstruction PAVGB PAVGW PEXTRW PINSRW PMAXSW PMAXUB +syn keyword nasmMmxInstruction PMINSW PMINUB PMOVMSKB PMULHUW PSADBW PSHUFW + + +" Streaming SIMD Extension Packed Instructions: (requires SSE unit) +syn match nasmInstructnError "\<CMP\a\{1,5}[PS]S\>" +syn match nasmSseInstruction "\<CMP\(N\=\(EQ\|L[ET]\)\|\(UN\)\=ORD\)\=[PS]S\>" +syn keyword nasmSseInstruction ADDPS ADDSS ANDNPS ANDPS +syn keyword nasmSseInstruction COMISS CVTPI2PS CVTPS2PI +syn keyword nasmSseInstruction CVTSI2SS CVTSS2SI CVTTPS2PI CVTTSS2SI +syn keyword nasmSseInstruction DIVPS DIVSS FXRSTOR FXSAVE LDMXCSR +syn keyword nasmSseInstruction MAXPS MAXSS MINPS MINSS MOVAPS MOVHLPS MOVHPS +syn keyword nasmSseInstruction MOVLHPS MOVLPS MOVMSKPS MOVNTPS MOVSS MOVUPS +syn keyword nasmSseInstruction MULPS MULSS +syn keyword nasmSseInstruction ORPS RCPPS RCPSS RSQRTPS RSQRTSS +syn keyword nasmSseInstruction SHUFPS SQRTPS SQRTSS STMXCSR SUBPS SUBSS +syn keyword nasmSseInstruction UCOMISS UNPCKHPS UNPCKLPS XORPS + + +" Three Dimensional Now Packed Instructions: (requires 3DNow! unit) +syn keyword nasmNowInstruction FEMMS PAVGUSB PF2ID PFACC PFADD PFCMPEQ PFCMPGE +syn keyword nasmNowInstruction PFCMPGT PFMAX PFMIN PFMUL PFRCP PFRCPIT1 +syn keyword nasmNowInstruction PFRCPIT2 PFRSQIT1 PFRSQRT PFSUB[R] PI2FD +syn keyword nasmNowInstruction PMULHRWA PREFETCH[W] + + +" Vendor Specific Instructions: +" Cyrix instructions (requires Cyrix processor) +syn keyword nasmCrxInstruction PADDSIW PAVEB PDISTIB PMAGW PMULHRW[C] PMULHRIW +syn keyword nasmCrxInstruction PMVGEZB PMVLZB PMVNZB PMVZB PSUBSIW +syn keyword nasmCrxInstruction RDSHR RSDC RSLDT SMINT SMINTOLD SVDC SVLDT SVTS +syn keyword nasmCrxInstruction WRSHR +" AMD instructions (requires AMD processor) +syn keyword nasmAmdInstruction SYSCALL SYSRET + + +" Undocumented Instructions: +syn match nasmUndInstruction "\<POP\s[^;]*\<CS\>"me=s+3 +syn keyword nasmUndInstruction CMPXCHG486 IBTS ICEBP INT01 INT03 LOADALL +syn keyword nasmUndInstruction LOADALL286 LOADALL386 SALC SMI UD1 UMOV XBTS + + + +" Synchronize Syntax: +syn sync clear +syn sync minlines=50 "for multiple region nesting +syn sync match nasmSync grouphere nasmMacroDef "^\s*%i\=macro\>"me=s-1 +syn sync match nasmSync grouphere NONE "^\s*%endmacro\>" + + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later : only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_nasm_syntax_inits") + if version < 508 + let did_nasm_syntax_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + " Sub Links: + HiLink nasmInMacDirective nasmDirective + HiLink nasmInMacLabel nasmLocalLabel + HiLink nasmInMacLblWarn nasmLabelWarn + HiLink nasmInMacMacro nasmMacro + HiLink nasmInMacParam nasmMacro + HiLink nasmInMacParamNum nasmDecNumber + HiLink nasmInMacPreCondit nasmPreCondit + HiLink nasmInMacPreProc nasmPreProc + HiLink nasmInPreCondit nasmPreCondit + HiLink nasmInStructure nasmStructure + HiLink nasmStructureLabel nasmStructure + + " Comment Group: + HiLink nasmComment Comment + HiLink nasmSpecialComment SpecialComment + HiLink nasmInCommentTodo Todo + + " Constant Group: + HiLink nasmString String + HiLink nasmStringError Error + HiLink nasmBinNumber Number + HiLink nasmOctNumber Number + HiLink nasmDecNumber Number + HiLink nasmHexNumber Number + HiLink nasmFltNumber Float + HiLink nasmNumberError Error + + " Identifier Group: + HiLink nasmLabel Identifier + HiLink nasmLocalLabel Identifier + HiLink nasmSpecialLabel Special + HiLink nasmLabelError Error + HiLink nasmLabelWarn Todo + + " PreProc Group: + HiLink nasmPreProc PreProc + HiLink nasmDefine Define + HiLink nasmInclude Include + HiLink nasmMacro Macro + HiLink nasmPreCondit PreCondit + HiLink nasmPreProcError Error + HiLink nasmPreProcWarn Todo + + " Type Group: + HiLink nasmType Type + HiLink nasmStorage StorageClass + HiLink nasmStructure Structure + HiLink nasmTypeError Error + + " Directive Group: + HiLink nasmConstant Constant + HiLink nasmInstrModifier Operator + HiLink nasmRepeat Repeat + HiLink nasmDirective Keyword + HiLink nasmStdDirective Operator + HiLink nasmFmtDirective Keyword + + " Register Group: + HiLink nasmCtrlRegister Special + HiLink nasmDebugRegister Debug + HiLink nasmTestRegister Special + HiLink nasmRegisterError Error + HiLink nasmMemRefError Error + + " Instruction Group: + HiLink nasmStdInstruction Statement + HiLink nasmSysInstruction Statement + HiLink nasmDbgInstruction Debug + HiLink nasmFpuInstruction Statement + HiLink nasmMmxInstruction Statement + HiLink nasmSseInstruction Statement + HiLink nasmNowInstruction Statement + HiLink nasmAmdInstruction Special + HiLink nasmCrxInstruction Special + HiLink nasmUndInstruction Todo + HiLink nasmInstructnError Error + + delcommand HiLink +endif + +let b:current_syntax = "nasm" + +" vim:ts=8 sw=4 |