j avatar j committed bc17c57

vim improvements and syntax file additions

Comments (0)

Files changed (4)

etc/vim/filetype.vim

-au BufNewFile,BufRead *.ini,*/.hgrc,*/.hg/hgrc setf ini
+au BufNewFile,BufRead *.ini,*/.hgrc,*/.hgrc_*,*/.hg/hgrc setf ini

etc/vim/syntax/django.vim

+" Vim syntax file
+" Language:	Django template
+" Maintainer:	Dave Hodder <dmh@dmh.org.uk>
+" Last Change:	2010 May 19
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+
+syntax case match
+
+" Mark illegal characters
+syn match djangoError "%}\|}}\|#}"
+
+" Django template built-in tags and parameters
+" 'comment' doesn't appear here because it gets special treatment
+syn keyword djangoStatement contained autoescape csrf_token empty
+" FIXME ==, !=, <, >, <=, and >= should be djangoStatements:
+" syn keyword djangoStatement contained == != < > <= >=
+syn keyword djangoStatement contained and as block endblock by cycle debug else
+syn keyword djangoStatement contained extends filter endfilter firstof for
+syn keyword djangoStatement contained endfor if endif ifchanged endifchanged
+syn keyword djangoStatement contained ifequal endifequal ifnotequal
+syn keyword djangoStatement contained endifnotequal in include load not now or
+syn keyword djangoStatement contained parsed regroup reversed spaceless
+syn keyword djangoStatement contained endspaceless ssi templatetag openblock
+syn keyword djangoStatement contained closeblock openvariable closevariable
+syn keyword djangoStatement contained openbrace closebrace opencomment
+syn keyword djangoStatement contained closecomment widthratio url with endwith
+syn keyword djangoStatement contained get_current_language trans noop blocktrans
+syn keyword djangoStatement contained endblocktrans get_available_languages
+syn keyword djangoStatement contained get_current_language_bidi plural
+
+" Django templete built-in filters
+syn keyword djangoFilter contained add addslashes capfirst center cut date
+syn keyword djangoFilter contained default default_if_none dictsort
+syn keyword djangoFilter contained dictsortreversed divisibleby escape escapejs
+syn keyword djangoFilter contained filesizeformat first fix_ampersands
+syn keyword djangoFilter contained floatformat get_digit join last length length_is
+syn keyword djangoFilter contained linebreaks linebreaksbr linenumbers ljust
+syn keyword djangoFilter contained lower make_list phone2numeric pluralize
+syn keyword djangoFilter contained pprint random removetags rjust slice slugify
+syn keyword djangoFilter contained safe safeseq stringformat striptags
+syn keyword djangoFilter contained time timesince timeuntil title
+syn keyword djangoFilter contained truncatewords truncatewords_html unordered_list upper urlencode
+syn keyword djangoFilter contained urlize urlizetrunc wordcount wordwrap yesno
+
+" Keywords to highlight within comments
+syn keyword djangoTodo contained TODO FIXME XXX
+
+" Django template constants (always surrounded by double quotes)
+syn region djangoArgument contained start=/"/ skip=/\\"/ end=/"/
+
+" Mark illegal characters within tag and variables blocks
+syn match djangoTagError contained "#}\|{{\|[^%]}}\|[&#]"
+syn match djangoVarError contained "#}\|{%\|%}\|[<>!&#%]"
+
+" Django template tag and variable blocks
+syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display
+syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display
+
+" Django template 'comment' tag and comment block
+syn region djangoComment start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}" contains=djangoTodo
+syn region djangoComBlock start="{#" end="#}" contains=djangoTodo
+
+" 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_django_syn_inits")
+  if version < 508
+    let did_django_syn_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
+
+  HiLink djangoTagBlock PreProc
+  HiLink djangoVarBlock PreProc
+  HiLink djangoStatement Statement
+  HiLink djangoFilter Identifier
+  HiLink djangoArgument Constant
+  HiLink djangoTagError Error
+  HiLink djangoVarError Error
+  HiLink djangoError Error
+  HiLink djangoComment Comment
+  HiLink djangoComBlock Comment
+  HiLink djangoTodo Todo
+
+  delcommand HiLink
+endif
+
+let b:current_syntax = "django"

etc/vim/syntax/markdown.vim

