Pathogen and new bundles
git-svn-id: http://photonzero.com/dotfiles/trunk@65 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
9b767aed56
commit
96a93bce9e
78 changed files with 10717 additions and 0 deletions
7
.vim/bundle/vim-coffee-script/ftdetect/coffee.vim
Normal file
7
.vim/bundle/vim-coffee-script/ftdetect/coffee.vim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
" Language: CoffeeScript
|
||||
" Maintainer: Mick Koch <kchmck@gmail.com>
|
||||
" URL: http://github.com/kchmck/vim-coffee-script
|
||||
" License: WTFPL
|
||||
|
||||
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
|
||||
autocmd BufNewFile,BufRead *Cakefile set filetype=coffee
|
||||
14
.vim/bundle/vim-coffee-script/ftplugin/coffee.vim
Normal file
14
.vim/bundle/vim-coffee-script/ftplugin/coffee.vim
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
" Language: CoffeeScript
|
||||
" Maintainer: Mick Koch <kchmck@gmail.com>
|
||||
" URL: http://github.com/kchmck/vim-coffee-script
|
||||
" License: WTFPL
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal formatoptions-=t formatoptions+=croql
|
||||
setlocal comments=s:###,m:\ ,e:###,:#
|
||||
setlocal commentstring=#\ %s
|
||||
157
.vim/bundle/vim-coffee-script/indent/coffee.vim
Normal file
157
.vim/bundle/vim-coffee-script/indent/coffee.vim
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
" Language: CoffeeScript
|
||||
" Maintainer: Mick Koch <kchmck@gmail.com>
|
||||
" URL: http://github.com/kchmck/vim-coffee-script
|
||||
" License: WTFPL
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetCoffeeIndent(v:lnum)
|
||||
" Make sure GetCoffeeIndent is run when these are typed so they can be outdented
|
||||
setlocal indentkeys+=0],0),=else,=when,=catch,=finally
|
||||
|
||||
" Only define the function once
|
||||
if exists("*GetCoffeeIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Join a list of regexps as branches
|
||||
function! s:RegexpJoin(regexps)
|
||||
return join(a:regexps, '\|')
|
||||
endfunction
|
||||
|
||||
" Create a regexp group from a list of regexps
|
||||
function! s:RegexpGroup(...)
|
||||
return '\%(' . s:RegexpJoin(a:000) . '\)'
|
||||
endfunction
|
||||
|
||||
" Outdent certain keywords and brackets
|
||||
let s:outdent = '^'
|
||||
\ . s:RegexpGroup('else', 'when', 'catch', 'finally',
|
||||
\ ']', '}', ')')
|
||||
|
||||
" Indent after certain keywords
|
||||
let s:indent_after_keywords = '^'
|
||||
\ . s:RegexpGroup('if', 'unless', 'else', 'for',
|
||||
\ 'while', 'until', 'loop', 'switch',
|
||||
\ 'when', 'try', 'catch', 'finally',
|
||||
\ 'class')
|
||||
\ . '\>'
|
||||
|
||||
" Indent after brackets, functions, and assignments
|
||||
let s:indent_after_literals = s:RegexpGroup('\[', '{', '(', '->', '=>',
|
||||
\ ':', '=')
|
||||
\ . '$'
|
||||
|
||||
" Combine the two regexps above
|
||||
let s:indent_after = s:RegexpJoin([s:indent_after_keywords,
|
||||
\ s:indent_after_literals])
|
||||
|
||||
" Indent after certain keywords used in multi-line assignments
|
||||
let s:assignment_keywords = s:RegexpGroup(':', '=')
|
||||
\ . '\s*\<'
|
||||
\ . s:RegexpGroup('if', 'unless', 'for', 'while',
|
||||
\ 'until', 'switch', 'try', 'class')
|
||||
\ . '\>'
|
||||
|
||||
" Outdent after certain keywords
|
||||
let s:outdent_after = '^'
|
||||
\ . s:RegexpGroup('return', 'break', 'continue', 'throw')
|
||||
\ . '\>'
|
||||
|
||||
" Don't outdent if the line contains one of these keywords (for cases like
|
||||
" 'return if a is b', 'break unless a', etc.)
|
||||
let s:dont_outdent_after = '\<' . s:RegexpGroup('if', 'unless') . '\>'
|
||||
|
||||
" Check for a single-line statement (e.g., 'if a then b'), which doesn't need an
|
||||
" indent afterwards
|
||||
function! s:IsSingleLineStatement(line)
|
||||
" The 'then' keyword is usually a good hint
|
||||
return a:line =~ '\<then\>'
|
||||
endfunction
|
||||
|
||||
" Check for a single-line 'else' statement (e.g., 'else return a' but
|
||||
" not 'else if a'), which doesn't need an indent afterwards
|
||||
function! s:IsSingleLineElse(line)
|
||||
" Check if the line actually starts with 'else', then if the line contains
|
||||
" anything other than 'else', then finally if the line is actually an 'else'
|
||||
" statement rather than an 'else if' statement
|
||||
return a:line =~ '^else\>' && a:line !~ '^else$' && a:line !~ '^else if\>'
|
||||
endfunction
|
||||
|
||||
" Check if a 'when' statement is the first in a 'switch' block by searching the
|
||||
" previous line for the 'switch' keyword. The first 'when' shouldn't be
|
||||
" outdented
|
||||
function! s:IsFirstWhen(curline, prevline)
|
||||
return a:curline =~ '^when\>' && a:prevline =~ '\<switch\>'
|
||||
endfunction
|
||||
|
||||
" Check for a multi-line assignment like
|
||||
" a: if b
|
||||
" c
|
||||
" else
|
||||
" d
|
||||
function! s:IsMultiLineAssignment(line)
|
||||
return a:line =~ s:assignment_keywords
|
||||
endfunction
|
||||
|
||||
function! s:ShouldOutdent(curline, prevline)
|
||||
return !s:IsSingleLineStatement(a:prevline)
|
||||
\ && !s:IsFirstWhen(a:curline, a:prevline)
|
||||
\ && a:prevline !~ s:outdent_after
|
||||
\ && a:curline =~ s:outdent
|
||||
endfunction
|
||||
|
||||
function! s:ShouldIndentAfter(prevline)
|
||||
return !s:IsSingleLineStatement(a:prevline)
|
||||
\ && !s:IsSingleLineElse(a:prevline)
|
||||
\ && (a:prevline =~ s:indent_after
|
||||
\ || s:IsMultiLineAssignment(a:prevline))
|
||||
endfunction
|
||||
|
||||
function! s:ShouldOutdentAfter(prevline)
|
||||
return (a:prevline !~ s:dont_outdent_after
|
||||
\ || s:IsSingleLineStatement(a:prevline))
|
||||
\ && a:prevline =~ s:outdent_after
|
||||
endfunction
|
||||
|
||||
function! GetCoffeeIndent(curlinenum)
|
||||
" Find a non-blank line above the current line
|
||||
let prevlinenum = prevnonblank(a:curlinenum - 1)
|
||||
|
||||
" No indenting is needed at the start of a file
|
||||
if prevlinenum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let curindent = indent(a:curlinenum)
|
||||
let previndent = indent(prevlinenum)
|
||||
|
||||
" Strip off leading whitespace
|
||||
let curline = getline(a:curlinenum)[curindent : -1]
|
||||
let prevline = getline(prevlinenum)[previndent : -1]
|
||||
|
||||
if s:ShouldOutdent(curline, prevline)
|
||||
" Is the line already outdented?
|
||||
if curindent < previndent
|
||||
return curindent
|
||||
else
|
||||
return curindent - &shiftwidth
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:ShouldIndentAfter(prevline)
|
||||
return previndent + &shiftwidth
|
||||
endif
|
||||
|
||||
if s:ShouldOutdentAfter(prevline)
|
||||
return previndent - &shiftwidth
|
||||
endif
|
||||
|
||||
" No indenting or outdenting is needed
|
||||
return curindent
|
||||
endfunction
|
||||
77
.vim/bundle/vim-coffee-script/readme.md
Normal file
77
.vim/bundle/vim-coffee-script/readme.md
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
This project adds [CoffeeScript] support to the vim editor. Currently, it
|
||||
supports [almost][todo] all of CoffeeScript 0.9.2's syntax and indentation style.
|
||||
|
||||
![Screenshot][screenshot]
|
||||
|
||||
[CoffeeScript]: http://coffeescript.org
|
||||
[todo]: http://github.com/kchmck/vim-coffee-script/blob/master/todo.md
|
||||
[screenshot]: http://i.imgur.com/xbto8.png
|
||||
|
||||
### Installing and using
|
||||
|
||||
1. Install [pathogen] into `~/.vim/autoload/` and add the following line to your
|
||||
`~/.vimrc`:
|
||||
|
||||
call pathogen#runtime_append_all_bundles()
|
||||
|
||||
Be aware that it must be added before any `filetype plugin indent on`
|
||||
lines according to the install page:
|
||||
|
||||
> Note that you need to invoke the pathogen functions before invoking
|
||||
> "filetype plugin indent on" if you want it to load ftdetect files. On
|
||||
> Debian (and probably other distros), the system vimrc does this early on,
|
||||
> so you actually need to "filetype off" before "filetype plugin indent on"
|
||||
> to force reloading.
|
||||
|
||||
[pathogen]: http://vim.org/scripts/script.php?script_id=2332
|
||||
|
||||
2. Create, and change into, the `~/.vim/bundle/` directory:
|
||||
|
||||
$ mkdir -p ~/.vim/bundle
|
||||
$ cd ~/.vim/bundle
|
||||
|
||||
3. Make a clone of the `vim-coffee-script` repository:
|
||||
|
||||
$ git clone git://github.com/kchmck/vim-coffee-script.git
|
||||
[...]
|
||||
$ ls
|
||||
vim-coffee-script/
|
||||
|
||||
Thatʼs it. Pathogen should handle the rest. Opening a file with a `.coffee`
|
||||
extension or a `Cakefile` will load all the CoffeeScript stuff.
|
||||
|
||||
### Updating
|
||||
|
||||
1. Change into the `~/.vim/bundle/vim-coffee-script/` directory:
|
||||
|
||||
$ cd ~/.vim/bundle/vim-coffee-script
|
||||
|
||||
2. Pull in the latest changes:
|
||||
|
||||
$ git pull
|
||||
|
||||
Everything will then be brought up to date!
|
||||
|
||||
### Customizing
|
||||
|
||||
Some of the possibly unwanted syntax highlighting elements can be disabled
|
||||
in the following ways.
|
||||
|
||||
#### Disable trailing whitespace error highlighting
|
||||
|
||||
If having trailing whitespace highlighted as an error is a bit much, the
|
||||
following line can be added to your `~/.vimrc` to disable it:
|
||||
|
||||
let coffee_no_trailing_space_error = 1
|
||||
|
||||
#### Disable trailing semicolon error highlighting
|
||||
|
||||
Likewise for the highlighting of trailing semicolons:
|
||||
|
||||
let coffee_no_trailing_semicolon_error = 1
|
||||
|
||||
#### Disable future/reserved words error highlighting
|
||||
|
||||
The same for reserved words:
|
||||
|
||||
let coffee_no_reserved_words_error = 1
|
||||
161
.vim/bundle/vim-coffee-script/syntax/coffee.vim
Normal file
161
.vim/bundle/vim-coffee-script/syntax/coffee.vim
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
" Language: CoffeeScript
|
||||
" Maintainer: Mick Koch <kchmck@gmail.com>
|
||||
" URL: http://github.com/kchmck/vim-coffee-script
|
||||
" License: WTFPL
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
endif
|
||||
|
||||
let b:current_syntax = "coffee"
|
||||
|
||||
syntax sync minlines=100
|
||||
|
||||
" CoffeeScript allows dollar signs in identifiers
|
||||
setlocal isident+=$
|
||||
|
||||
syntax match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/
|
||||
highlight default link coffeeStatement Statement
|
||||
|
||||
syntax match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/
|
||||
highlight default link coffeeRepeat Repeat
|
||||
|
||||
syntax match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/
|
||||
highlight default link coffeeConditional Conditional
|
||||
|
||||
syntax match coffeeException /\<\%(try\|catch\|finally\)\>/
|
||||
highlight default link coffeeException Exception
|
||||
|
||||
syntax match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/
|
||||
highlight default link coffeeOperator Operator
|
||||
|
||||
syntax match coffeeKeyword /\<\%(new\|in\|of\|by\|where\|and\|or\|not\|is\|isnt\|class\|extends\|super\|all\)\>/
|
||||
highlight default link coffeeKeyword Keyword
|
||||
|
||||
syntax match coffeeBoolean /\<\%(\%(true\|on\|yes\|false\|off\|no\)\)\>/
|
||||
highlight default link coffeeBoolean Boolean
|
||||
|
||||
syntax match coffeeGlobal /\<\%(null\|undefined\)\>/
|
||||
highlight default link coffeeGlobal Type
|
||||
|
||||
syntax cluster coffeeReserved contains=coffeeStatement,coffeeRepeat,
|
||||
\ coffeeConditional,coffeeException,
|
||||
\ coffeeOperator,coffeeKeyword,
|
||||
\ coffeeBoolean,coffeeGlobal
|
||||
|
||||
syntax match coffeeAssignmentMod /\%(\s\+\zs\%(and\|or\)\|\W\{,3}\)\ze=/ contained
|
||||
highlight default link coffeeAssignmentMod SpecialChar
|
||||
|
||||
syntax match coffeeAssignmentChar /:\|=/ contained
|
||||
highlight default link coffeeAssignmentChar SpecialChar
|
||||
|
||||
syntax match coffeeVar /\<\%(this\|prototype\|arguments\)\>/
|
||||
" Matches @-variables like @abc
|
||||
syntax match coffeeVar /@\%(\I\i*\)\?/
|
||||
highlight default link coffeeVar Type
|
||||
|
||||
" Matches class-like names that start with a capital letter, like Array or
|
||||
" Object
|
||||
syntax match coffeeObject /\<\u\w*\>/
|
||||
highlight default link coffeeObject Structure
|
||||
|
||||
" Matches constant-like names in SCREAMING_CAPS
|
||||
syntax match coffeeConstant /\<\u[A-Z0-9_]\+\>/
|
||||
highlight default link coffeeConstant Constant
|
||||
|
||||
syntax match coffeePrototype /::/
|
||||
highlight default link coffeePrototype SpecialChar
|
||||
|
||||
syntax region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=@coffeeInterpString
|
||||
syntax region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=@coffeeSimpleString
|
||||
highlight default link coffeeString String
|
||||
|
||||
" What can make up a variable name
|
||||
syntax cluster coffeeIdentifier contains=coffeeVar,coffeeObject,coffeeConstant,
|
||||
\ coffeePrototype
|
||||
|
||||
syntax match coffeeAssignment /@\?\I\%(\i\|::\|\.\|\[.\+\]\|([^)]*)\)*\s*\%(::\@!\|\%(and\|or\|\|&&\|||\|?\|+\|-\|\/\|\*\|%\|<<\|>>\|>>>\|&\||\|\^\)==\@!>\@!\)/
|
||||
\ contains=@coffeeIdentifier,coffeeAssignmentMod,
|
||||
\ coffeeAssignmentChar,coffeeBrackets,
|
||||
\ coffeeParens
|
||||
syntax match coffeeAssignment /\%("\|'\)[^'"]\+\%("\|'\)\s*:/ contains=coffeeString,
|
||||
\ coffeeAssignmentChar
|
||||
syntax match coffeeAssignment /\d*\%(\.\d\+\)\?\s*:/ contains=coffeeNumber,coffeeAssignmentChar
|
||||
highlight default link coffeeAssignment Identifier
|
||||
|
||||
syntax match coffeeFunction /->\|=>/
|
||||
highlight default link coffeeFunction Function
|
||||
|
||||
syntax keyword coffeeTodo TODO FIXME XXX contained
|
||||
highlight default link coffeeTodo Todo
|
||||
|
||||
syntax match coffeeComment /#.*/ contains=@Spell,coffeeTodo
|
||||
syntax match coffeeComment /####\@!\_.\{-}###/ contains=@Spell,coffeeTodo
|
||||
highlight default link coffeeComment Comment
|
||||
|
||||
syntax region coffeeEmbed start=/`/ end=/`/
|
||||
highlight default link coffeeEmbed Special
|
||||
|
||||
" Matches numbers like -10, -10e8, -10E8, 10, 10e8, 10E8
|
||||
syntax match coffeeNumber /\<-\?\d\+\%([eE][+-]\?\d\+\)\?\>/
|
||||
" Matches hex numbers like 0xfff, 0x000
|
||||
syntax match coffeeNumber /\<0[xX]\x\+\>/
|
||||
highlight default link coffeeNumber Number
|
||||
|
||||
" Matches floating-point numbers like -10.42e8, 10.42e-8
|
||||
syntax match coffeeFloat /-\?\d*\.\@<!\.\d\+\%([eE][+-]\?\d\+\)\?/
|
||||
highlight default link coffeeFloat Float
|
||||
|
||||
syntax region coffeeInterpolation matchgroup=coffeeInterpDelim
|
||||
\ start=/\#{/ end=/}/
|
||||
\ contained contains=TOP
|
||||
highlight default link coffeeInterpDelim Delimiter
|
||||
|
||||
syntax match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained
|
||||
highlight default link coffeeEscape SpecialChar
|
||||
|
||||
syntax cluster coffeeSimpleString contains=@Spell,coffeeEscape
|
||||
syntax cluster coffeeInterpString contains=@coffeeSimpleString,
|
||||
\ coffeeInterpolation
|
||||
|
||||
syntax region coffeeRegExp start=/)\@<!\%(\%((\s*\|=\s\+\)\@<=\/\|\s\zs\/\s\@!\)/
|
||||
\ end=/\/[gimy]\{,4}/ oneline
|
||||
\ contains=@coffeeInterpString
|
||||
highlight default link coffeeRegExp String
|
||||
|
||||
syntax region coffeeHeredoc start=/"""/ end=/"""/ contains=@coffeeInterpString
|
||||
syntax region coffeeHeredoc start=/'''/ end=/'''/ contains=@coffeeSimpleString
|
||||
highlight default link coffeeHeredoc String
|
||||
|
||||
syntax region coffeeCurlies start=/{/ end=/}/ contains=TOP
|
||||
syntax region coffeeBrackets start=/\[/ end=/\]/ contains=TOP,coffeeAssignment
|
||||
syntax match coffeeParens /(.*)/ contains=TOP,coffeeAssignment
|
||||
|
||||
" Displays an error for trailing whitespace
|
||||
if !exists("coffee_no_trailing_space_error")
|
||||
syntax match coffeeSpaceError /\s\+$/ display
|
||||
highlight default link coffeeSpaceError Error
|
||||
endif
|
||||
|
||||
" Displays an error for trailing semicolons
|
||||
if !exists("coffee_no_trailing_semicolon_error")
|
||||
syntax match coffeeSemicolonError /;$/ display
|
||||
highlight default link coffeeSemicolonError Error
|
||||
endif
|
||||
|
||||
" Displays an error for reserved words
|
||||
if !exists("coffee_no_reserved_words_error")
|
||||
syntax keyword coffeeReservedError case default do function var void with const
|
||||
\ let enum export import native __hasProp
|
||||
\ __extends __slice
|
||||
highlight default link coffeeReservedError Error
|
||||
endif
|
||||
|
||||
" Reserved words can be used as dot-properties
|
||||
syntax match coffeeDot /\.\@<!\.\i\+/ transparent
|
||||
\ contains=ALLBUT,@coffeeReserved,
|
||||
\ coffeeReservedError
|
||||
35
.vim/bundle/vim-coffee-script/todo.md
Normal file
35
.vim/bundle/vim-coffee-script/todo.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# To do for full support
|
||||
|
||||
- Destructuring assignments like:
|
||||
|
||||
[a, b] = c
|
||||
{a, b} = c
|
||||
└──┴─ these should be highlighted as identifiers
|
||||
|
||||
- Assignments inside brackets (sounds simple enough):
|
||||
|
||||
a[b -= c] = d
|
||||
|
||||
this should still be highlighted correctly:
|
||||
|
||||
a[b[c]] = d
|
||||
|
||||
- Smart, lookback outdenting for cases like:
|
||||
|
||||
a = {
|
||||
b: ->
|
||||
c
|
||||
}
|
||||
└─ bracket should be put here
|
||||
|
||||
- Should indent if the previous line ends, or the current line starts, with one
|
||||
of these:
|
||||
|
||||
+ - * / % | & , . is isnt and or && ||
|
||||
|
||||
- Support `else unless` in indentation:
|
||||
|
||||
unless a
|
||||
b
|
||||
else unless c
|
||||
d
|
||||
Loading…
Add table
Add a link
Reference in a new issue