소스 검색

vimrc tweaks, add disas syntax

Taddeus Kroes 8 년 전
부모
커밋
767c205ba7
3개의 변경된 파일과 126개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 0
      bashrc
  2. 114 0
      vim/syntax/dis.vim
  3. 9 5
      vimrc

+ 3 - 0
bashrc

@@ -135,6 +135,9 @@ alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo
 
 # syntax-highlighted cat
 alias pcat="pygmentize -f terminal256 -O style=native -g"
+pless() {
+    pcat "$@" | less -r
+}
 
 #
 # Environment

+ 114 - 0
vim/syntax/dis.vim

@@ -0,0 +1,114 @@
+" Vim syntax file
+" Language:     x86/x64 GNU Disassembler (objdump -d -Mintel)
+" Maintainer:   @shiracamus <shiracamus@gmail.com>
+" 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   "\<r[0-9]\+[dwb]\?\>"
+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] \)\+"hs=s+1
+
+syn match disError      "<internal disassembler error>"
+syn match disError      "(bad)"
+
+syn keyword disTodo     contained TODO
+
+syn region disComment   start="/\*" end="\*/" contains=disTodo
+syn match disComment    "[#;!|].*" contains=disLabel,disTodo
+
+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    "\<add "
+syn match disOpecode    "\<adc "
+syn match disOpecode    "\<dec "
+syn match disOpecode    "\<fadd "
+
+syn case match
+
+" 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_dis_syntax_inits")
+  if version < 508
+    let did_dis_syntax_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  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 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

+ 9 - 5
vimrc

@@ -55,7 +55,8 @@ set number              " show line numbers
 set title               " change the terminal's title
 set nocompatible        " disable Vi-compatibility
 set laststatus=2        " always display filename
-set textwidth=79        " break line at 79 chars
+set textwidth=80        " break line at 80 chars
+set scrolloff=5         " always keep current line five lines off the screen edge
 
 " Tabs are for heathens, we indent with spaces
 set expandtab smarttab
@@ -137,19 +138,18 @@ cmap w!! w !sudo tee % >/dev/null
 " ---------------
 
 " Some files only have 2 spaces indent
-autocmd FileType css,less,sass,html,ocaml,bib,llvm set shiftwidth=2
+autocmd FileType css,less,sass,html,ocaml,bib,llvm,tex,markdown set shiftwidth=2
 
 " Make pfd's readable
 autocmd BufReadPre *.pdf set ro nowrap
 autocmd BufReadPost *.pdf silent %!pdftotext "%" -nopgbrk -layout -q -eol unix -
 
-" C syntax highlighting for CiviC files
-autocmd BufNewFile,BufRead *.cvc set filetype=c
-
 " Status line highlight
 highlight StatusLine ctermbg=black ctermfg=grey
 
 " Syntax highlighting by extension
+autocmd BufNewFile,BufRead *.cvc set filetype=c
+autocmd BufNewFile,BufRead *.fc set filetype=c
 autocmd BufNewFile,BufRead *.less set filetype=less
 autocmd BufNewFile,BufRead *.md set filetype=markdown
 autocmd BufNewFile,BufRead *.gv set filetype=dot
@@ -159,10 +159,14 @@ autocmd BufNewFile,BufRead *.mustache set filetype=html
 autocmd BufNewFile,BufRead *.ts set filetype=javascript
 autocmd BufNewFile,BufRead *.scss set filetype=sass
 autocmd BufNewFile,BufRead *.fc,*.fh set filetype=fennec
+autocmd BufNewFile,BufRead *.dis set filetype=dis
 
 " Highlight and underline badly spelled words when spellcheck is on
 highlight SpellBad guisp=#fcaf3e cterm=underline
 
+" Auto enable spellchecking for text-based files
+autocmd FileType tex,markdown setlocal spell nonu
+
 " -----------------------
 " Additional local config
 " -----------------------