+" Vim syntax file
+" Language:     Markdown
+" Maintainer:   Tim Pope <vimNOSPAM@tpope.org>
+" Filenames:    *.markdown
+
+if exists("b:current_syntax")
+  finish
+endif
+
+runtime! syntax/html.vim
+unlet! b:current_syntax
+
+syn sync minlines=10
+syn case ignore
+
+syn match markdownValid '[<>]\S\@!'
+syn match markdownValid '&\%(#\=\w*;\)\@!'
+
+syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock
+
+syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule
+syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop
+
+syn match markdownH1 ".\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule
+syn match markdownH2 ".\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule
+
+syn match markdownHeadingRule "^[=-]\+$" contained
+
+syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!"      end="#*\s*$" keepend oneline contains=@markdownInline contained
+syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!"     end="#*\s*$" keepend oneline contains=@markdownInline contained
+syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!"    end="#*\s*$" keepend oneline contains=@markdownInline contained
+syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!"   end="#*\s*$" keepend oneline contains=@markdownInline contained
+syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!"  end="#*\s*$" keepend oneline contains=@markdownInline contained
+syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
+
+syn match markdownBlockquote ">\s" contained nextgroup=@markdownBlock
+
+syn region markdownCodeBlock start="    \|\t" end="$" contained
+
+" TODO: real nesting
+syn match markdownListMarker " \{0,4\}[-*+]\%(\s\+\S\)\@=" contained
+syn match markdownOrderedListMarker " \{0,4}\<\d\+\.\%(\s*\S\)\@=" contained
+
+syn match markdownRule "\* *\* *\*[ *]*$" contained
+syn match markdownRule "- *- *-[ -]*$" contained
+
+syn match markdownLineBreak "\s\{2,\}$"
+
+syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
+syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
+syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
+syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
+syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained
+syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained
+
+syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" keepend nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
+syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
+syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
+syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
+
+syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
+syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
+syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart
+syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart
+syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart
+syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart
+syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart
+syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart
+syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*\zs```\s*\w*\ze\s*$" end="^```\ze\s*$" keepend
+
+syn match markdownEscape "\\[][\\`*_{}()#+.!-]"
+syn match markdownError "\w\@<=_\w\@="
+
+hi def link markdownH1                    htmlH1
+hi def link markdownH2                    htmlH2
+hi def link markdownH3                    htmlH3
+hi def link markdownH4                    htmlH4
+hi def link markdownH5                    htmlH5
+hi def link markdownH6                    htmlH6
+hi def link markdownHeadingRule           markdownRule
+hi def link markdownHeadingDelimiter      Delimiter
+hi def link markdownOrderedListMarker     markdownListMarker
+hi def link markdownListMarker            htmlTagName
+hi def link markdownBlockquote            Comment
+hi def link markdownRule                  PreProc
+
+hi def link markdownLinkText              htmlLink
+hi def link markdownIdDeclaration         Typedef
+hi def link markdownId                    Type
+hi def link markdownAutomaticLink         markdownUrl
+hi def link markdownUrl                   Float
+hi def link markdownUrlTitle              String
+hi def link markdownIdDelimiter           markdownLinkDelimiter
+hi def link markdownUrlDelimiter          htmlTag
+hi def link markdownUrlTitleDelimiter     Delimiter
+
+hi def link markdownItalic                htmlItalic
+hi def link markdownBold                  htmlBold
+hi def link markdownBoldItalic            htmlBoldItalic
+hi def link markdownCodeDelimiter         Delimiter
+
+hi def link markdownEscape                Special
+hi def link markdownError                 Error
+
+let b:current_syntax = "markdown"
+
+" vim:set sw=2:
 " |                   (see gvimrc for gui vim settings)                       |
 " |                                                                           |
 " | Some highlights:                                                          |
-" |   jj = <esc>  Very useful for keeping your hands on the home row          |
+" |   ,m = paste mode (prevents un-wanted indentation when pasting)           |
 " |   ,n = toggle NERDTree off and on                                         |
 " |                                                                           |
 " |   ,f = fuzzy find all files                                               |
 " |   enter and shift-enter = adds a new line after/before the current line   |
 " |                                                                           |
 " |   :call Tabstyle_tabs = set tab to real tabs                              |
-" |   :call Tabstyle_spaces = set tab to 2 spaces                             |
+" |   :call Tabstyle_spaces = set tab to 4 spaces                             |
 " |                                                                           |
 " | Put machine/user specific settings in ~/.vimrc.local                      |
 " -----------------------------------------------------------------------------  
 
 set nocompatible
 let mapleader = ","
-imap jj <Esc> " Professor VIM says '87% of users prefer jj over esc', jj abrams disagrees
-
 
 " Tabs ************************************************************************
 "set sta " a <Tab> in an indent inserts 'shiftwidth' spaces
 endfunction
 
 function! Tabstyle_spaces()
-  " Use 2 spaces
-  set softtabstop=2
-  set shiftwidth=2
-  set tabstop=2
+  " Use 4 spaces
+  set softtabstop=4
+  set shiftwidth=4
+  set tabstop=4
   set expandtab
 endfunction
 
 
 
 " Toggle paste mode, hiding line numbers as well ******************************
-nnoremap pp :set nonumber! <bar> set invpaste paste?<CR>
-set pastetoggle=pp
+nnoremap <Leader>m :set nonumber! <bar> set invpaste paste?<CR>
+set pastetoggle=<Leader>m
 set showmode
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.