inital checkin using existing vim and preparing for use of bash_magic
This commit is contained in:
2
vim/bundle/custom/ftdetect/ctp.vim
Normal file
2
vim/bundle/custom/ftdetect/ctp.vim
Normal file
@@ -0,0 +1,2 @@
|
||||
" custom rule for cake template files
|
||||
au BufNewFile,BufRead *.ctp setfiletype php
|
||||
10
vim/bundle/custom/ftplugin/coffee.vim
Normal file
10
vim/bundle/custom/ftplugin/coffee.vim
Normal file
@@ -0,0 +1,10 @@
|
||||
" modify the indenting
|
||||
set expandtab " insert spaces instead of tabs
|
||||
set tabstop=2 " use X spaces when tab is pressed
|
||||
set shiftwidth=2 " shifttabs are also X spaces
|
||||
|
||||
" vim-coffee-sript settings
|
||||
" TODO: add check for vim-coffee-script
|
||||
vmap <leader>v <esc>:'<,'>:CoffeeCompile vert<CR>
|
||||
map <leader>v :CoffeeCompile vert<CR>
|
||||
map <leader>c :silent CoffeeMake <CR>
|
||||
4
vim/bundle/custom/ftplugin/jade.vim
Normal file
4
vim/bundle/custom/ftplugin/jade.vim
Normal file
@@ -0,0 +1,4 @@
|
||||
" modify the indenting
|
||||
set expandtab " insert spaces instead of tabs
|
||||
set tabstop=2 " use X spaces when tab is pressed
|
||||
set shiftwidth=2 " shifttabs are also X spaces
|
||||
12
vim/bundle/custom/ftplugin/javascript.vim
Normal file
12
vim/bundle/custom/ftplugin/javascript.vim
Normal file
@@ -0,0 +1,12 @@
|
||||
" disable default indent rules
|
||||
"let b:did_indent = 1
|
||||
|
||||
" disable indenting on the fly
|
||||
nnoremap <F8> :setl noai nosi nocin indentexpr= indentkeys=
|
||||
" enable indenting on the fly
|
||||
nnoremap <F7> :setl ai si cin indentexpr= indentkeys=0{,0},:,0#,!^F,o,O,e
|
||||
|
||||
" modify the indenting
|
||||
"set expandtab " insert spaces instead of tabs
|
||||
set tabstop=2 " use X spaces when tab is pressed
|
||||
set shiftwidth=2 " shifttabs are also X spaces
|
||||
8
vim/bundle/custom/ftplugin/php.vim
Normal file
8
vim/bundle/custom/ftplugin/php.vim
Normal file
@@ -0,0 +1,8 @@
|
||||
" disable indenting on the fly
|
||||
nnoremap <F8> :setl indentexpr= indentkeys=
|
||||
" enable indenting on the fly
|
||||
nnoremap <F7> :setl indentexpr=GetPhpIndent() indentkeys=0{,0},0),:,!^F,o,O,e,*<Return>,=?>,=<?,=*/
|
||||
|
||||
" Folding
|
||||
"let php_folding=1
|
||||
let g:DisableAutoPHPFolding = 1
|
||||
65
vim/bundle/phpfolding.vim/README
Normal file
65
vim/bundle/phpfolding.vim/README
Normal file
@@ -0,0 +1,65 @@
|
||||
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1623
|
||||
|
||||
This script can fold PHP functions and/or classes, properties with their PhpDoc,
|
||||
without manually adding marker style folds ({{{ and }}}). It will generate the following
|
||||
folds when executed:
|
||||
|
||||
<?php
|
||||
/**
|
||||
* This is Foo...
|
||||
* @author Foo
|
||||
*/
|
||||
class Foo {
|
||||
+-- 11 lines: function fooFunction($bar) ** -----------------------------------------
|
||||
+-- 8 lines: function fooFunction2($bar) ** ----------------------------------------
|
||||
+-- 24 lines: function fooFunction3($bar) -------------------------------------------
|
||||
}
|
||||
|
||||
+--112 lines: class Foo2 ** -------------------------------------------------------------
|
||||
?>
|
||||
|
||||
Based on e.g. functions declared like this:
|
||||
|
||||
<?php
|
||||
/**
|
||||
* This is fooFunction...
|
||||
*
|
||||
* @param mixed $bar
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function fooFunction($bar) {
|
||||
[...]
|
||||
}
|
||||
?>
|
||||
|
||||
SCREENSHOT
|
||||
You can view a screenshot here: http://www.fighterz.net/trig/folding.gif
|
||||
|
||||
FEATURES
|
||||
- It remembers fold settings. If you add functions and execute the script again,
|
||||
your opened folds will not be closed.
|
||||
- It will not be confused by brackets in comment blocks or string literals.
|
||||
- The folding of class properties with their PhpDoc comments.
|
||||
- The folding of all class properties into one fold.
|
||||
- Folding the original marker style folds too.
|
||||
- An "**" postfixing the fold indicates PhpDoc is inside (configurable).
|
||||
- An "**#@+" postfixing the fold indicates PhpDocBlock is inside (configurable).
|
||||
- Empty lines postfixing the folds can be configured to be included in the fold.
|
||||
- Nested folds are supported (functions inside functions, etc.)
|
||||
|
||||
FUTURE
|
||||
- Better 'configurability' as opposed to editting the PHPCustomFolds() function and
|
||||
some "Script configuration" global variables.
|
||||
|
||||
NOTE
|
||||
If anyone has emailed me and I have not replied, it's probably lost. I just found out
|
||||
hotmail recognizes alot as junk. I now turned off the junk filter..
|
||||
|
||||
NOTE2:
|
||||
I'm currently more active again with this project, so if you have any contributions to
|
||||
this project, please let me know.
|
||||
|
||||
COMPATIBILITY
|
||||
This script is tested successfully with Vim version >= 6.3 on windows and linux
|
||||
(With 6.0 it works *sometimes*, I don't recommend using it in that version)
|
||||
611
vim/bundle/phpfolding.vim/plugin/phpfolding.vim
Normal file
611
vim/bundle/phpfolding.vim/plugin/phpfolding.vim
Normal file
@@ -0,0 +1,611 @@
|
||||
" Plugin for automatic folding of PHP functions (also folds related PHPdoc)
|
||||
"
|
||||
" Maintainer: Ray Burgemeestre
|
||||
" Last Change: 2010 Jan 15
|
||||
"
|
||||
" USAGE
|
||||
" If you enabled the script in your after/ftplugin directory (see install)
|
||||
" then it will be executed after you open a .php file.
|
||||
"
|
||||
" After e.g. adding/moving functions, you can re-execute the script by using
|
||||
" the following key mappings:
|
||||
"
|
||||
" F5 - To fold functions, classes, and other stuff with PHPdoc (depending
|
||||
" on your configuration).
|
||||
" F6 - To do the same with more extensive bracket checking (might work
|
||||
" better if your folds are messed up due to misinterpreted brackets).
|
||||
" F7 - To remove all folds.
|
||||
"
|
||||
" INSTALL
|
||||
" 1. Put phpfolding.vim in your plugin directory (~/.vim/plugin)
|
||||
" 2. You might want to add the following keyboard mappings to your .vimrc:
|
||||
"
|
||||
" map <F5> <Esc>:EnableFastPHPFolds<Cr>
|
||||
" map <F6> <Esc>:EnablePHPFolds<Cr>
|
||||
" map <F7> <Esc>:DisablePHPFolds<Cr>
|
||||
"
|
||||
" 3. You can disable auto folding in your .vimrc with:
|
||||
"
|
||||
" let g:DisableAutoPHPFolding = 1
|
||||
"
|
||||
" By default EnableFastPHPFolds is called. Do these mess up your folds,
|
||||
" you can try to replace EnableFastPHPFolds by EnablePHPFolds. You can
|
||||
" change this in function s:CheckAutocmdEnablePHPFold.
|
||||
"
|
||||
" NOTE
|
||||
" It may be that you need to load the plugin from your .vimrc manually, in
|
||||
" case it doesn't work:
|
||||
"
|
||||
" let php_folding=0
|
||||
" (if you can't use the after directory in step 3)
|
||||
" source ~/path/to/phpfolding.vim
|
||||
" (if you're not using the default plugin directory)
|
||||
"
|
||||
" MORE INFORMATION
|
||||
" - In PHPCustomFolds() you can i.e. comment the PHPFoldPureBlock('class', ...)
|
||||
" call to have the script not fold classes. You can also change the second
|
||||
" parameter passed to that function call, to have it or not have it fold
|
||||
" PhpDoc comments. All other folding you can turn on/off in this function.
|
||||
" - You can tweak the foldtext to your liking in the function PHPFoldText().
|
||||
" - You can set some preferences and default settings a few lines below
|
||||
" at the "Script configuration" part.
|
||||
"
|
||||
" This script is tested with Vim version >= 6.3 on windows and linux.
|
||||
|
||||
" Avoid reloading {{{1
|
||||
if exists('loaded_phpfolding')
|
||||
finish
|
||||
endif
|
||||
|
||||
let loaded_phpfolding = 1
|
||||
" }}}
|
||||
|
||||
" .vimrc variable to disable autofolding for php files {{{1
|
||||
if !exists("g:DisableAutoPHPFolding")
|
||||
let g:DisableAutoPHPFolding = 0
|
||||
endif
|
||||
" }}}
|
||||
|
||||
command! EnableFastPHPFolds call <SID>EnableFastPHPFolds()
|
||||
command! -nargs=* EnablePHPFolds call <SID>EnablePHPFolds(<f-args>)
|
||||
command! DisablePHPFolds call <SID>DisablePHPFolds()
|
||||
|
||||
" {{{ Script configuration
|
||||
" Display the following after the foldtext if a fold contains phpdoc
|
||||
let g:phpDocIncludedPostfix = '**'
|
||||
let g:phpDocBlockIncludedPostfix = '**#@+'
|
||||
|
||||
" Default values
|
||||
" .. search this # of empty lines for PhpDoc comments
|
||||
let g:searchPhpDocLineCount = 1
|
||||
" .. search this # of empty lines that 'trail' the foldmatch
|
||||
let g:searchEmptyLinesPostfixing = 1
|
||||
" }}}
|
||||
" {{{ Script constants
|
||||
let s:synIDattr_exists = exists('*synIDattr')
|
||||
let s:TRUE = 1
|
||||
let s:FALSE = 0
|
||||
let s:MODE_CREATE_FOLDS = 1
|
||||
let s:MODE_REMEMBER_FOLD_SETTINGS = 2
|
||||
let s:FOLD_WITH_PHPDOC = 1
|
||||
let s:FOLD_WITHOUT_PHPDOC = 2
|
||||
let s:SEARCH_PAIR_START_FIRST = 1
|
||||
let s:SEARCH_PAIR_IMMEDIATELY = 2
|
||||
" }}}
|
||||
|
||||
function! s:EnableFastPHPFolds() " {{{
|
||||
call s:EnablePHPFolds(s:FALSE)
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:EnablePHPFolds(...) " {{{
|
||||
let s:extensiveBracketChecking = s:TRUE
|
||||
|
||||
" Check function arguments
|
||||
if a:0 == 1
|
||||
let s:extensiveBracketChecking = a:1
|
||||
endif
|
||||
|
||||
" Remember cursor information if possible
|
||||
let s:savedCursor = line(".")
|
||||
|
||||
" Initialize variables
|
||||
set foldmethod=manual
|
||||
set foldtext=PHPFoldText()
|
||||
let s:openFoldListItems = 0
|
||||
let s:fileLineCount = line('$')
|
||||
|
||||
let s:searchPhpDocLineCount = g:searchPhpDocLineCount
|
||||
let s:searchEmptyLinesPostfixing = g:searchEmptyLinesPostfixing
|
||||
|
||||
|
||||
" Move to end of file
|
||||
exec s:fileLineCount
|
||||
|
||||
" First pass: Look for Folds, remember opened folds
|
||||
let s:foldingMode = s:MODE_REMEMBER_FOLD_SETTINGS
|
||||
call s:PHPCustomFolds()
|
||||
|
||||
" Second pass: Recreate Folds, restore previously opened
|
||||
let s:foldingMode = s:MODE_CREATE_FOLDS
|
||||
" .. Remove all folds first
|
||||
normal zE
|
||||
let s:foldsCreated = 0
|
||||
call s:PHPCustomFolds()
|
||||
" .. Fold all
|
||||
normal zM
|
||||
|
||||
" Restore previously opened folds
|
||||
let currentItem = 0
|
||||
while currentItem < s:openFoldListItems
|
||||
exec s:foldsOpenedList{currentItem}
|
||||
normal zo
|
||||
let currentItem = currentItem + 1
|
||||
endwhile
|
||||
|
||||
:redraw
|
||||
echo s:foldsCreated . " fold(s) created"
|
||||
|
||||
" Restore cursor
|
||||
exec s:savedCursor
|
||||
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:DisablePHPFolds() " {{{
|
||||
"set foldmethod=manual
|
||||
set foldtext=
|
||||
normal zE
|
||||
echo "php fold(s) deleted"
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:PHPCustomFolds() " {{{
|
||||
" NOTE: The two last parameters for functions PHPFoldProperties() and
|
||||
" PHPFoldPureBlock() overwrite: 'g:searchPhpDocLineCount' and
|
||||
" 'g:searchEmptyLinesPostfixing'..
|
||||
|
||||
" Fold function with PhpDoc (function foo() {})
|
||||
call s:PHPFoldPureBlock('function', s:FOLD_WITH_PHPDOC)
|
||||
|
||||
" Fold class properties with PhpDoc (var $foo = NULL;)
|
||||
call s:PHPFoldProperties('^\s*var\s\$', ";", s:FOLD_WITH_PHPDOC, 1, 1)
|
||||
|
||||
" Fold class without PhpDoc (class foo {})
|
||||
call s:PHPFoldPureBlock('^\s*\(abstract\s*\)\?class', s:FOLD_WITH_PHPDOC)
|
||||
|
||||
" Fold define()'s with their PhpDoc
|
||||
call s:PHPFoldProperties('^\s*define\s*(', ";", s:FOLD_WITH_PHPDOC)
|
||||
|
||||
" Fold includes with their PhpDoc
|
||||
call s:PHPFoldProperties('^\s*require\s*', ";", s:FOLD_WITH_PHPDOC)
|
||||
call s:PHPFoldProperties('^\s*include\s*', ";", s:FOLD_WITH_PHPDOC)
|
||||
|
||||
" Fold GLOBAL Arrays with their PhpDoc (some PEAR packages use these)
|
||||
call s:PHPFoldProperties('^\s*\$GLOBALS.*array\s*(', ";", s:FOLD_WITH_PHPDOC)
|
||||
|
||||
" Fold marker style comments ({{{ foo }}})
|
||||
call s:PHPFoldMarkers('{{{', '}}}')
|
||||
|
||||
" Fold PhpDoc "DocBlock" templates (#@+ foo #@-)
|
||||
call s:PHPFoldMarkers('#@+', '#@-')
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:PHPFoldPureBlock(startPattern, ...) " {{{
|
||||
let s:searchPhpDocLineCount = g:searchPhpDocLineCount
|
||||
let s:searchEmptyLinesPostfixing = g:searchEmptyLinesPostfixing
|
||||
let s:currentPhpDocMode = s:FOLD_WITH_PHPDOC
|
||||
|
||||
if a:0 >= 1
|
||||
" Do we also put the PHP doc part in the fold?
|
||||
let s:currentPhpDocMode = a:1
|
||||
endif
|
||||
if a:0 >= 2
|
||||
" How far do we want to look for PhpDoc comments?
|
||||
let s:searchPhpDocLineCount = a:2
|
||||
endif
|
||||
if a:0 == 3
|
||||
" How greedy are we on postfixing empty lines?
|
||||
let s:searchEmptyLinesPostfixing = a:3
|
||||
endif
|
||||
|
||||
" Move to file end
|
||||
exec s:fileLineCount
|
||||
|
||||
" Loop through file, searching for folds
|
||||
while 1
|
||||
let s:lineStart = s:FindPureBlockStart(a:startPattern)
|
||||
|
||||
if s:lineStart != 0
|
||||
|
||||
let s:lineStart = s:FindOptionalPHPDocComment()
|
||||
let s:lineStop = s:FindPureBlockEnd('{', '}', s:SEARCH_PAIR_START_FIRST)
|
||||
|
||||
" Stop on Error
|
||||
if s:lineStop == 0
|
||||
break
|
||||
endif
|
||||
|
||||
" Do something with the potential fold based on the Mode we're in
|
||||
call s:HandleFold()
|
||||
|
||||
else
|
||||
break
|
||||
endif
|
||||
|
||||
" Goto fold start (remember we're searching upwards)
|
||||
exec s:lineStart
|
||||
endwhile
|
||||
|
||||
|
||||
if s:foldingMode != s:MODE_REMEMBER_FOLD_SETTINGS
|
||||
" Remove created folds
|
||||
normal zR
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:PHPFoldMarkers(startPattern, endPattern, ...) " {{{
|
||||
let s:currentPhpDocMode = s:FOLD_WITHOUT_PHPDOC
|
||||
|
||||
" Move to file end
|
||||
exec s:fileLineCount
|
||||
|
||||
" Loop through file, searching for folds
|
||||
while 1
|
||||
let s:lineStart = s:FindPatternStart(a:startPattern)
|
||||
|
||||
if s:lineStart != 0
|
||||
let s:lineStart = s:FindOptionalPHPDocComment()
|
||||
" The fourth parameter is for disabling the search for trailing
|
||||
" empty lines..
|
||||
let s:lineStop = s:FindPureBlockEnd(a:startPattern, a:endPattern,
|
||||
\ s:SEARCH_PAIR_IMMEDIATELY, s:FALSE)
|
||||
|
||||
" Stop on Error
|
||||
if s:lineStop == 0
|
||||
break
|
||||
endif
|
||||
|
||||
" Do something with the potential fold based on the Mode we're in
|
||||
call s:HandleFold()
|
||||
else
|
||||
break
|
||||
endif
|
||||
|
||||
" Goto fold start (remember we're searching upwards)
|
||||
exec s:lineStart
|
||||
endwhile
|
||||
|
||||
if s:foldingMode != s:MODE_REMEMBER_FOLD_SETTINGS
|
||||
" Remove created folds
|
||||
normal zR
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:PHPFoldProperties(startPattern, endPattern, ...) " {{{
|
||||
let s:searchPhpDocLineCount = g:searchPhpDocLineCount
|
||||
let s:searchEmptyLinesPostfixing = g:searchEmptyLinesPostfixing
|
||||
let s:currentPhpDocMode = s:FOLD_WITH_PHPDOC
|
||||
if a:0 >= 1
|
||||
" Do we also put the PHP doc part in the fold?
|
||||
let s:currentPhpDocMode = a:1
|
||||
endif
|
||||
if a:0 >= 2
|
||||
" How far do we want to look for PhpDoc comments?
|
||||
let s:searchPhpDocLineCount = a:2
|
||||
endif
|
||||
if a:0 == 3
|
||||
" How greedy are we on postfixing empty lines?
|
||||
let s:searchEmptyLinesPostfixing = a:3
|
||||
endif
|
||||
|
||||
" Move to end of file
|
||||
exec s:fileLineCount
|
||||
|
||||
" Loop through file, searching for folds
|
||||
while 1
|
||||
let s:lineStart = s:FindPatternStart(a:startPattern)
|
||||
|
||||
if s:lineStart != 0
|
||||
let s:lineStart = s:FindOptionalPHPDocComment()
|
||||
let s:lineStop = s:FindPatternEnd(a:endPattern)
|
||||
|
||||
" Stop on Error
|
||||
if s:lineStop == 0
|
||||
break
|
||||
endif
|
||||
|
||||
" Do something with the potential fold based on the Mode we're in
|
||||
call s:HandleFold()
|
||||
else
|
||||
break
|
||||
endif
|
||||
|
||||
" Goto fold start (remember we're searching upwards)
|
||||
exec s:lineStart
|
||||
|
||||
endwhile
|
||||
|
||||
if s:foldingMode != s:MODE_REMEMBER_FOLD_SETTINGS
|
||||
" Remove created folds
|
||||
normal zR
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:HandleFold() " {{{
|
||||
if s:foldingMode == s:MODE_REMEMBER_FOLD_SETTINGS
|
||||
" If we are in an actual fold..,
|
||||
if foldlevel(s:lineStart) != 0
|
||||
" .. and it is not closed..,
|
||||
if foldclosed(s:lineStart) == -1
|
||||
" .. and it is more then one lines
|
||||
" (it has to be or it will be open by default)
|
||||
if s:lineStop - s:lineStart >= 1
|
||||
" Remember it as an open fold
|
||||
let s:foldsOpenedList{s:openFoldListItems} = s:lineStart
|
||||
let s:openFoldListItems = s:openFoldListItems + 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the cursor is inside the fold, it needs to be opened
|
||||
if s:lineStart <= s:savedCursor && s:lineStop >= s:savedCursor
|
||||
" Remember it as an open fold
|
||||
let s:foldsOpenedList{s:openFoldListItems} = s:lineStart
|
||||
let s:openFoldListItems = s:openFoldListItems + 1
|
||||
endif
|
||||
|
||||
elseif s:foldingMode == s:MODE_CREATE_FOLDS
|
||||
" Correct lineStop if needed (the script might have mistaken lines
|
||||
" beyond the file's scope for trailing empty lines)
|
||||
if s:lineStop > s:fileLineCount
|
||||
let s:lineStop = s:fileLineCount
|
||||
endif
|
||||
" Create the actual fold!
|
||||
exec s:lineStart . "," . s:lineStop . "fold"
|
||||
let s:foldsCreated = s:foldsCreated + 1
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:FindPureBlockStart(startPattern) " {{{
|
||||
" When the startPattern is 'function', this following search will match:
|
||||
"
|
||||
" function foo($bar) { function foo($bar)
|
||||
" {
|
||||
"
|
||||
" function foo($bar) function foo($bar1,
|
||||
" .. { $bar2)
|
||||
" {
|
||||
"
|
||||
"return search(a:startPattern . '.*\%[\n].*{', 'W')
|
||||
"return search(a:startPattern . '.*\%[\n].*\%[\n].*{', 'bW')
|
||||
|
||||
" This function can match the line its on *again* if the cursor was
|
||||
" restored.. hence we search twice if needed..
|
||||
let currentLine = line('.')
|
||||
let line = search(a:startPattern . '.*\%[\n].*\%[\n].*{', 'bW')
|
||||
if currentLine == line
|
||||
let line = search(a:startPattern . '.*\%[\n].*\%[\n].*{', 'bW')
|
||||
endif
|
||||
return line
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:FindPatternStart(startPattern) " {{{
|
||||
" This function can match the line its on *again* if the cursor was
|
||||
" restored.. hence we search twice if needed..
|
||||
let currentLine = line('.')
|
||||
let line = search(a:startPattern, 'bW')
|
||||
if currentLine == line
|
||||
let line = search(a:startPattern, 'bW')
|
||||
endif
|
||||
return line
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:FindOptionalPHPDocComment() " {{{
|
||||
" Is searching for PHPDoc disabled?
|
||||
if s:currentPhpDocMode == s:FOLD_WITHOUT_PHPDOC
|
||||
" .. Return the original Fold's start
|
||||
return s:lineStart
|
||||
endif
|
||||
|
||||
" Skipover 'empty' lines in search for PhpDoc
|
||||
let s:counter = 0
|
||||
let s:currentLine = s:lineStart - 1
|
||||
while s:counter < s:searchPhpDocLineCount
|
||||
let line = getline(s:currentLine)
|
||||
if (matchstr(line, '^\s*$') == line)
|
||||
let s:currentLine = s:currentLine - 1
|
||||
endif
|
||||
let s:counter = s:counter + 1
|
||||
endwhile
|
||||
|
||||
" Is there a closing C style */ on the above line?
|
||||
let checkLine = s:currentLine
|
||||
if strridx(getline(checkLine), "\*\/") != -1
|
||||
" Then search for the matching C style /* opener
|
||||
while 1
|
||||
if strridx(getline(checkLine), "\/\*") != -1
|
||||
" Only continue adjusting the Fold's start if it really is PHPdoc..
|
||||
" (which is characterized by a double asterisk, like /**)
|
||||
if strridx(getline(checkLine), "\/\*\*") != -1
|
||||
" Also only continue adjusting if the PHPdoc opener does
|
||||
" not contain a '/**#@+'. Those type of comments are
|
||||
" supposed to match with a #@- ..
|
||||
if strridx(getline(checkLine), '#@+') == -1
|
||||
" .. Return this as the Fold's start
|
||||
return checkLine
|
||||
else
|
||||
break
|
||||
endif
|
||||
else
|
||||
break
|
||||
endif
|
||||
endif
|
||||
let checkLine = checkLine - 1
|
||||
endwhile
|
||||
endif
|
||||
" .. Return the original Fold's start
|
||||
return s:lineStart
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:FindPureBlockEnd(startPair, endPair, searchStartPairFirst, ...) " {{{
|
||||
" Place Cursor on the opening pair/brace?
|
||||
if a:searchStartPairFirst == s:SEARCH_PAIR_START_FIRST
|
||||
let line = search(a:startPair, 'W')
|
||||
endif
|
||||
|
||||
" Search for the entangled closing brace
|
||||
" call cursor(line, 1) " set the cursor to the start of the lnum line
|
||||
if s:extensiveBracketChecking == s:TRUE
|
||||
let line = searchpair(a:startPair, a:startPair, a:endPair, 'W', 'SkipMatch()')
|
||||
else
|
||||
let line = searchpair(a:startPair, a:startPair, a:endPair, 'W')
|
||||
endif
|
||||
if line == 0
|
||||
let line = search(a:endPair, 'W')
|
||||
endif
|
||||
if line == 0
|
||||
" Return error
|
||||
return 0
|
||||
endif
|
||||
|
||||
" If the fold exceeds more than one line, and searching for empty lines is
|
||||
" not disabled..
|
||||
let foldExceedsOneLine = line - s:lineStart >= 1
|
||||
if a:0 == 1
|
||||
let emptyLinesNotDisabled = a:1
|
||||
else
|
||||
let emptyLinesNotDisabled = s:TRUE
|
||||
endif
|
||||
if foldExceedsOneLine && emptyLinesNotDisabled
|
||||
" Then be greedy with extra 'trailing' empty line(s)
|
||||
let s:counter = 0
|
||||
while s:counter < s:searchEmptyLinesPostfixing
|
||||
let linestr = getline(line + 1)
|
||||
if (matchstr(linestr, '^\s*$') == linestr)
|
||||
let line = line + 1
|
||||
endif
|
||||
let s:counter = s:counter + 1
|
||||
endwhile
|
||||
endif
|
||||
|
||||
return line
|
||||
endfunction
|
||||
" }}}
|
||||
function! s:FindPatternEnd(endPattern) " {{{
|
||||
let line = search(a:endPattern, 'W')
|
||||
|
||||
" If the fold exceeds more than one line
|
||||
if line - s:lineStart >= 1
|
||||
" Then be greedy with extra 'trailing' empty line(s)
|
||||
let s:counter = 0
|
||||
while s:counter < s:searchEmptyLinesPostfixing
|
||||
let linestr = getline(line + 1)
|
||||
if (matchstr(linestr, '^\s*$') == linestr)
|
||||
let line = line + 1
|
||||
endif
|
||||
let s:counter = s:counter + 1
|
||||
endwhile
|
||||
endif
|
||||
|
||||
return line
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! PHPFoldText() " {{{
|
||||
let currentLine = v:foldstart
|
||||
let lines = (v:foldend - v:foldstart + 1)
|
||||
let lineString = getline(currentLine)
|
||||
" See if we folded a marker
|
||||
if strridx(lineString, "{{{") != -1 " }}}
|
||||
" Is there text after the fold opener?
|
||||
if (matchstr(lineString, '^.*{{{..*$') == lineString) " }}}
|
||||
" Then only show that text
|
||||
let lineString = substitute(lineString, '^.*{{{', '', 'g') " }}}
|
||||
" There is text before the fold opener
|
||||
else
|
||||
" Try to strip away the remainder
|
||||
let lineString = substitute(lineString, '\s*{{{.*$', '', 'g') " }}}
|
||||
endif
|
||||
" See if we folded a DocBlock
|
||||
elseif strridx(lineString, '#@+') != -1
|
||||
" Is there text after the #@+ piece?
|
||||
if (matchstr(lineString, '^.*#@+..*$') == lineString)
|
||||
" Then show that text
|
||||
let lineString = substitute(lineString, '^.*#@+', '', 'g') . ' ' . g:phpDocBlockIncludedPostfix
|
||||
" There is nothing?
|
||||
else
|
||||
" Use the next line..
|
||||
let lineString = getline(currentLine + 1) . ' ' . g:phpDocBlockIncludedPostfix
|
||||
endif
|
||||
" See if we folded an API comment block
|
||||
elseif strridx(lineString, "\/\*\*") != -1
|
||||
" (I can't get search() or searchpair() to work.., therefore the
|
||||
" following loop)
|
||||
let s:state = 0
|
||||
while currentLine < v:foldend
|
||||
let line = getline(currentLine)
|
||||
if s:state == 0 && strridx(line, "\*\/") != -1
|
||||
" Found the end, now we need to find the first not-empty line
|
||||
let s:state = 1
|
||||
elseif s:state == 1 && (matchstr(line, '^\s*$') != line)
|
||||
" Found the line to display in fold!
|
||||
break
|
||||
endif
|
||||
let currentLine = currentLine + 1
|
||||
endwhile
|
||||
let lineString = getline(currentLine)
|
||||
endif
|
||||
|
||||
" Some common replaces...
|
||||
" if currentLine != v:foldend
|
||||
let lineString = substitute(lineString, '/\*\|\*/\d\=', '', 'g')
|
||||
let lineString = substitute(lineString, '^\s*\*\?\s*', '', 'g')
|
||||
let lineString = substitute(lineString, '{$', '', 'g')
|
||||
let lineString = substitute(lineString, '($', '(..);', 'g')
|
||||
" endif
|
||||
|
||||
" Emulates printf("%3d", lines)..
|
||||
if lines < 10
|
||||
let lines = " " . lines
|
||||
elseif lines < 100
|
||||
let lines = " " . lines
|
||||
endif
|
||||
|
||||
" Append an (a) if there is PhpDoc in the fold (a for API)
|
||||
if currentLine != v:foldstart
|
||||
let lineString = lineString . " " . g:phpDocIncludedPostfix . " "
|
||||
endif
|
||||
|
||||
" Return the foldtext
|
||||
return "+--".lines." lines: " . lineString
|
||||
endfunction
|
||||
" }}}
|
||||
function! SkipMatch() " {{{
|
||||
" This function is modified from a PHP indent file by John Wellesz
|
||||
" found here: http://www.vim.org/scripts/script.php?script_id=1120
|
||||
if (!s:synIDattr_exists)
|
||||
return 0
|
||||
endif
|
||||
let synname = synIDattr(synID(line("."), col("."), 0), "name")
|
||||
if synname == "phpParent" || synname == "javaScriptBraces" || synname == "phpComment"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endfun
|
||||
" }}}
|
||||
|
||||
" Check filetype == php before automatically creating (fast) folds {{{1
|
||||
function! s:CheckAutocmdEnablePHPFold()
|
||||
if &filetype == "php" && ! g:DisableAutoPHPFolding
|
||||
call s:EnableFastPHPFolds()
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
" Call CheckAutocmdEnablePHPFold on BufReadPost {{{1
|
||||
augroup SetPhpFolds
|
||||
au!
|
||||
au BufReadPost * call s:CheckAutocmdEnablePHPFold()
|
||||
augroup END
|
||||
" }}}
|
||||
|
||||
" vim:ft=vim:foldmethod=marker:nowrap:tabstop=4:shiftwidth=4
|
||||
5
vim/bundle/snipmate.vim/README.markdown
Normal file
5
vim/bundle/snipmate.vim/README.markdown
Normal file
@@ -0,0 +1,5 @@
|
||||
Quickly install with:
|
||||
|
||||
git clone git://github.com/msanders/snipmate.vim.git
|
||||
cd snipmate.vim
|
||||
cp -R * ~/.vim
|
||||
40
vim/bundle/snipmate.vim/after/plugin/snipMate.vim
Normal file
40
vim/bundle/snipmate.vim/after/plugin/snipMate.vim
Normal file
@@ -0,0 +1,40 @@
|
||||
" These are the mappings for snipMate.vim. Putting it here ensures that it
|
||||
" will be mapped after other plugins such as supertab.vim.
|
||||
if !exists('loaded_snips') || exists('s:did_snips_mappings')
|
||||
finish
|
||||
endif
|
||||
let s:did_snips_mappings = 1
|
||||
|
||||
" This is put here in the 'after' directory in order for snipMate to override
|
||||
" other plugin mappings (e.g., supertab).
|
||||
"
|
||||
" You can safely adjust these mappings to your preferences (as explained in
|
||||
" :help snipMate-remap).
|
||||
ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
|
||||
snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr>
|
||||
snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr>
|
||||
ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<cr>
|
||||
|
||||
" The default mappings for these are annoying & sometimes break snipMate.
|
||||
" You can change them back if you want, I've put them here for convenience.
|
||||
snor <bs> b<bs>
|
||||
snor <right> <esc>a
|
||||
snor <left> <esc>bi
|
||||
snor ' b<bs>'
|
||||
snor ` b<bs>`
|
||||
snor % b<bs>%
|
||||
snor U b<bs>U
|
||||
snor ^ b<bs>^
|
||||
snor \ b<bs>\
|
||||
snor <c-x> b<bs><c-x>
|
||||
|
||||
" By default load snippets in snippets_dir
|
||||
if empty(snippets_dir)
|
||||
finish
|
||||
endif
|
||||
|
||||
call GetSnippets(snippets_dir, '_') " Get global snippets
|
||||
|
||||
au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
435
vim/bundle/snipmate.vim/autoload/snipMate.vim
Normal file
435
vim/bundle/snipmate.vim/autoload/snipMate.vim
Normal file
@@ -0,0 +1,435 @@
|
||||
fun! Filename(...)
|
||||
let filename = expand('%:t:r')
|
||||
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
|
||||
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
|
||||
endf
|
||||
|
||||
fun s:RemoveSnippet()
|
||||
unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen
|
||||
\ s:lastBuf s:oldWord
|
||||
if exists('s:update')
|
||||
unl s:startCol s:origWordLen s:update
|
||||
if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif
|
||||
endif
|
||||
aug! snipMateAutocmds
|
||||
endf
|
||||
|
||||
fun snipMate#expandSnip(snip, col)
|
||||
let lnum = line('.') | let col = a:col
|
||||
|
||||
let snippet = s:ProcessSnippet(a:snip)
|
||||
" Avoid error if eval evaluates to nothing
|
||||
if snippet == '' | return '' | endif
|
||||
|
||||
" Expand snippet onto current position with the tab stops removed
|
||||
let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1)
|
||||
|
||||
let line = getline(lnum)
|
||||
let afterCursor = strpart(line, col - 1)
|
||||
" Keep text after the cursor
|
||||
if afterCursor != "\t" && afterCursor != ' '
|
||||
let line = strpart(line, 0, col - 1)
|
||||
let snipLines[-1] .= afterCursor
|
||||
else
|
||||
let afterCursor = ''
|
||||
" For some reason the cursor needs to move one right after this
|
||||
if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore'
|
||||
let col += 1
|
||||
endif
|
||||
endif
|
||||
|
||||
call setline(lnum, line.snipLines[0])
|
||||
|
||||
" Autoindent snippet according to previous indentation
|
||||
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
|
||||
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
|
||||
|
||||
" Open any folds snippet expands into
|
||||
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
|
||||
|
||||
let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent)
|
||||
|
||||
if s:snipLen
|
||||
aug snipMateAutocmds
|
||||
au CursorMovedI * call s:UpdateChangedSnip(0)
|
||||
au InsertEnter * call s:UpdateChangedSnip(1)
|
||||
aug END
|
||||
let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer
|
||||
let s:curPos = 0
|
||||
let s:endCol = g:snipPos[s:curPos][1]
|
||||
let s:endLine = g:snipPos[s:curPos][0]
|
||||
|
||||
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif
|
||||
else
|
||||
unl g:snipPos s:snipLen
|
||||
" Place cursor at end of snippet if no tab stop is given
|
||||
let newlines = len(snipLines) - 1
|
||||
call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor)
|
||||
\ + (newlines ? 0: col - 1))
|
||||
endif
|
||||
return ''
|
||||
endf
|
||||
|
||||
" Prepare snippet to be processed by s:BuildTabStops
|
||||
fun s:ProcessSnippet(snip)
|
||||
let snippet = a:snip
|
||||
" Evaluate eval (`...`) expressions.
|
||||
" Backquotes prefixed with a backslash "\" are ignored.
|
||||
" Using a loop here instead of a regex fixes a bug with nested "\=".
|
||||
if stridx(snippet, '`') != -1
|
||||
while match(snippet, '\(^\|[^\\]\)`.\{-}[^\\]`') != -1
|
||||
let snippet = substitute(snippet, '\(^\|[^\\]\)\zs`.\{-}[^\\]`\ze',
|
||||
\ substitute(eval(matchstr(snippet, '\(^\|[^\\]\)`\zs.\{-}[^\\]\ze`')),
|
||||
\ "\n\\%$", '', ''), '')
|
||||
endw
|
||||
let snippet = substitute(snippet, "\r", "\n", 'g')
|
||||
let snippet = substitute(snippet, '\\`', '`', 'g')
|
||||
endif
|
||||
|
||||
" Place all text after a colon in a tab stop after the tab stop
|
||||
" (e.g. "${#:foo}" becomes "${:foo}foo").
|
||||
" This helps tell the position of the tab stops later.
|
||||
let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g')
|
||||
|
||||
" Update the a:snip so that all the $# become the text after
|
||||
" the colon in their associated ${#}.
|
||||
" (e.g. "${1:foo}" turns all "$1"'s into "foo")
|
||||
let i = 1
|
||||
while stridx(snippet, '${'.i) != -1
|
||||
let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}')
|
||||
if s != ''
|
||||
let snippet = substitute(snippet, '$'.i, s.'&', 'g')
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
|
||||
if &et " Expand tabs to spaces if 'expandtab' is set.
|
||||
return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g')
|
||||
endif
|
||||
return snippet
|
||||
endf
|
||||
|
||||
" Counts occurences of haystack in needle
|
||||
fun s:Count(haystack, needle)
|
||||
let counter = 0
|
||||
let index = stridx(a:haystack, a:needle)
|
||||
while index != -1
|
||||
let index = stridx(a:haystack, a:needle, index+1)
|
||||
let counter += 1
|
||||
endw
|
||||
return counter
|
||||
endf
|
||||
|
||||
" Builds a list of a list of each tab stop in the snippet containing:
|
||||
" 1.) The tab stop's line number.
|
||||
" 2.) The tab stop's column number
|
||||
" (by getting the length of the string between the last "\n" and the
|
||||
" tab stop).
|
||||
" 3.) The length of the text after the colon for the current tab stop
|
||||
" (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned.
|
||||
" 4.) If the "${#:}" construct is given, another list containing all
|
||||
" the matches of "$#", to be replaced with the placeholder. This list is
|
||||
" composed the same way as the parent; the first item is the line number,
|
||||
" and the second is the column.
|
||||
fun s:BuildTabStops(snip, lnum, col, indent)
|
||||
let snipPos = []
|
||||
let i = 1
|
||||
let withoutVars = substitute(a:snip, '$\d\+', '', 'g')
|
||||
while stridx(a:snip, '${'.i) != -1
|
||||
let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D')
|
||||
let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g')
|
||||
|
||||
let j = i - 1
|
||||
call add(snipPos, [0, 0, -1])
|
||||
let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n")
|
||||
let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D'))
|
||||
if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif
|
||||
|
||||
" Get all $# matches in another list, if ${#:name} is given
|
||||
if stridx(withoutVars, '${'.i.':') != -1
|
||||
let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}'))
|
||||
let dots = repeat('.', snipPos[j][2])
|
||||
call add(snipPos[j], [])
|
||||
let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g')
|
||||
while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1
|
||||
let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)')
|
||||
call add(snipPos[j][3], [0, 0])
|
||||
let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n")
|
||||
let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum
|
||||
\ ? len(matchstr(beforeMark, '.*\n\zs.*'))
|
||||
\ : a:col + len(beforeMark))
|
||||
let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '')
|
||||
endw
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
return [snipPos, i - 1]
|
||||
endf
|
||||
|
||||
fun snipMate#jumpTabStop(backwards)
|
||||
let leftPlaceholder = exists('s:origWordLen')
|
||||
\ && s:origWordLen != g:snipPos[s:curPos][2]
|
||||
if leftPlaceholder && exists('s:oldEndCol')
|
||||
let startPlaceholder = s:oldEndCol + 1
|
||||
endif
|
||||
|
||||
if exists('s:update')
|
||||
call s:UpdatePlaceholderTabStops()
|
||||
else
|
||||
call s:UpdateTabStops()
|
||||
endif
|
||||
|
||||
" Don't reselect placeholder if it has been modified
|
||||
if leftPlaceholder && g:snipPos[s:curPos][2] != -1
|
||||
if exists('startPlaceholder')
|
||||
let g:snipPos[s:curPos][1] = startPlaceholder
|
||||
else
|
||||
let g:snipPos[s:curPos][1] = col('.')
|
||||
let g:snipPos[s:curPos][2] = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
let s:curPos += a:backwards ? -1 : 1
|
||||
" Loop over the snippet when going backwards from the beginning
|
||||
if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif
|
||||
|
||||
if s:curPos == s:snipLen
|
||||
let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2]
|
||||
call s:RemoveSnippet()
|
||||
return sMode ? "\<tab>" : TriggerSnippet()
|
||||
endif
|
||||
|
||||
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
|
||||
|
||||
let s:endLine = g:snipPos[s:curPos][0]
|
||||
let s:endCol = g:snipPos[s:curPos][1]
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
|
||||
return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord()
|
||||
endf
|
||||
|
||||
fun s:UpdatePlaceholderTabStops()
|
||||
let changeLen = s:origWordLen - g:snipPos[s:curPos][2]
|
||||
unl s:startCol s:origWordLen s:update
|
||||
if !exists('s:oldVars') | return | endif
|
||||
" Update tab stops in snippet if text has been added via "$#"
|
||||
" (e.g., in "${1:foo}bar$1${2}").
|
||||
if changeLen != 0
|
||||
let curLine = line('.')
|
||||
|
||||
for pos in g:snipPos
|
||||
if pos == g:snipPos[s:curPos] | continue | endif
|
||||
let changed = pos[0] == curLine && pos[1] > s:oldEndCol
|
||||
let changedVars = 0
|
||||
let endPlaceholder = pos[2] - 1 + pos[1]
|
||||
" Subtract changeLen from each tab stop that was after any of
|
||||
" the current tab stop's placeholders.
|
||||
for [lnum, col] in s:oldVars
|
||||
if lnum > pos[0] | break | endif
|
||||
if pos[0] == lnum
|
||||
if pos[1] > col || (pos[2] == -1 && pos[1] == col)
|
||||
let changed += 1
|
||||
elseif col < endPlaceholder
|
||||
let changedVars += 1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let pos[1] -= changeLen * changed
|
||||
let pos[2] -= changeLen * changedVars " Parse variables within placeholders
|
||||
" e.g., "${1:foo} ${2:$1bar}"
|
||||
|
||||
if pos[2] == -1 | continue | endif
|
||||
" Do the same to any placeholders in the other tab stops.
|
||||
for nPos in pos[3]
|
||||
let changed = nPos[0] == curLine && nPos[1] > s:oldEndCol
|
||||
for [lnum, col] in s:oldVars
|
||||
if lnum > nPos[0] | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
let changed += 1
|
||||
endif
|
||||
endfor
|
||||
let nPos[1] -= changeLen * changed
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
unl s:endCol s:oldVars s:oldEndCol
|
||||
endf
|
||||
|
||||
fun s:UpdateTabStops()
|
||||
let changeLine = s:endLine - g:snipPos[s:curPos][0]
|
||||
let changeCol = s:endCol - g:snipPos[s:curPos][1]
|
||||
if exists('s:origWordLen')
|
||||
let changeCol -= s:origWordLen
|
||||
unl s:origWordLen
|
||||
endif
|
||||
let lnum = g:snipPos[s:curPos][0]
|
||||
let col = g:snipPos[s:curPos][1]
|
||||
" Update the line number of all proceeding tab stops if <cr> has
|
||||
" been inserted.
|
||||
if changeLine != 0
|
||||
let changeLine -= 1
|
||||
for pos in g:snipPos
|
||||
if pos[0] >= lnum
|
||||
if pos[0] == lnum | let pos[1] += changeCol | endif
|
||||
let pos[0] += changeLine
|
||||
endif
|
||||
if pos[2] == -1 | continue | endif
|
||||
for nPos in pos[3]
|
||||
if nPos[0] >= lnum
|
||||
if nPos[0] == lnum | let nPos[1] += changeCol | endif
|
||||
let nPos[0] += changeLine
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
elseif changeCol != 0
|
||||
" Update the column of all proceeding tab stops if text has
|
||||
" been inserted/deleted in the current line.
|
||||
for pos in g:snipPos
|
||||
if pos[1] >= col && pos[0] == lnum
|
||||
let pos[1] += changeCol
|
||||
endif
|
||||
if pos[2] == -1 | continue | endif
|
||||
for nPos in pos[3]
|
||||
if nPos[0] > lnum | break | endif
|
||||
if nPos[0] == lnum && nPos[1] >= col
|
||||
let nPos[1] += changeCol
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endf
|
||||
|
||||
fun s:SelectWord()
|
||||
let s:origWordLen = g:snipPos[s:curPos][2]
|
||||
let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1,
|
||||
\ s:origWordLen)
|
||||
let s:prevLen[1] -= s:origWordLen
|
||||
if !empty(g:snipPos[s:curPos][3])
|
||||
let s:update = 1
|
||||
let s:endCol = -1
|
||||
let s:startCol = g:snipPos[s:curPos][1] - 1
|
||||
endif
|
||||
if !s:origWordLen | return '' | endif
|
||||
let l = col('.') != 1 ? 'l' : ''
|
||||
if &sel == 'exclusive'
|
||||
return "\<esc>".l.'v'.s:origWordLen."l\<c-g>"
|
||||
endif
|
||||
return s:origWordLen == 1 ? "\<esc>".l.'gh'
|
||||
\ : "\<esc>".l.'v'.(s:origWordLen - 1)."l\<c-g>"
|
||||
endf
|
||||
|
||||
" This updates the snippet as you type when text needs to be inserted
|
||||
" into multiple places (e.g. in "${1:default text}foo$1bar$1",
|
||||
" "default text" would be highlighted, and if the user types something,
|
||||
" UpdateChangedSnip() would be called so that the text after "foo" & "bar"
|
||||
" are updated accordingly)
|
||||
"
|
||||
" It also automatically quits the snippet if the cursor is moved out of it
|
||||
" while in insert mode.
|
||||
fun s:UpdateChangedSnip(entering)
|
||||
if exists('g:snipPos') && bufnr(0) != s:lastBuf
|
||||
call s:RemoveSnippet()
|
||||
elseif exists('s:update') " If modifying a placeholder
|
||||
if !exists('s:oldVars') && s:curPos + 1 < s:snipLen
|
||||
" Save the old snippet & word length before it's updated
|
||||
" s:startCol must be saved too, in case text is added
|
||||
" before the snippet (e.g. in "foo$1${2}bar${1:foo}").
|
||||
let s:oldEndCol = s:startCol
|
||||
let s:oldVars = deepcopy(g:snipPos[s:curPos][3])
|
||||
endif
|
||||
let col = col('.') - 1
|
||||
|
||||
if s:endCol != -1
|
||||
let changeLen = col('$') - s:prevLen[1]
|
||||
let s:endCol += changeLen
|
||||
else " When being updated the first time, after leaving select mode
|
||||
if a:entering | return | endif
|
||||
let s:endCol = col - 1
|
||||
endif
|
||||
|
||||
" If the cursor moves outside the snippet, quit it
|
||||
if line('.') != g:snipPos[s:curPos][0] || col < s:startCol ||
|
||||
\ col - 1 > s:endCol
|
||||
unl! s:startCol s:origWordLen s:oldVars s:update
|
||||
return s:RemoveSnippet()
|
||||
endif
|
||||
|
||||
call s:UpdateVars()
|
||||
let s:prevLen[1] = col('$')
|
||||
elseif exists('g:snipPos')
|
||||
if !a:entering && g:snipPos[s:curPos][2] != -1
|
||||
let g:snipPos[s:curPos][2] = -2
|
||||
endif
|
||||
|
||||
let col = col('.')
|
||||
let lnum = line('.')
|
||||
let changeLine = line('$') - s:prevLen[0]
|
||||
|
||||
if lnum == s:endLine
|
||||
let s:endCol += col('$') - s:prevLen[1]
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
endif
|
||||
if changeLine != 0
|
||||
let s:endLine += changeLine
|
||||
let s:endCol = col
|
||||
endif
|
||||
|
||||
" Delete snippet if cursor moves out of it in insert mode
|
||||
if (lnum == s:endLine && (col > s:endCol || col < g:snipPos[s:curPos][1]))
|
||||
\ || lnum > s:endLine || lnum < g:snipPos[s:curPos][0]
|
||||
call s:RemoveSnippet()
|
||||
endif
|
||||
endif
|
||||
endf
|
||||
|
||||
" This updates the variables in a snippet when a placeholder has been edited.
|
||||
" (e.g., each "$1" in "${1:foo} $1bar $1bar")
|
||||
fun s:UpdateVars()
|
||||
let newWordLen = s:endCol - s:startCol + 1
|
||||
let newWord = strpart(getline('.'), s:startCol, newWordLen)
|
||||
if newWord == s:oldWord || empty(g:snipPos[s:curPos][3])
|
||||
return
|
||||
endif
|
||||
|
||||
let changeLen = g:snipPos[s:curPos][2] - newWordLen
|
||||
let curLine = line('.')
|
||||
let startCol = col('.')
|
||||
let oldStartSnip = s:startCol
|
||||
let updateTabStops = changeLen != 0
|
||||
let i = 0
|
||||
|
||||
for [lnum, col] in g:snipPos[s:curPos][3]
|
||||
if updateTabStops
|
||||
let start = s:startCol
|
||||
if lnum == curLine && col <= start
|
||||
let s:startCol -= changeLen
|
||||
let s:endCol -= changeLen
|
||||
endif
|
||||
for nPos in g:snipPos[s:curPos][3][(i):]
|
||||
" This list is in ascending order, so quit if we've gone too far.
|
||||
if nPos[0] > lnum | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
let nPos[1] -= changeLen
|
||||
endif
|
||||
endfor
|
||||
if lnum == curLine && col > start
|
||||
let col -= changeLen
|
||||
let g:snipPos[s:curPos][3][i][1] = col
|
||||
endif
|
||||
let i += 1
|
||||
endif
|
||||
|
||||
" "Very nomagic" is used here to allow special characters.
|
||||
call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'.
|
||||
\ escape(s:oldWord, '\'), escape(newWord, '\&'), ''))
|
||||
endfor
|
||||
if oldStartSnip != s:startCol
|
||||
call cursor(0, startCol + s:startCol - oldStartSnip)
|
||||
endif
|
||||
|
||||
let s:oldWord = newWord
|
||||
let g:snipPos[s:curPos][2] = newWordLen
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
322
vim/bundle/snipmate.vim/doc/snipMate.txt
Normal file
322
vim/bundle/snipmate.vim/doc/snipMate.txt
Normal file
@@ -0,0 +1,322 @@
|
||||
*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
|
||||
|
||||
snipMate *snippet* *snippets* *snipMate*
|
||||
Last Change: December 27, 2009
|
||||
|
||||
|snipMate-description| Description
|
||||
|snipMate-syntax| Snippet syntax
|
||||
|snipMate-usage| Usage
|
||||
|snipMate-settings| Settings
|
||||
|snipMate-features| Features
|
||||
|snipMate-disadvantages| Disadvantages to TextMate
|
||||
|snipMate-contact| Contact
|
||||
|snipMate-license| License
|
||||
|
||||
For Vim version 7.0 or later.
|
||||
This plugin only works if 'compatible' is not set.
|
||||
{Vi does not have any of these features.}
|
||||
|
||||
==============================================================================
|
||||
DESCRIPTION *snipMate-description*
|
||||
|
||||
snipMate.vim implements some of TextMate's snippets features in Vim. A
|
||||
snippet is a piece of often-typed text that you can insert into your
|
||||
document using a trigger word followed by a <tab>.
|
||||
|
||||
For instance, in a C file using the default installation of snipMate.vim, if
|
||||
you type "for<tab>" in insert mode, it will expand a typical for loop in C: >
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
To go to the next item in the loop, simply <tab> over to it; if there is
|
||||
repeated code, such as the "i" variable in this example, you can simply
|
||||
start typing once it's highlighted and all the matches specified in the
|
||||
snippet will be updated. To go in reverse, use <shift-tab>.
|
||||
|
||||
==============================================================================
|
||||
SYNTAX *snippet-syntax*
|
||||
|
||||
Snippets can be defined in two ways. They can be in their own file, named
|
||||
after their trigger in 'snippets/<filetype>/<trigger>.snippet', or they can be
|
||||
defined together in a 'snippets/<filetype>.snippets' file. Note that dotted
|
||||
'filetype' syntax is supported -- e.g., you can use >
|
||||
|
||||
:set ft=html.eruby
|
||||
|
||||
to activate snippets for both HTML and eRuby for the current file.
|
||||
|
||||
The syntax for snippets in *.snippets files is the following: >
|
||||
|
||||
snippet trigger
|
||||
expanded text
|
||||
more expanded text
|
||||
|
||||
Note that the first hard tab after the snippet trigger is required, and not
|
||||
expanded in the actual snippet. The syntax for *.snippet files is the same,
|
||||
only without the trigger declaration and starting indentation.
|
||||
|
||||
Also note that snippets must be defined using hard tabs. They can be expanded
|
||||
to spaces later if desired (see |snipMate-indenting|).
|
||||
|
||||
"#" is used as a line-comment character in *.snippets files; however, they can
|
||||
only be used outside of a snippet declaration. E.g.: >
|
||||
|
||||
# this is a correct comment
|
||||
snippet trigger
|
||||
expanded text
|
||||
snippet another_trigger
|
||||
# this isn't a comment!
|
||||
expanded text
|
||||
<
|
||||
This should hopefully be obvious with the included syntax highlighting.
|
||||
|
||||
*snipMate-${#}*
|
||||
Tab stops ~
|
||||
|
||||
By default, the cursor is placed at the end of a snippet. To specify where the
|
||||
cursor is to be placed next, use "${#}", where the # is the number of the tab
|
||||
stop. E.g., to place the cursor first on the id of a <div> tag, and then allow
|
||||
the user to press <tab> to go to the middle of it:
|
||||
>
|
||||
snippet div
|
||||
<div id="${1}">
|
||||
${2}
|
||||
</div>
|
||||
<
|
||||
*snipMate-placeholders* *snipMate-${#:}* *snipMate-$#*
|
||||
Placeholders ~
|
||||
|
||||
Placeholder text can be supplied using "${#:text}", where # is the number of
|
||||
the tab stop. This text then can be copied throughout the snippet using "$#",
|
||||
given # is the same number as used before. So, to make a C for loop: >
|
||||
|
||||
snippet for
|
||||
for (${2:i}; $2 < ${1:count}; $1++) {
|
||||
${4}
|
||||
}
|
||||
|
||||
This will cause "count" to first be selected and change if the user starts
|
||||
typing. When <tab> is pressed, the "i" in ${2}'s position will be selected;
|
||||
all $2 variables will default to "i" and automatically be updated if the user
|
||||
starts typing.
|
||||
NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate.
|
||||
|
||||
Variables within variables are also possible. For instance: >
|
||||
|
||||
snippet opt
|
||||
<option value="${1:option}">${2:$1}</option>
|
||||
|
||||
Will, as usual, cause "option" to first be selected and update all the $1
|
||||
variables if the user starts typing. Since one of these variables is inside of
|
||||
${2}, this text will then be used as a placeholder for the next tab stop,
|
||||
allowing the user to change it if he wishes.
|
||||
|
||||
To copy a value throughout a snippet without supplying default text, simply
|
||||
use the "${#:}" construct without the text; e.g.: >
|
||||
|
||||
snippet foo
|
||||
${1:}bar$1
|
||||
< *snipMate-commands*
|
||||
Interpolated Vim Script ~
|
||||
|
||||
Snippets can also contain Vim script commands that are executed (via |eval()|)
|
||||
when the snippet is inserted. Commands are given inside backticks (`...`); for
|
||||
TextMates's functionality, use the |system()| function. E.g.: >
|
||||
|
||||
snippet date
|
||||
`system("date +%Y-%m-%d")`
|
||||
|
||||
will insert the current date, assuming you are on a Unix system. Note that you
|
||||
can also (and should) use |strftime()| for this example.
|
||||
|
||||
Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
|
||||
|
||||
Since the current filename is used often in snippets, a default function
|
||||
has been defined for it in snipMate.vim, appropriately called Filename().
|
||||
|
||||
With no arguments, the default filename without an extension is returned;
|
||||
the first argument specifies what to place before or after the filename,
|
||||
and the second argument supplies the default text to be used if the file
|
||||
has not been named. "$1" in the first argument is replaced with the filename;
|
||||
if you only want the filename to be returned, the first argument can be left
|
||||
blank. Examples: >
|
||||
|
||||
snippet filename
|
||||
`Filename()`
|
||||
snippet filename_with_default
|
||||
`Filename('', 'name')`
|
||||
snippet filename_foo
|
||||
`filename('$1_foo')`
|
||||
|
||||
The first example returns the filename if it the file has been named, and an
|
||||
empty string if it hasn't. The second returns the filename if it's been named,
|
||||
and "name" if it hasn't. The third returns the filename followed by "_foo" if
|
||||
it has been named, and an empty string if it hasn't.
|
||||
|
||||
*multi_snip*
|
||||
To specify that a snippet can have multiple matches in a *.snippets file, use
|
||||
this syntax: >
|
||||
|
||||
snippet trigger A description of snippet #1
|
||||
expand this text
|
||||
snippet trigger A description of snippet #2
|
||||
expand THIS text!
|
||||
|
||||
In this example, when "trigger<tab>" is typed, a numbered menu containing all
|
||||
of the descriptions of the "trigger" will be shown; when the user presses the
|
||||
corresponding number, that snippet will then be expanded.
|
||||
|
||||
To create a snippet with multiple matches using *.snippet files,
|
||||
simply place all the snippets in a subdirectory with the trigger name:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet'.
|
||||
|
||||
==============================================================================
|
||||
USAGE *snipMate-usage*
|
||||
|
||||
*'snippets'* *g:snippets_dir*
|
||||
Snippets are by default looked for any 'snippets' directory in your
|
||||
'runtimepath'. Typically, it is located at '~/.vim/snippets/' on *nix or
|
||||
'$HOME\vimfiles\snippets\' on Windows. To change that location or add another
|
||||
one, change the g:snippets_dir variable in your |.vimrc| to your preferred
|
||||
directory, or use the |ExtractSnips()|function. This will be used by the
|
||||
|globpath()| function, and so accepts the same syntax as it (e.g.,
|
||||
comma-separated paths).
|
||||
|
||||
ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets*
|
||||
|
||||
ExtractSnipsFile() extracts the specified *.snippets file for the given
|
||||
filetype. A .snippets file contains multiple snippet declarations for the
|
||||
filetype. It is further explained above, in |snippet-syntax|.
|
||||
|
||||
ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet*
|
||||
|
||||
ExtractSnips() extracts *.snippet files from the specified directory and
|
||||
defines them as snippets for the given filetype. The directory tree should
|
||||
look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has
|
||||
multiple matches, it should look like this:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
||||
|
||||
ResetAllSnippets() *ResetAllSnippets()*
|
||||
ResetAllSnippets() removes all snippets from memory. This is useful to put at
|
||||
the top of a snippet setup file for if you would like to |:source| it multiple
|
||||
times.
|
||||
|
||||
ResetSnippets({filetype}) *ResetSnippets()*
|
||||
ResetSnippets() removes all snippets from memory for the given filetype.
|
||||
|
||||
ReloadAllSnippets() *ReloadAllSnippets()*
|
||||
ReloadAllSnippets() reloads all snippets for all filetypes. This is useful for
|
||||
testing and debugging.
|
||||
|
||||
ReloadSnippets({filetype}) *ReloadSnippets()*
|
||||
ReloadSnippets() reloads all snippets for the given filetype.
|
||||
|
||||
*list-snippets* *i_CTRL-R_<Tab>*
|
||||
If you would like to see what snippets are available, simply type <c-r><tab>
|
||||
in the current buffer to show a list via |popupmenu-completion|.
|
||||
|
||||
==============================================================================
|
||||
SETTINGS *snipMate-settings* *g:snips_author*
|
||||
|
||||
The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set
|
||||
to your name; it can then be used in snippets to automatically add it. E.g.: >
|
||||
|
||||
let g:snips_author = 'Hubert Farnsworth'
|
||||
snippet name
|
||||
`g:snips_author`
|
||||
<
|
||||
*snipMate-expandtab* *snipMate-indenting*
|
||||
If you would like your snippets to be expanded using spaces instead of tabs,
|
||||
just enable 'expandtab' and set 'softtabstop' to your preferred amount of
|
||||
spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead.
|
||||
|
||||
*snipMate-remap*
|
||||
snipMate does not come with a setting to customize the trigger key, but you
|
||||
can remap it easily in the two lines it's defined in the 'after' directory
|
||||
under 'plugin/snipMate.vim'. For instance, to change the trigger key
|
||||
to CTRL-J, just change this: >
|
||||
|
||||
ino <tab> <c-r>=TriggerSnippet()<cr>
|
||||
snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
|
||||
to this: >
|
||||
ino <c-j> <c-r>=TriggerSnippet()<cr>
|
||||
snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
|
||||
==============================================================================
|
||||
FEATURES *snipMate-features*
|
||||
|
||||
snipMate.vim has the following features among others:
|
||||
- The syntax of snippets is very similar to TextMate's, allowing
|
||||
easy conversion.
|
||||
- The position of the snippet is kept transparently (i.e. it does not use
|
||||
markers/placeholders written to the buffer), which allows you to escape
|
||||
out of an incomplete snippet, something particularly useful in Vim.
|
||||
- Variables in snippets are updated as-you-type.
|
||||
- Snippets can have multiple matches.
|
||||
- Snippets can be out of order. For instance, in a do...while loop, the
|
||||
condition can be added before the code.
|
||||
- [New] File-based snippets are supported.
|
||||
- [New] Triggers after non-word delimiters are expanded, e.g. "foo"
|
||||
in "bar.foo".
|
||||
- [New] <shift-tab> can now be used to jump tab stops in reverse order.
|
||||
|
||||
==============================================================================
|
||||
DISADVANTAGES *snipMate-disadvantages*
|
||||
|
||||
snipMate.vim currently has the following disadvantages to TextMate's snippets:
|
||||
- There is no $0; the order of tab stops must be explicitly stated.
|
||||
- Placeholders within placeholders are not possible. E.g.: >
|
||||
|
||||
'<div${1: id="${2:some_id}}">${3}</div>'
|
||||
<
|
||||
In TextMate this would first highlight ' id="some_id"', and if
|
||||
you hit delete it would automatically skip ${2} and go to ${3}
|
||||
on the next <tab>, but if you didn't delete it it would highlight
|
||||
"some_id" first. You cannot do this in snipMate.vim.
|
||||
- Regex cannot be performed on variables, such as "${1/.*/\U&}"
|
||||
- Placeholders cannot span multiple lines.
|
||||
- Activating snippets in different scopes of the same file is
|
||||
not possible.
|
||||
|
||||
Perhaps some of these features will be added in a later release.
|
||||
|
||||
==============================================================================
|
||||
CONTACT *snipMate-contact* *snipMate-author*
|
||||
|
||||
To contact the author (Michael Sanders), please email:
|
||||
msanders42+snipmate <at> gmail <dot> com
|
||||
|
||||
I greatly appreciate any suggestions or improvements offered for the script.
|
||||
|
||||
==============================================================================
|
||||
LICENSE *snipMate-license*
|
||||
|
||||
snipMate is released under the MIT license:
|
||||
|
||||
Copyright 2009-2010 Michael Sanders. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or
|
||||
implied, including but not limited to the warranties of merchantability,
|
||||
fitness for a particular purpose and noninfringement. In no event shall the
|
||||
authors or copyright holders be liable for any claim, damages or other
|
||||
liability, whether in an action of contract, tort or otherwise, arising from,
|
||||
out of or in connection with the software or the use or other dealings in the
|
||||
software.
|
||||
|
||||
==============================================================================
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
37
vim/bundle/snipmate.vim/doc/tags
Normal file
37
vim/bundle/snipmate.vim/doc/tags
Normal file
@@ -0,0 +1,37 @@
|
||||
'snippets' snipMate.txt /*'snippets'*
|
||||
.snippet snipMate.txt /*.snippet*
|
||||
.snippets snipMate.txt /*.snippets*
|
||||
ExtractSnips() snipMate.txt /*ExtractSnips()*
|
||||
ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()*
|
||||
Filename() snipMate.txt /*Filename()*
|
||||
ReloadAllSnippets() snipMate.txt /*ReloadAllSnippets()*
|
||||
ReloadSnippets() snipMate.txt /*ReloadSnippets()*
|
||||
ResetAllSnippets() snipMate.txt /*ResetAllSnippets()*
|
||||
ResetSnippets() snipMate.txt /*ResetSnippets()*
|
||||
g:snippets_dir snipMate.txt /*g:snippets_dir*
|
||||
g:snips_author snipMate.txt /*g:snips_author*
|
||||
i_CTRL-R_<Tab> snipMate.txt /*i_CTRL-R_<Tab>*
|
||||
list-snippets snipMate.txt /*list-snippets*
|
||||
multi_snip snipMate.txt /*multi_snip*
|
||||
snipMate snipMate.txt /*snipMate*
|
||||
snipMate-$# snipMate.txt /*snipMate-$#*
|
||||
snipMate-${#:} snipMate.txt /*snipMate-${#:}*
|
||||
snipMate-${#} snipMate.txt /*snipMate-${#}*
|
||||
snipMate-author snipMate.txt /*snipMate-author*
|
||||
snipMate-commands snipMate.txt /*snipMate-commands*
|
||||
snipMate-contact snipMate.txt /*snipMate-contact*
|
||||
snipMate-description snipMate.txt /*snipMate-description*
|
||||
snipMate-disadvantages snipMate.txt /*snipMate-disadvantages*
|
||||
snipMate-expandtab snipMate.txt /*snipMate-expandtab*
|
||||
snipMate-features snipMate.txt /*snipMate-features*
|
||||
snipMate-filename snipMate.txt /*snipMate-filename*
|
||||
snipMate-indenting snipMate.txt /*snipMate-indenting*
|
||||
snipMate-license snipMate.txt /*snipMate-license*
|
||||
snipMate-placeholders snipMate.txt /*snipMate-placeholders*
|
||||
snipMate-remap snipMate.txt /*snipMate-remap*
|
||||
snipMate-settings snipMate.txt /*snipMate-settings*
|
||||
snipMate-usage snipMate.txt /*snipMate-usage*
|
||||
snipMate.txt snipMate.txt /*snipMate.txt*
|
||||
snippet snipMate.txt /*snippet*
|
||||
snippet-syntax snipMate.txt /*snippet-syntax*
|
||||
snippets snipMate.txt /*snippets*
|
||||
10
vim/bundle/snipmate.vim/ftplugin/html_snip_helper.vim
Normal file
10
vim/bundle/snipmate.vim/ftplugin/html_snip_helper.vim
Normal file
@@ -0,0 +1,10 @@
|
||||
" Helper function for (x)html snippets
|
||||
if exists('s:did_snip_helper') || &cp || !exists('loaded_snips')
|
||||
finish
|
||||
endif
|
||||
let s:did_snip_helper = 1
|
||||
|
||||
" Automatically closes tag if in xhtml
|
||||
fun! Close()
|
||||
return stridx(&ft, 'xhtml') == -1 ? '' : ' /'
|
||||
endf
|
||||
8
vim/bundle/snipmate.vim/plugin-info.txt
Normal file
8
vim/bundle/snipmate.vim/plugin-info.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name" : "snipmate",
|
||||
"version" : "dev",
|
||||
"author" : "Michael Sanders <msanders42@gmail.com>",
|
||||
"repository" : {"type": "git", "url": "git://github.com/msanders/snipmate.vim.git"},
|
||||
"dependencies" : {},
|
||||
"description" : "snipMate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim."
|
||||
}
|
||||
271
vim/bundle/snipmate.vim/plugin/snipMate.vim
Normal file
271
vim/bundle/snipmate.vim/plugin/snipMate.vim
Normal file
@@ -0,0 +1,271 @@
|
||||
" File: snipMate.vim
|
||||
" Author: Michael Sanders
|
||||
" Version: 0.84
|
||||
" Description: snipMate.vim implements some of TextMate's snippets features in
|
||||
" Vim. A snippet is a piece of often-typed text that you can
|
||||
" insert into your document using a trigger word followed by a "<tab>".
|
||||
"
|
||||
" For more help see snipMate.txt; you can do this by using:
|
||||
" :helptags ~/.vim/doc
|
||||
" :h snipMate.txt
|
||||
|
||||
if exists('loaded_snips') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
let loaded_snips = 1
|
||||
if !exists('snips_author') | let snips_author = 'Me' | endif
|
||||
|
||||
au BufRead,BufNewFile *.snippets\= set ft=snippet
|
||||
au FileType snippet setl noet fdm=indent
|
||||
|
||||
let s:snippets = {} | let s:multi_snips = {}
|
||||
|
||||
if !exists('snippets_dir')
|
||||
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
|
||||
endif
|
||||
|
||||
fun! MakeSnip(scope, trigger, content, ...)
|
||||
let multisnip = a:0 && a:1 != ''
|
||||
let var = multisnip ? 's:multi_snips' : 's:snippets'
|
||||
if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif
|
||||
if !has_key({var}[a:scope], a:trigger)
|
||||
let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content
|
||||
elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]]
|
||||
else
|
||||
echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.'
|
||||
\ .' See :h multi_snip for help on snippets with multiple matches.'
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! ExtractSnips(dir, ft)
|
||||
for path in split(globpath(a:dir, '*'), "\n")
|
||||
if isdirectory(path)
|
||||
let pathname = fnamemodify(path, ':t')
|
||||
for snipFile in split(globpath(path, '*.snippet'), "\n")
|
||||
call s:ProcessFile(snipFile, a:ft, pathname)
|
||||
endfor
|
||||
elseif fnamemodify(path, ':e') == 'snippet'
|
||||
call s:ProcessFile(path, a:ft)
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Processes a single-snippet file; optionally add the name of the parent
|
||||
" directory for a snippet with multiple matches.
|
||||
fun s:ProcessFile(file, ft, ...)
|
||||
let keyword = fnamemodify(a:file, ':t:r')
|
||||
if keyword == '' | return | endif
|
||||
try
|
||||
let text = join(readfile(a:file), "\n")
|
||||
catch /E484/
|
||||
echom "Error in snipMate.vim: couldn't read file: ".a:file
|
||||
endtry
|
||||
return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
|
||||
\ : MakeSnip(a:ft, keyword, text)
|
||||
endf
|
||||
|
||||
fun! ExtractSnipsFile(file, ft)
|
||||
if !filereadable(a:file) | return | endif
|
||||
let text = readfile(a:file)
|
||||
let inSnip = 0
|
||||
for line in text + ["\n"]
|
||||
if inSnip && (line[0] == "\t" || line == '')
|
||||
let content .= strpart(line, 1)."\n"
|
||||
continue
|
||||
elseif inSnip
|
||||
call MakeSnip(a:ft, trigger, content[:-2], name)
|
||||
let inSnip = 0
|
||||
endif
|
||||
|
||||
if line[:6] == 'snippet'
|
||||
let inSnip = 1
|
||||
let trigger = strpart(line, 8)
|
||||
let name = ''
|
||||
let space = stridx(trigger, ' ') + 1
|
||||
if space " Process multi snip
|
||||
let name = strpart(trigger, space)
|
||||
let trigger = strpart(trigger, 0, space - 1)
|
||||
endif
|
||||
let content = ''
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Reset snippets for filetype.
|
||||
fun! ResetSnippets(ft)
|
||||
let ft = a:ft == '' ? '_' : a:ft
|
||||
for dict in [s:snippets, s:multi_snips, g:did_ft]
|
||||
if has_key(dict, ft)
|
||||
unlet dict[ft]
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Reset snippets for all filetypes.
|
||||
fun! ResetAllSnippets()
|
||||
let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {}
|
||||
endf
|
||||
|
||||
" Reload snippets for filetype.
|
||||
fun! ReloadSnippets(ft)
|
||||
let ft = a:ft == '' ? '_' : a:ft
|
||||
call ResetSnippets(ft)
|
||||
call GetSnippets(g:snippets_dir, ft)
|
||||
endf
|
||||
|
||||
" Reload snippets for all filetypes.
|
||||
fun! ReloadAllSnippets()
|
||||
for ft in keys(g:did_ft)
|
||||
call ReloadSnippets(ft)
|
||||
endfor
|
||||
endf
|
||||
|
||||
let g:did_ft = {}
|
||||
fun! GetSnippets(dir, filetypes)
|
||||
for ft in split(a:filetypes, '\.')
|
||||
if has_key(g:did_ft, ft) | continue | endif
|
||||
call s:DefineSnips(a:dir, ft, ft)
|
||||
if ft == 'objc' || ft == 'cpp' || ft == 'cs'
|
||||
call s:DefineSnips(a:dir, 'c', ft)
|
||||
elseif ft == 'xhtml'
|
||||
call s:DefineSnips(a:dir, 'html', 'xhtml')
|
||||
endif
|
||||
let g:did_ft[ft] = 1
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Define "aliasft" snippets for the filetype "realft".
|
||||
fun s:DefineSnips(dir, aliasft, realft)
|
||||
for path in split(globpath(a:dir, a:aliasft.'/')."\n".
|
||||
\ globpath(a:dir, a:aliasft.'-*/'), "\n")
|
||||
call ExtractSnips(path, a:realft)
|
||||
endfor
|
||||
for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n".
|
||||
\ globpath(a:dir, a:aliasft.'-*.snippets'), "\n")
|
||||
call ExtractSnipsFile(path, a:realft)
|
||||
endfor
|
||||
endf
|
||||
|
||||
fun! TriggerSnippet()
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingForward == "<tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
elseif g:SuperTabMappingBackward == "<tab>"
|
||||
let SuperTabKey = "\<c-p>"
|
||||
endif
|
||||
endif
|
||||
|
||||
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey) | return ''
|
||||
endif
|
||||
call feedkeys("\<esc>a", 'n') " Close completion menu
|
||||
call feedkeys("\<tab>") | return ''
|
||||
endif
|
||||
|
||||
if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif
|
||||
|
||||
let word = matchstr(getline('.'), '\S\+\%'.col('.').'c')
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
let [trigger, snippet] = s:GetSnippet(word, scope)
|
||||
" If word is a trigger for a snippet, delete the trigger & expand
|
||||
" the snippet.
|
||||
if snippet != ''
|
||||
let col = col('.') - len(trigger)
|
||||
sil exe 's/\V'.escape(trigger, '/\.').'\%#//'
|
||||
return snipMate#expandSnip(snippet, col)
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
return ''
|
||||
endif
|
||||
return "\<tab>"
|
||||
endf
|
||||
|
||||
fun! BackwardsSnippet()
|
||||
if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif
|
||||
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingBackward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-p>"
|
||||
elseif g:SuperTabMappingForward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
endif
|
||||
endif
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
return ''
|
||||
endif
|
||||
return "\<s-tab>"
|
||||
endf
|
||||
|
||||
" Check if word under cursor is snippet trigger; if it isn't, try checking if
|
||||
" the text after non-word characters is (e.g. check for "foo" in "bar.foo")
|
||||
fun s:GetSnippet(word, scope)
|
||||
let word = a:word | let snippet = ''
|
||||
while snippet == ''
|
||||
if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]')
|
||||
let snippet = s:snippets[a:scope][word]
|
||||
elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]')
|
||||
let snippet = s:ChooseSnippet(a:scope, word)
|
||||
if snippet == '' | break | endif
|
||||
else
|
||||
if match(word, '\W') == -1 | break | endif
|
||||
let word = substitute(word, '.\{-}\W', '', '')
|
||||
endif
|
||||
endw
|
||||
if word == '' && a:word != '.' && stridx(a:word, '.') != -1
|
||||
let [word, snippet] = s:GetSnippet('.', a:scope)
|
||||
endif
|
||||
return [word, snippet]
|
||||
endf
|
||||
|
||||
fun s:ChooseSnippet(scope, trigger)
|
||||
let snippet = []
|
||||
let i = 1
|
||||
for snip in s:multi_snips[a:scope][a:trigger]
|
||||
let snippet += [i.'. '.snip[0]]
|
||||
let i += 1
|
||||
endfor
|
||||
if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif
|
||||
let num = inputlist(snippet) - 1
|
||||
return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
|
||||
endf
|
||||
|
||||
fun! ShowAvailableSnips()
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let word = matchstr(getline('.'), '\S\+\%'.col.'c')
|
||||
let words = [word]
|
||||
if stridx(word, '.')
|
||||
let words += split(word, '\.', 1)
|
||||
endif
|
||||
let matchlen = 0
|
||||
let matches = []
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : []
|
||||
if has_key(s:multi_snips, scope)
|
||||
let triggers += keys(s:multi_snips[scope])
|
||||
endif
|
||||
for trigger in triggers
|
||||
for word in words
|
||||
if word == ''
|
||||
let matches += [trigger] " Show all matches if word is empty
|
||||
elseif trigger =~ '^'.word
|
||||
let matches += [trigger]
|
||||
let len = len(word)
|
||||
if len > matchlen | let matchlen = len | endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
|
||||
" This is to avoid a bug with Vim when using complete(col - matchlen, matches)
|
||||
" (Issue#46 on the Google Code snipMate issue tracker).
|
||||
call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', ''))
|
||||
call complete(col, matches)
|
||||
return ''
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
9
vim/bundle/snipmate.vim/snippets/_.snippets
Normal file
9
vim/bundle/snipmate.vim/snippets/_.snippets
Normal file
@@ -0,0 +1,9 @@
|
||||
# Global snippets
|
||||
|
||||
# (c) holds no legal value ;)
|
||||
snippet c)
|
||||
Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}
|
||||
snippet date
|
||||
`strftime("%Y-%m-%d")`
|
||||
snippet ddate
|
||||
`strftime("%B %d, %Y")`
|
||||
66
vim/bundle/snipmate.vim/snippets/autoit.snippets
Normal file
66
vim/bundle/snipmate.vim/snippets/autoit.snippets
Normal file
@@ -0,0 +1,66 @@
|
||||
snippet if
|
||||
If ${1:condition} Then
|
||||
${2:; True code}
|
||||
EndIf
|
||||
snippet el
|
||||
Else
|
||||
${1}
|
||||
snippet elif
|
||||
ElseIf ${1:condition} Then
|
||||
${2:; True code}
|
||||
# If/Else block
|
||||
snippet ifel
|
||||
If ${1:condition} Then
|
||||
${2:; True code}
|
||||
Else
|
||||
${3:; Else code}
|
||||
EndIf
|
||||
# If/ElseIf/Else block
|
||||
snippet ifelif
|
||||
If ${1:condition 1} Then
|
||||
${2:; True code}
|
||||
ElseIf ${3:condition 2} Then
|
||||
${4:; True code}
|
||||
Else
|
||||
${5:; Else code}
|
||||
EndIf
|
||||
# Switch block
|
||||
snippet switch
|
||||
Switch (${1:condition})
|
||||
Case {$2:case1}:
|
||||
{$3:; Case 1 code}
|
||||
Case Else:
|
||||
{$4:; Else code}
|
||||
EndSwitch
|
||||
# Select block
|
||||
snippet select
|
||||
Select (${1:condition})
|
||||
Case {$2:case1}:
|
||||
{$3:; Case 1 code}
|
||||
Case Else:
|
||||
{$4:; Else code}
|
||||
EndSelect
|
||||
# While loop
|
||||
snippet while
|
||||
While (${1:condition})
|
||||
${2:; code...}
|
||||
WEnd
|
||||
# For loop
|
||||
snippet for
|
||||
For ${1:n} = ${3:1} to ${2:count}
|
||||
${4:; code...}
|
||||
Next
|
||||
# New Function
|
||||
snippet func
|
||||
Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
${4:Return}
|
||||
EndFunc
|
||||
# Message box
|
||||
snippet msg
|
||||
MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"})
|
||||
# Debug Message
|
||||
snippet debug
|
||||
MsgBox(0, "Debug", ${1:"Debug Message"})
|
||||
# Show Variable Debug Message
|
||||
snippet showvar
|
||||
MsgBox(0, "${1:VarName}", $1)
|
||||
113
vim/bundle/snipmate.vim/snippets/c.snippets
Normal file
113
vim/bundle/snipmate.vim/snippets/c.snippets
Normal file
@@ -0,0 +1,113 @@
|
||||
# main()
|
||||
snippet main
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
${1}
|
||||
return 0;
|
||||
}
|
||||
snippet mainn
|
||||
int main(void)
|
||||
{
|
||||
${1}
|
||||
return 0;
|
||||
}
|
||||
# #include <...>
|
||||
snippet inc
|
||||
#include <${1:stdio}.h>${2}
|
||||
# #include "..."
|
||||
snippet Inc
|
||||
#include "${1:`Filename("$1.h")`}"${2}
|
||||
# #ifndef ... #define ... #endif
|
||||
snippet Def
|
||||
#ifndef $1
|
||||
#define ${1:SYMBOL} ${2:value}
|
||||
#endif${3}
|
||||
snippet def
|
||||
#define
|
||||
snippet ifdef
|
||||
#ifdef ${1:FOO}
|
||||
${2:#define }
|
||||
#endif
|
||||
snippet #if
|
||||
#if ${1:FOO}
|
||||
${2}
|
||||
#endif
|
||||
# Header Include-Guard
|
||||
snippet once
|
||||
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
|
||||
|
||||
#define $1
|
||||
|
||||
${2}
|
||||
|
||||
#endif /* end of include guard: $1 */
|
||||
# If Condition
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
snippet el
|
||||
else {
|
||||
${1}
|
||||
}
|
||||
# Ternary conditional
|
||||
snippet t
|
||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||
# Do While Loop
|
||||
snippet do
|
||||
do {
|
||||
${2:/* code */}
|
||||
} while (${1:/* condition */});
|
||||
# While Loop
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
# For Loop
|
||||
snippet for
|
||||
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||
${4:/* code */}
|
||||
}
|
||||
# Custom For Loop
|
||||
snippet forr
|
||||
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
|
||||
${5:/* code */}
|
||||
}
|
||||
# Function
|
||||
snippet fun
|
||||
${1:void} ${2:function_name}(${3})
|
||||
{
|
||||
${4:/* code */}
|
||||
}
|
||||
# Function Declaration
|
||||
snippet fund
|
||||
${1:void} ${2:function_name}(${3});${4}
|
||||
# Typedef
|
||||
snippet td
|
||||
typedef ${1:int} ${2:MyCustomType};${3}
|
||||
# Struct
|
||||
snippet st
|
||||
struct ${1:`Filename('$1_t', 'name')`} {
|
||||
${2:/* data */}
|
||||
}${3: /* optional variable list */};${4}
|
||||
# Typedef struct
|
||||
snippet tds
|
||||
typedef struct ${2:_$1 }{
|
||||
${3:/* data */}
|
||||
} ${1:`Filename('$1_t', 'name')`};
|
||||
# Typdef enum
|
||||
snippet tde
|
||||
typedef enum {
|
||||
${1:/* data */}
|
||||
} ${2:foo};
|
||||
# printf
|
||||
# unfortunately version this isn't as nice as TextMates's, given the lack of a
|
||||
# dynamic `...`
|
||||
snippet pr
|
||||
printf("${1:%s}\n"${2});${3}
|
||||
# fprintf (again, this isn't as nice as TextMate's version, but it works)
|
||||
snippet fpr
|
||||
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
|
||||
# This is kind of convenient
|
||||
snippet .
|
||||
[${1}]${2}
|
||||
63
vim/bundle/snipmate.vim/snippets/coffee.snippets
Normal file
63
vim/bundle/snipmate.vim/snippets/coffee.snippets
Normal file
@@ -0,0 +1,63 @@
|
||||
snippet bfun
|
||||
${1:(${2:args}) }=>
|
||||
${3:# body...}
|
||||
|
||||
snippet cla
|
||||
class ${1:ClassName}${2: extends ${3:Ancestor}}
|
||||
${4:constructor: (${5:args}) ->
|
||||
${6:# body...}}
|
||||
$7
|
||||
|
||||
snippet elif
|
||||
else if ${1:condition}
|
||||
${2:# body...}
|
||||
|
||||
snippet fora
|
||||
for ${1:name} in ${2:array}
|
||||
${3:# body...}
|
||||
|
||||
snippet foro
|
||||
for ${1:key}, ${2:value} of ${3:Object}
|
||||
${0:# body...}
|
||||
|
||||
snippet forr
|
||||
for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}}
|
||||
${6:# body...}
|
||||
|
||||
snippet forrex
|
||||
for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}}
|
||||
${6:# body...}
|
||||
|
||||
snippet fun
|
||||
${1:name} = (${2:args}) ->
|
||||
${3:# body...}
|
||||
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2:# body...}
|
||||
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2:# body...}
|
||||
else
|
||||
${3:# body...}
|
||||
|
||||
snippet ifte
|
||||
if ${1:condition} then ${2:value} else ${3:other}
|
||||
|
||||
snippet log
|
||||
console.log $1
|
||||
|
||||
snippet swi
|
||||
switch ${1:object}
|
||||
when ${2:value}
|
||||
${0:# body...}
|
||||
|
||||
snippet try
|
||||
try
|
||||
$1
|
||||
catch ${2:error}
|
||||
$3
|
||||
|
||||
snippet unl
|
||||
${1:action} unless ${2:condition}
|
||||
34
vim/bundle/snipmate.vim/snippets/cpp.snippets
Normal file
34
vim/bundle/snipmate.vim/snippets/cpp.snippets
Normal file
@@ -0,0 +1,34 @@
|
||||
# Read File Into Vector
|
||||
snippet readfile
|
||||
std::vector<char> v;
|
||||
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
|
||||
char buf[1024];
|
||||
while (size_t len = fread(buf, 1, sizeof(buf), $2))
|
||||
v.insert(v.end(), buf, buf + len);
|
||||
fclose($2);
|
||||
}${3}
|
||||
# std::map
|
||||
snippet map
|
||||
std::map<${1:key}, ${2:value}> map${3};
|
||||
# std::vector
|
||||
snippet vector
|
||||
std::vector<${1:char}> v${2};
|
||||
# Namespace
|
||||
snippet ns
|
||||
namespace ${1:`Filename('', 'my')`} {
|
||||
${2}
|
||||
} /* $1 */
|
||||
# Class
|
||||
snippet cl
|
||||
class ${1:`Filename('$1_t', 'name')`} {
|
||||
public:
|
||||
$1 (${2:arguments});
|
||||
virtual ~$1 ();
|
||||
|
||||
private:
|
||||
${3:/* data */}
|
||||
};
|
||||
snippet fori
|
||||
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||
${4:/* code */}
|
||||
}
|
||||
39
vim/bundle/snipmate.vim/snippets/erlang.snippets
Normal file
39
vim/bundle/snipmate.vim/snippets/erlang.snippets
Normal file
@@ -0,0 +1,39 @@
|
||||
# module and export all
|
||||
snippet mod
|
||||
-module(${1:`Filename('', 'my')`}).
|
||||
|
||||
-compile([export_all]).
|
||||
|
||||
start() ->
|
||||
${2}
|
||||
|
||||
stop() ->
|
||||
ok.
|
||||
# define directive
|
||||
snippet def
|
||||
-define(${1:macro}, ${2:body}).${3}
|
||||
# export directive
|
||||
snippet exp
|
||||
-export([${1:function}/${2:arity}]).
|
||||
# include directive
|
||||
snippet inc
|
||||
-include("${1:file}").${2}
|
||||
# behavior directive
|
||||
snippet beh
|
||||
-behaviour(${1:behaviour}).${2}
|
||||
# if expression
|
||||
snippet if
|
||||
if
|
||||
${1:guard} ->
|
||||
${2:body}
|
||||
end
|
||||
# case expression
|
||||
snippet case
|
||||
case ${1:expression} of
|
||||
${2:pattern} ->
|
||||
${3:body};
|
||||
end
|
||||
# record directive
|
||||
snippet rec
|
||||
-record(${1:record}, {
|
||||
${2:field}=${3:value}}).${4}
|
||||
190
vim/bundle/snipmate.vim/snippets/html.snippets
Normal file
190
vim/bundle/snipmate.vim/snippets/html.snippets
Normal file
@@ -0,0 +1,190 @@
|
||||
# Some useful Unicode entities
|
||||
# Non-Breaking Space
|
||||
snippet nbs
|
||||
|
||||
# ←
|
||||
snippet left
|
||||
←
|
||||
# →
|
||||
snippet right
|
||||
→
|
||||
# ↑
|
||||
snippet up
|
||||
↑
|
||||
# ↓
|
||||
snippet down
|
||||
↓
|
||||
# ↩
|
||||
snippet return
|
||||
↩
|
||||
# ⇤
|
||||
snippet backtab
|
||||
⇤
|
||||
# ⇥
|
||||
snippet tab
|
||||
⇥
|
||||
# ⇧
|
||||
snippet shift
|
||||
⇧
|
||||
# ⌃
|
||||
snippet control
|
||||
⌃
|
||||
# ⌅
|
||||
snippet enter
|
||||
⌅
|
||||
# ⌘
|
||||
snippet command
|
||||
⌘
|
||||
# ⌥
|
||||
snippet option
|
||||
⌥
|
||||
# ⌦
|
||||
snippet delete
|
||||
⌦
|
||||
# ⌫
|
||||
snippet backspace
|
||||
⌫
|
||||
# ⎋
|
||||
snippet escape
|
||||
⎋
|
||||
# Generic Doctype
|
||||
snippet doctype HTML 4.01 Strict
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
snippet doctype HTML 4.01 Transitional
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
snippet doctype HTML 5
|
||||
<!DOCTYPE HTML>
|
||||
snippet doctype XHTML 1.0 Frameset
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
snippet doctype XHTML 1.0 Strict
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
snippet doctype XHTML 1.0 Transitional
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
snippet doctype XHTML 1.1
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
# HTML Doctype 4.01 Strict
|
||||
snippet docts
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
# HTML Doctype 4.01 Transitional
|
||||
snippet doct
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
# HTML Doctype 5
|
||||
snippet doct5
|
||||
<!DOCTYPE HTML>
|
||||
# XHTML Doctype 1.0 Frameset
|
||||
snippet docxf
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
# XHTML Doctype 1.0 Strict
|
||||
snippet docxs
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
# XHTML Doctype 1.0 Transitional
|
||||
snippet docxt
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
# XHTML Doctype 1.1
|
||||
snippet docx
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
snippet html
|
||||
<html>
|
||||
${1}
|
||||
</html>
|
||||
snippet xhtml
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
${1}
|
||||
</html>
|
||||
snippet body
|
||||
<body>
|
||||
${1}
|
||||
</body>
|
||||
snippet head
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"`Close()`>
|
||||
|
||||
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||
${2}
|
||||
</head>
|
||||
snippet title
|
||||
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>${2}
|
||||
snippet script
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
${1}
|
||||
</script>${2}
|
||||
snippet scriptsrc
|
||||
<script src="${1}.js" type="text/javascript" charset="utf-8"></script>${2}
|
||||
snippet style
|
||||
<style type="text/css" media="${1:screen}">
|
||||
${2}
|
||||
</style>${3}
|
||||
snippet base
|
||||
<base href="${1}" target="${2}"`Close()`>
|
||||
snippet r
|
||||
<br`Close()[1:]`>
|
||||
snippet div
|
||||
<div id="${1:name}">
|
||||
${2}
|
||||
</div>
|
||||
# Embed QT Movie
|
||||
snippet movie
|
||||
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
|
||||
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||
<param name="src" value="$1"`Close()`>
|
||||
<param name="controller" value="$4"`Close()`>
|
||||
<param name="autoplay" value="$5"`Close()`>
|
||||
<embed src="${1:movie.mov}"
|
||||
width="${2:320}" height="${3:240}"
|
||||
controller="${4:true}" autoplay="${5:true}"
|
||||
scale="tofit" cache="true"
|
||||
pluginspage="http://www.apple.com/quicktime/download/"
|
||||
`Close()[1:]`>
|
||||
</object>${6}
|
||||
snippet fieldset
|
||||
<fieldset id="$1">
|
||||
<legend>${1:name}</legend>
|
||||
|
||||
${3}
|
||||
</fieldset>
|
||||
snippet form
|
||||
<form action="${1:`Filename('$1_submit')`}" method="${2:get}" accept-charset="utf-8">
|
||||
${3}
|
||||
|
||||
|
||||
<p><input type="submit" value="Continue →"`Close()`></p>
|
||||
</form>
|
||||
snippet h1
|
||||
<h1 id="${1:heading}">${2:$1}</h1>
|
||||
snippet input
|
||||
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"`Close()`>${4}
|
||||
snippet label
|
||||
<label for="${2:$1}">${1:name}</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="${5}" id="${6:$2}"`Close()`>${7}
|
||||
snippet link
|
||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"`Close()`>${4}
|
||||
snippet mailto
|
||||
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
|
||||
snippet meta
|
||||
<meta name="${1:name}" content="${2:content}"`Close()`>${3}
|
||||
snippet opt
|
||||
<option value="${1:option}">${2:$1}</option>${3}
|
||||
snippet optt
|
||||
<option>${1:option}</option>${2}
|
||||
snippet select
|
||||
<select name="${1:some_name}" id="${2:$1}">
|
||||
<option value="${3:option}">${4:$3}</option>
|
||||
</select>${5}
|
||||
snippet table
|
||||
<table border="${1:0}">
|
||||
<tr><th>${2:Header}</th></tr>
|
||||
<tr><th>${3:Data}</th></tr>
|
||||
</table>${4}
|
||||
snippet textarea
|
||||
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}
|
||||
95
vim/bundle/snipmate.vim/snippets/java.snippets
Normal file
95
vim/bundle/snipmate.vim/snippets/java.snippets
Normal file
@@ -0,0 +1,95 @@
|
||||
snippet main
|
||||
public static void main (String [] args)
|
||||
{
|
||||
${1:/* code */}
|
||||
}
|
||||
snippet pu
|
||||
public
|
||||
snippet po
|
||||
protected
|
||||
snippet pr
|
||||
private
|
||||
snippet st
|
||||
static
|
||||
snippet fi
|
||||
final
|
||||
snippet ab
|
||||
abstract
|
||||
snippet re
|
||||
return
|
||||
snippet br
|
||||
break;
|
||||
snippet de
|
||||
default:
|
||||
${1}
|
||||
snippet ca
|
||||
catch(${1:Exception} ${2:e}) ${3}
|
||||
snippet th
|
||||
throw
|
||||
snippet sy
|
||||
synchronized
|
||||
snippet im
|
||||
import
|
||||
snippet imp
|
||||
implements
|
||||
snippet ext
|
||||
extends
|
||||
snippet j.u
|
||||
java.util
|
||||
snippet j.i
|
||||
java.io.
|
||||
snippet j.b
|
||||
java.beans.
|
||||
snippet j.n
|
||||
java.net.
|
||||
snippet j.m
|
||||
java.math.
|
||||
snippet if
|
||||
if (${1}) ${2}
|
||||
snippet el
|
||||
else
|
||||
snippet elif
|
||||
else if (${1}) ${2}
|
||||
snippet wh
|
||||
while (${1}) ${2}
|
||||
snippet for
|
||||
for (${1}; ${2}; ${3}) ${4}
|
||||
snippet fore
|
||||
for (${1} : ${2}) ${3}
|
||||
snippet sw
|
||||
switch (${1}) ${2}
|
||||
snippet cs
|
||||
case ${1}:
|
||||
${2}
|
||||
${3}
|
||||
snippet tc
|
||||
public class ${1:`Filename()`} extends ${2:TestCase}
|
||||
snippet t
|
||||
public void test${1:Name}() throws Exception ${2}
|
||||
snippet cl
|
||||
class ${1:`Filename("", "untitled")`} ${2}
|
||||
snippet in
|
||||
interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}
|
||||
snippet m
|
||||
${1:void} ${2:method}(${3}) ${4:throws }${5}
|
||||
snippet v
|
||||
${1:String} ${2:var}${3: = null}${4};${5}
|
||||
snippet co
|
||||
static public final ${1:String} ${2:var} = ${3};${4}
|
||||
snippet cos
|
||||
static public final String ${1:var} = "${2}";${3}
|
||||
snippet as
|
||||
assert ${1:test} : "${2:Failure message}";${3}
|
||||
snippet try
|
||||
try {
|
||||
${3}
|
||||
} catch(${1:Exception} ${2:e}) {
|
||||
}
|
||||
snippet tryf
|
||||
try {
|
||||
${3}
|
||||
} catch(${1:Exception} ${2:e}) {
|
||||
} finally {
|
||||
}
|
||||
snippet rst
|
||||
ResultSet ${1:rst}${2: = null}${3};${4}
|
||||
74
vim/bundle/snipmate.vim/snippets/javascript.snippets
Normal file
74
vim/bundle/snipmate.vim/snippets/javascript.snippets
Normal file
@@ -0,0 +1,74 @@
|
||||
# Prototype
|
||||
snippet proto
|
||||
${1:class_name}.prototype.${2:method_name} =
|
||||
function(${3:first_argument}) {
|
||||
${4:// body...}
|
||||
};
|
||||
# Function
|
||||
snippet fun
|
||||
function ${1:function_name} (${2:argument}) {
|
||||
${3:// body...}
|
||||
}
|
||||
# Anonymous Function
|
||||
snippet f
|
||||
function(${1}) {${2}};
|
||||
# if
|
||||
snippet if
|
||||
if (${1:true}) {${2}}
|
||||
# if ... else
|
||||
snippet ife
|
||||
if (${1:true}) {${2}}
|
||||
else{${3}}
|
||||
# tertiary conditional
|
||||
snippet t
|
||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||
# switch
|
||||
snippet switch
|
||||
switch(${1:expression}) {
|
||||
case '${3:case}':
|
||||
${4:// code}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${2:// code}
|
||||
}
|
||||
# case
|
||||
snippet case
|
||||
case '${1:case}':
|
||||
${2:// code}
|
||||
break;
|
||||
${3}
|
||||
# for (...) {...}
|
||||
snippet for
|
||||
for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {
|
||||
${4:$1[$2]}
|
||||
};
|
||||
# for (...) {...} (Improved Native For-Loop)
|
||||
snippet forr
|
||||
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {
|
||||
${4:$1[$2]}
|
||||
};
|
||||
# while (...) {...}
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
# do...while
|
||||
snippet do
|
||||
do {
|
||||
${2:/* code */}
|
||||
} while (${1:/* condition */});
|
||||
# Object Method
|
||||
snippet :f
|
||||
${1:method_name}: function(${2:attribute}) {
|
||||
${4}
|
||||
}${3:,}
|
||||
# setTimeout function
|
||||
snippet timeout
|
||||
setTimeout(function() {${3}}${2}, ${1:10};
|
||||
# Get Elements
|
||||
snippet get
|
||||
getElementsBy${1:TagName}('${2}')${3}
|
||||
# Get Element
|
||||
snippet gett
|
||||
getElementBy${1:Id}('${2}')${3}
|
||||
54
vim/bundle/snipmate.vim/snippets/mako.snippets
Normal file
54
vim/bundle/snipmate.vim/snippets/mako.snippets
Normal file
@@ -0,0 +1,54 @@
|
||||
snippet def
|
||||
<%def name="${1:name}">
|
||||
${2:}
|
||||
</%def>
|
||||
snippet call
|
||||
<%call expr="${1:name}">
|
||||
${2:}
|
||||
</%call>
|
||||
snippet doc
|
||||
<%doc>
|
||||
${1:}
|
||||
</%doc>
|
||||
snippet text
|
||||
<%text>
|
||||
${1:}
|
||||
</%text>
|
||||
snippet for
|
||||
% for ${1:i} in ${2:iter}:
|
||||
${3:}
|
||||
% endfor
|
||||
snippet if if
|
||||
% if ${1:condition}:
|
||||
${2:}
|
||||
% endif
|
||||
snippet if if/else
|
||||
% if ${1:condition}:
|
||||
${2:}
|
||||
% else:
|
||||
${3:}
|
||||
% endif
|
||||
snippet try
|
||||
% try:
|
||||
${1:}
|
||||
% except${2:}:
|
||||
${3:pass}
|
||||
% endtry
|
||||
snippet wh
|
||||
% while ${1:}:
|
||||
${2:}
|
||||
% endwhile
|
||||
snippet $
|
||||
${ ${1:} }
|
||||
snippet <%
|
||||
<% ${1:} %>
|
||||
snippet <!%
|
||||
<!% ${1:} %>
|
||||
snippet inherit
|
||||
<%inherit file="${1:filename}" />
|
||||
snippet include
|
||||
<%include file="${1:filename}" />
|
||||
snippet namespace
|
||||
<%namespace file="${1:name}" />
|
||||
snippet page
|
||||
<%page args="${1:}" />
|
||||
247
vim/bundle/snipmate.vim/snippets/objc.snippets
Normal file
247
vim/bundle/snipmate.vim/snippets/objc.snippets
Normal file
@@ -0,0 +1,247 @@
|
||||
# #import <...>
|
||||
snippet Imp
|
||||
#import <${1:Cocoa/Cocoa.h}>${2}
|
||||
# #import "..."
|
||||
snippet imp
|
||||
#import "${1:`Filename()`.h}"${2}
|
||||
# @selector(...)
|
||||
snippet sel
|
||||
@selector(${1:method}:)${3}
|
||||
# @"..." string
|
||||
snippet s
|
||||
@"${1}"${2}
|
||||
# Object
|
||||
snippet o
|
||||
${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5}
|
||||
# NSLog(...)
|
||||
snippet log
|
||||
NSLog(@"${1:%@}"${2});${3}
|
||||
# Class
|
||||
snippet objc
|
||||
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation $1
|
||||
${3}
|
||||
@end
|
||||
# Class Interface
|
||||
snippet int
|
||||
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
|
||||
{${3}
|
||||
}
|
||||
${4}
|
||||
@end
|
||||
snippet @interface
|
||||
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
|
||||
{${3}
|
||||
}
|
||||
${4}
|
||||
@end
|
||||
# Class Implementation
|
||||
snippet impl
|
||||
@implementation ${1:`Filename('', 'someClass')`}
|
||||
${2}
|
||||
@end
|
||||
snippet @implementation
|
||||
@implementation ${1:`Filename('', 'someClass')`}
|
||||
${2}
|
||||
@end
|
||||
# Protocol
|
||||
snippet pro
|
||||
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
|
||||
${3}
|
||||
@end
|
||||
snippet @protocol
|
||||
@protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
|
||||
${3}
|
||||
@end
|
||||
# init Definition
|
||||
snippet init
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
${1}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
# dealloc Definition
|
||||
snippet dealloc
|
||||
- (void) dealloc
|
||||
{
|
||||
${1:deallocations}
|
||||
[super dealloc];
|
||||
}
|
||||
snippet su
|
||||
[super ${1:init}]${2}
|
||||
snippet ibo
|
||||
IBOutlet ${1:NSSomeClass} *${2:$1};${3}
|
||||
# Category
|
||||
snippet cat
|
||||
@interface ${1:NSObject} (${2:MyCategory})
|
||||
@end
|
||||
|
||||
@implementation $1 ($2)
|
||||
${3}
|
||||
@end
|
||||
# Category Interface
|
||||
snippet cath
|
||||
@interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory})
|
||||
${3}
|
||||
@end
|
||||
# Method
|
||||
snippet m
|
||||
- (${1:id})${2:method}
|
||||
{
|
||||
${3}
|
||||
}
|
||||
# Method declaration
|
||||
snippet md
|
||||
- (${1:id})${2:method};${3}
|
||||
# IBAction declaration
|
||||
snippet ibad
|
||||
- (IBAction)${1:method}:(${2:id})sender;${3}
|
||||
# IBAction method
|
||||
snippet iba
|
||||
- (IBAction)${1:method}:(${2:id})sender
|
||||
{
|
||||
${3}
|
||||
}
|
||||
# awakeFromNib method
|
||||
snippet wake
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
${1}
|
||||
}
|
||||
# Class Method
|
||||
snippet M
|
||||
+ (${1:id})${2:method}
|
||||
{
|
||||
${3:return nil;}
|
||||
}
|
||||
# Sub-method (Call super)
|
||||
snippet sm
|
||||
- (${1:id})${2:method}
|
||||
{
|
||||
[super $2];${3}
|
||||
return self;
|
||||
}
|
||||
# Accessor Methods For:
|
||||
# Object
|
||||
snippet objacc
|
||||
- (${1:id})${2:thing}
|
||||
{
|
||||
return $2;
|
||||
}
|
||||
|
||||
- (void)set$2:($1)${3:new$2}
|
||||
{
|
||||
[$3 retain];
|
||||
[$2 release];
|
||||
$2 = $3;
|
||||
}${4}
|
||||
# for (object in array)
|
||||
snippet forin
|
||||
for (${1:Class} *${2:some$1} in ${3:array}) {
|
||||
${4}
|
||||
}
|
||||
snippet fore
|
||||
for (${1:object} in ${2:array}) {
|
||||
${3:statements}
|
||||
}
|
||||
snippet forarray
|
||||
unsigned int ${1:object}Count = [${2:array} count];
|
||||
|
||||
for (unsigned int index = 0; index < $1Count; index++) {
|
||||
${3:id} $1 = [$2 $1AtIndex:index];
|
||||
${4}
|
||||
}
|
||||
snippet fora
|
||||
unsigned int ${1:object}Count = [${2:array} count];
|
||||
|
||||
for (unsigned int index = 0; index < $1Count; index++) {
|
||||
${3:id} $1 = [$2 $1AtIndex:index];
|
||||
${4}
|
||||
}
|
||||
# Try / Catch Block
|
||||
snippet @try
|
||||
@try {
|
||||
${1:statements}
|
||||
}
|
||||
@catch (NSException * e) {
|
||||
${2:handler}
|
||||
}
|
||||
@finally {
|
||||
${3:statements}
|
||||
}
|
||||
snippet @catch
|
||||
@catch (${1:exception}) {
|
||||
${2:handler}
|
||||
}
|
||||
snippet @finally
|
||||
@finally {
|
||||
${1:statements}
|
||||
}
|
||||
# IBOutlet
|
||||
# @property (Objective-C 2.0)
|
||||
snippet prop
|
||||
@property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4}
|
||||
# @synthesize (Objective-C 2.0)
|
||||
snippet syn
|
||||
@synthesize ${1:property};${2}
|
||||
# [[ alloc] init]
|
||||
snippet alloc
|
||||
[[${1:foo} alloc] init${2}];${3}
|
||||
snippet a
|
||||
[[${1:foo} alloc] init${2}];${3}
|
||||
# retain
|
||||
snippet ret
|
||||
[${1:foo} retain];${2}
|
||||
# release
|
||||
snippet rel
|
||||
[${1:foo} release];
|
||||
# autorelease
|
||||
snippet arel
|
||||
[${1:foo} autorelease];
|
||||
# autorelease pool
|
||||
snippet pool
|
||||
NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
|
||||
${2:/* code */}
|
||||
[$1 drain];
|
||||
# Throw an exception
|
||||
snippet except
|
||||
NSException *${1:badness};
|
||||
$1 = [NSException exceptionWithName:@"${2:$1Name}"
|
||||
reason:@"${3}"
|
||||
userInfo:nil];
|
||||
[$1 raise];
|
||||
snippet prag
|
||||
#pragma mark ${1:-}
|
||||
snippet cl
|
||||
@class ${1:Foo};${2}
|
||||
snippet color
|
||||
[[NSColor ${1:blackColor}] set];
|
||||
# NSArray
|
||||
snippet array
|
||||
NSMutableArray *${1:array} = [NSMutable array];${2}
|
||||
snippet nsa
|
||||
NSArray ${1}
|
||||
snippet nsma
|
||||
NSMutableArray ${1}
|
||||
snippet aa
|
||||
NSArray * array;${1}
|
||||
snippet ma
|
||||
NSMutableArray * array;${1}
|
||||
# NSDictionary
|
||||
snippet dict
|
||||
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
|
||||
snippet nsd
|
||||
NSDictionary ${1}
|
||||
snippet nsmd
|
||||
NSMutableDictionary ${1}
|
||||
# NSString
|
||||
snippet nss
|
||||
NSString ${1}
|
||||
snippet nsms
|
||||
NSMutableString ${1}
|
||||
97
vim/bundle/snipmate.vim/snippets/perl.snippets
Normal file
97
vim/bundle/snipmate.vim/snippets/perl.snippets
Normal file
@@ -0,0 +1,97 @@
|
||||
# #!/usr/bin/perl
|
||||
snippet #!
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Hash Pointer
|
||||
snippet .
|
||||
=>
|
||||
# Function
|
||||
snippet sub
|
||||
sub ${1:function_name} {
|
||||
${2:#body ...}
|
||||
}
|
||||
# Conditional
|
||||
snippet if
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# Conditional if..else
|
||||
snippet ife
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
else {
|
||||
${3:# else...}
|
||||
}
|
||||
# Conditional if..elsif..else
|
||||
snippet ifee
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
elsif (${3}) {
|
||||
${4:# elsif...}
|
||||
}
|
||||
else {
|
||||
${5:# else...}
|
||||
}
|
||||
# Conditional One-line
|
||||
snippet xif
|
||||
${1:expression} if ${2:condition};${3}
|
||||
# Unless conditional
|
||||
snippet unless
|
||||
unless (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# Unless conditional One-line
|
||||
snippet xunless
|
||||
${1:expression} unless ${2:condition};${3}
|
||||
# Try/Except
|
||||
snippet eval
|
||||
eval {
|
||||
${1:# do something risky...}
|
||||
};
|
||||
if ($@) {
|
||||
${2:# handle failure...}
|
||||
}
|
||||
# While Loop
|
||||
snippet wh
|
||||
while (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# While Loop One-line
|
||||
snippet xwh
|
||||
${1:expression} while ${2:condition};${3}
|
||||
# C-style For Loop
|
||||
snippet cfor
|
||||
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||
${4:# body...}
|
||||
}
|
||||
# For loop one-line
|
||||
snippet xfor
|
||||
${1:expression} for @${2:array};${3}
|
||||
# Foreach Loop
|
||||
snippet for
|
||||
foreach my $${1:x} (@${2:array}) {
|
||||
${3:# body...}
|
||||
}
|
||||
# Foreach Loop One-line
|
||||
snippet fore
|
||||
${1:expression} foreach @${2:array};${3}
|
||||
# Package
|
||||
snippet cl
|
||||
package ${1:ClassName};
|
||||
|
||||
use base qw(${2:ParentClass});
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
$class = ref $class if ref $class;
|
||||
my $self = bless {}, $class;
|
||||
$self;
|
||||
}
|
||||
|
||||
1;${3}
|
||||
# Read File
|
||||
snippet slurp
|
||||
my $${1:var};
|
||||
{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${3}
|
||||
222
vim/bundle/snipmate.vim/snippets/php.default
Normal file
222
vim/bundle/snipmate.vim/snippets/php.default
Normal file
@@ -0,0 +1,222 @@
|
||||
snippet php
|
||||
<?php
|
||||
${1}
|
||||
?>
|
||||
snippet ec
|
||||
echo "${1:string}"${2};
|
||||
snippet inc
|
||||
include '${1:file}';${2}
|
||||
snippet inc1
|
||||
include_once '${1:file}';${2}
|
||||
snippet req
|
||||
require '${1:file}';${2}
|
||||
snippet req1
|
||||
require_once '${1:file}';${2}
|
||||
# $GLOBALS['...']
|
||||
snippet globals
|
||||
$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}
|
||||
snippet $_ COOKIE['...']
|
||||
$_COOKIE['${1:variable}']${2}
|
||||
snippet $_ ENV['...']
|
||||
$_ENV['${1:variable}']${2}
|
||||
snippet $_ FILES['...']
|
||||
$_FILES['${1:variable}']${2}
|
||||
snippet $_ Get['...']
|
||||
$_GET['${1:variable}']${2}
|
||||
snippet $_ POST['...']
|
||||
$_POST['${1:variable}']${2}
|
||||
snippet $_ REQUEST['...']
|
||||
$_REQUEST['${1:variable}']${2}
|
||||
snippet $_ SERVER['...']
|
||||
$_SERVER['${1:variable}']${2}
|
||||
snippet $_ SESSION['...']
|
||||
$_SESSION['${1:variable}']${2}
|
||||
# Start Docblock
|
||||
snippet /*
|
||||
/**
|
||||
* ${1}
|
||||
**/
|
||||
# Class - post doc
|
||||
snippet doc_cp
|
||||
/**
|
||||
* ${1:undocumented class}
|
||||
*
|
||||
* @package ${2:default}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Class Variable - post doc
|
||||
snippet doc_vp
|
||||
/**
|
||||
* ${1:undocumented class variable}
|
||||
*
|
||||
* @var ${2:string}
|
||||
**/${3}
|
||||
# Class Variable
|
||||
snippet doc_v
|
||||
/**
|
||||
* ${3:undocumented class variable}
|
||||
*
|
||||
* @var ${4:string}
|
||||
**/
|
||||
${1:var} $${2};${5}
|
||||
# Class
|
||||
snippet doc_c
|
||||
/**
|
||||
* ${3:undocumented class}
|
||||
*
|
||||
* @packaged ${4:default}
|
||||
* @author ${5:`g:snips_author`}
|
||||
**/
|
||||
${1:}class ${2:}
|
||||
{${6}
|
||||
} // END $1class $2
|
||||
# Constant Definition - post doc
|
||||
snippet doc_dp
|
||||
/**
|
||||
* ${1:undocumented constant}
|
||||
**/${2}
|
||||
# Constant Definition
|
||||
snippet doc_d
|
||||
/**
|
||||
* ${3:undocumented constant}
|
||||
**/
|
||||
define(${1}, ${2});${4}
|
||||
# Function - post doc
|
||||
snippet doc_fp
|
||||
/**
|
||||
* ${1:undocumented function}
|
||||
*
|
||||
* @return ${2:void}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Function signature
|
||||
snippet doc_s
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3});${7}
|
||||
# Function
|
||||
snippet doc_f
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3})
|
||||
{${7}
|
||||
}
|
||||
# Header
|
||||
snippet doc_h
|
||||
/**
|
||||
* ${1}
|
||||
*
|
||||
* @author ${2:`g:snips_author`}
|
||||
* @version ${3:$Id$}
|
||||
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
||||
* @package ${5:default}
|
||||
**/
|
||||
|
||||
/**
|
||||
* Define DocBlock
|
||||
*//
|
||||
# Interface
|
||||
snippet doc_i
|
||||
/**
|
||||
* ${2:undocumented class}
|
||||
*
|
||||
* @package ${3:default}
|
||||
* @author ${4:`g:snips_author`}
|
||||
**/
|
||||
interface ${1:}
|
||||
{${5}
|
||||
} // END interface $1
|
||||
# class ...
|
||||
snippet class
|
||||
/**
|
||||
* ${1}
|
||||
**/
|
||||
class ${2:ClassName}
|
||||
{
|
||||
${3}
|
||||
function ${4:__construct}(${5:argument})
|
||||
{
|
||||
${6:// code...}
|
||||
}
|
||||
}
|
||||
# define(...)
|
||||
snippet def
|
||||
define('${1}'${2});${3}
|
||||
# defined(...)
|
||||
snippet def?
|
||||
${1}defined('${2}')${3}
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# do ... while
|
||||
snippet do
|
||||
do {
|
||||
${2:// code... }
|
||||
} while (${1:/* condition */});
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
snippet ife
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
} else {
|
||||
${3:// code...}
|
||||
}
|
||||
${4}
|
||||
snippet else
|
||||
else {
|
||||
${1:// code...}
|
||||
}
|
||||
snippet elseif
|
||||
elseif (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# Tertiary conditional
|
||||
snippet t
|
||||
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
|
||||
snippet switch
|
||||
switch ($${1:variable}) {
|
||||
case '${2:value}':
|
||||
${3:// code...}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${4:// code...}
|
||||
break;
|
||||
}
|
||||
snippet case
|
||||
case '${1:value}':
|
||||
${2:// code...}
|
||||
break;${3}
|
||||
snippet for
|
||||
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||
${4: // code...}
|
||||
}
|
||||
snippet foreach
|
||||
foreach ($${1:variable} as $${2:key}) {
|
||||
${3:// code...}
|
||||
}
|
||||
snippet fun
|
||||
${1:public }function ${2:FunctionName}(${3})
|
||||
{
|
||||
${4:// code...}
|
||||
}
|
||||
# $... = array (...)
|
||||
snippet array
|
||||
$${1:arrayName} = array('${2}' => ${3});${4}
|
||||
snippet arr
|
||||
array(
|
||||
'${1:key}' => ${2:value}
|
||||
);
|
||||
snippet a
|
||||
array('${1:key}' => ${2:value});
|
||||
221
vim/bundle/snipmate.vim/snippets/php.snippets
Normal file
221
vim/bundle/snipmate.vim/snippets/php.snippets
Normal file
@@ -0,0 +1,221 @@
|
||||
snippet php
|
||||
<?php
|
||||
${1}
|
||||
?>
|
||||
snippet ec
|
||||
echo "${1:string}"${2};
|
||||
snippet {
|
||||
{
|
||||
${1}
|
||||
}
|
||||
snippet inc
|
||||
include '${1:file}';${2}
|
||||
snippet inc1
|
||||
include_once '${1:file}';${2}
|
||||
snippet req
|
||||
require '${1:file}';${2}
|
||||
snippet req1
|
||||
require_once '${1:file}';${2}
|
||||
# $GLOBALS['...']
|
||||
snippet globals
|
||||
$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}
|
||||
snippet $_ COOKIE['...']
|
||||
$_COOKIE['${1:variable}']${2}
|
||||
snippet $_ ENV['...']
|
||||
$_ENV['${1:variable}']${2}
|
||||
snippet $_ FILES['...']
|
||||
$_FILES['${1:variable}']${2}
|
||||
snippet $_ Get['...']
|
||||
$_GET['${1:variable}']${2}
|
||||
snippet $_ POST['...']
|
||||
$_POST['${1:variable}']${2}
|
||||
snippet $_ REQUEST['...']
|
||||
$_REQUEST['${1:variable}']${2}
|
||||
snippet $_ SERVER['...']
|
||||
$_SERVER['${1:variable}']${2}
|
||||
snippet $_ SESSION['...']
|
||||
$_SESSION['${1:variable}']${2}
|
||||
# Start Docblock
|
||||
snippet /*
|
||||
/**
|
||||
* ${1:description}
|
||||
*
|
||||
* @param ${2:int} ${3:var} ${4:desc}
|
||||
* @return ${5:int} ${6:desc}
|
||||
* @access ${7:public}
|
||||
**/
|
||||
# Class - post doc
|
||||
snippet doc_cp
|
||||
/**
|
||||
* ${1:undocumented class}
|
||||
*
|
||||
* @package ${2:default}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Class Variable - post doc
|
||||
snippet doc_vp
|
||||
/**
|
||||
* ${1:undocumented class variable}
|
||||
*
|
||||
* @var ${2:string}
|
||||
**/${3}
|
||||
# Class Variable
|
||||
snippet doc_v
|
||||
/**
|
||||
* ${3:undocumented class variable}
|
||||
*
|
||||
* @var ${4:string}
|
||||
**/
|
||||
${1:var} $${2};${5}
|
||||
# Class
|
||||
snippet doc_c
|
||||
/**
|
||||
* ${3:undocumented class}
|
||||
*
|
||||
* @packaged ${4:default}
|
||||
* @author ${5:`g:snips_author`}
|
||||
**/
|
||||
${1:}class ${2:}
|
||||
{${6}
|
||||
} // END $1class $2
|
||||
# Constant Definition - post doc
|
||||
snippet doc_dp
|
||||
/**
|
||||
* ${1:undocumented constant}
|
||||
**/${2}
|
||||
# Constant Definition
|
||||
snippet doc_d
|
||||
/**
|
||||
* ${3:undocumented constant}
|
||||
**/
|
||||
define(${1}, ${2});${4}
|
||||
# Function - post doc
|
||||
snippet doc_fp
|
||||
/**
|
||||
* ${1:undocumented function}
|
||||
*
|
||||
* @return ${2:void}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Function signature
|
||||
snippet doc_s
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3});${7}
|
||||
# Function
|
||||
snippet doc_f
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3})
|
||||
{${7}
|
||||
}
|
||||
# Header
|
||||
snippet doc_h
|
||||
/**
|
||||
* ${1}
|
||||
*
|
||||
* @author ${2:`g:snips_author`}
|
||||
* @version ${3:$Id$}
|
||||
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
||||
* @package ${5:default}
|
||||
**/
|
||||
|
||||
/**
|
||||
* Define DocBlock
|
||||
*//
|
||||
# Interface
|
||||
snippet doc_i
|
||||
/**
|
||||
* ${2:undocumented class}
|
||||
*
|
||||
* @package ${3:default}
|
||||
* @author ${4:`g:snips_author`}
|
||||
**/
|
||||
interface ${1:}
|
||||
{${5}
|
||||
} // END interface $1
|
||||
# class ...
|
||||
snippet class
|
||||
class ${1:ClassName} ${2:extends} ${3:ClassName} {
|
||||
${4}
|
||||
}
|
||||
# define(...)
|
||||
snippet def
|
||||
define('${1}', ${2});${3}
|
||||
# defined(...)
|
||||
snippet def?
|
||||
${1}defined('${2}')${3}
|
||||
snippet while
|
||||
while (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# do ... while
|
||||
snippet do
|
||||
do {
|
||||
${2:// code... }
|
||||
} while (${1:/* condition */});
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
snippet ife
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
} else {
|
||||
${3:// code...}
|
||||
}
|
||||
${4}
|
||||
snippet else
|
||||
else {
|
||||
${1:// code...}
|
||||
}
|
||||
snippet elseif
|
||||
elseif (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# Tertiary conditional
|
||||
snippet t
|
||||
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
|
||||
snippet switch
|
||||
switch ($${1:variable}) {
|
||||
case '${2:value}':
|
||||
${3:// code...}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${4:// code...}
|
||||
break;
|
||||
}
|
||||
snippet case
|
||||
case '${1:value}':
|
||||
${2:// code...}
|
||||
break;${3}
|
||||
snippet for
|
||||
for ($${1:i}=${2:0}; $$1 < ${3:count}; $$1${4:++}) {
|
||||
${5: // code...}
|
||||
}
|
||||
snippet foreach
|
||||
foreach ($${1:variable} as $${2:key}) {
|
||||
${3:// code...}
|
||||
}
|
||||
snippet fun
|
||||
${1:public} function ${2:FunctionName}(${3}) {
|
||||
${4}
|
||||
}
|
||||
# $... = array (...)
|
||||
snippet ar
|
||||
$${1:arrayName} = array(${2:key} => ${3:value});
|
||||
snippet a
|
||||
array(${1})
|
||||
snippet arr
|
||||
array(
|
||||
${1}
|
||||
)
|
||||
86
vim/bundle/snipmate.vim/snippets/python.snippets
Normal file
86
vim/bundle/snipmate.vim/snippets/python.snippets
Normal file
@@ -0,0 +1,86 @@
|
||||
snippet #!
|
||||
#!/usr/bin/env python
|
||||
|
||||
snippet imp
|
||||
import ${1:module}
|
||||
# Module Docstring
|
||||
snippet docs
|
||||
'''
|
||||
File: ${1:`Filename('$1.py', 'foo.py')`}
|
||||
Author: ${2:`g:snips_author`}
|
||||
Description: ${3}
|
||||
'''
|
||||
snippet wh
|
||||
while ${1:condition}:
|
||||
${2:# code...}
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}:
|
||||
${3:# code...}
|
||||
# New Class
|
||||
snippet cl
|
||||
class ${1:ClassName}(${2:object}):
|
||||
"""${3:docstring for $1}"""
|
||||
def __init__(self, ${4:arg}):
|
||||
${5:super($1, self).__init__()}
|
||||
self.$4 = $4
|
||||
${6}
|
||||
# New Function
|
||||
snippet def
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
"""${3:docstring for $1}"""
|
||||
${4:pass}
|
||||
snippet deff
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
${3}
|
||||
# New Method
|
||||
snippet defs
|
||||
def ${1:mname}(self, ${2:arg}):
|
||||
${3:pass}
|
||||
# New Property
|
||||
snippet property
|
||||
def ${1:foo}():
|
||||
doc = "${2:The $1 property.}"
|
||||
def fget(self):
|
||||
${3:return self._$1}
|
||||
def fset(self, value):
|
||||
${4:self._$1 = value}
|
||||
# Lambda
|
||||
snippet ld
|
||||
${1:var} = lambda ${2:vars} : ${3:action}
|
||||
snippet .
|
||||
self.
|
||||
snippet try Try/Except
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
snippet try Try/Except/Else
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
finally:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Else/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
finally:
|
||||
${6:pass}
|
||||
# if __name__ == '__main__':
|
||||
snippet ifmain
|
||||
if __name__ == '__main__':
|
||||
${1:main()}
|
||||
# __magic__
|
||||
snippet _
|
||||
__${1:init}__${2}
|
||||
504
vim/bundle/snipmate.vim/snippets/ruby.snippets
Normal file
504
vim/bundle/snipmate.vim/snippets/ruby.snippets
Normal file
@@ -0,0 +1,504 @@
|
||||
# #!/usr/bin/env ruby
|
||||
snippet #!
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# New Block
|
||||
snippet =b
|
||||
=begin rdoc
|
||||
${1}
|
||||
=end
|
||||
snippet y
|
||||
:yields: ${1:arguments}
|
||||
snippet rb
|
||||
#!/usr/bin/env ruby -wKU
|
||||
snippet beg
|
||||
begin
|
||||
${3}
|
||||
rescue ${1:Exception} => ${2:e}
|
||||
end
|
||||
|
||||
snippet req
|
||||
require "${1}"${2}
|
||||
snippet #
|
||||
# =>
|
||||
snippet end
|
||||
__END__
|
||||
snippet case
|
||||
case ${1:object}
|
||||
when ${2:condition}
|
||||
${3}
|
||||
end
|
||||
snippet when
|
||||
when ${1:condition}
|
||||
${2}
|
||||
snippet def
|
||||
def ${1:method_name}
|
||||
${2}
|
||||
end
|
||||
snippet deft
|
||||
def test_${1:case_name}
|
||||
${2}
|
||||
end
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
end
|
||||
snippet elsif
|
||||
elsif ${1:condition}
|
||||
${2}
|
||||
snippet unless
|
||||
unless ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet while
|
||||
while ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet for
|
||||
for ${1:e} in ${2:c}
|
||||
${3}
|
||||
end
|
||||
snippet until
|
||||
until ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet cla class .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
${2}
|
||||
end
|
||||
snippet cla class .. initialize .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
def initialize(${2:args})
|
||||
${3}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla class .. < ParentClass .. initialize .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass}
|
||||
def initialize(${3:args})
|
||||
${4}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla ClassName = Struct .. do .. end
|
||||
${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do
|
||||
def ${3:method_name}
|
||||
${4}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla class BlankSlate .. initialize .. end
|
||||
class ${1:BlankSlate}
|
||||
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
|
||||
snippet cla class << self .. end
|
||||
class << ${1:self}
|
||||
${2}
|
||||
end
|
||||
# class .. < DelegateClass .. initialize .. end
|
||||
snippet cla-
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass})
|
||||
def initialize(${3:args})
|
||||
super(${4:del_obj})
|
||||
|
||||
${5}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet mod module .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
${2}
|
||||
end
|
||||
snippet mod module .. module_function .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
module_function
|
||||
|
||||
${2}
|
||||
end
|
||||
snippet mod module .. ClassMethods .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
module ClassMethods
|
||||
${2}
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
end
|
||||
|
||||
def self.included(receiver)
|
||||
receiver.extend ClassMethods
|
||||
receiver.send :include, InstanceMethods
|
||||
end
|
||||
end
|
||||
# attr_reader
|
||||
snippet r
|
||||
attr_reader :${1:attr_names}
|
||||
# attr_writer
|
||||
snippet w
|
||||
attr_writer :${1:attr_names}
|
||||
# attr_accessor
|
||||
snippet rw
|
||||
attr_accessor :${1:attr_names}
|
||||
# include Enumerable
|
||||
snippet Enum
|
||||
include Enumerable
|
||||
|
||||
def each(&block)
|
||||
${1}
|
||||
end
|
||||
# include Comparable
|
||||
snippet Comp
|
||||
include Comparable
|
||||
|
||||
def <=>(other)
|
||||
${1}
|
||||
end
|
||||
# extend Forwardable
|
||||
snippet Forw-
|
||||
extend Forwardable
|
||||
# def self
|
||||
snippet defs
|
||||
def self.${1:class_method_name}
|
||||
${2}
|
||||
end
|
||||
# def method_missing
|
||||
snippet defmm
|
||||
def method_missing(meth, *args, &blk)
|
||||
${1}
|
||||
end
|
||||
snippet defd
|
||||
def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}
|
||||
snippet defds
|
||||
def_delegators :${1:@del_obj}, :${2:del_methods}
|
||||
snippet am
|
||||
alias_method :${1:new_name}, :${2:old_name}
|
||||
snippet app
|
||||
if __FILE__ == $PROGRAM_NAME
|
||||
${1}
|
||||
end
|
||||
# usage_if()
|
||||
snippet usai
|
||||
if ARGV.${1}
|
||||
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
|
||||
end
|
||||
# usage_unless()
|
||||
snippet usau
|
||||
unless ARGV.${1}
|
||||
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
|
||||
end
|
||||
snippet array
|
||||
Array.new(${1:10}) { |${2:i}| ${3} }
|
||||
snippet hash
|
||||
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }
|
||||
snippet file File.foreach() { |line| .. }
|
||||
File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }
|
||||
snippet file File.read()
|
||||
File.read(${1:"path/to/file"})${2}
|
||||
snippet Dir Dir.global() { |file| .. }
|
||||
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }
|
||||
snippet Dir Dir[".."]
|
||||
Dir[${1:"glob/**/*.rb"}]${2}
|
||||
snippet dir
|
||||
Filename.dirname(__FILE__)
|
||||
snippet deli
|
||||
delete_if { |${1:e}| ${2} }
|
||||
snippet fil
|
||||
fill(${1:range}) { |${2:i}| ${3} }
|
||||
# flatten_once()
|
||||
snippet flao
|
||||
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}
|
||||
snippet zip
|
||||
zip(${1:enums}) { |${2:row}| ${3} }
|
||||
# downto(0) { |n| .. }
|
||||
snippet dow
|
||||
downto(${1:0}) { |${2:n}| ${3} }
|
||||
snippet ste
|
||||
step(${1:2}) { |${2:n}| ${3} }
|
||||
snippet tim
|
||||
times { |${1:n}| ${2} }
|
||||
snippet upt
|
||||
upto(${1:1.0/0.0}) { |${2:n}| ${3} }
|
||||
snippet loo
|
||||
loop { ${1} }
|
||||
snippet ea
|
||||
each { |${1:e}| ${2} }
|
||||
snippet ead
|
||||
each do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet eab
|
||||
each_byte { |${1:byte}| ${2} }
|
||||
snippet eac- each_char { |chr| .. }
|
||||
each_char { |${1:chr}| ${2} }
|
||||
snippet eac- each_cons(..) { |group| .. }
|
||||
each_cons(${1:2}) { |${2:group}| ${3} }
|
||||
snippet eai
|
||||
each_index { |${1:i}| ${2} }
|
||||
snippet eaid
|
||||
each_index do |${1:i}|
|
||||
end
|
||||
snippet eak
|
||||
each_key { |${1:key}| ${2} }
|
||||
snippet eakd
|
||||
each_key do |${1:key}|
|
||||
${2}
|
||||
end
|
||||
snippet eal
|
||||
each_line { |${1:line}| ${2} }
|
||||
snippet eald
|
||||
each_line do |${1:line}|
|
||||
${2}
|
||||
end
|
||||
snippet eap
|
||||
each_pair { |${1:name}, ${2:val}| ${3} }
|
||||
snippet eapd
|
||||
each_pair do |${1:name}, ${2:val}|
|
||||
${3}
|
||||
end
|
||||
snippet eas-
|
||||
each_slice(${1:2}) { |${2:group}| ${3} }
|
||||
snippet easd-
|
||||
each_slice(${1:2}) do |${2:group}|
|
||||
${3}
|
||||
end
|
||||
snippet eav
|
||||
each_value { |${1:val}| ${2} }
|
||||
snippet eavd
|
||||
each_value do |${1:val}|
|
||||
${2}
|
||||
end
|
||||
snippet eawi
|
||||
each_with_index { |${1:e}, ${2:i}| ${3} }
|
||||
snippet eawid
|
||||
each_with_index do |${1:e},${2:i}|
|
||||
${3}
|
||||
end
|
||||
snippet reve
|
||||
reverse_each { |${1:e}| ${2} }
|
||||
snippet reved
|
||||
reverse_each do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet inj
|
||||
inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }
|
||||
snippet injd
|
||||
inject(${1:init}) do |${2:mem}, ${3:var}|
|
||||
${4}
|
||||
end
|
||||
snippet map
|
||||
map { |${1:e}| ${2} }
|
||||
snippet mapd
|
||||
map do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet mapwi-
|
||||
enum_with_index.map { |${1:e}, ${2:i}| ${3} }
|
||||
snippet sor
|
||||
sort { |a, b| ${1} }
|
||||
snippet sorb
|
||||
sort_by { |${1:e}| ${2} }
|
||||
snippet ran
|
||||
sort_by { rand }
|
||||
snippet all
|
||||
all? { |${1:e}| ${2} }
|
||||
snippet any
|
||||
any? { |${1:e}| ${2} }
|
||||
snippet cl
|
||||
classify { |${1:e}| ${2} }
|
||||
snippet col
|
||||
collect { |${1:e}| ${2} }
|
||||
snippet cold
|
||||
collect do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet det
|
||||
detect { |${1:e}| ${2} }
|
||||
snippet detd
|
||||
detect do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet fet
|
||||
fetch(${1:name}) { |${2:key}| ${3} }
|
||||
snippet fin
|
||||
find { |${1:e}| ${2} }
|
||||
snippet find
|
||||
find do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet fina
|
||||
find_all { |${1:e}| ${2} }
|
||||
snippet finad
|
||||
find_all do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet gre
|
||||
grep(${1:/pattern/}) { |${2:match}| ${3} }
|
||||
snippet sub
|
||||
${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }
|
||||
snippet sca
|
||||
scan(${1:/pattern/}) { |${2:match}| ${3} }
|
||||
snippet scad
|
||||
scan(${1:/pattern/}) do |${2:match}|
|
||||
${3}
|
||||
end
|
||||
snippet max
|
||||
max { |a, b| ${1} }
|
||||
snippet min
|
||||
min { |a, b| ${1} }
|
||||
snippet par
|
||||
partition { |${1:e}| ${2} }
|
||||
snippet pard
|
||||
partition do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet rej
|
||||
reject { |${1:e}| ${2} }
|
||||
snippet rejd
|
||||
reject do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet sel
|
||||
select { |${1:e}| ${2} }
|
||||
snippet seld
|
||||
select do |${1:e}|
|
||||
${2}
|
||||
end
|
||||
snippet lam
|
||||
lambda { |${1:args}| ${2} }
|
||||
snippet do
|
||||
do |${1:variable}|
|
||||
${2}
|
||||
end
|
||||
snippet :
|
||||
:${1:key} => ${2:"value"}${3}
|
||||
snippet ope
|
||||
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
|
||||
# path_from_here()
|
||||
snippet patfh
|
||||
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
|
||||
# unix_filter {}
|
||||
snippet unif
|
||||
ARGF.each_line${1} do |${2:line}|
|
||||
${3}
|
||||
end
|
||||
# option_parse {}
|
||||
snippet optp
|
||||
require "optparse"
|
||||
|
||||
options = {${1:default => "args"}}
|
||||
|
||||
ARGV.options do |opts|
|
||||
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
|
||||
snippet opt
|
||||
opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
|
||||
"${4:Option description.}") do |${5:opt}|
|
||||
${6}
|
||||
end
|
||||
snippet tc
|
||||
require "test/unit"
|
||||
|
||||
require "${1:library_file_name}"
|
||||
|
||||
class Test${2:$1} < Test::Unit::TestCase
|
||||
def test_${3:case_name}
|
||||
${4}
|
||||
end
|
||||
end
|
||||
snippet ts
|
||||
require "test/unit"
|
||||
|
||||
require "tc_${1:test_case_file}"
|
||||
require "tc_${2:test_case_file}"${3}
|
||||
snippet as
|
||||
assert(${1:test}, "${2:Failure message.}")${3}
|
||||
snippet ase
|
||||
assert_equal(${1:expected}, ${2:actual})${3}
|
||||
snippet asne
|
||||
assert_not_equal(${1:unexpected}, ${2:actual})${3}
|
||||
snippet asid
|
||||
assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
|
||||
snippet asio
|
||||
assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
|
||||
snippet asko
|
||||
assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
|
||||
snippet asn
|
||||
assert_nil(${1:instance})${2}
|
||||
snippet asnn
|
||||
assert_not_nil(${1:instance})${2}
|
||||
snippet asm
|
||||
assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
|
||||
snippet asnm
|
||||
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
|
||||
snippet aso
|
||||
assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
|
||||
snippet asr
|
||||
assert_raise(${1:Exception}) { ${2} }
|
||||
snippet asnr
|
||||
assert_nothing_raised(${1:Exception}) { ${2} }
|
||||
snippet asrt
|
||||
assert_respond_to(${1:object}, :${2:method})${3}
|
||||
snippet ass assert_same(..)
|
||||
assert_same(${1:expected}, ${2:actual})${3}
|
||||
snippet ass assert_send(..)
|
||||
assert_send([${1:object}, :${2:message}, ${3:args}])${4}
|
||||
snippet asns
|
||||
assert_not_same(${1:unexpected}, ${2:actual})${3}
|
||||
snippet ast
|
||||
assert_throws(:${1:expected}) { ${2} }
|
||||
snippet asnt
|
||||
assert_nothing_thrown { ${1} }
|
||||
snippet fl
|
||||
flunk("${1:Failure message.}")${2}
|
||||
# Benchmark.bmbm do .. end
|
||||
snippet bm-
|
||||
TESTS = ${1:10_000}
|
||||
Benchmark.bmbm do |results|
|
||||
${2}
|
||||
end
|
||||
snippet rep
|
||||
results.report("${1:name}:") { TESTS.times { ${2} }}
|
||||
# Marshal.dump(.., file)
|
||||
snippet Md
|
||||
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}
|
||||
# Mashal.load(obj)
|
||||
snippet Ml
|
||||
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}
|
||||
# deep_copy(..)
|
||||
snippet deec
|
||||
Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}
|
||||
snippet Pn-
|
||||
PStore.new(${1:"file_name.pstore"})${2}
|
||||
snippet tra
|
||||
transaction(${1:true}) { ${2} }
|
||||
# xmlread(..)
|
||||
snippet xml-
|
||||
REXML::Document.new(File.read(${1:"path/to/file"}))${2}
|
||||
# xpath(..) { .. }
|
||||
snippet xpa
|
||||
elements.each(${1:"//Xpath"}) do |${2:node}|
|
||||
${3}
|
||||
end
|
||||
# class_from_name()
|
||||
snippet clafn
|
||||
split("::").inject(Object) { |par, const| par.const_get(const) }
|
||||
# singleton_class()
|
||||
snippet sinc
|
||||
class << self; self end
|
||||
snippet nam
|
||||
namespace :${1:`Filename()`} do
|
||||
${2}
|
||||
end
|
||||
snippet tas
|
||||
desc "${1:Task description\}"
|
||||
task :${2:task_name => [:dependent, :tasks]} do
|
||||
${3}
|
||||
end
|
||||
28
vim/bundle/snipmate.vim/snippets/sh.snippets
Normal file
28
vim/bundle/snipmate.vim/snippets/sh.snippets
Normal file
@@ -0,0 +1,28 @@
|
||||
# #!/bin/bash
|
||||
snippet #!
|
||||
#!/bin/bash
|
||||
|
||||
snippet if
|
||||
if [[ ${1:condition} ]]; then
|
||||
${2:#statements}
|
||||
fi
|
||||
snippet elif
|
||||
elif [[ ${1:condition} ]]; then
|
||||
${2:#statements}
|
||||
snippet for
|
||||
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||
${3:#statements}
|
||||
done
|
||||
snippet wh
|
||||
while [[ ${1:condition} ]]; do
|
||||
${2:#statements}
|
||||
done
|
||||
snippet until
|
||||
until [[ ${1:condition} ]]; do
|
||||
${2:#statements}
|
||||
done
|
||||
snippet case
|
||||
case ${1:word} in
|
||||
${2:pattern})
|
||||
${3};;
|
||||
esac
|
||||
7
vim/bundle/snipmate.vim/snippets/snippet.snippets
Normal file
7
vim/bundle/snipmate.vim/snippets/snippet.snippets
Normal file
@@ -0,0 +1,7 @@
|
||||
# snippets for making snippets :)
|
||||
snippet snip
|
||||
snippet ${1:trigger}
|
||||
${2}
|
||||
snippet msnip
|
||||
snippet ${1:trigger} ${2:description}
|
||||
${3}
|
||||
92
vim/bundle/snipmate.vim/snippets/tcl.snippets
Normal file
92
vim/bundle/snipmate.vim/snippets/tcl.snippets
Normal file
@@ -0,0 +1,92 @@
|
||||
# #!/usr/bin/env tclsh
|
||||
snippet #!
|
||||
#!/usr/bin/env tclsh
|
||||
|
||||
# Process
|
||||
snippet pro
|
||||
proc ${1:function_name} {${2:args}} {
|
||||
${3:#body ...}
|
||||
}
|
||||
#xif
|
||||
snippet xif
|
||||
${1:expr}? ${2:true} : ${3:false}
|
||||
# Conditional
|
||||
snippet if
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
}
|
||||
# Conditional if..else
|
||||
snippet ife
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
} else {
|
||||
${3:# else...}
|
||||
}
|
||||
# Conditional if..elsif..else
|
||||
snippet ifee
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
} elseif {${3}} {
|
||||
${4:# elsif...}
|
||||
} else {
|
||||
${5:# else...}
|
||||
}
|
||||
# If catch then
|
||||
snippet ifc
|
||||
if { [catch {${1:#do something...}} ${2:err}] } {
|
||||
${3:# handle failure...}
|
||||
}
|
||||
# Catch
|
||||
snippet catch
|
||||
catch {${1}} ${2:err} ${3:options}
|
||||
# While Loop
|
||||
snippet wh
|
||||
while {${1}} {
|
||||
${2:# body...}
|
||||
}
|
||||
# For Loop
|
||||
snippet for
|
||||
for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
|
||||
${4:# body...}
|
||||
}
|
||||
# Foreach Loop
|
||||
snippet fore
|
||||
foreach ${1:x} {${2:#list}} {
|
||||
${3:# body...}
|
||||
}
|
||||
# after ms script...
|
||||
snippet af
|
||||
after ${1:ms} ${2:#do something}
|
||||
# after cancel id
|
||||
snippet afc
|
||||
after cancel ${1:id or script}
|
||||
# after idle
|
||||
snippet afi
|
||||
after idle ${1:script}
|
||||
# after info id
|
||||
snippet afin
|
||||
after info ${1:id}
|
||||
# Expr
|
||||
snippet exp
|
||||
expr {${1:#expression here}}
|
||||
# Switch
|
||||
snippet sw
|
||||
switch ${1:var} {
|
||||
${3:pattern 1} {
|
||||
${4:#do something}
|
||||
}
|
||||
default {
|
||||
${2:#do something}
|
||||
}
|
||||
}
|
||||
# Case
|
||||
snippet ca
|
||||
${1:pattern} {
|
||||
${2:#do something}
|
||||
}${3}
|
||||
# Namespace eval
|
||||
snippet ns
|
||||
namespace eval ${1:path} {${2:#script...}}
|
||||
# Namespace current
|
||||
snippet nsc
|
||||
namespace current
|
||||
115
vim/bundle/snipmate.vim/snippets/tex.snippets
Normal file
115
vim/bundle/snipmate.vim/snippets/tex.snippets
Normal file
@@ -0,0 +1,115 @@
|
||||
# \begin{}...\end{}
|
||||
snippet begin
|
||||
\begin{${1:env}}
|
||||
${2}
|
||||
\end{$1}
|
||||
# Tabular
|
||||
snippet tab
|
||||
\begin{${1:tabular}}{${2:c}}
|
||||
${3}
|
||||
\end{$1}
|
||||
# Align(ed)
|
||||
snippet ali
|
||||
\begin{align${1:ed}}
|
||||
${2}
|
||||
\end{align$1}
|
||||
# Gather(ed)
|
||||
snippet gat
|
||||
\begin{gather${1:ed}}
|
||||
${2}
|
||||
\end{gather$1}
|
||||
# Equation
|
||||
snippet eq
|
||||
\begin{equation}
|
||||
${1}
|
||||
\end{equation}
|
||||
# Unnumbered Equation
|
||||
snippet \
|
||||
\\[
|
||||
${1}
|
||||
\\]
|
||||
# Enumerate
|
||||
snippet enum
|
||||
\begin{enumerate}
|
||||
\item ${1}
|
||||
\end{enumerate}
|
||||
# Itemize
|
||||
snippet item
|
||||
\begin{itemize}
|
||||
\item ${1}
|
||||
\end{itemize}
|
||||
# Description
|
||||
snippet desc
|
||||
\begin{description}
|
||||
\item[${1}] ${2}
|
||||
\end{description}
|
||||
# Matrix
|
||||
snippet mat
|
||||
\begin{${1:p/b/v/V/B/small}matrix}
|
||||
${2}
|
||||
\end{$1matrix}
|
||||
# Cases
|
||||
snippet cas
|
||||
\begin{cases}
|
||||
${1:equation}, &\text{ if }${2:case}\\
|
||||
${3}
|
||||
\end{cases}
|
||||
# Split
|
||||
snippet spl
|
||||
\begin{split}
|
||||
${1}
|
||||
\end{split}
|
||||
# Part
|
||||
snippet part
|
||||
\part{${1:part name}} % (fold)
|
||||
\label{prt:${2:$1}}
|
||||
${3}
|
||||
% part $2 (end)
|
||||
# Chapter
|
||||
snippet cha
|
||||
\chapter{${1:chapter name}} % (fold)
|
||||
\label{cha:${2:$1}}
|
||||
${3}
|
||||
% chapter $2 (end)
|
||||
# Section
|
||||
snippet sec
|
||||
\section{${1:section name}} % (fold)
|
||||
\label{sec:${2:$1}}
|
||||
${3}
|
||||
% section $2 (end)
|
||||
# Sub Section
|
||||
snippet sub
|
||||
\subsection{${1:subsection name}} % (fold)
|
||||
\label{sub:${2:$1}}
|
||||
${3}
|
||||
% subsection $2 (end)
|
||||
# Sub Sub Section
|
||||
snippet subs
|
||||
\subsubsection{${1:subsubsection name}} % (fold)
|
||||
\label{ssub:${2:$1}}
|
||||
${3}
|
||||
% subsubsection $2 (end)
|
||||
# Paragraph
|
||||
snippet par
|
||||
\paragraph{${1:paragraph name}} % (fold)
|
||||
\label{par:${2:$1}}
|
||||
${3}
|
||||
% paragraph $2 (end)
|
||||
# Sub Paragraph
|
||||
snippet subp
|
||||
\subparagraph{${1:subparagraph name}} % (fold)
|
||||
\label{subp:${2:$1}}
|
||||
${3}
|
||||
% subparagraph $2 (end)
|
||||
snippet itd
|
||||
\item[${1:description}] ${2:item}
|
||||
snippet figure
|
||||
${1:Figure}~\ref{${2:fig:}}${3}
|
||||
snippet table
|
||||
${1:Table}~\ref{${2:tab:}}${3}
|
||||
snippet listing
|
||||
${1:Listing}~\ref{${2:list}}${3}
|
||||
snippet section
|
||||
${1:Section}~\ref{${2:sec:}}${3}
|
||||
snippet page
|
||||
${1:page}~\pageref{${2}}${3}
|
||||
32
vim/bundle/snipmate.vim/snippets/vim.snippets
Normal file
32
vim/bundle/snipmate.vim/snippets/vim.snippets
Normal file
@@ -0,0 +1,32 @@
|
||||
snippet header
|
||||
" File: ${1:`expand('%:t')`}
|
||||
" Author: ${2:`g:snips_author`}
|
||||
" Description: ${3}
|
||||
${4:" Last Modified: `strftime("%B %d, %Y")`}
|
||||
snippet guard
|
||||
if exists('${1:did_`Filename()`}') || &cp${2: || version < 700}
|
||||
finish
|
||||
endif
|
||||
let $1 = 1${3}
|
||||
snippet f
|
||||
fun ${1:function_name}(${2})
|
||||
${3:" code}
|
||||
endf
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}
|
||||
${3:" code}
|
||||
endfor
|
||||
snippet wh
|
||||
while ${1:condition}
|
||||
${2:" code}
|
||||
endw
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2:" code}
|
||||
endif
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
endif
|
||||
58
vim/bundle/snipmate.vim/snippets/zsh.snippets
Normal file
58
vim/bundle/snipmate.vim/snippets/zsh.snippets
Normal file
@@ -0,0 +1,58 @@
|
||||
# #!/bin/zsh
|
||||
snippet #!
|
||||
#!/bin/zsh
|
||||
|
||||
snippet if
|
||||
if ${1:condition}; then
|
||||
${2:# statements}
|
||||
fi
|
||||
snippet ife
|
||||
if ${1:condition}; then
|
||||
${2:# statements}
|
||||
else
|
||||
${3:# statements}
|
||||
fi
|
||||
snippet elif
|
||||
elif ${1:condition} ; then
|
||||
${2:# statements}
|
||||
snippet for
|
||||
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||
${3:# statements}
|
||||
done
|
||||
snippet fore
|
||||
for ${1:item} in ${2:list}; do
|
||||
${3:# statements}
|
||||
done
|
||||
snippet wh
|
||||
while ${1:condition}; do
|
||||
${2:# statements}
|
||||
done
|
||||
snippet until
|
||||
until ${1:condition}; do
|
||||
${2:# statements}
|
||||
done
|
||||
snippet repeat
|
||||
repeat ${1:integer}; do
|
||||
${2:# statements}
|
||||
done
|
||||
snippet case
|
||||
case ${1:word} in
|
||||
${2:pattern})
|
||||
${3};;
|
||||
esac
|
||||
snippet select
|
||||
select ${1:answer} in ${2:choices}; do
|
||||
${3:# statements}
|
||||
done
|
||||
snippet (
|
||||
( ${1:#statements} )
|
||||
snippet {
|
||||
{ ${1:#statements} }
|
||||
snippet [
|
||||
[[ ${1:test} ]]
|
||||
snippet always
|
||||
{ ${1:try} } always { ${2:always} }
|
||||
snippet fun
|
||||
function ${1:name} (${2:args}) {
|
||||
${3:# body}
|
||||
}
|
||||
19
vim/bundle/snipmate.vim/syntax/snippet.vim
Normal file
19
vim/bundle/snipmate.vim/syntax/snippet.vim
Normal file
@@ -0,0 +1,19 @@
|
||||
" Syntax highlighting for snippet files (used for snipMate.vim)
|
||||
" Hopefully this should make snippets a bit nicer to write!
|
||||
syn match snipComment '^#.*'
|
||||
syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
|
||||
syn match tabStop '\$\d\+'
|
||||
syn match snipCommand '[^\\]`.\{-}`'
|
||||
syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword
|
||||
syn match multiSnipText '\S\+ \zs.*' contained
|
||||
syn match snipKeyword '^snippet'me=s+8 contained
|
||||
syn match snipError "^[^#s\t].*$"
|
||||
|
||||
hi link snipComment Comment
|
||||
hi link multiSnipText String
|
||||
hi link snipKeyword Keyword
|
||||
hi link snipComment Comment
|
||||
hi link placeHolder Special
|
||||
hi link tabStop Special
|
||||
hi link snipCommand String
|
||||
hi link snipError Error
|
||||
142
vim/bundle/syntastic/README.markdown
Normal file
142
vim/bundle/syntastic/README.markdown
Normal file
@@ -0,0 +1,142 @@
|
||||
,
|
||||
/ \,,_ .'|
|
||||
,{{| /}}}}/_.' _____________________________________________
|
||||
}}}}` '{{' '. / \
|
||||
{{{{{ _ ;, \ / Gentlemen, \
|
||||
,}}}}}} /o`\ ` ;) | |
|
||||
{{{{{{ / ( | this is ... |
|
||||
}}}}}} | \ | |
|
||||
{{{{{{{{ \ \ | |
|
||||
}}}}}}}}} '.__ _ | | _____ __ __ _ |
|
||||
{{{{{{{{ /`._ (_\ / | / ___/__ ______ / /_____ ______/ /_(_)____ |
|
||||
}}}}}}' | //___/ --=: \__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ |
|
||||
jgs `{{{{` | '--' | ___/ / /_/ / / / / /_/ /_/ (__ ) /_/ / /__ |
|
||||
}}}` | /____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/ |
|
||||
| /____/ |
|
||||
| /
|
||||
\_____________________________________________/
|
||||
|
||||
|
||||
|
||||
|
||||
Syntastic is a syntax checking plugin that runs files through external syntax
|
||||
checkers and displays any resulting errors to the user. This can be done on
|
||||
demand, or automatically as files are saved. If syntax errors are detected, the
|
||||
user is notified and is happy because they didn't have to compile their code or
|
||||
execute their script to find them.
|
||||
|
||||
At the time of this writing, syntax checking plugins exist for applescript, c,
|
||||
coffee, cpp, css, cucumber, cuda, docbk, erlang, eruby, fortran,
|
||||
gentoo_metadata, go, haml, haskell, html, javascript, json, less, lua, matlab,
|
||||
perl, php, puppet, python, rst, ruby, sass/scss, sh, tcl, tex, vala, xhtml,
|
||||
xml, xslt, yaml, zpt
|
||||
|
||||
Screenshot
|
||||
----------
|
||||
|
||||
Below is a screenshot showing the methods that Syntastic uses to display syntax
|
||||
errors. Note that, in practise, you will only have a subset of these methods
|
||||
enabled.
|
||||
|
||||

|
||||
|
||||
1. Errors are loaded into the location list for the corresponding window.
|
||||
2. When the cursor is on a line containing an error, the error message is echoed in the command window.
|
||||
3. Signs are placed beside lines with errors - note that warnings are displayed in a different color.
|
||||
4. There is a configurable statusline flag you can include in your statusline config.
|
||||
5. Hover the mouse over a line containing an error and the error message is displayed as a balloon.
|
||||
6. (not shown) Highlighting errors with syntax highlighting. Erroneous parts of lines can be highlighted.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install syntastic.
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/scrooloose/syntastic.git
|
||||
|
||||
Then reload vim, run `:helptags`, and check out `:help syntastic.txt`.
|
||||
|
||||
|
||||
Google group
|
||||
------------
|
||||
|
||||
To get information or make suggestions check out the [google group](https://groups.google.com/group/vim-syntastic).
|
||||
|
||||
|
||||
Changelog
|
||||
---------
|
||||
|
||||
2.2.0 (24-dec-2011)
|
||||
|
||||
* only do syntax checks when files are saved (not when first opened) - add g:syntastic_check_on_open option to get the old behavior back
|
||||
* bug fix with echoing error messages; fixes incompatability with cmd-t (datanoise)
|
||||
* dont allow warnings to mask errors when signing/echoing errors (ashikase)
|
||||
* auto close location list when leaving buffer. (millermedeiros)
|
||||
* update errors appropriately when :SyntasticToggleMode is called
|
||||
* updates/fixes to existing checkers:
|
||||
* javascript/jshint (millermedeiros)
|
||||
* javascript/jslint
|
||||
* c (kongo2002)
|
||||
* Support for new filetypes:
|
||||
* JSON (millermedeiros, tocer)
|
||||
* rst (reStructuredText files) (JNRowe)
|
||||
* gentoo-metadata (JNRowe)
|
||||
|
||||
2.1.0 (14-dec-2011)
|
||||
|
||||
* when the cursor is on a line containing an error, echo the
|
||||
* error msg (kevinw)
|
||||
* various bug fixes and refactoring
|
||||
* updates/fixes to existing checkers:
|
||||
* html (millermedeiros)
|
||||
* erlang
|
||||
* coffeescript
|
||||
* javascript
|
||||
* sh
|
||||
* php (add support for phpcs - technosophos)
|
||||
* add an applescript checker (Zhai Cai)
|
||||
* add support for hyphenated filetypes (JNRowe)
|
||||
|
||||
2.0.0 (2-dec-2011):
|
||||
|
||||
* Add support for highlighting the erroneous parts of lines (kstep)
|
||||
* Add support for displaying errors via balloons (kstep)
|
||||
* Add syntastic_mode_map option to give more control over when checking should be done.
|
||||
* Add :SyntasticCheck command to force a syntax check - useful in passive mode (justone).
|
||||
* Add the option to automatically close the location list, but not automatically open it (milkypostman)
|
||||
* Add syntastic_auto_jump option to automatically jump to the first error (milkypostman)
|
||||
* Only source syntax checkers as needed - instead of loading all of them when vim starts
|
||||
|
||||
* Support for new filetypes:
|
||||
* less (julienXX)
|
||||
* docbook (tpope)
|
||||
* matlab (jasongraham)
|
||||
* go (dtjm)
|
||||
* puppet (uggedal, roman, zsprackett)
|
||||
* haskell (baldo, roman)
|
||||
* tcl (et)
|
||||
* vala (kstep)
|
||||
* cuda (temporaer)
|
||||
* css (oryband, sitedyno)
|
||||
* fortran (Karl Yngve Lervåg)
|
||||
* xml (kusnier)
|
||||
* xslt (kusnier)
|
||||
* erlang (kTT)
|
||||
* zpt (claytron)
|
||||
|
||||
* updates to existing checkers:
|
||||
* javascript (mogren, bryanforbes, cjab, ajduncan)
|
||||
* sass/scss (tmm1, atourino, dlee, epeli)
|
||||
* ruby (changa)
|
||||
* perl (harleypig)
|
||||
* haml (bmihelac)
|
||||
* php (kstep, docteurklein)
|
||||
* python (kstep, soli)
|
||||
* lua (kstep)
|
||||
* html (kstep)
|
||||
* xhtml (kstep)
|
||||
* c (kongo2002, brandonw)
|
||||
* cpp (kongo2002)
|
||||
* coffee (industrial)
|
||||
* eruby (sergevm)
|
||||
BIN
vim/bundle/syntastic/_assets/screenshot_1.png
Normal file
BIN
vim/bundle/syntastic/_assets/screenshot_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
171
vim/bundle/syntastic/autoload/syntastic/c.vim
Normal file
171
vim/bundle/syntastic/autoload/syntastic/c.vim
Normal file
@@ -0,0 +1,171 @@
|
||||
if exists("g:loaded_syntastic_c_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" initialize c/cpp syntax checker handlers
|
||||
function! s:Init()
|
||||
let s:handlers = []
|
||||
let s:cflags = {}
|
||||
|
||||
call s:RegHandler('gtk', 'syntastic#c#CheckPKG',
|
||||
\ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
|
||||
call s:RegHandler('glib', 'syntastic#c#CheckPKG',
|
||||
\ ['glib', 'glib-2.0', 'glib'])
|
||||
call s:RegHandler('glade', 'syntastic#c#CheckPKG',
|
||||
\ ['glade', 'libglade-2.0', 'libglade'])
|
||||
call s:RegHandler('libsoup', 'syntastic#c#CheckPKG',
|
||||
\ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
|
||||
call s:RegHandler('webkit', 'syntastic#c#CheckPKG',
|
||||
\ ['webkit', 'webkit-1.0'])
|
||||
call s:RegHandler('cairo', 'syntastic#c#CheckPKG',
|
||||
\ ['cairo', 'cairo'])
|
||||
call s:RegHandler('pango', 'syntastic#c#CheckPKG',
|
||||
\ ['pango', 'pango'])
|
||||
call s:RegHandler('libxml', 'syntastic#c#CheckPKG',
|
||||
\ ['libxml', 'libxml-2.0', 'libxml'])
|
||||
call s:RegHandler('freetype', 'syntastic#c#CheckPKG',
|
||||
\ ['freetype', 'freetype2', 'freetype'])
|
||||
call s:RegHandler('SDL', 'syntastic#c#CheckPKG',
|
||||
\ ['sdl', 'sdl'])
|
||||
call s:RegHandler('opengl', 'syntastic#c#CheckPKG',
|
||||
\ ['opengl', 'gl'])
|
||||
call s:RegHandler('ruby', 'syntastic#c#CheckRuby', [])
|
||||
call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', [])
|
||||
call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
|
||||
endfunction
|
||||
|
||||
" search the first 100 lines for include statements that are
|
||||
" given in the handlers dictionary
|
||||
function! syntastic#c#SearchHeaders()
|
||||
let includes = ''
|
||||
let files = []
|
||||
let found = []
|
||||
let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
|
||||
|
||||
" search current buffer
|
||||
for line in lines
|
||||
let file = matchstr(line, '"\zs\S\+\ze"')
|
||||
if file != ''
|
||||
call add(files, file)
|
||||
continue
|
||||
endif
|
||||
for handler in s:handlers
|
||||
if line =~# handler["regex"]
|
||||
let includes .= call(handler["func"], handler["args"])
|
||||
call add(found, handler["regex"])
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
" search included headers
|
||||
for hfile in files
|
||||
if hfile != ''
|
||||
let filename = expand('%:p:h') . ((has('win32') || has('win64')) ?
|
||||
\ '\' : '/') . hfile
|
||||
try
|
||||
let lines = readfile(filename, '', 100)
|
||||
catch /E484/
|
||||
continue
|
||||
endtry
|
||||
let lines = filter(lines, 'v:val =~# "#\s*include"')
|
||||
for handler in s:handlers
|
||||
if index(found, handler["regex"]) != -1
|
||||
continue
|
||||
endif
|
||||
for line in lines
|
||||
if line =~# handler["regex"]
|
||||
let includes .= call(handler["func"], handler["args"])
|
||||
call add(found, handler["regex"])
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
return includes
|
||||
endfunction
|
||||
|
||||
" try to find library with 'pkg-config'
|
||||
" search possible libraries from first to last given
|
||||
" argument until one is found
|
||||
function! syntastic#c#CheckPKG(name, ...)
|
||||
if executable('pkg-config')
|
||||
if !has_key(s:cflags, a:name)
|
||||
for i in range(a:0)
|
||||
let l:cflags = system('pkg-config --cflags '.a:000[i])
|
||||
" since we cannot necessarily trust the pkg-config exit code
|
||||
" we have to check for an error output as well
|
||||
if v:shell_error == 0 && l:cflags !~? 'not found'
|
||||
let l:cflags = ' '.substitute(l:cflags, "\n", '', '')
|
||||
let s:cflags[a:name] = l:cflags
|
||||
return l:cflags
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
return s:cflags[a:name]
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" try to find PHP includes with 'php-config'
|
||||
function! syntastic#c#CheckPhp()
|
||||
if executable('php-config')
|
||||
if !exists('s:php_flags')
|
||||
let s:php_flags = system('php-config --includes')
|
||||
let s:php_flags = ' ' . substitute(s:php_flags, "\n", '', '')
|
||||
endif
|
||||
return s:php_flags
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" try to find the ruby headers with 'rbconfig'
|
||||
function! syntastic#c#CheckRuby()
|
||||
if executable('ruby')
|
||||
if !exists('s:ruby_flags')
|
||||
let s:ruby_flags = system('ruby -r rbconfig -e '
|
||||
\ . '''puts Config::CONFIG["archdir"]''')
|
||||
let s:ruby_flags = substitute(s:ruby_flags, "\n", '', '')
|
||||
let s:ruby_flags = ' -I' . s:ruby_flags
|
||||
endif
|
||||
return s:ruby_flags
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" try to find the python headers with distutils
|
||||
function! syntastic#c#CheckPython()
|
||||
if executable('python')
|
||||
if !exists('s:python_flags')
|
||||
let s:python_flags = system('python -c ''from distutils import '
|
||||
\ . 'sysconfig; print sysconfig.get_python_inc()''')
|
||||
let s:python_flags = substitute(s:python_flags, "\n", '', '')
|
||||
let s:python_flags = ' -I' . s:python_flags
|
||||
endif
|
||||
return s:python_flags
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" return a handler dictionary object
|
||||
function! s:RegHandler(regex, function, args)
|
||||
let handler = {}
|
||||
let handler["regex"] = a:regex
|
||||
let handler["func"] = function(a:function)
|
||||
let handler["args"] = a:args
|
||||
call add(s:handlers, handler)
|
||||
endfunction
|
||||
|
||||
call s:Init()
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
527
vim/bundle/syntastic/doc/syntastic.txt
Normal file
527
vim/bundle/syntastic/doc/syntastic.txt
Normal file
@@ -0,0 +1,527 @@
|
||||
*syntastic.txt* Syntax checking on the fly has never been so pimp.
|
||||
*syntastic*
|
||||
|
||||
|
||||
It's a bird! It's a plane! ZOMG It's ... ~
|
||||
|
||||
_____ __ __ _ ~
|
||||
/ ___/__ ______ / /_____ ______/ /_(_)____ ~
|
||||
\__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ ~
|
||||
___/ / /_/ / / / / /_/ /_/ (__ ) /_/ / /__ ~
|
||||
/____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/ ~
|
||||
/____/ ~
|
||||
|
||||
|
||||
|
||||
Reference Manual~
|
||||
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *syntastic-contents*
|
||||
|
||||
1.Intro...................................|syntastic-intro|
|
||||
2.Functionality provided..................|syntastic-functionality|
|
||||
2.1.The statusline flag...............|syntastic-statusline-flag|
|
||||
2.2.Error signs.......................|syntastic-error-signs|
|
||||
2.3.Error window......................|syntastic-error-window|
|
||||
3.Commands................................|syntastic-commands|
|
||||
4.Options.................................|syntastic-options|
|
||||
5.Writing syntax checkers.................|syntastic-syntax-checkers|
|
||||
6.About...................................|syntastic-about|
|
||||
7.Changelog...............................|syntastic-changelog|
|
||||
8.Credits.................................|syntastic-credits|
|
||||
9.License.................................|syntastic-license|
|
||||
|
||||
|
||||
==============================================================================
|
||||
1. Intro *syntastic-intro*
|
||||
|
||||
Syntastic is a syntax checking plugin that runs files through external syntax
|
||||
checkers. This can be done on demand, or automatically as files are saved and
|
||||
opened. If syntax errors are detected, the user is notified and is happy
|
||||
because they didn't have to compile their code or execute their script to find
|
||||
them.
|
||||
|
||||
Syntastic comes in two parts: the syntax checker plugins, and the core script
|
||||
(i.e. syntastic.vim). The syntax checker plugins are defined on a per-filetype
|
||||
basis where each one wraps up an external syntax checking program. The core
|
||||
script delegates off to these plugins and uses their output to provide the
|
||||
syntastic functionality. At the time of this writing, syntax checking plugins
|
||||
exist for c, coffee, cpp, css, cucumber, cuda, docbk, erlang, eruby, fortran,
|
||||
go, haml, haskell, html, javascript, less, lua, matlab, perl, php, puppet,
|
||||
python, ruby, sass/scss, sh, tcl, tex, vala, xhtml, xml, xslt, zpt
|
||||
|
||||
Take a look in the syntax_checkers directory for the most up to date list.
|
||||
|
||||
If your language is not supported then see |syntastic-syntax-checkers| for
|
||||
details on how to implement a syntax checking plugin, and be sure to send me a
|
||||
patch ;-)
|
||||
|
||||
This plugin is currently only recommended for *nix users. It is functional on
|
||||
Windows, but since the syntax checking plugins shell out, the command window
|
||||
briefly appears whenever one is executed.
|
||||
|
||||
|
||||
==============================================================================
|
||||
2. Functionality provided *syntastic-functionality*
|
||||
|
||||
Syntax checking can be done automatically or on demand (see
|
||||
|'syntastic_mode_map'| for configuring this).
|
||||
|
||||
When syntax checking is done, the features below can be used to notify the
|
||||
user of errors. See |syntastic-options| for how to configure and
|
||||
activate/deactivate these features.
|
||||
|
||||
* A configurable statusline flag
|
||||
* Lines with errors can have |signs| placed beside them - where a different
|
||||
sign is used for errors and warnings.
|
||||
* A |location-list| can be displayed with error messages for erroneous
|
||||
buffers.
|
||||
* Offending parts of lines can be highlighted (this functionality is only
|
||||
provided by some syntax checkers).
|
||||
* Balloons (if compiled in) can be used to display error messages for
|
||||
erroneous lines when hovering the mouse over them.
|
||||
|
||||
|
||||
Note: This functionality is only available if a syntax checker plugin is
|
||||
present for the filetype of the buffer in question. See
|
||||
|syntastic-syntax-checkers| for details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1. The statusline flag *syntastic-statusline-flag*
|
||||
|
||||
To use the statusline flag, this must appear in your |'statusline'| setting >
|
||||
%{SyntasticStatuslineFlag()}
|
||||
<
|
||||
Something like this could be more useful: >
|
||||
set statusline+=%#warningmsg#
|
||||
set statusline+=%{SyntasticStatuslineFlag()}
|
||||
set statusline+=%*
|
||||
<
|
||||
When syntax errors are detected a flag will be shown. The content of the flag
|
||||
is derived from the |syntastic_stl_format| option
|
||||
------------------------------------------------------------------------------
|
||||
2.2. Error signs *syntastic-error-signs*
|
||||
|
||||
Syntastic uses the |:sign| commands to mark lines with errors and warnings in
|
||||
the sign column. To enable this feature, use the |'syntastic_enable_signs'|
|
||||
option.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3. The error window *:Errors* *syntastic-error-window*
|
||||
|
||||
You can use the :Errors command to display the errors for the current buffer
|
||||
in the |location-list|.
|
||||
|
||||
Note that when you use :Errors, the current location list is overwritten with
|
||||
Syntastic's own location list.
|
||||
|
||||
|
||||
==============================================================================
|
||||
3. Commands *syntastic-commands*
|
||||
|
||||
:Errors *:SyntasticErrors*
|
||||
|
||||
When errors have been detected, use this command to pop up the |location-list|
|
||||
and display the error messages.
|
||||
|
||||
|
||||
:SyntasticToggleMode *:SyntasticToggleMode*
|
||||
|
||||
Toggles syntastic between active and passive mode. See |'syntastic_mode_map'|
|
||||
for more info.
|
||||
|
||||
|
||||
:SyntasticCheck *:SyntasticCheck*
|
||||
|
||||
Manually cause a syntax check to be done. Useful in passive mode, or if the
|
||||
current filetype is set to passive. See |'syntastic_mode_map'| for more info.
|
||||
|
||||
|
||||
==============================================================================
|
||||
4. Options *syntastic-options*
|
||||
|
||||
|
||||
*'syntastic_check_on_open'*
|
||||
Default: 0
|
||||
If enabled, syntastic will do syntax checks when buffers are first loaded as
|
||||
well as on saving >
|
||||
let g:syntastic_check_on_open=1
|
||||
<
|
||||
|
||||
*'syntastic_echo_current_error'*
|
||||
Default: 1
|
||||
If enabled, syntastic will error message associated with the current line to
|
||||
the command window. If multiple errors are found, the first will be used. >
|
||||
let g:syntastic_echo_current_error=1
|
||||
<
|
||||
|
||||
*'syntastic_enable_signs'*
|
||||
Default: 1
|
||||
Use this option to tell syntastic whether to use the |:sign| interface to mark
|
||||
syntax errors: >
|
||||
let g:syntastic_enable_signs=1
|
||||
<
|
||||
|
||||
*'syntastic_enable_balloons'*
|
||||
Default: 1
|
||||
Use this option to tell syntastic whether to display error messages in balloons
|
||||
when the mouse is hovered over erroneous lines: >
|
||||
let g:syntastic_enable_balloons = 1
|
||||
<
|
||||
Note that vim must be compiled with |+balloon_eval|.
|
||||
|
||||
*'syntastic_enable_highlighting'*
|
||||
Default: 1
|
||||
Use this option to tell syntastic whether to use syntax highlighting to mark
|
||||
errors (where possible). Highlighting can be turned off with the following >
|
||||
let g:syntastic_enable_highlighting = 0
|
||||
<
|
||||
|
||||
*'syntastic_auto_jump'*
|
||||
Default: 0
|
||||
Enable this option if you want the cursor to jump to the first detected error
|
||||
when saving or opening a file: >
|
||||
let g:syntastic_auto_jump=1
|
||||
<
|
||||
|
||||
*'syntastic_auto_loc_list'*
|
||||
Default: 2
|
||||
Use this option to tell syntastic to automatically open and/or close the
|
||||
|location-list| (see |syntastic-error-window|).
|
||||
|
||||
When set to 0 the error window will not be opened or closed automatically. >
|
||||
let g:syntastic_auto_loc_list=0
|
||||
<
|
||||
|
||||
When set to 1 the error window will be automatically opened when errors are
|
||||
detected, and closed when none are detected. >
|
||||
let g:syntastic_auto_loc_list=1
|
||||
<
|
||||
When set to 2 the error window will be automatically closed when no errors are
|
||||
detected, but not opened automatically. >
|
||||
let g:syntastic_auto_loc_list=2
|
||||
<
|
||||
|
||||
*'syntastic_mode_map'*
|
||||
Default: { "mode": "active",
|
||||
"active_filetypes": [],
|
||||
"passive_filetypes": [] }
|
||||
|
||||
Use this option to fine tune when automatic syntax checking is done (or not
|
||||
done).
|
||||
|
||||
The option should be set to something like: >
|
||||
|
||||
let g:syntastic_mode_map = { 'mode': 'active',
|
||||
\ 'active_filetypes': ['ruby', 'php'],
|
||||
\ 'passive_filetypes': ['puppet'] }
|
||||
<
|
||||
|
||||
"mode" can be mapped to one of two values - "active" or "passive". When set to
|
||||
active, syntastic does automatic checking whenever a buffer is saved or
|
||||
initially opened. When set to "passive" syntastic only checks when the user
|
||||
calls :SyntasticCheck.
|
||||
|
||||
The exceptions to these rules are defined with "active_filetypes" and
|
||||
"passive_filetypes". In passive mode, automatic checks are still done
|
||||
for all filetypes in the "active_filetypes" array. In active mode,
|
||||
automatic checks are not done for any filetypes in the
|
||||
"passive_filetypes" array.
|
||||
|
||||
At runtime, the |:SyntasticToggleMode| command can be used to switch between
|
||||
active and passive mode.
|
||||
|
||||
If any of "mode", "active_filetypes", or "passive_filetypes" are not specified
|
||||
then they will default to their default value as above.
|
||||
|
||||
*'syntastic_quiet_warnings'*
|
||||
|
||||
Use this option if you only care about syntax errors, not warnings. When set,
|
||||
this option has the following effects:
|
||||
* no |signs| appear unless there is at least one error, whereupon both
|
||||
errors and warnings are displayed
|
||||
* the |'syntastic_auto_loc_list'| option only pops up the error window if
|
||||
there's at least one error, whereupon both errors and warnings are
|
||||
displayed
|
||||
>
|
||||
let g:syntastic_quiet_warnings=1
|
||||
<
|
||||
|
||||
*'syntastic_stl_format'*
|
||||
|
||||
Default: [Syntax: line:%F (%t)]
|
||||
Use this option to control what the syntastic statusline text contains. Several
|
||||
magic flags are availble to insert information:
|
||||
%e - number of errors
|
||||
%w - number of warnings
|
||||
%t - total number of warnings and errors
|
||||
%fe - line number of first error
|
||||
%fw - line number of first warning
|
||||
%F - line number of first warning or error
|
||||
|
||||
Several additional flags are available to hide text under certain conditions:
|
||||
%E{...} - hide the text in the brackets unless there are errors
|
||||
%W{...} - hide the text in the brackets unless there are warnings
|
||||
%B{...} - hide the text in the brackets unless there are both warnings AND
|
||||
errors
|
||||
These flags cant be nested.
|
||||
|
||||
Example: >
|
||||
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
|
||||
<
|
||||
If this format is used and the current buffer has 5 errors and 1 warning
|
||||
starting on lines 20 and 10 respectively then this would appear on the
|
||||
statusline: >
|
||||
[Err: 20 #5, Warn: 10 #1]
|
||||
<
|
||||
If the buffer had 2 warnings, starting on line 5 then this would appear: >
|
||||
[Warn: 5 #2]
|
||||
<
|
||||
|
||||
|
||||
==============================================================================
|
||||
5. Writing syntax checkers *syntastic-syntax-checkers*
|
||||
|
||||
|
||||
A syntax checker plugin is really nothing more than a single function. You
|
||||
should define them in ~/.vim/syntax_checkers/<filetype>.vim, but this is
|
||||
purely for convenience; Syntastic doesn't actually care where these functions
|
||||
are defined.
|
||||
|
||||
A syntax checker plugin must define a function of the form:
|
||||
>
|
||||
SyntaxCheckers_<filetype>_GetLocList()
|
||||
<
|
||||
The output of this function must be of the same format as that returned by
|
||||
the |getloclist()| function. See |getloclist()| and |getqflist()| for
|
||||
details.
|
||||
|
||||
To achieve this, the function should call |SyntasticMake()| or shell out to a
|
||||
syntax checker, parse the output and munge it into the format.
|
||||
|
||||
There are several syntax checker plugins provided with this plugin. The ruby
|
||||
one is a good example of |SyntasticMake()|, while the haml one is a good
|
||||
example of how to create the data structure manually.
|
||||
|
||||
|
||||
SyntasticMake({options}) *SyntasticMake()*
|
||||
{options} must be a dictionary. It can contain "makeprg" and "errorformat"
|
||||
as keys (both optional).
|
||||
|
||||
SyntasticMake will run |:lmake| with the given |'makeprg'| and
|
||||
|'errorformat'| (using the current settings if none are supplied). It will
|
||||
store the resulting error list and use it to provide all of the
|
||||
|syntastic-functionality|. The previous makeprg and errorformat settings
|
||||
will then be restored, as well as the location list for the window. From
|
||||
the user's perspective, it will be as though |:lmake| was never run.
|
||||
|
||||
Note that the given "makeprg" and "errorformat" will be set using |:let-&|,
|
||||
so you should not escape spaces.
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. About *syntastic-about*
|
||||
|
||||
The author of syntastic is a mighty wild stallion, hear him roar! >
|
||||
_ _ _____ _____ ___ ___ ___ ____ _ _ _
|
||||
| \ | | ____| ____|_ _|_ _|_ _/ ___| | | | |
|
||||
| \| | _| | _| | | | | | | | _| |_| | |
|
||||
| |\ | |___| |___ | | | | | | |_| | _ |_|
|
||||
|_| \_|_____|_____|___|___|___\____|_| |_(_)
|
||||
|
||||
<
|
||||
He likes to trot around in the back yard reading his emails and sipping a
|
||||
scolding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com.
|
||||
He can also be found trolling the #vim channel on the freenode IRC network as
|
||||
scrooloose.
|
||||
|
||||
Bug reports, feedback, suggestions etc are welcomed.
|
||||
|
||||
|
||||
The latest official releases will be on vim.org at some point.
|
||||
|
||||
The latest dev versions are on github
|
||||
http://github.com/scrooloose/syntastic
|
||||
|
||||
==============================================================================
|
||||
7. Changelog *syntastic-changelog*
|
||||
|
||||
next
|
||||
- Support for new filetypes:
|
||||
- yaml
|
||||
|
||||
2.2.0
|
||||
- only do syntax checks when files are saved (not when first opened) - add
|
||||
g:syntastic_check_on_open option to get the old behavior back
|
||||
- bug fix with echoing error messages; fixes incompatability with cmd-t (datanoise)
|
||||
- dont allow warnings to mask errors when signing/echoing errors (ashikase)
|
||||
- auto close location list when leaving buffer. (millermedeiros)
|
||||
- update errors appropriately when :SyntasticToggleMode is called
|
||||
- updates/fixes to existing checkers:
|
||||
- javascript/jshint (millermedeiros)
|
||||
- javascript/jslint
|
||||
- c (kongo2002)
|
||||
- Support for new filetypes:
|
||||
- JSON (millermedeiros, tocer)
|
||||
- rst (reStructuredText files) (JNRowe)
|
||||
- gentoo-metadata (JNRowe)
|
||||
|
||||
|
||||
2.1.0
|
||||
- when the cursor is on a line containing an error, echo the
|
||||
error msg (kevinw)
|
||||
- various bug fixes and refactoring
|
||||
- updates/fixes to existing checkers:
|
||||
- html (millermedeiros)
|
||||
- erlang
|
||||
- coffeescript
|
||||
- javascript
|
||||
- sh
|
||||
- php (add support for phpcs - technosophos)
|
||||
- add an applescript checker (Zhai Cai)
|
||||
- add support for hyphenated filetypes (JNRowe)
|
||||
|
||||
2.0.0
|
||||
- Add support for highlighting the erroneous parts of lines (kstep)
|
||||
- Add support for displaying errors via balloons (kstep)
|
||||
- Add syntastic_mode_map option to give more control over when checking
|
||||
should be done.
|
||||
- Add :SyntasticCheck command to force a syntax check - useful in passive
|
||||
mode (justone).
|
||||
- Add the option to automatically close the location list, but not
|
||||
automatically open it (milkypostman)
|
||||
- Add syntastic_auto_jump option to automatically jump to the first
|
||||
error (milkypostman)
|
||||
- Only source syntax checkers as needed - instead of loading all of them
|
||||
when vim starts
|
||||
|
||||
- Support for new filetypes:
|
||||
- less (julienXX)
|
||||
- docbook (tpope)
|
||||
- matlab (jasongraham)
|
||||
- go (dtjm)
|
||||
- puppet (uggedal, roman, zsprackett)
|
||||
- haskell (baldo, roman)
|
||||
- tcl (et)
|
||||
- vala (kstep)
|
||||
- cuda (temporaer)
|
||||
- css (oryband, sitedyno)
|
||||
- fortran (Karl Yngve Lervåg)
|
||||
- xml (kusnier)
|
||||
- xslt (kusnier)
|
||||
- erlang (kTT)
|
||||
- zpt (claytron)
|
||||
|
||||
- updates to existing checkers:
|
||||
- javascript (mogren, bryanforbes, cjab, ajduncan)
|
||||
- sass/scss (tmm1, atourino, dlee, epeli)
|
||||
- ruby (changa)
|
||||
- perl (harleypig)
|
||||
- haml (bmihelac)
|
||||
- php (kstep, docteurklein)
|
||||
- python (kstep, soli)
|
||||
- lua (kstep)
|
||||
- html (kstep)
|
||||
- xhtml (kstep)
|
||||
- c (kongo2002, brandonw)
|
||||
- cpp (kongo2002)
|
||||
- coffee (industrial)
|
||||
- eruby (sergevm)
|
||||
|
||||
1.2.0
|
||||
- New syntax checkers from github:kongo2002
|
||||
- c (thanks also to github:jperras)
|
||||
- cpp
|
||||
- lua
|
||||
- sh (thanks also to github:jmcantrell)
|
||||
- add coffee syntax checked by github:lstoll
|
||||
- add tex syntax checker
|
||||
- make html checker play nicer with html5, thanks to github:enaeseth
|
||||
- escape filenames properly when invoking syntax checkers, thanks to
|
||||
github:jmcantrell
|
||||
- adjust the ruby syntax checker to avoid some common annoying warnings,
|
||||
thanks to github:robertwahler
|
||||
|
||||
1.1.0 [codenamed: tpimp]
|
||||
- Dont load rubygems for ruby/eruby syntax checkers. Thanks tpope.
|
||||
- Improve the javascript syntax checker to catch some warnings that were
|
||||
getting missed. Thanks tpope.
|
||||
- Dont automatically focus the error window. Thanks tpope.
|
||||
- Add support for cucumber [tpope], haskell & perl [Anthony Carapetis],
|
||||
and xhtml
|
||||
- Add commands to enable/disable syntax checking at runtime. See :help
|
||||
syntastic-commands.
|
||||
- Add an option to specifiy syntax checkers that should be disabled by
|
||||
default. See :help syntastic_disabled_filetypes.
|
||||
- Dont use :signs if vim wasnt compiled with support for them.
|
||||
)
|
||||
|
||||
==============================================================================
|
||||
8. Credits *syntastic-credits*
|
||||
|
||||
Thanks to the following people for testing, bug reports, patches etc. They own,
|
||||
hard.
|
||||
|
||||
Benji Fisher (benjifisher)
|
||||
Lance Fetters (ashikase)
|
||||
datanoise
|
||||
Giuseppe Rota (grota)
|
||||
tocer
|
||||
James Rowe (JNRowe)
|
||||
Zhai Cai
|
||||
Matt Butcher (technosophos)
|
||||
Kevin Watters (kevinw)
|
||||
Miller Medeiros (millermedeiros)
|
||||
Pawel Salata (kTT)
|
||||
Fjölnir Ásgeirsson (aptiva)
|
||||
Clayton Parker (claytron)
|
||||
S. Zachariah Sprackett (zsprackett)
|
||||
Sylvain Soliman (soli)
|
||||
Ricardo Catalinas Jiménez (jimenezrick)
|
||||
kusnier
|
||||
Klein Florian (docteurklein)
|
||||
sitedyno
|
||||
Matthew Batema (mlb-)
|
||||
Nate Jones (justone)
|
||||
sergevm
|
||||
Karl Yngve Lervåg
|
||||
Pavel Argentov (argent-smith)
|
||||
Andy Duncan (ajduncan)
|
||||
Antonio Touriño (atourino)
|
||||
Chad Jablonski (cjab)
|
||||
Roman Gonzalez (roman)
|
||||
Tom Wieland (industrial)
|
||||
Ory Band (oryband)
|
||||
Esa-Matti Suuronen (epeli)
|
||||
Brandon Waskiewicz (brandonw)
|
||||
dlee
|
||||
temporaer
|
||||
Jason Graham (jasongraham)
|
||||
Sam Nguyen (dtjm)
|
||||
Claes Mogren (mogren)
|
||||
Eivind Uggedal (uggedal)
|
||||
kstep
|
||||
Andreas Baldeau (baldo)
|
||||
Eric Thomas (et)
|
||||
Brian Donovan (eventualbuddha)
|
||||
Bryan Forbes (bryanforbes)
|
||||
Aman Gupta (tmm1)
|
||||
Donald Ephraim Curtis (milkypostman)
|
||||
Dominique Rose-Rosette (changa)
|
||||
Harley Pig (harleypig)
|
||||
bmihelac
|
||||
Julien Blanchard (julienXX)
|
||||
Gregor Uhlenheuer (kongo2002)
|
||||
Lincoln Stoll
|
||||
Tim Carey-Smith (halorgium)
|
||||
Tim Pope (tpope)
|
||||
Travis Jeffery
|
||||
Anthony Carapetis
|
||||
|
||||
|
||||
==============================================================================
|
||||
9. License *syntastic-license*
|
||||
|
||||
Syntastic is released under the wtfpl.
|
||||
See http://sam.zoy.org/wtfpl/COPYING.
|
||||
562
vim/bundle/syntastic/plugin/syntastic.vim
Normal file
562
vim/bundle/syntastic/plugin/syntastic.vim
Normal file
@@ -0,0 +1,562 @@
|
||||
"============================================================================
|
||||
"File: syntastic.vim
|
||||
"Description: vim plugin for on the fly syntax checking
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"Version: 2.2.0
|
||||
"Last Change: 24 Dec, 2011
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("g:loaded_syntastic_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_plugin = 1
|
||||
|
||||
let s:running_windows = has("win16") || has("win32") || has("win64")
|
||||
|
||||
if !s:running_windows
|
||||
let s:uname = system('uname')
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_enable_signs")
|
||||
let g:syntastic_enable_signs = 1
|
||||
endif
|
||||
if !has('signs')
|
||||
let g:syntastic_enable_signs = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_enable_balloons")
|
||||
let g:syntastic_enable_balloons = 1
|
||||
endif
|
||||
if !has('balloon_eval')
|
||||
let g:syntastic_enable_balloons = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_enable_highlighting")
|
||||
let g:syntastic_enable_highlighting = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_echo_current_error")
|
||||
let g:syntastic_echo_current_error = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_auto_loc_list")
|
||||
let g:syntastic_auto_loc_list = 2
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_auto_jump")
|
||||
let syntastic_auto_jump=0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_quiet_warnings")
|
||||
let g:syntastic_quiet_warnings = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_stl_format")
|
||||
let g:syntastic_stl_format = '[Syntax: line:%F (%t)]'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_mode_map")
|
||||
let g:syntastic_mode_map = {}
|
||||
endif
|
||||
|
||||
if !has_key(g:syntastic_mode_map, "mode")
|
||||
let g:syntastic_mode_map['mode'] = 'active'
|
||||
endif
|
||||
|
||||
if !has_key(g:syntastic_mode_map, "active_filetypes")
|
||||
let g:syntastic_mode_map['active_filetypes'] = []
|
||||
endif
|
||||
|
||||
if !has_key(g:syntastic_mode_map, "passive_filetypes")
|
||||
let g:syntastic_mode_map['passive_filetypes'] = []
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_check_on_open")
|
||||
let g:syntastic_check_on_open = 0
|
||||
endif
|
||||
|
||||
command! SyntasticToggleMode call s:ToggleMode()
|
||||
command! SyntasticCheck call s:UpdateErrors(0) <bar> redraw!
|
||||
command! Errors call s:ShowLocList()
|
||||
|
||||
highlight link SyntasticError SpellBad
|
||||
highlight link SyntasticWarning SpellCap
|
||||
|
||||
augroup syntastic
|
||||
if g:syntastic_echo_current_error
|
||||
autocmd cursormoved * call s:EchoCurrentError()
|
||||
endif
|
||||
|
||||
autocmd BufReadPost * if g:syntastic_check_on_open | call s:UpdateErrors(1) | endif
|
||||
autocmd BufWritePost * call s:UpdateErrors(1)
|
||||
|
||||
autocmd BufWinEnter * if empty(&bt) | call s:AutoToggleLocList() | endif
|
||||
autocmd BufWinLeave * if empty(&bt) | lclose | endif
|
||||
augroup END
|
||||
|
||||
|
||||
"refresh and redraw all the error info for this buf when saving or reading
|
||||
function! s:UpdateErrors(auto_invoked)
|
||||
if !empty(&buftype)
|
||||
return
|
||||
endif
|
||||
|
||||
if !a:auto_invoked || s:ModeMapAllowsAutoChecking()
|
||||
call s:CacheErrors()
|
||||
end
|
||||
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
call setloclist(0, s:LocList())
|
||||
endif
|
||||
|
||||
if g:syntastic_enable_balloons
|
||||
call s:RefreshBalloons()
|
||||
endif
|
||||
|
||||
if g:syntastic_enable_signs
|
||||
call s:RefreshSigns()
|
||||
endif
|
||||
|
||||
if g:syntastic_auto_jump && s:BufHasErrorsOrWarningsToDisplay()
|
||||
silent! ll
|
||||
endif
|
||||
|
||||
call s:AutoToggleLocList()
|
||||
endfunction
|
||||
|
||||
"automatically open/close the location list window depending on the users
|
||||
"config and buffer error state
|
||||
function! s:AutoToggleLocList()
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
if g:syntastic_auto_loc_list == 1
|
||||
call s:ShowLocList()
|
||||
endif
|
||||
else
|
||||
if g:syntastic_auto_loc_list > 0
|
||||
|
||||
"TODO: this will close the loc list window if one was opened by
|
||||
"something other than syntastic
|
||||
lclose
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"lazy init the loc list for the current buffer
|
||||
function! s:LocList()
|
||||
if !exists("b:syntastic_loclist")
|
||||
let b:syntastic_loclist = []
|
||||
endif
|
||||
return b:syntastic_loclist
|
||||
endfunction
|
||||
|
||||
"clear the loc list for the buffer
|
||||
function! s:ClearLocList()
|
||||
let b:syntastic_loclist = []
|
||||
endfunction
|
||||
|
||||
"detect and cache all syntax errors in this buffer
|
||||
"
|
||||
"depends on a function called SyntaxCheckers_{&ft}_GetLocList() existing
|
||||
"elsewhere
|
||||
function! s:CacheErrors()
|
||||
call s:ClearLocList()
|
||||
|
||||
if filereadable(expand("%"))
|
||||
|
||||
"sub - for _ in filetypes otherwise we cant name syntax checker
|
||||
"functions legally for filetypes like "gentoo-metadata"
|
||||
let fts = substitute(&ft, '-', '_', 'g')
|
||||
for ft in split(fts, '\.')
|
||||
if s:Checkable(ft)
|
||||
let errors = SyntaxCheckers_{ft}_GetLocList()
|
||||
"make errors have type "E" by default
|
||||
call SyntasticAddToErrors(errors, {'type': 'E'})
|
||||
call extend(s:LocList(), errors)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"toggle the g:syntastic_mode_map['mode']
|
||||
function! s:ToggleMode()
|
||||
if g:syntastic_mode_map['mode'] == "active"
|
||||
let g:syntastic_mode_map['mode'] = "passive"
|
||||
else
|
||||
let g:syntastic_mode_map['mode'] = "active"
|
||||
endif
|
||||
|
||||
call s:ClearLocList()
|
||||
call s:UpdateErrors(1)
|
||||
|
||||
echo "Syntastic: " . g:syntastic_mode_map['mode'] . " mode enabled"
|
||||
endfunction
|
||||
|
||||
"check the current filetypes against g:syntastic_mode_map to determine whether
|
||||
"active mode syntax checking should be done
|
||||
function! s:ModeMapAllowsAutoChecking()
|
||||
let fts = split(&ft, '\.')
|
||||
|
||||
if g:syntastic_mode_map['mode'] == 'passive'
|
||||
"check at least one filetype is active
|
||||
let actives = g:syntastic_mode_map["active_filetypes"]
|
||||
return !empty(filter(fts, 'index(actives, v:val) != -1'))
|
||||
else
|
||||
"check no filetypes are passive
|
||||
let passives = g:syntastic_mode_map["passive_filetypes"]
|
||||
return empty(filter(fts, 'index(passives, v:val) != -1'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"return true if there are cached errors/warnings for this buf
|
||||
function! s:BufHasErrorsOrWarnings()
|
||||
return !empty(s:LocList())
|
||||
endfunction
|
||||
|
||||
"return true if there are cached errors for this buf
|
||||
function! s:BufHasErrors()
|
||||
return len(s:ErrorsForType('E')) > 0
|
||||
endfunction
|
||||
|
||||
function! s:BufHasErrorsOrWarningsToDisplay()
|
||||
return s:BufHasErrors() || (!g:syntastic_quiet_warnings && s:BufHasErrorsOrWarnings())
|
||||
endfunction
|
||||
|
||||
function! s:ErrorsForType(type)
|
||||
return s:FilterLocList({'type': a:type})
|
||||
endfunction
|
||||
|
||||
function! s:Errors()
|
||||
return s:ErrorsForType("E")
|
||||
endfunction
|
||||
|
||||
function! s:Warnings()
|
||||
return s:ErrorsForType("W")
|
||||
endfunction
|
||||
|
||||
"Filter a loc list (defaults to s:LocList()) by a:filters
|
||||
"e.g.
|
||||
" s:FilterLocList({'bufnr': 10, 'type': 'e'})
|
||||
"
|
||||
"would return all errors in s:LocList() for buffer 10.
|
||||
"
|
||||
"Note that all comparisons are done with ==?
|
||||
function! s:FilterLocList(filters, ...)
|
||||
let llist = a:0 ? a:1 : s:LocList()
|
||||
|
||||
let rv = deepcopy(llist)
|
||||
for error in llist
|
||||
for key in keys(a:filters)
|
||||
let rhs = a:filters[key]
|
||||
if type(rhs) == 1 "string
|
||||
let rhs = '"' . rhs . '"'
|
||||
endif
|
||||
|
||||
call filter(rv, "v:val['".key."'] ==? " . rhs)
|
||||
endfor
|
||||
endfor
|
||||
return rv
|
||||
endfunction
|
||||
|
||||
if g:syntastic_enable_signs
|
||||
"use >> to display syntax errors in the sign column
|
||||
sign define SyntasticError text=>> texthl=error
|
||||
sign define SyntasticWarning text=>> texthl=todo
|
||||
endif
|
||||
|
||||
"start counting sign ids at 5000, start here to hopefully avoid conflicting
|
||||
"with any other code that places signs (not sure if this precaution is
|
||||
"actually needed)
|
||||
let s:first_sign_id = 5000
|
||||
let s:next_sign_id = s:first_sign_id
|
||||
|
||||
"place signs by all syntax errs in the buffer
|
||||
function! s:SignErrors()
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
|
||||
let errors = s:FilterLocList({'bufnr': bufnr('')})
|
||||
for i in errors
|
||||
let sign_type = 'SyntasticError'
|
||||
if i['type'] ==? 'W'
|
||||
let sign_type = 'SyntasticWarning'
|
||||
endif
|
||||
|
||||
if !s:WarningMasksError(i, errors)
|
||||
exec "sign place ". s:next_sign_id ." line=". i['lnum'] ." name=". sign_type ." file=". expand("%:p")
|
||||
call add(s:BufSignIds(), s:next_sign_id)
|
||||
let s:next_sign_id += 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"return true if the given error item is a warning that, if signed, would
|
||||
"potentially mask an error if displayed at the same time
|
||||
function! s:WarningMasksError(error, llist)
|
||||
if a:error['type'] !=? 'w'
|
||||
return 0
|
||||
endif
|
||||
|
||||
return len(s:FilterLocList({ 'type': "E", 'lnum': a:error['lnum'] }, a:llist)) > 0
|
||||
endfunction
|
||||
|
||||
"remove the signs with the given ids from this buffer
|
||||
function! s:RemoveSigns(ids)
|
||||
for i in a:ids
|
||||
exec "sign unplace " . i
|
||||
call remove(s:BufSignIds(), index(s:BufSignIds(), i))
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"get all the ids of the SyntaxError signs in the buffer
|
||||
function! s:BufSignIds()
|
||||
if !exists("b:syntastic_sign_ids")
|
||||
let b:syntastic_sign_ids = []
|
||||
endif
|
||||
return b:syntastic_sign_ids
|
||||
endfunction
|
||||
|
||||
"update the error signs
|
||||
function! s:RefreshSigns()
|
||||
let old_signs = copy(s:BufSignIds())
|
||||
call s:SignErrors()
|
||||
call s:RemoveSigns(old_signs)
|
||||
let s:first_sign_id = s:next_sign_id
|
||||
endfunction
|
||||
|
||||
"display the cached errors for this buf in the location list
|
||||
function! s:ShowLocList()
|
||||
if !empty(s:LocList())
|
||||
let num = winnr()
|
||||
lopen
|
||||
if num != winnr()
|
||||
wincmd p
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"remove all error highlights from the window
|
||||
function! s:ClearErrorHighlights()
|
||||
for match in getmatches()
|
||||
if stridx(match['group'], 'Syntastic') == 0
|
||||
call matchdelete(match['id'])
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"check if a syntax checker exists for the given filetype - and attempt to
|
||||
"load one
|
||||
function! s:Checkable(ft)
|
||||
if !exists("g:loaded_" . a:ft . "_syntax_checker")
|
||||
exec "runtime syntax_checkers/" . a:ft . ".vim"
|
||||
endif
|
||||
|
||||
return exists("*SyntaxCheckers_". a:ft ."_GetLocList")
|
||||
endfunction
|
||||
|
||||
"set up error ballons for the current set of errors
|
||||
function! s:RefreshBalloons()
|
||||
let b:syntastic_balloons = {}
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
for i in s:LocList()
|
||||
let b:syntastic_balloons[i['lnum']] = i['text']
|
||||
endfor
|
||||
set beval bexpr=SyntasticErrorBalloonExpr()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"print as much of a:msg as possible without "Press Enter" prompt appearing
|
||||
function! s:WideMsg(msg)
|
||||
let old_ruler = &ruler
|
||||
let old_showcmd = &showcmd
|
||||
|
||||
let msg = strpart(a:msg, 0, winwidth(0)-1)
|
||||
|
||||
"This is here because it is possible for some error messages to begin with
|
||||
"\n which will cause a "press enter" prompt. I have noticed this in the
|
||||
"javascript:jshint checker and have been unable to figure out why it
|
||||
"happens
|
||||
let msg = substitute(msg, "\n", "", "g")
|
||||
|
||||
set noruler noshowcmd
|
||||
redraw
|
||||
|
||||
echo msg
|
||||
|
||||
let &ruler=old_ruler
|
||||
let &showcmd=old_showcmd
|
||||
endfunction
|
||||
|
||||
"echo out the first error we find for the current line in the cmd window
|
||||
function! s:EchoCurrentError()
|
||||
"If we have an error or warning at the current line, show it
|
||||
let errors = s:FilterLocList({'lnum': line("."), "type": 'e'})
|
||||
let warnings = s:FilterLocList({'lnum': line("."), "type": 'w'})
|
||||
|
||||
let b:syntastic_echoing_error = len(errors) || len(warnings)
|
||||
if len(errors)
|
||||
return s:WideMsg(errors[0]['text'])
|
||||
endif
|
||||
if len(warnings)
|
||||
return s:WideMsg(warnings[0]['text'])
|
||||
endif
|
||||
|
||||
"Otherwise, clear the status line
|
||||
if b:syntastic_echoing_error
|
||||
echo
|
||||
let b:syntastic_echoing_error = 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"return a string representing the state of buffer according to
|
||||
"g:syntastic_stl_format
|
||||
"
|
||||
"return '' if no errors are cached for the buffer
|
||||
function! SyntasticStatuslineFlag()
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
let errors = s:Errors()
|
||||
let warnings = s:Warnings()
|
||||
|
||||
let output = g:syntastic_stl_format
|
||||
|
||||
"hide stuff wrapped in %E(...) unless there are errors
|
||||
let output = substitute(output, '\C%E{\([^}]*\)}', len(errors) ? '\1' : '' , 'g')
|
||||
|
||||
"hide stuff wrapped in %W(...) unless there are warnings
|
||||
let output = substitute(output, '\C%W{\([^}]*\)}', len(warnings) ? '\1' : '' , 'g')
|
||||
|
||||
"hide stuff wrapped in %B(...) unless there are both errors and warnings
|
||||
let output = substitute(output, '\C%B{\([^}]*\)}', (len(warnings) && len(errors)) ? '\1' : '' , 'g')
|
||||
|
||||
"sub in the total errors/warnings/both
|
||||
let output = substitute(output, '\C%w', len(warnings), 'g')
|
||||
let output = substitute(output, '\C%e', len(errors), 'g')
|
||||
let output = substitute(output, '\C%t', len(s:LocList()), 'g')
|
||||
|
||||
"first error/warning line num
|
||||
let output = substitute(output, '\C%F', s:LocList()[0]['lnum'], 'g')
|
||||
|
||||
"first error line num
|
||||
let output = substitute(output, '\C%fe', len(errors) ? errors[0]['lnum'] : '', 'g')
|
||||
|
||||
"first warning line num
|
||||
let output = substitute(output, '\C%fw', len(warnings) ? warnings[0]['lnum'] : '', 'g')
|
||||
|
||||
return output
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"A wrapper for the :lmake command. Sets up the make environment according to
|
||||
"the options given, runs make, resets the environment, returns the location
|
||||
"list
|
||||
"
|
||||
"a:options can contain the following keys:
|
||||
" 'makeprg'
|
||||
" 'errorformat'
|
||||
"
|
||||
"The corresponding options are set for the duration of the function call. They
|
||||
"are set with :let, so dont escape spaces.
|
||||
"
|
||||
"a:options may also contain:
|
||||
" 'defaults' - a dict containing default values for the returned errors
|
||||
function! SyntasticMake(options)
|
||||
let old_loclist = getloclist(0)
|
||||
let old_makeprg = &makeprg
|
||||
let old_shellpipe = &shellpipe
|
||||
let old_shell = &shell
|
||||
let old_errorformat = &errorformat
|
||||
|
||||
if !s:running_windows && (s:uname !~ "FreeBSD")
|
||||
"this is a hack to stop the screen needing to be ':redraw'n when
|
||||
"when :lmake is run. Otherwise the screen flickers annoyingly
|
||||
let &shellpipe='&>'
|
||||
let &shell = '/bin/bash'
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'makeprg')
|
||||
let &makeprg = a:options['makeprg']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &errorformat = a:options['errorformat']
|
||||
endif
|
||||
|
||||
silent lmake!
|
||||
let errors = getloclist(0)
|
||||
|
||||
call setloclist(0, old_loclist)
|
||||
let &makeprg = old_makeprg
|
||||
let &errorformat = old_errorformat
|
||||
let &shellpipe=old_shellpipe
|
||||
let &shell=old_shell
|
||||
|
||||
if !s:running_windows && s:uname =~ "FreeBSD"
|
||||
redraw!
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'defaults')
|
||||
call SyntasticAddToErrors(errors, a:options['defaults'])
|
||||
endif
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
"get the error balloon for the current mouse position
|
||||
function! SyntasticErrorBalloonExpr()
|
||||
if !exists('b:syntastic_balloons')
|
||||
return ''
|
||||
endif
|
||||
return get(b:syntastic_balloons, v:beval_lnum, '')
|
||||
endfunction
|
||||
|
||||
"highlight the list of errors (a:errors) using matchadd()
|
||||
"
|
||||
"a:termfunc is provided to highlight errors that do not have a 'col' key (and
|
||||
"hence cant be done automatically). This function must take one arg (an error
|
||||
"item) and return a regex to match that item in the buffer.
|
||||
"
|
||||
"an optional boolean third argument can be provided to force a:termfunc to be
|
||||
"used regardless of whether a 'col' key is present for the error
|
||||
function! SyntasticHighlightErrors(errors, termfunc, ...)
|
||||
if !g:syntastic_enable_highlighting
|
||||
return
|
||||
endif
|
||||
|
||||
call s:ClearErrorHighlights()
|
||||
|
||||
let force_callback = a:0 && a:1
|
||||
for item in a:errors
|
||||
let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
|
||||
if item['col'] && !force_callback
|
||||
let lastcol = col([item['lnum'], '$'])
|
||||
let lcol = min([lastcol, item['col']])
|
||||
call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c')
|
||||
else
|
||||
let term = a:termfunc(item)
|
||||
if len(term) > 0
|
||||
call matchadd(group, '\%' . item['lnum'] . 'l' . term)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"take a list of errors and add default values to them from a:options
|
||||
function! SyntasticAddToErrors(errors, options)
|
||||
for i in range(0, len(a:errors)-1)
|
||||
for key in keys(a:options)
|
||||
if empty(a:errors[i][key])
|
||||
let a:errors[i][key] = a:options[key]
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
return a:errors
|
||||
endfunction
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
43
vim/bundle/syntastic/syntax_checkers/applescript.vim
Normal file
43
vim/bundle/syntastic/syntax_checkers/applescript.vim
Normal file
@@ -0,0 +1,43 @@
|
||||
"==============================================================================
|
||||
" FileName: applescript.vim
|
||||
" Desc: Syntax checking plugin for syntastic.vim
|
||||
" Author: Zhao Cai
|
||||
" Email: caizhaoff@gmail.com
|
||||
" Version: 0.2.1
|
||||
" Date Created: Thu 09 Sep 2011 10:30:09 AM EST
|
||||
" Last Modified: Fri 09 Dec 2011 01:10:24 PM EST
|
||||
"
|
||||
" History: 0.1.0 - working, but it will run the script everytime to check
|
||||
" syntax. Should use osacompile but strangely it does not give
|
||||
" errors.
|
||||
"
|
||||
" 0.2.0 - switch to osacompile, it gives less errors compared
|
||||
" with osascript.
|
||||
"
|
||||
" 0.2.1 - remove g:syntastic_applescript_tempfile. use
|
||||
" tempname() instead.
|
||||
"
|
||||
" License: This program is free software. It comes without any
|
||||
" warranty, to the extent permitted by applicable law. You can
|
||||
" redistribute it and/or modify it under the terms of the Do What The
|
||||
" Fuck You Want To Public License, Version 2, as published by Sam
|
||||
" Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("loaded_applescript_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_applescript_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have osacompile installed
|
||||
if !executable("osacompile")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_applescript_GetLocList()
|
||||
let makeprg = 'osacompile -o ' . tempname() . '.scpt '. shellescape(expand('%'))
|
||||
let errorformat = '%f:%l:%m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
156
vim/bundle/syntastic/syntax_checkers/c.vim
Normal file
156
vim/bundle/syntastic/syntax_checkers/c.vim
Normal file
@@ -0,0 +1,156 @@
|
||||
"============================================================================
|
||||
"File: c.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" In order to also check header files add this to your .vimrc:
|
||||
" (this usually creates a .gch file in your source directory)
|
||||
"
|
||||
" let g:syntastic_c_check_header = 1
|
||||
"
|
||||
" To disable the search of included header files after special
|
||||
" libraries like gtk and glib add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_c_no_include_search = 1
|
||||
"
|
||||
" To enable header files being re-checked on every file write add the
|
||||
" following line to your .vimrc. Otherwise the header files are checked only
|
||||
" one time on initially loading the file.
|
||||
" In order to force syntastic to refresh the header includes simply
|
||||
" unlet b:syntastic_c_includes. Then the header files are being re-checked on
|
||||
" the next file write.
|
||||
"
|
||||
" let g:syntastic_c_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_c_cflags.
|
||||
" If this variable is set for the current buffer no search for additional
|
||||
" libraries is done. I.e. set the variable like this:
|
||||
"
|
||||
" let b:syntastic_c_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" In order to add some custom include directories that should be added to the
|
||||
" gcc command line you can add those to the global variable
|
||||
" g:syntastic_c_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_c_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_c_compiler_options':
|
||||
"
|
||||
" let g:syntastic_c_compiler_options = ' -ansi'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_c_remove_include_errors' you can
|
||||
" specify whether errors of files included via the g:syntastic_c_include_dirs'
|
||||
" setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_c_remove_include_errors = 1
|
||||
|
||||
if exists('loaded_c_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_c_syntax_checker = 1
|
||||
|
||||
if !executable('gcc')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" default include directories
|
||||
let s:default_includes = [ '.', '..', 'include', 'includes',
|
||||
\ '../include', '../includes' ]
|
||||
|
||||
" uniquify the input list
|
||||
function! s:Unique(list)
|
||||
let l = []
|
||||
for elem in a:list
|
||||
if index(l, elem) == -1
|
||||
let l = add(l, elem)
|
||||
endif
|
||||
endfor
|
||||
return l
|
||||
endfunction
|
||||
|
||||
" get the gcc include directory argument depending on the default
|
||||
" includes and the optional user-defined 'g:syntastic_c_include_dirs'
|
||||
function! s:GetIncludeDirs()
|
||||
let include_dirs = s:default_includes
|
||||
|
||||
if exists('g:syntastic_c_include_dirs')
|
||||
call extend(include_dirs, g:syntastic_c_include_dirs)
|
||||
endif
|
||||
|
||||
return join(map(s:Unique(include_dirs), '"-I" . v:val'), ' ')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_c_GetLocList()
|
||||
let makeprg = 'gcc -fsyntax-only -std=gnu99 '.shellescape(expand('%')).
|
||||
\ ' '.s:GetIncludeDirs()
|
||||
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
|
||||
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
|
||||
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
|
||||
\ '%-G %#from %f:%l\,,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %m'
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '.h$'
|
||||
if exists('g:syntastic_c_check_header')
|
||||
let makeprg = 'gcc -c '.shellescape(expand('%')).
|
||||
\ ' '.s:GetIncludeDirs()
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
if exists('g:syntastic_c_compiler_options')
|
||||
let makeprg .= g:syntastic_c_compiler_options
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_c_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_c_no_include_search') ||
|
||||
\ g:syntastic_c_no_include_search != 1
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_c_auto_refresh_includes') &&
|
||||
\ g:syntastic_c_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_c_includes')
|
||||
let b:syntastic_c_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_c_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= b:syntastic_c_cflags
|
||||
endif
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_c_remove_include_errors') &&
|
||||
\ g:syntastic_c_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
27
vim/bundle/syntastic/syntax_checkers/coffee.vim
Normal file
27
vim/bundle/syntastic/syntax_checkers/coffee.vim
Normal file
@@ -0,0 +1,27 @@
|
||||
"============================================================================
|
||||
"File: coffee.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Lincoln Stoll <l@lds.li>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_coffee_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_coffee_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have coffee installed
|
||||
if !executable("coffee")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_coffee_GetLocList()
|
||||
let makeprg = 'coffee -c -l -o /tmp '.shellescape(expand('%'))
|
||||
let errorformat = 'Syntax%trror: In %f\, %m on line %l,%EError: In %f\, Parse error on line %l: %m,%EError: In %f\, %m on line %l,%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
94
vim/bundle/syntastic/syntax_checkers/cpp.vim
Normal file
94
vim/bundle/syntastic/syntax_checkers/cpp.vim
Normal file
@@ -0,0 +1,94 @@
|
||||
"============================================================================
|
||||
"File: cpp.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" in order to also check header files add this to your .vimrc:
|
||||
" (this usually creates a .gch file in your source directory)
|
||||
"
|
||||
" let g:syntastic_cpp_check_header = 1
|
||||
"
|
||||
" To disable the search of included header files after special
|
||||
" libraries like gtk and glib add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_cpp_no_include_search = 1
|
||||
"
|
||||
" To enable header files being re-checked on every file write add the
|
||||
" following line to your .vimrc. Otherwise the header files are checked only
|
||||
" one time on initially loading the file.
|
||||
" In order to force syntastic to refresh the header includes simply
|
||||
" unlet b:syntastic_cpp_includes. Then the header files are being re-checked
|
||||
" on the next file write.
|
||||
"
|
||||
" let g:syntastic_cpp_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_cpp_cflags.
|
||||
" If this variable is set for the current buffer no search for additional
|
||||
" libraries is done. I.e. set the variable like this:
|
||||
"
|
||||
" let b:syntastic_cpp_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_cpp_compiler_options':
|
||||
"
|
||||
" let g:syntastic_cpp_compiler_options = ' -std=c++0x'
|
||||
|
||||
if exists('loaded_cpp_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_cpp_syntax_checker = 1
|
||||
|
||||
if !executable('g++')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_cpp_GetLocList()
|
||||
let makeprg = 'g++ -fsyntax-only '.shellescape(expand('%'))
|
||||
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
|
||||
|
||||
if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
|
||||
if exists('g:syntastic_cpp_check_header')
|
||||
let makeprg = 'g++ -c '.shellescape(expand('%'))
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('g:syntastic_cpp_compiler_options')
|
||||
let makeprg .= g:syntastic_cpp_compiler_options
|
||||
endif
|
||||
|
||||
if !exists('b:syntastic_cpp_cflags')
|
||||
if !exists('g:syntastic_cpp_no_include_search') ||
|
||||
\ g:syntastic_cpp_no_include_search != 1
|
||||
if exists('g:syntastic_cpp_auto_refresh_includes') &&
|
||||
\ g:syntastic_cpp_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
if !exists('b:syntastic_cpp_includes')
|
||||
let b:syntastic_cpp_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_cpp_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let makeprg .= b:syntastic_cpp_cflags
|
||||
endif
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
31
vim/bundle/syntastic/syntax_checkers/css.vim
Normal file
31
vim/bundle/syntastic/syntax_checkers/css.vim
Normal file
@@ -0,0 +1,31 @@
|
||||
"============================================================================
|
||||
"File: css.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim using `csslint` CLI tool (http://csslint.net).
|
||||
"Maintainer: Ory Band <oryband at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
if exists("loaded_css_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_css_syntax_checker = 1
|
||||
|
||||
" Bail if the user doesn't have `csslint` installed.
|
||||
if !executable("csslint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_css_GetLocList()
|
||||
let makeprg = 'csslint --format=compact '.shellescape(expand('%'))
|
||||
|
||||
" Print CSS Lint's error/warning messages from compact format. Ignores blank lines.
|
||||
let errorformat = '%-G,%-G%f: lint free!,%f: line %l\, col %c\, %trror - %m,%f: line %l\, col %c\, %tarning - %m,%f: line %l\, col %c\, %m,'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
|
||||
endfunction
|
||||
27
vim/bundle/syntastic/syntax_checkers/cucumber.vim
Normal file
27
vim/bundle/syntastic/syntax_checkers/cucumber.vim
Normal file
@@ -0,0 +1,27 @@
|
||||
"============================================================================
|
||||
"File: cucumber.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_cucumber_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_cucumber_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have cucumber installed
|
||||
if !executable("cucumber")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cucumber_GetLocList()
|
||||
let makeprg = 'cucumber --dry-run --quiet --strict --format pretty '.shellescape(expand('%'))
|
||||
let errorformat = '%f:%l:%c:%m,%W %.%# (%m),%-Z%f:%l:%.%#,%-G%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
37
vim/bundle/syntastic/syntax_checkers/cuda.vim
Normal file
37
vim/bundle/syntastic/syntax_checkers/cuda.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
"============================================================================
|
||||
"File: cuda.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"
|
||||
"Author: Hannes Schulz <schulz at ais dot uni-bonn dot de>
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" in order to also check header files add this to your .vimrc:
|
||||
" (this creates an empty .syntastic_dummy.cu file in your source directory)
|
||||
"
|
||||
" let g:syntastic_cuda_check_header = 1
|
||||
|
||||
if exists('loaded_cuda_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_cuda_syntax_checker = 1
|
||||
|
||||
if !executable('nvcc')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cuda_GetLocList()
|
||||
let makeprg = 'nvcc --cuda -O0 -I . -Xcompiler -fsyntax-only '.shellescape(expand('%')).' -o /dev/null'
|
||||
"let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
|
||||
let errorformat = '%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f'',%X%*\a[%*\d]: Leaving directory `%f'',%D%*\a: Entering directory `%f'',%X%*\a: Leaving directory `%f'',%DMaking %*\a in %f,%f|%l| %m'
|
||||
|
||||
if expand('%') =~? '\%(.h\|.hpp\|.cuh\)$'
|
||||
if exists('g:syntastic_cuda_check_header')
|
||||
let makeprg = 'echo > .syntastic_dummy.cu ; nvcc --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include '.shellescape(expand('%')).' -o /dev/null'
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
29
vim/bundle/syntastic/syntax_checkers/docbk.vim
Normal file
29
vim/bundle/syntastic/syntax_checkers/docbk.vim
Normal file
@@ -0,0 +1,29 @@
|
||||
"============================================================================
|
||||
"File: docbk.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_docbk_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_docbk_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("xmllint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_docbk_GetLocList()
|
||||
|
||||
let makeprg="xmllint --xinclude --noout --postvalid ".shellescape(expand(%:p))
|
||||
let errorformat='%E%f:%l: parser error : %m,%W%f:%l: parser warning : %m,%E%f:%l:%.%# validity error : %m,%W%f:%l:%.%# validity warning : %m,%-Z%p^,%-C%.%#,%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
42
vim/bundle/syntastic/syntax_checkers/erlang.vim
Normal file
42
vim/bundle/syntastic/syntax_checkers/erlang.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
"============================================================================
|
||||
"File: erlang.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Pawel Salata <rockplayer.pl at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_erlang_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_erlang_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have escript installed
|
||||
if !executable("escript")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:check_file = expand('<sfile>:p:h') . '/erlang_check_file.erl'
|
||||
|
||||
function! SyntaxCheckers_erlang_GetLocList()
|
||||
let extension = expand('%:e')
|
||||
if match(extension, 'hrl') >= 0
|
||||
return []
|
||||
endif
|
||||
let shebang = getbufline(bufnr('%'), 1)[0]
|
||||
if len(shebang) > 0
|
||||
if match(shebang, 'escript') >= 0
|
||||
let makeprg = 'escript -s '.shellescape(expand('%:p'))
|
||||
else
|
||||
let makeprg = s:check_file . ' '. shellescape(expand('%:p'))
|
||||
endif
|
||||
else
|
||||
let makeprg = s:check_file . ' ' . shellescape(expand('%:p'))
|
||||
endif
|
||||
let errorformat = '%f:%l:\ %tarning:\ %m,%E%f:%l:\ %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
12
vim/bundle/syntastic/syntax_checkers/erlang_check_file.erl
Executable file
12
vim/bundle/syntastic/syntax_checkers/erlang_check_file.erl
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env escript
|
||||
-export([main/1]).
|
||||
|
||||
main([FileName]) ->
|
||||
compile:file(FileName, [warn_obsolete_guard,
|
||||
warn_unused_import,
|
||||
warn_shadow_vars,
|
||||
warn_export_vars,
|
||||
strong_validation,
|
||||
report,
|
||||
{i, filename:dirname(FileName) ++ "/../include"}
|
||||
]).
|
||||
34
vim/bundle/syntastic/syntax_checkers/eruby.vim
Normal file
34
vim/bundle/syntastic/syntax_checkers/eruby.vim
Normal file
@@ -0,0 +1,34 @@
|
||||
"============================================================================
|
||||
"File: eruby.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_eruby_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_eruby_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have ruby or cat installed
|
||||
if !executable("ruby") || !executable("cat")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_eruby_GetLocList()
|
||||
if has('win32') || has('win64')
|
||||
let makeprg='sed "s/<\%=/<\%/g" '. shellescape(expand("%")) . ' \| ruby -e "require \"erb\"; puts ERB.new(ARGF.read, nil, \"-\").src" \| ruby -c'
|
||||
else
|
||||
let makeprg='sed "s/<\%=/<\%/g" '. shellescape(expand("%")) . ' \| RUBYOPT= ruby -e "require \"erb\"; puts ERB.new(ARGF.read, nil, \"-\").src" \| RUBYOPT= ruby -c'
|
||||
endif
|
||||
|
||||
let errorformat='%-GSyntax OK,%E-:%l: syntax error\, %m,%Z%p^,%W-:%l: warning: %m,%Z%p^,%-C%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
|
||||
endfunction
|
||||
44
vim/bundle/syntastic/syntax_checkers/fortran.vim
Normal file
44
vim/bundle/syntastic/syntax_checkers/fortran.vim
Normal file
@@ -0,0 +1,44 @@
|
||||
"============================================================================
|
||||
"File: fortran.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Karl Yngve Lervåg <karl.yngve@lervag.net>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"Note: This syntax checker uses gfortran with the option -fsyntax-only
|
||||
" to check for errors and warnings. Additional flags may be
|
||||
" supplied through both local and global variables,
|
||||
" b:syntastic_fortran_flags,
|
||||
" g:syntastic_fortran_flags.
|
||||
" This is particularly useful when the source requires module files
|
||||
" in order to compile (that is when it needs modules defined in
|
||||
" separate files).
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("loaded_fortran_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_fortran_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have fortran installed
|
||||
if !executable("gfortran")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_fortran_flags')
|
||||
let g:syntastic_fortran_flags = ''
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_fortran_GetLocList()
|
||||
let makeprg = 'gfortran -fsyntax-only'
|
||||
let makeprg .= g:syntastic_fortran_flags
|
||||
if exists('b:syntastic_fortran_flags')
|
||||
let makeprg .= b:syntastic_fortran_flags
|
||||
endif
|
||||
let makeprg .= ' ' . shellescape(expand('%'))
|
||||
let errorformat = '%-C %#,%-C %#%.%#,%A%f:%l.%c:,%Z%m,%G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
37
vim/bundle/syntastic/syntax_checkers/gentoo_metadata.vim
Normal file
37
vim/bundle/syntastic/syntax_checkers/gentoo_metadata.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
"============================================================================
|
||||
"File: gentoo-metadata.vim
|
||||
"Description: Syntax checking plugin for Gentoo's metadata.xml files
|
||||
"Maintainer: James Rowe <jnrowe at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" The DTDs required to validate metadata.xml files are available in
|
||||
" $PORTDIR/metadata/dtd, and these local files can be used to significantly
|
||||
" speed up validation. You can create a catalog file with:
|
||||
"
|
||||
" xmlcatalog --create --add rewriteURI http://www.gentoo.org/dtd/ \
|
||||
" ${PORTDIR:-/usr/portage}/metadata/dtd/ /etc/xml/gentoo
|
||||
"
|
||||
" See xmlcatalog(1) and http://www.xmlsoft.org/catalog.html for more
|
||||
" information.
|
||||
|
||||
if exists("loaded_gentoo_metadata_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_gentoo_metadata_syntax_checker = 1
|
||||
|
||||
"bail if the user doesn't have xmllint installed
|
||||
if !executable("xmllint")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime syntax_checkers/xml.vim
|
||||
|
||||
function! SyntaxCheckers_gentoo_metadata_GetLocList()
|
||||
return SyntaxCheckers_xml_GetLocList()
|
||||
endfunction
|
||||
27
vim/bundle/syntastic/syntax_checkers/go.vim
Normal file
27
vim/bundle/syntastic/syntax_checkers/go.vim
Normal file
@@ -0,0 +1,27 @@
|
||||
"============================================================================
|
||||
"File: go.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Sam Nguyen <samxnguyen@gmail.com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_go_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_go_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have 6g installed
|
||||
if !executable("6g")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_go_GetLocList()
|
||||
let makeprg = '6g -o /dev/null %'
|
||||
let errorformat = '%E%f:%l: %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
26
vim/bundle/syntastic/syntax_checkers/haml.vim
Normal file
26
vim/bundle/syntastic/syntax_checkers/haml.vim
Normal file
@@ -0,0 +1,26 @@
|
||||
"============================================================================
|
||||
"File: haml.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_haml_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_haml_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have the haml binary installed
|
||||
if !executable("haml")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_haml_GetLocList()
|
||||
let makeprg = "haml -c " . shellescape(expand("%"))
|
||||
let errorformat = 'Haml error on line %l: %m,Syntax error on line %l: %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
37
vim/bundle/syntastic/syntax_checkers/haskell.vim
Normal file
37
vim/bundle/syntastic/syntax_checkers/haskell.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
"============================================================================
|
||||
"File: haskell.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Anthony Carapetis <anthony.carapetis at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_haskell_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_haskell_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have ghc-mod installed
|
||||
if !executable("ghc-mod")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_haskell_GetLocList()
|
||||
let makeprg =
|
||||
\ "{ ".
|
||||
\ "ghc-mod check ". shellescape(expand('%')) . "; " .
|
||||
\ "ghc-mod lint " . shellescape(expand('%')) . ";" .
|
||||
\ " }"
|
||||
let errorformat = '%-G\\s%#,%f:%l:%c:%trror: %m,%f:%l:%c:%tarning: %m,'.
|
||||
\ '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,%f:%l:%c:%m,'.
|
||||
\ '%E%f:%l:%c:,%Z%m,'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_lhaskell_GetLocList()
|
||||
return SyntaxCheckers_haskell_GetLocList()
|
||||
endfunction
|
||||
55
vim/bundle/syntastic/syntax_checkers/haxe.vim
Executable file
55
vim/bundle/syntastic/syntax_checkers/haxe.vim
Executable file
@@ -0,0 +1,55 @@
|
||||
"============================================================================
|
||||
"File: haxe.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: David Bernard <david.bernard.31 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_haxe_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_haxe_syntax_checker = 1
|
||||
|
||||
"bail if the user doesn't have haxe installed
|
||||
if !executable("haxe")
|
||||
finish
|
||||
endif
|
||||
|
||||
" s:FindInParent
|
||||
" find the file argument and returns the path to it.
|
||||
" Starting with the current working dir, it walks up the parent folders
|
||||
" until it finds the file, or it hits the stop dir.
|
||||
" If it doesn't find it, it returns "Nothing"
|
||||
function! s:FindInParent(fln,flsrt,flstp)
|
||||
let here = a:flsrt
|
||||
while ( strlen( here) > 0 )
|
||||
let p = split(globpath(here, a:fln), '\n')
|
||||
if len(p) > 0
|
||||
return ['ok', here, fnamemodify(p[0], ':p:t')]
|
||||
endif
|
||||
let fr = match(here, '/[^/]*$')
|
||||
if fr == -1
|
||||
break
|
||||
endif
|
||||
let here = strpart(here, 0, fr)
|
||||
if here == a:flstp
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
return ['fail', '', '']
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haxe_GetLocList()
|
||||
let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/')
|
||||
if success == 'ok'
|
||||
let makeprg = 'cd ' . hxmldir . '; haxe ' . hxmlname
|
||||
let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
else
|
||||
return SyntasticMake({})
|
||||
endif
|
||||
endfunction
|
||||
86
vim/bundle/syntastic/syntax_checkers/html.vim
Normal file
86
vim/bundle/syntastic/syntax_checkers/html.vim
Normal file
@@ -0,0 +1,86 @@
|
||||
"============================================================================
|
||||
"File: html.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_html_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_html_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("tidy") || !executable("grep")
|
||||
finish
|
||||
endif
|
||||
|
||||
" TODO: join this with xhtml.vim for DRY's sake?
|
||||
function! s:TidyEncOptByFenc()
|
||||
let tidy_opts = {
|
||||
\'utf-8' : '-utf8',
|
||||
\'ascii' : '-ascii',
|
||||
\'latin1' : '-latin1',
|
||||
\'iso-2022-jp' : '-iso-2022',
|
||||
\'cp1252' : '-win1252',
|
||||
\'macroman' : '-mac',
|
||||
\'utf-16le' : '-utf16le',
|
||||
\'utf-16' : '-utf16',
|
||||
\'big5' : '-big5',
|
||||
\'sjis' : '-shiftjis',
|
||||
\'cp850' : '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
let s:ignore_html_errors = [
|
||||
\ "<table> lacks \"summary\" attribute",
|
||||
\ "not approved by W3C",
|
||||
\ "attribute \"placeholder\"",
|
||||
\ "<meta> proprietary attribute \"charset\"",
|
||||
\ "<meta> lacks \"content\" attribute",
|
||||
\ "inserting \"type\" attribute",
|
||||
\ "proprietary attribute \"data-"
|
||||
\]
|
||||
|
||||
function! s:ValidateError(text)
|
||||
let valid = 0
|
||||
for i in s:ignore_html_errors
|
||||
if stridx(a:text, i) != -1
|
||||
let valid = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
return valid
|
||||
endfunction
|
||||
|
||||
|
||||
function! SyntaxCheckers_html_GetLocList()
|
||||
|
||||
let encopt = s:TidyEncOptByFenc()
|
||||
let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1"
|
||||
let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" process loclist since we need to add some info and filter out valid HTML5
|
||||
" from the errors
|
||||
let n = len(loclist) - 1
|
||||
let bufnum = bufnr("")
|
||||
while n >= 0
|
||||
let i = loclist[n]
|
||||
" filter out valid HTML5
|
||||
if s:ValidateError(i['text']) == 1
|
||||
unlet loclist[n]
|
||||
else
|
||||
"the file name isnt in the output so stick in the buf num manually
|
||||
let i['bufnr'] = bufnum
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
41
vim/bundle/syntastic/syntax_checkers/javascript.vim
Normal file
41
vim/bundle/syntastic/syntax_checkers/javascript.vim
Normal file
@@ -0,0 +1,41 @@
|
||||
"============================================================================
|
||||
"File: javascript.vim
|
||||
"Description: Figures out which javascript syntax checker (if any) to load
|
||||
" from the javascript directory.
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" Use g:syntastic_javascript_checker option to specify which jslint executable
|
||||
" should be used (see below for a list of supported checkers).
|
||||
" If g:syntastic_javascript_checker is not set, just use the first syntax
|
||||
" checker that we find installed.
|
||||
"============================================================================
|
||||
if exists("loaded_javascript_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_javascript_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint"]
|
||||
|
||||
function! s:load_checker(checker)
|
||||
exec "runtime syntax_checkers/javascript/" . a:checker . ".vim"
|
||||
endfunction
|
||||
|
||||
if exists("g:syntastic_javascript_checker")
|
||||
if index(s:supported_checkers, g:syntastic_javascript_checker) != -1 && executable(g:syntastic_javascript_checker)
|
||||
call s:load_checker(g:syntastic_javascript_checker)
|
||||
else
|
||||
echoerr "Javascript syntax not supported or not installed."
|
||||
endif
|
||||
else
|
||||
for checker in s:supported_checkers
|
||||
if executable(checker)
|
||||
call s:load_checker(checker)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
20
vim/bundle/syntastic/syntax_checkers/javascript/gjslint.vim
Normal file
20
vim/bundle/syntastic/syntax_checkers/javascript/gjslint.vim
Normal file
@@ -0,0 +1,20 @@
|
||||
"============================================================================
|
||||
"File: gjslint.vim
|
||||
"Description: Javascript syntax checker - using gjslint
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
if !exists("g:syntastic_javascript_gjslint_conf")
|
||||
let g:syntastic_javascript_gjslint_conf = ""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
let makeprg = "gjslint " . g:syntastic_javascript_gjslint_conf . " --nosummary --unix_mode --nodebug_indentation --nobeep " . shellescape(expand('%'))
|
||||
let errorformat="%f:%l:(New Error -%\\?\%n) %m,%f:%l:(-%\\?%n) %m,%-G1 files checked, no errors found.,%-G%.%#"
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
21
vim/bundle/syntastic/syntax_checkers/javascript/jshint.vim
Normal file
21
vim/bundle/syntastic/syntax_checkers/javascript/jshint.vim
Normal file
@@ -0,0 +1,21 @@
|
||||
"============================================================================
|
||||
"File: jshint.vim
|
||||
"Description: Javascript syntax checker - using jshint
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
if !exists("g:syntastic_javascript_jshint_conf")
|
||||
let g:syntastic_javascript_jshint_conf = ""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
" node-jshint uses .jshintrc as config unless --config arg is present
|
||||
let args = g:syntastic_javascript_jshint_conf? ' --config ' . g:syntastic_javascript_jshint_conf : ''
|
||||
let makeprg = 'jshint ' . shellescape(expand("%")) . args
|
||||
let errorformat = '%ELine %l:%c,%Z\\s%#Reason: %m,%C%.%#,%f: line %l\, col %c\, %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
20
vim/bundle/syntastic/syntax_checkers/javascript/jsl.vim
Normal file
20
vim/bundle/syntastic/syntax_checkers/javascript/jsl.vim
Normal file
@@ -0,0 +1,20 @@
|
||||
"============================================================================
|
||||
"File: jsl.vim
|
||||
"Description: Javascript syntax checker - using jsl
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
if !exists("g:syntastic_javascript_jsl_conf")
|
||||
let g:syntastic_javascript_jsl_conf = ""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
let makeprg = "jsl " . g:syntastic_javascript_jsl_conf . " -nologo -nofilelisting -nosummary -nocontext -process ".shellescape(expand('%'))
|
||||
let errorformat='%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
31
vim/bundle/syntastic/syntax_checkers/javascript/jslint.vim
Normal file
31
vim/bundle/syntastic/syntax_checkers/javascript/jslint.vim
Normal file
@@ -0,0 +1,31 @@
|
||||
"============================================================================
|
||||
"File: jslint.vim
|
||||
"Description: Javascript syntax checker - using jslint
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"Tested with jslint 0.1.4.
|
||||
"============================================================================
|
||||
if !exists("g:syntastic_javascript_jslint_conf")
|
||||
let g:syntastic_javascript_jslint_conf = "--white --undef --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars"
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_HighlightTerm(error)
|
||||
let unexpected = matchstr(a:error['text'], 'Expected.*and instead saw \'\zs.*\ze\'')
|
||||
if len(unexpected) < 1 | return '' | end
|
||||
return '\V'.split(unexpected, "'")[1]
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
let makeprg = "jslint " . g:syntastic_javascript_jslint_conf . " " . shellescape(expand('%'))
|
||||
let errorformat='%E %##%n %m,%-Z%.%#Line %l\, Pos %c,%-G%.%#'
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
call SyntasticHighlightErrors(errors, function('SyntaxCheckers_javascript_HighlightTerm'))
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
41
vim/bundle/syntastic/syntax_checkers/json.vim
Normal file
41
vim/bundle/syntastic/syntax_checkers/json.vim
Normal file
@@ -0,0 +1,41 @@
|
||||
"============================================================================
|
||||
"File: json.vim
|
||||
"Description: Figures out which json syntax checker (if any) to load
|
||||
" from the json directory.
|
||||
"Maintainer: Miller Medeiros <contact at millermedeiros dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" Use g:syntastic_json_checker option to specify which jsonlint executable
|
||||
" should be used (see below for a list of supported checkers).
|
||||
" If g:syntastic_json_checker is not set, just use the first syntax
|
||||
" checker that we find installed.
|
||||
"============================================================================
|
||||
if exists("loaded_json_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_json_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["jsonlint", "jsonval"]
|
||||
|
||||
function! s:load_checker(checker)
|
||||
exec "runtime syntax_checkers/json/" . a:checker . ".vim"
|
||||
endfunction
|
||||
|
||||
if exists("g:syntastic_json_checker")
|
||||
if index(s:supported_checkers, g:syntastic_json_checker) != -1 && executable(g:syntastic_json_checker)
|
||||
call s:load_checker(g:syntastic_json_checker)
|
||||
else
|
||||
echoerr "JSON syntax not supported or not installed."
|
||||
endif
|
||||
else
|
||||
for checker in s:supported_checkers
|
||||
if executable(checker)
|
||||
call s:load_checker(checker)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
16
vim/bundle/syntastic/syntax_checkers/json/jsonlint.vim
Normal file
16
vim/bundle/syntastic/syntax_checkers/json/jsonlint.vim
Normal file
@@ -0,0 +1,16 @@
|
||||
"============================================================================
|
||||
"File: jsonlint.vim
|
||||
"Description: JSON syntax checker - using jsonlint
|
||||
"Maintainer: Miller Medeiros <contact at millermedeiros dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
|
||||
function! SyntaxCheckers_json_GetLocList()
|
||||
let makeprg = 'jsonlint ' . shellescape(expand("%")) . ' --compact'
|
||||
let errorformat = '%ELine %l:%c,%Z\\s%#Reason: %m,%C%.%#,%f: line %l\, col %c\, %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
17
vim/bundle/syntastic/syntax_checkers/json/jsonval.vim
Normal file
17
vim/bundle/syntastic/syntax_checkers/json/jsonval.vim
Normal file
@@ -0,0 +1,17 @@
|
||||
"============================================================================
|
||||
"File: jsonval.vim
|
||||
"Description: JSON syntax checker - using jsonval
|
||||
"Maintainer: Miller Medeiros <contact at millermedeiros dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"============================================================================
|
||||
|
||||
function! SyntaxCheckers_json_GetLocList()
|
||||
" based on https://gist.github.com/1196345
|
||||
let makeprg = 'jsonval '. shellescape(expand('%'))
|
||||
let errorformat = '%E%f:\ %m\ at\ line\ %l,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
38
vim/bundle/syntastic/syntax_checkers/less.vim
Normal file
38
vim/bundle/syntastic/syntax_checkers/less.vim
Normal file
@@ -0,0 +1,38 @@
|
||||
"============================================================================
|
||||
"File: less.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Julien Blanchard <julien at sideburns dot eu>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_less_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_less_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have the lessc binary installed
|
||||
if !executable("lessc")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_less_options")
|
||||
let g:syntastic_less_options = "--no-color"
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_less_GetLocList()
|
||||
let makeprg = 'lessc '. g:syntastic_less_options .' '. shellescape(expand('%')) . ' /dev/null'
|
||||
|
||||
"lessc >= 1.2
|
||||
let errorformat = 'ParseError: Syntax Error on line %[0-9]%# in %f:%l:%c'
|
||||
"lessc < 1.2
|
||||
let errorformat .= ', Syntax %trror on line %l in %f,Syntax %trror on line %l,! Syntax %trror: on line %l: %m,%-G%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr(""), 'text': "Syntax error"} })
|
||||
endfunction
|
||||
|
||||
58
vim/bundle/syntastic/syntax_checkers/lua.vim
Normal file
58
vim/bundle/syntastic/syntax_checkers/lua.vim
Normal file
@@ -0,0 +1,58 @@
|
||||
"============================================================================
|
||||
"File: lua.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists('loaded_lua_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_lua_syntax_checker = 1
|
||||
|
||||
" check if the lua compiler is installed
|
||||
if !executable('luac')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_lua_Term(pos)
|
||||
let near = matchstr(a:pos['text'], "near '[^']\\+'")
|
||||
let result = ''
|
||||
if len(near) > 0
|
||||
let near = split(near, "'")[1]
|
||||
if near == '<eof>'
|
||||
let p = getpos('$')
|
||||
let a:pos['lnum'] = p[1]
|
||||
let a:pos['col'] = p[2]
|
||||
let result = '\%'.p[2].'c'
|
||||
else
|
||||
let result = '\V'.near
|
||||
endif
|
||||
let open = matchstr(a:pos['text'], "(to close '[^']\\+' at line [0-9]\\+)")
|
||||
if len(open) > 0
|
||||
let oline = split(open, "'")[1:2]
|
||||
let line = 0+strpart(oline[1], 9)
|
||||
call matchadd('SpellCap', '\%'.line.'l\V'.oline[0])
|
||||
endif
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_lua_GetLocList()
|
||||
let makeprg = 'luac -p ' . shellescape(expand('%'))
|
||||
let errorformat = 'luac: %#%f:%l: %m'
|
||||
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': { 'bufnr': bufnr(''), 'type': 'E' } })
|
||||
|
||||
call SyntasticHighlightErrors(loclist, function("SyntaxCheckers_lua_Term"))
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
28
vim/bundle/syntastic/syntax_checkers/matlab.vim
Normal file
28
vim/bundle/syntastic/syntax_checkers/matlab.vim
Normal file
@@ -0,0 +1,28 @@
|
||||
"============================================================================
|
||||
"File: matlab.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Jason Graham <jason at the-graham dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("loaded_matlab_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_matlab_syntax_checker = 1
|
||||
|
||||
"bail if the user doesn't have mlint installed
|
||||
if !executable("mlint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_matlab_GetLocList()
|
||||
let makeprg = 'mlint -id $* '.shellescape(expand('%'))
|
||||
let errorformat = 'L %l (C %c): %*[a-zA-Z0-9]: %m,L %l (C %c-%*[0-9]): %*[a-zA-Z0-9]: %m'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
endfunction
|
||||
|
||||
89
vim/bundle/syntastic/syntax_checkers/ocaml.vim
Normal file
89
vim/bundle/syntastic/syntax_checkers/ocaml.vim
Normal file
@@ -0,0 +1,89 @@
|
||||
"============================================================================
|
||||
"File: ocaml.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Török Edwin <edwintorok at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" By default the camlp4o preprocessor is used to check the syntax of .ml, and .mli files,
|
||||
" ocamllex is used to check .mll files and menhir is used to check .mly files.
|
||||
" The output is all redirected to /dev/null, nothing is written to the disk.
|
||||
"
|
||||
" If your source code needs camlp4r then you can define this in your .vimrc:
|
||||
"
|
||||
" let g:syntastic_ocaml_camlp4r = 1
|
||||
"
|
||||
" If you used some syntax extensions, or you want to also typecheck the source
|
||||
" code, then you can define this:
|
||||
"
|
||||
" let g:syntastic_ocaml_use_ocamlbuild = 1
|
||||
"
|
||||
" This will run ocamlbuild <name>.inferred.mli, so it will write to your _build
|
||||
" directory (and possibly rebuild your myocamlbuild.ml plugin), only enable this
|
||||
" if you are ok with that.
|
||||
"
|
||||
" If you are using syntax extensions / external libraries and have a properly
|
||||
" set up _tags (and myocamlbuild.ml file) then it should just work
|
||||
" to enable this flag and get syntax / type checks through syntastic.
|
||||
"
|
||||
" For best results your current directory should be the project root
|
||||
" (same situation if you want useful output from :make).
|
||||
|
||||
if exists("loaded_ocaml_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_ocaml_syntax_checker = 1
|
||||
|
||||
if exists('g:syntastic_ocaml_camlp4r') &&
|
||||
\ g:syntastic_ocaml_camlp4r != 0
|
||||
let s:ocamlpp="camlp4r"
|
||||
else
|
||||
let s:ocamlpp="camlp4o"
|
||||
endif
|
||||
|
||||
"bail if the user doesnt have the preprocessor
|
||||
if !executable(s:ocamlpp)
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_ocaml_GetLocList()
|
||||
if exists('g:syntastic_ocaml_use_ocamlbuild') &&
|
||||
\ g:syntastic_ocaml_use_ocamlbuild != 0 &&
|
||||
\ executable("ocamlbuild") &&
|
||||
\ isdirectory('_build')
|
||||
let makeprg = "ocamlbuild -quiet -no-log -tag annot,". s:ocamlpp. " -no-links -no-hygiene -no-sanitize ".
|
||||
\ shellescape(expand('%:r')).".cmi"
|
||||
else
|
||||
let extension = expand('%:e')
|
||||
if match(extension, 'mly') >= 0
|
||||
" ocamlyacc output can't be redirected, so use menhir
|
||||
if !executable("menhir")
|
||||
return []
|
||||
endif
|
||||
let makeprg = "menhir --only-preprocess ".shellescape(expand('%')) . " >/dev/null"
|
||||
elseif match(extension,'mll') >= 0
|
||||
if !executable("ocamllex")
|
||||
return []
|
||||
endif
|
||||
let makeprg = "ocamllex -q -o /dev/null ".shellescape(expand('%'))
|
||||
else
|
||||
let makeprg = "camlp4o -o /dev/null ".shellescape(expand('%'))
|
||||
endif
|
||||
endif
|
||||
let errorformat = '%AFile "%f"\, line %l\, characters %c-%*\d:,'.
|
||||
\ '%AFile "%f"\, line %l\, characters %c-%*\d (end at line %*\d\, character %*\d):,'.
|
||||
\ '%AFile "%f"\, line %l\, character %c:,'.
|
||||
\ '%AFile "%f"\, line %l\, character %c:%m,'.
|
||||
\ '%-GPreprocessing error %.%#,'.
|
||||
\ '%-GCommand exited %.%#,'.
|
||||
\ '%C%tarning %n: %m,'.
|
||||
\ '%C%m,'.
|
||||
\ '%-G+%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
35
vim/bundle/syntastic/syntax_checkers/perl.vim
Normal file
35
vim/bundle/syntastic/syntax_checkers/perl.vim
Normal file
@@ -0,0 +1,35 @@
|
||||
"============================================================================
|
||||
"File: perl.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Anthony Carapetis <anthony.carapetis at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" This checker requires efm_perl.pl, which is distributed with Vim version
|
||||
" seven and greater, as far as I know.
|
||||
|
||||
if exists("loaded_perl_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_perl_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have perl installed
|
||||
if !executable("perl")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_perl_efm_program")
|
||||
let g:syntastic_perl_efm_program = 'perl '.$VIMRUNTIME.'/tools/efm_perl.pl -c'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_perl_GetLocList()
|
||||
let makeprg = g:syntastic_perl_efm_program . ' ' . shellescape(expand('%'))
|
||||
let errorformat = '%f:%l:%m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
57
vim/bundle/syntastic/syntax_checkers/php.vim
Normal file
57
vim/bundle/syntastic/syntax_checkers/php.vim
Normal file
@@ -0,0 +1,57 @@
|
||||
"============================================================================
|
||||
"File: php.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_php_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_php_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have php installed
|
||||
if !executable("php")
|
||||
finish
|
||||
endif
|
||||
|
||||
"Support passing configuration directives to phpcs
|
||||
if !exists("g:syntastic_phpcs_conf")
|
||||
let g:syntastic_phpcs_conf = ""
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_phpcs_disable")
|
||||
let g:syntastic_phpcs_disable = 0
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_php_Term(item)
|
||||
let unexpected = matchstr(a:item['text'], "unexpected '[^']\\+'")
|
||||
if len(unexpected) < 1 | return '' | end
|
||||
return '\V'.split(unexpected, "'")[1]
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_php_GetLocList()
|
||||
|
||||
let errors = []
|
||||
if !g:syntastic_phpcs_disable && executable("phpcs")
|
||||
let errors = s:GetPHPCSErrors()
|
||||
endif
|
||||
|
||||
let makeprg = "php -l ".shellescape(expand('%'))
|
||||
let errorformat='%-GNo syntax errors detected in%.%#,PHP Parse error: %#syntax %trror\, %m in %f on line %l,PHP Fatal %trror: %m in %f on line %l,%-GErrors parsing %.%#,%-G\s%#,Parse error: %#syntax %trror\, %m in %f on line %l,Fatal %trror: %m in %f on line %l'
|
||||
let errors = errors + SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
call SyntasticHighlightErrors(errors, function('SyntaxCheckers_php_Term'))
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
function! s:GetPHPCSErrors()
|
||||
let makeprg = "phpcs " . g:syntastic_phpcs_conf . " --report=csv ".shellescape(expand('%'))
|
||||
let errorformat = '%-GFile\,Line\,Column\,Type\,Message\,Source\,Severity,"%f"\,%l\,%c\,%t%*[a-zA-Z]\,"%m"\,%*[a-zA-Z0-9_.-]\,%*[0-9]'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
38
vim/bundle/syntastic/syntax_checkers/puppet.vim
Normal file
38
vim/bundle/syntastic/syntax_checkers/puppet.vim
Normal file
@@ -0,0 +1,38 @@
|
||||
"============================================================================
|
||||
"File: puppet.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Eivind Uggedal <eivind at uggedal dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_puppet_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_puppet_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have puppet installed
|
||||
if !executable("puppet")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_puppet_GetLocList()
|
||||
let l:puppetVersion = system("puppet --version")
|
||||
let l:digits = split(l:puppetVersion, "\\.")
|
||||
"
|
||||
" If it is on the 2.7 series... use new executable
|
||||
if l:digits[0] == '2' && l:digits[1] == '7'
|
||||
let makeprg = 'puppet parser validate ' .
|
||||
\ shellescape(expand('%')) .
|
||||
\ ' --color=false --ignoreimport'
|
||||
else
|
||||
let makeprg = 'puppet --color=false --parseonly --ignoreimport '.shellescape(expand('%'))
|
||||
endif
|
||||
|
||||
let errorformat = 'err: Could not parse for environment %*[a-z]: %m at %f:%l'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
77
vim/bundle/syntastic/syntax_checkers/python.vim
Normal file
77
vim/bundle/syntastic/syntax_checkers/python.vim
Normal file
@@ -0,0 +1,77 @@
|
||||
"============================================================================
|
||||
"File: python.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"
|
||||
"Authors: Martin Grenfell <martin.grenfell@gmail.com>
|
||||
" kstep <me@kstep.me>
|
||||
" Parantapa Bhattacharya <parantapa@gmail.com>
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" For forcing the use of flake8, pyflakes, or pylint set
|
||||
"
|
||||
" let g:syntastic_python_checker = 'pyflakes'
|
||||
"
|
||||
" in your .vimrc. Default is flake8.
|
||||
|
||||
if exists("loaded_python_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_python_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have his favorite checker or flake8 or pyflakes installed
|
||||
if !exists('g:syntastic_python_checker') || !executable('g:syntastic_python_checker')
|
||||
if executable("flake8")
|
||||
let g:syntastic_python_checker = 'flake8'
|
||||
elseif executable("pyflakes")
|
||||
let g:syntastic_python_checker = 'pyflakes'
|
||||
elseif executable("pylint")
|
||||
let g:syntastic_python_checker = 'pylint'
|
||||
else
|
||||
finish
|
||||
endif
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_python_Term(i)
|
||||
if a:i['type'] ==# 'E'
|
||||
let a:i['text'] = "Syntax error"
|
||||
endif
|
||||
if match(a:i['text'], 'is assigned to but never used') > -1
|
||||
\ || match(a:i['text'], 'imported but unused') > -1
|
||||
\ || match(a:i['text'], 'undefined name') > -1
|
||||
\ || match(a:i['text'], 'redefinition of') > -1
|
||||
\ || match(a:i['text'], 'referenced before assignment') > -1
|
||||
\ || match(a:i['text'], 'duplicate argument') > -1
|
||||
\ || match(a:i['text'], 'after other statements') > -1
|
||||
\ || match(a:i['text'], 'shadowed by loop variable') > -1
|
||||
|
||||
let term = split(a:i['text'], "'", 1)[1]
|
||||
return '\V\<'.term.'\>'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
if g:syntastic_python_checker == 'pylint'
|
||||
function! SyntaxCheckers_python_GetLocList()
|
||||
let makeprg = 'pylint -f parseable -r n -i y ' .
|
||||
\ shellescape(expand('%')) .
|
||||
\ ' \| sed ''s_: \[[RC]_: \[W_''' .
|
||||
\ ' \| sed ''s_: \[[F]_:\ \[E_'''
|
||||
let errorformat = '%f:%l: [%t%n] %m,%-GNo config%m'
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
else
|
||||
function! SyntaxCheckers_python_GetLocList()
|
||||
let makeprg = g:syntastic_python_checker.' '.shellescape(expand('%'))
|
||||
let errorformat =
|
||||
\ '%E%f:%l: could not compile,%-Z%p^,%W%f:%l:%c: %m,%W%f:%l: %m,%-G%.%#'
|
||||
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
call SyntasticHighlightErrors(errors, function('SyntaxCheckers_python_Term'))
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
endif
|
||||
37
vim/bundle/syntastic/syntax_checkers/rst.vim
Normal file
37
vim/bundle/syntastic/syntax_checkers/rst.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
"============================================================================
|
||||
"File: rst.vim
|
||||
"Description: Syntax checking plugin for docutil's reStructuredText files
|
||||
"Maintainer: James Rowe <jnrowe at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" We use rst2pseudoxml.py, as it is ever so marginally faster than the other
|
||||
" rst2${x} tools in docutils.
|
||||
|
||||
if exists("loaded_rst_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_rst_syntax_checker = 1
|
||||
|
||||
"bail if the user doesn't have rst2pseudoxml.py installed
|
||||
if !executable("rst2pseudoxml.py")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_rst_GetLocList()
|
||||
let makeprg = 'rst2pseudoxml.py --report=1 --exit-status=1 ' .
|
||||
\ shellescape(expand('%')) . ' /dev/null'
|
||||
|
||||
let errorformat = '%f:%l:\ (%tNFO/1)\ %m,
|
||||
\%f:%l:\ (%tARNING/2)\ %m,
|
||||
\%f:%l:\ (%tRROR/3)\ %m,
|
||||
\%f:%l:\ (%tEVERE/4)\ %m,
|
||||
\%-G%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
32
vim/bundle/syntastic/syntax_checkers/ruby.vim
Normal file
32
vim/bundle/syntastic/syntax_checkers/ruby.vim
Normal file
@@ -0,0 +1,32 @@
|
||||
"============================================================================
|
||||
"File: ruby.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_ruby_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_ruby_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have ruby installed
|
||||
if !executable("ruby")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_ruby_GetLocList()
|
||||
" we cannot set RUBYOPT on windows like that
|
||||
if has('win32') || has('win64')
|
||||
let makeprg = 'ruby -W1 -T1 -c '.shellescape(expand('%'))
|
||||
else
|
||||
let makeprg = 'RUBYOPT= ruby -W1 -c '.shellescape(expand('%'))
|
||||
endif
|
||||
let errorformat = '%-GSyntax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
35
vim/bundle/syntastic/syntax_checkers/sass.vim
Normal file
35
vim/bundle/syntastic/syntax_checkers/sass.vim
Normal file
@@ -0,0 +1,35 @@
|
||||
"============================================================================
|
||||
"File: sass.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_sass_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_sass_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have the sass binary installed
|
||||
if !executable("sass")
|
||||
finish
|
||||
endif
|
||||
|
||||
"use compass imports if available
|
||||
let s:imports = ""
|
||||
if executable("compass")
|
||||
let s:imports = "--compass"
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_sass_GetLocList()
|
||||
let makeprg='sass '.s:imports.' --check '.shellescape(expand('%'))
|
||||
let errorformat = '%ESyntax %trror:%m,%C on line %l of %f,%Z%.%#'
|
||||
let errorformat .= ',%Wwarning on line %l:,%Z%m,Syntax %trror on line %l: %m'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
27
vim/bundle/syntastic/syntax_checkers/scss.vim
Normal file
27
vim/bundle/syntastic/syntax_checkers/scss.vim
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
"============================================================================
|
||||
"File: scss.vim
|
||||
"Description: scss syntax checking plugin for syntastic
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_scss_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_scss_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have the sass binary installed
|
||||
if !executable("sass")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime syntax_checkers/sass.vim
|
||||
|
||||
function! SyntaxCheckers_scss_GetLocList()
|
||||
return SyntaxCheckers_sass_GetLocList()
|
||||
endfunction
|
||||
52
vim/bundle/syntastic/syntax_checkers/sh.vim
Normal file
52
vim/bundle/syntastic/syntax_checkers/sh.vim
Normal file
@@ -0,0 +1,52 @@
|
||||
"============================================================================
|
||||
"File: sh.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists('loaded_sh_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_sh_syntax_checker = 1
|
||||
|
||||
function! s:GetShell()
|
||||
if !exists('b:shell') || b:shell == ""
|
||||
let b:shell = ''
|
||||
let shebang = getbufline(bufnr('%'), 1)[0]
|
||||
if len(shebang) > 0
|
||||
if match(shebang, 'bash') >= 0
|
||||
let b:shell = 'bash'
|
||||
elseif match(shebang, 'zsh') >= 0
|
||||
let b:shell = 'zsh'
|
||||
elseif match(shebang, 'sh') >= 0
|
||||
let b:shell = 'sh'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return b:shell
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_sh_GetLocList()
|
||||
if len(s:GetShell()) == 0 || !executable(s:GetShell())
|
||||
return []
|
||||
endif
|
||||
let output = split(system(s:GetShell().' -n '.shellescape(expand('%'))), '\n')
|
||||
if v:shell_error != 0
|
||||
let result = []
|
||||
for err_line in output
|
||||
let line = substitute(err_line, '^[^:]*:\D\{-}\(\d\+\):.*', '\1', '')
|
||||
let msg = substitute(err_line, '^[^:]*:\D\{-}\d\+: \(.*\)', '\1', '')
|
||||
call add(result, {'lnum' : line,
|
||||
\ 'text' : msg,
|
||||
\ 'bufnr': bufnr(''),
|
||||
\ 'type': 'E' })
|
||||
endfor
|
||||
return result
|
||||
endif
|
||||
return []
|
||||
endfunction
|
||||
28
vim/bundle/syntastic/syntax_checkers/tcl.vim
Normal file
28
vim/bundle/syntastic/syntax_checkers/tcl.vim
Normal file
@@ -0,0 +1,28 @@
|
||||
"============================================================================
|
||||
"File: tcl.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Eric Thomas <eric.l.m.thomas at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("loaded_tcl_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_tcl_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tclsh installed
|
||||
if !executable("tclsh")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_tcl_GetLocList()
|
||||
let makeprg = 'tclsh '.shellescape(expand('%'))
|
||||
let errorformat = '%f:%l:%m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
26
vim/bundle/syntastic/syntax_checkers/tex.vim
Normal file
26
vim/bundle/syntastic/syntax_checkers/tex.vim
Normal file
@@ -0,0 +1,26 @@
|
||||
"============================================================================
|
||||
"File: tex.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_tex_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_tex_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have lacheck installed
|
||||
if !executable("lacheck")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_tex_GetLocList()
|
||||
let makeprg = 'lacheck '.shellescape(expand('%'))
|
||||
let errorformat = '%-G** %f:,%E"%f"\, line %l: %m'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
56
vim/bundle/syntastic/syntax_checkers/vala.vim
Normal file
56
vim/bundle/syntastic/syntax_checkers/vala.vim
Normal file
@@ -0,0 +1,56 @@
|
||||
"============================================================================
|
||||
"File: vala.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Konstantin Stepanov (me@kstep.me)
|
||||
"Notes: Add special comment line into your vala file starting with
|
||||
" "// modules: " and containing space delimited list of vala
|
||||
" modules, used by the file, so this script can build correct
|
||||
" --pkg arguments.
|
||||
" Valac compiler is not the fastest thing in the world, so you
|
||||
" may want to disable this plugin with
|
||||
" let g:syntastic_vala_check_disabled = 1 command in your .vimrc or
|
||||
" command line. Unlet this variable to set it to 0 to reenable
|
||||
" this checker.
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists('loaded_vala_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_vala_syntax_checker = 1
|
||||
|
||||
if !executable('valac')
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists('g:syntastic_vala_check_disabled') && g:syntastic_vala_check_disabled
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_vala_Term(pos)
|
||||
let strlength = strlen(matchstr(a:pos['text'], '\^\+$'))
|
||||
return '\%>'.(a:pos.col-1).'c.*\%<'.(a:pos.col+strlength+1).'c'
|
||||
endfunction
|
||||
|
||||
function! s:GetValaModules()
|
||||
let modules_line = search('^// modules: ', 'n')
|
||||
let modules_str = getline(modules_line)
|
||||
let modules = split(strpart(modules_str, 12), '\s\+')
|
||||
return modules
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_vala_GetLocList()
|
||||
let vala_pkg_args = join(map(s:GetValaModules(), '"--pkg ".v:val'), ' ')
|
||||
let makeprg = 'valac -C ' . vala_pkg_args . ' ' .shellescape(expand('%'))
|
||||
let errorformat = '%A%f:%l.%c-%\d%\+.%\d%\+: %t%[a-z]%\+: %m,%C%m,%Z%m'
|
||||
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
call SyntasticHighlightErrors(loclist, function("SyntaxCheckers_vala_Term"), 1)
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
46
vim/bundle/syntastic/syntax_checkers/xhtml.vim
Normal file
46
vim/bundle/syntastic/syntax_checkers/xhtml.vim
Normal file
@@ -0,0 +1,46 @@
|
||||
"============================================================================
|
||||
"File: xhtml.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_xhtml_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_xhtml_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("tidy")
|
||||
finish
|
||||
endif
|
||||
|
||||
" TODO: join this with html.vim DRY's sake?
|
||||
function! s:TidyEncOptByFenc()
|
||||
let tidy_opts = {
|
||||
\'utf-8' : '-utf8',
|
||||
\'ascii' : '-ascii',
|
||||
\'latin1' : '-latin1',
|
||||
\'iso-2022-jp' : '-iso-2022',
|
||||
\'cp1252' : '-win1252',
|
||||
\'macroman' : '-mac',
|
||||
\'utf-16le' : '-utf16le',
|
||||
\'utf-16' : '-utf16',
|
||||
\'big5' : '-big5',
|
||||
\'sjis' : '-shiftjis',
|
||||
\'cp850' : '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_xhtml_GetLocList()
|
||||
|
||||
let encopt = s:TidyEncOptByFenc()
|
||||
let makeprg="tidy ".encopt." -xml -e ".shellescape(expand('%'))
|
||||
let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
endfunction
|
||||
42
vim/bundle/syntastic/syntax_checkers/xml.vim
Normal file
42
vim/bundle/syntastic/syntax_checkers/xml.vim
Normal file
@@ -0,0 +1,42 @@
|
||||
"============================================================================
|
||||
"File: xml.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Sebastian Kusnier <sebastian at kusnier dot net>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" You can use a local installation of DTDs to significantly speed up validation
|
||||
" and allow you to validate XML data without network access, see xmlcatalog(1)
|
||||
" and http://www.xmlsoft.org/catalog.html for more information.
|
||||
|
||||
if exists("loaded_xml_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_xml_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("xmllint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_xml_GetLocList()
|
||||
|
||||
let makeprg="xmllint --xinclude --noout --postvalid " . shellescape(expand("%:p"))
|
||||
let errorformat='%E%f:%l:\ error\ :\ %m,
|
||||
\%-G%f:%l:\ validity\ error\ :\ Validation\ failed:\ no\ DTD\ found\ %m,
|
||||
\%W%f:%l:\ warning\ :\ %m,
|
||||
\%W%f:%l:\ validity\ warning\ :\ %m,
|
||||
\%E%f:%l:\ validity\ error\ :\ %m,
|
||||
\%E%f:%l:\ parser\ error\ :\ %m,
|
||||
\%E%f:%l:\ %m,
|
||||
\%-Z%p^,
|
||||
\%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
38
vim/bundle/syntastic/syntax_checkers/xslt.vim
Normal file
38
vim/bundle/syntastic/syntax_checkers/xslt.vim
Normal file
@@ -0,0 +1,38 @@
|
||||
"============================================================================
|
||||
"File: xslt.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Sebastian Kusnier <sebastian at kusnier dot net>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_xslt_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_xslt_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("xmllint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_xslt_GetLocList()
|
||||
|
||||
let makeprg="xmllint --xinclude --noout --postvalid " . shellescape(expand("%:p"))
|
||||
let errorformat='%E%f:%l:\ error\ :\ %m,
|
||||
\%-G%f:%l:\ validity\ error\ :\ Validation\ failed:\ no\ DTD\ found\ %m,
|
||||
\%W%f:%l:\ warning\ :\ %m,
|
||||
\%W%f:%l:\ validity\ warning\ :\ %m,
|
||||
\%E%f:%l:\ validity\ error\ :\ %m,
|
||||
\%E%f:%l:\ parser\ error\ :\ %m,
|
||||
\%E%f:%l:\ namespace\ error\ :\ %m,
|
||||
\%E%f:%l:\ %m,
|
||||
\%-Z%p^,
|
||||
\%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
30
vim/bundle/syntastic/syntax_checkers/yaml.vim
Normal file
30
vim/bundle/syntastic/syntax_checkers/yaml.vim
Normal file
@@ -0,0 +1,30 @@
|
||||
"============================================================================
|
||||
"File: yaml.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"
|
||||
"Installation: $ npm install -g js-yaml.bin
|
||||
"
|
||||
"============================================================================
|
||||
if exists("loaded_yaml_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_yaml_syntax_checker = 1
|
||||
|
||||
if !executable("js-yaml")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_yaml_GetLocList()
|
||||
let makeprg='js-yaml --compact ' . shellescape(expand('%'))
|
||||
let errorformat='Error on line %l\, col %c:%m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
endfunction
|
||||
36
vim/bundle/syntastic/syntax_checkers/zpt.vim
Normal file
36
vim/bundle/syntastic/syntax_checkers/zpt.vim
Normal file
@@ -0,0 +1,36 @@
|
||||
"============================================================================
|
||||
"File: zpt.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: claytron <robots at claytron dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" In order for this plugin to be useful, you will need to set up the
|
||||
" zpt filetype in your vimrc
|
||||
"
|
||||
" " set up zope page templates as the zpt filetype
|
||||
" au BufNewFile,BufRead *.pt,*.cpt,*.zpt set filetype=zpt syntax=xml
|
||||
"
|
||||
" Then install the zptlint program, found on pypi:
|
||||
" http://pypi.python.org/pypi/zptlint
|
||||
|
||||
if exists("loaded_zpt_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_zpt_syntax_checker = 1
|
||||
|
||||
" Bail if the user doesn't have zptlint installed
|
||||
if !executable("zptlint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_zpt_GetLocList()
|
||||
let makeprg="zptlint ".shellescape(expand('%'))
|
||||
let errorformat='%-P*** Error in: %f,%Z%*\s\, at line %l\, column %c,%E%*\s%m,%-Q'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
22
vim/bundle/ubuntu-vim72/autoload/README.txt
Normal file
22
vim/bundle/ubuntu-vim72/autoload/README.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
The autoload directory is for standard Vim autoload scripts.
|
||||
|
||||
These are functions used by plugins and for general use. They will be loaded
|
||||
automatically when the function is invoked. See ":help autoload".
|
||||
|
||||
gzip.vim for editing compressed files
|
||||
netrw*.vim browsing (remote) directories and editing remote files
|
||||
tar.vim browsing tar files
|
||||
zip.vim browsing zip files
|
||||
paste.vim common code for mswin.vim, menu.vim and macmap.vim
|
||||
spellfile.vim downloading of a missing spell file
|
||||
|
||||
Omni completion files:
|
||||
ccomplete.vim C
|
||||
csscomplete.vim HTML / CSS
|
||||
htmlcomplete.vim HTML
|
||||
javascriptcomplete.vim Javascript
|
||||
phpcomplete.vim PHP
|
||||
pythoncomplete.vim Python
|
||||
rubycomplete.vim Ruby
|
||||
syntaxcomplete.vim from syntax highlighting
|
||||
xmlcomplete.vim XML (uses files in the xml directory)
|
||||
630
vim/bundle/ubuntu-vim72/autoload/ada.vim
Normal file
630
vim/bundle/ubuntu-vim72/autoload/ada.vim
Normal file
@@ -0,0 +1,630 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Perform Ada specific completion & tagging.
|
||||
" Language: Ada (2005)
|
||||
" $Id: ada.vim 887 2008-07-08 14:29:01Z krischik $
|
||||
" Maintainer: Martin Krischik <krischik@users.sourceforge.net>
|
||||
" Taylor Venable <taylor@metasyntax.net>
|
||||
" Neil Bird <neil@fnxweb.com>
|
||||
" Ned Okie <nokie@radford.edu>
|
||||
" $Author: krischik $
|
||||
" $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
|
||||
" Version: 4.6
|
||||
" $Revision: 887 $
|
||||
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/ada.vim $
|
||||
" History: 24.05.2006 MK Unified Headers
|
||||
" 26.05.2006 MK ' should not be in iskeyword.
|
||||
" 16.07.2006 MK Ada-Mode as vim-ball
|
||||
" 02.10.2006 MK Better folding.
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested not to use include protection for
|
||||
" autoload
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" 08.07.2007 TV fix mapleader problems.
|
||||
" 09.05.2007 MK Session just won't work no matter how much
|
||||
" tweaking is done
|
||||
" 19.09.2007 NO still some mapleader problems
|
||||
" Help Page: ft-ada-functions
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
if version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
" Section: Constants {{{1
|
||||
"
|
||||
let g:ada#DotWordRegex = '\a\w*\(\_s*\.\_s*\a\w*\)*'
|
||||
let g:ada#WordRegex = '\a\w*'
|
||||
let g:ada#Comment = "\\v^(\"[^\"]*\"|'.'|[^\"']){-}\\zs\\s*--.*"
|
||||
let g:ada#Keywords = []
|
||||
|
||||
" Section: g:ada#Keywords {{{1
|
||||
"
|
||||
" Section: add Ada keywords {{{2
|
||||
"
|
||||
for Item in ['abort', 'else', 'new', 'return', 'abs', 'elsif', 'not', 'reverse', 'abstract', 'end', 'null', 'accept', 'entry', 'select', 'access', 'exception', 'of', 'separate', 'aliased', 'exit', 'or', 'subtype', 'all', 'others', 'synchronized', 'and', 'for', 'out', 'array', 'function', 'overriding', 'tagged', 'at', 'task', 'generic', 'package', 'terminate', 'begin', 'goto', 'pragma', 'then', 'body', 'private', 'type', 'if', 'procedure', 'case', 'in', 'protected', 'until', 'constant', 'interface', 'use', 'is', 'raise', 'declare', 'range', 'when', 'delay', 'limited', 'record', 'while', 'delta', 'loop', 'rem', 'with', 'digits', 'renames', 'do', 'mod', 'requeue', 'xor']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'keyword',
|
||||
\ 'info': 'Ada keyword.',
|
||||
\ 'kind': 'k',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
|
||||
" Section: GNAT Project Files {{{3
|
||||
"
|
||||
if exists ('g:ada_with_gnat_project_files')
|
||||
for Item in ['project']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'keyword',
|
||||
\ 'info': 'GNAT projectfile keyword.',
|
||||
\ 'kind': 'k',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Section: add standart exception {{{2
|
||||
"
|
||||
for Item in ['Constraint_Error', 'Program_Error', 'Storage_Error', 'Tasking_Error', 'Status_Error', 'Mode_Error', 'Name_Error', 'Use_Error', 'Device_Error', 'End_Error', 'Data_Error', 'Layout_Error', 'Length_Error', 'Pattern_Error', 'Index_Error', 'Translation_Error', 'Time_Error', 'Argument_Error', 'Tag_Error', 'Picture_Error', 'Terminator_Error', 'Conversion_Error', 'Pointer_Error', 'Dereference_Error', 'Update_Error']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'exception',
|
||||
\ 'info': 'Ada standart exception.',
|
||||
\ 'kind': 'x',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
|
||||
" Section: add GNAT exception {{{3
|
||||
"
|
||||
if exists ('g:ada_gnat_extensions')
|
||||
for Item in ['Assert_Failure']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'exception',
|
||||
\ 'info': 'GNAT exception.',
|
||||
\ 'kind': 'x',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Section: add Ada buildin types {{{2
|
||||
"
|
||||
for Item in ['Boolean', 'Integer', 'Natural', 'Positive', 'Float', 'Character', 'Wide_Character', 'Wide_Wide_Character', 'String', 'Wide_String', 'Wide_Wide_String', 'Duration']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'type',
|
||||
\ 'info': 'Ada buildin type.',
|
||||
\ 'kind': 't',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
|
||||
" Section: add GNAT buildin types {{{3
|
||||
"
|
||||
if exists ('g:ada_gnat_extensions')
|
||||
for Item in ['Short_Integer', 'Short_Short_Integer', 'Long_Integer', 'Long_Long_Integer', 'Short_Float', 'Short_Short_Float', 'Long_Float', 'Long_Long_Float']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'type',
|
||||
\ 'info': 'GNAT buildin type.',
|
||||
\ 'kind': 't',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Section: add Ada Attributes {{{2
|
||||
"
|
||||
for Item in ['''Access', '''Address', '''Adjacent', '''Aft', '''Alignment', '''Base', '''Bit_Order', '''Body_Version', '''Callable', '''Caller', '''Ceiling', '''Class', '''Component_Size', '''Compose', '''Constrained', '''Copy_Sign', '''Count', '''Definite', '''Delta', '''Denorm', '''Digits', '''Emax', '''Exponent', '''External_Tag', '''Epsilon', '''First', '''First_Bit', '''Floor', '''Fore', '''Fraction', '''Identity', '''Image', '''Input', '''Large', '''Last', '''Last_Bit', '''Leading_Part', '''Length', '''Machine', '''Machine_Emax', '''Machine_Emin', '''Machine_Mantissa', '''Machine_Overflows', '''Machine_Radix', '''Machine_Rounding', '''Machine_Rounds', '''Mantissa', '''Max', '''Max_Size_In_Storage_Elements', '''Min', '''Mod', '''Model', '''Model_Emin', '''Model_Epsilon', '''Model_Mantissa', '''Model_Small', '''Modulus', '''Output', '''Partition_ID', '''Pos', '''Position', '''Pred', '''Priority', '''Range', '''Read', '''Remainder', '''Round', '''Rounding', '''Safe_Emax', '''Safe_First', '''Safe_Large', '''Safe_Last', '''Safe_Small', '''Scale', '''Scaling', '''Signed_Zeros', '''Size', '''Small', '''Storage_Pool', '''Storage_Size', '''Stream_Size', '''Succ', '''Tag', '''Terminated', '''Truncation', '''Unbiased_Rounding', '''Unchecked_Access', '''Val', '''Valid', '''Value', '''Version', '''Wide_Image', '''Wide_Value', '''Wide_Wide_Image', '''Wide_Wide_Value', '''Wide_Wide_Width', '''Wide_Width', '''Width', '''Write']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'attribute',
|
||||
\ 'info': 'Ada attribute.',
|
||||
\ 'kind': 'a',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
|
||||
" Section: add GNAT Attributes {{{3
|
||||
"
|
||||
if exists ('g:ada_gnat_extensions')
|
||||
for Item in ['''Abort_Signal', '''Address_Size', '''Asm_Input', '''Asm_Output', '''AST_Entry', '''Bit', '''Bit_Position', '''Code_Address', '''Default_Bit_Order', '''Elaborated', '''Elab_Body', '''Elab_Spec', '''Emax', '''Enum_Rep', '''Epsilon', '''Fixed_Value', '''Has_Access_Values', '''Has_Discriminants', '''Img', '''Integer_Value', '''Machine_Size', '''Max_Interrupt_Priority', '''Max_Priority', '''Maximum_Alignment', '''Mechanism_Code', '''Null_Parameter', '''Object_Size', '''Passed_By_Reference', '''Range_Length', '''Storage_Unit', '''Target_Name', '''Tick', '''To_Address', '''Type_Class', '''UET_Address', '''Unconstrained_Array', '''Universal_Literal_String', '''Unrestricted_Access', '''VADS_Size', '''Value_Size', '''Wchar_T_Size', '''Word_Size']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'attribute',
|
||||
\ 'info': 'GNAT attribute.',
|
||||
\ 'kind': 'a',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Section: add Ada Pragmas {{{2
|
||||
"
|
||||
for Item in ['All_Calls_Remote', 'Assert', 'Assertion_Policy', 'Asynchronous', 'Atomic', 'Atomic_Components', 'Attach_Handler', 'Controlled', 'Convention', 'Detect_Blocking', 'Discard_Names', 'Elaborate', 'Elaborate_All', 'Elaborate_Body', 'Export', 'Import', 'Inline', 'Inspection_Point', 'Interface (Obsolescent)', 'Interrupt_Handler', 'Interrupt_Priority', 'Linker_Options', 'List', 'Locking_Policy', 'Memory_Size (Obsolescent)', 'No_Return', 'Normalize_Scalars', 'Optimize', 'Pack', 'Page', 'Partition_Elaboration_Policy', 'Preelaborable_Initialization', 'Preelaborate', 'Priority', 'Priority_Specific_Dispatching', 'Profile', 'Pure', 'Queueing_Policy', 'Relative_Deadline', 'Remote_Call_Interface', 'Remote_Types', 'Restrictions', 'Reviewable', 'Shared (Obsolescent)', 'Shared_Passive', 'Storage_Size', 'Storage_Unit (Obsolescent)', 'Suppress', 'System_Name (Obsolescent)', 'Task_Dispatching_Policy', 'Unchecked_Union', 'Unsuppress', 'Volatile', 'Volatile_Components']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'pragma',
|
||||
\ 'info': 'Ada pragma.',
|
||||
\ 'kind': 'p',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
|
||||
" Section: add GNAT Pragmas {{{3
|
||||
"
|
||||
if exists ('g:ada_gnat_extensions')
|
||||
for Item in ['Abort_Defer', 'Ada_83', 'Ada_95', 'Ada_05', 'Annotate', 'Ast_Entry', 'C_Pass_By_Copy', 'Comment', 'Common_Object', 'Compile_Time_Warning', 'Complex_Representation', 'Component_Alignment', 'Convention_Identifier', 'CPP_Class', 'CPP_Constructor', 'CPP_Virtual', 'CPP_Vtable', 'Debug', 'Elaboration_Checks', 'Eliminate', 'Export_Exception', 'Export_Function', 'Export_Object', 'Export_Procedure', 'Export_Value', 'Export_Valued_Procedure', 'Extend_System', 'External', 'External_Name_Casing', 'Finalize_Storage_Only', 'Float_Representation', 'Ident', 'Import_Exception', 'Import_Function', 'Import_Object', 'Import_Procedure', 'Import_Valued_Procedure', 'Initialize_Scalars', 'Inline_Always', 'Inline_Generic', 'Interface_Name', 'Interrupt_State', 'Keep_Names', 'License', 'Link_With', 'Linker_Alias', 'Linker_Section', 'Long_Float', 'Machine_Attribute', 'Main_Storage', 'Obsolescent', 'Passive', 'Polling', 'Profile_Warnings', 'Propagate_Exceptions', 'Psect_Object', 'Pure_Function', 'Restriction_Warnings', 'Source_File_Name', 'Source_File_Name_Project', 'Source_Reference', 'Stream_Convert', 'Style_Checks', 'Subtitle', 'Suppress_All', 'Suppress_Exception_Locations', 'Suppress_Initialization', 'Task_Info', 'Task_Name', 'Task_Storage', 'Thread_Body', 'Time_Slice', 'Title', 'Unimplemented_Unit', 'Universal_Data', 'Unreferenced', 'Unreserve_All_Interrupts', 'Use_VADS_Size', 'Validity_Checks', 'Warnings', 'Weak_External']
|
||||
let g:ada#Keywords += [{
|
||||
\ 'word': Item,
|
||||
\ 'menu': 'pragma',
|
||||
\ 'info': 'GNAT pragma.',
|
||||
\ 'kind': 'p',
|
||||
\ 'icase': 1}]
|
||||
endfor
|
||||
endif
|
||||
" 1}}}
|
||||
|
||||
" Section: g:ada#Ctags_Kinds {{{1
|
||||
"
|
||||
let g:ada#Ctags_Kinds = {
|
||||
\ 'P': ["packspec", "package specifications"],
|
||||
\ 'p': ["package", "packages"],
|
||||
\ 'T': ["typespec", "type specifications"],
|
||||
\ 't': ["type", "types"],
|
||||
\ 'U': ["subspec", "subtype specifications"],
|
||||
\ 'u': ["subtype", "subtypes"],
|
||||
\ 'c': ["component", "record type components"],
|
||||
\ 'l': ["literal", "enum type literals"],
|
||||
\ 'V': ["varspec", "variable specifications"],
|
||||
\ 'v': ["variable", "variables"],
|
||||
\ 'f': ["formal", "generic formal parameters"],
|
||||
\ 'n': ["constant", "constants"],
|
||||
\ 'x': ["exception", "user defined exceptions"],
|
||||
\ 'R': ["subprogspec", "subprogram specifications"],
|
||||
\ 'r': ["subprogram", "subprograms"],
|
||||
\ 'K': ["taskspec", "task specifications"],
|
||||
\ 'k': ["task", "tasks"],
|
||||
\ 'O': ["protectspec", "protected data specifications"],
|
||||
\ 'o': ["protected", "protected data"],
|
||||
\ 'E': ["entryspec", "task/protected data entry specifications"],
|
||||
\ 'e': ["entry", "task/protected data entries"],
|
||||
\ 'b': ["label", "labels"],
|
||||
\ 'i': ["identifier", "loop/declare identifiers"],
|
||||
\ 'a': ["autovar", "automatic variables"],
|
||||
\ 'y': ["annon", "loops and blocks with no identifier"]}
|
||||
|
||||
" Section: ada#Word (...) {{{1
|
||||
"
|
||||
" Extract current Ada word across multiple lines
|
||||
" AdaWord ([line, column])\
|
||||
"
|
||||
function ada#Word (...)
|
||||
if a:0 > 1
|
||||
let l:Line_Nr = a:1
|
||||
let l:Column_Nr = a:2 - 1
|
||||
else
|
||||
let l:Line_Nr = line('.')
|
||||
let l:Column_Nr = col('.') - 1
|
||||
endif
|
||||
|
||||
let l:Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' )
|
||||
|
||||
" Cope with tag searching for items in comments; if we are, don't loop
|
||||
" backards looking for previous lines
|
||||
if l:Column_Nr > strlen(l:Line)
|
||||
" We were in a comment
|
||||
let l:Line = getline(l:Line_Nr)
|
||||
let l:Search_Prev_Lines = 0
|
||||
else
|
||||
let l:Search_Prev_Lines = 1
|
||||
endif
|
||||
|
||||
" Go backwards until we find a match (Ada ID) that *doesn't* include our
|
||||
" location - i.e., the previous ID. This is because the current 'correct'
|
||||
" match will toggle matching/not matching as we traverse characters
|
||||
" backwards. Thus, we have to find the previous unrelated match, exclude
|
||||
" it, then use the next full match (ours).
|
||||
" Remember to convert vim column 'l:Column_Nr' [1..n] to string offset [0..(n-1)]
|
||||
" ... but start, here, one after the required char.
|
||||
let l:New_Column = l:Column_Nr + 1
|
||||
while 1
|
||||
let l:New_Column = l:New_Column - 1
|
||||
if l:New_Column < 0
|
||||
" Have to include previous l:Line from file
|
||||
let l:Line_Nr = l:Line_Nr - 1
|
||||
if l:Line_Nr < 1 || !l:Search_Prev_Lines
|
||||
" Start of file or matching in a comment
|
||||
let l:Line_Nr = 1
|
||||
let l:New_Column = 0
|
||||
let l:Our_Match = match (l:Line, g:ada#WordRegex )
|
||||
break
|
||||
endif
|
||||
" Get previous l:Line, and prepend it to our search string
|
||||
let l:New_Line = substitute (getline (l:Line_Nr), g:ada#Comment, '', '' )
|
||||
let l:New_Column = strlen (l:New_Line) - 1
|
||||
let l:Column_Nr = l:Column_Nr + l:New_Column
|
||||
let l:Line = l:New_Line . l:Line
|
||||
endif
|
||||
" Check to see if this is a match excluding 'us'
|
||||
let l:Match_End = l:New_Column +
|
||||
\ matchend (strpart (l:Line,l:New_Column), g:ada#WordRegex ) - 1
|
||||
if l:Match_End >= l:New_Column &&
|
||||
\ l:Match_End < l:Column_Nr
|
||||
" Yes
|
||||
let l:Our_Match = l:Match_End+1 +
|
||||
\ match (strpart (l:Line,l:Match_End+1), g:ada#WordRegex )
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
||||
" Got anything?
|
||||
if l:Our_Match < 0
|
||||
return ''
|
||||
else
|
||||
let l:Line = strpart (l:Line, l:Our_Match)
|
||||
endif
|
||||
|
||||
" Now simply add further lines until the match gets no bigger
|
||||
let l:Match_String = matchstr (l:Line, g:ada#WordRegex)
|
||||
let l:Last_Line = line ('$')
|
||||
let l:Line_Nr = line ('.') + 1
|
||||
while l:Line_Nr <= l:Last_Line
|
||||
let l:Last_Match = l:Match_String
|
||||
let l:Line = l:Line .
|
||||
\ substitute (getline (l:Line_Nr), g:ada#Comment, '', '')
|
||||
let l:Match_String = matchstr (l:Line, g:ada#WordRegex)
|
||||
if l:Match_String == l:Last_Match
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
||||
" Strip whitespace & return
|
||||
return substitute (l:Match_String, '\s\+', '', 'g')
|
||||
endfunction ada#Word
|
||||
|
||||
" Section: ada#List_Tag (...) {{{1
|
||||
"
|
||||
" List tags in quickfix window
|
||||
"
|
||||
function ada#List_Tag (...)
|
||||
if a:0 > 1
|
||||
let l:Tag_Word = ada#Word (a:1, a:2)
|
||||
elseif a:0 > 0
|
||||
let l:Tag_Word = a:1
|
||||
else
|
||||
let l:Tag_Word = ada#Word ()
|
||||
endif
|
||||
|
||||
echo "Searching for" l:Tag_Word
|
||||
|
||||
let l:Pattern = '^' . l:Tag_Word . '$'
|
||||
let l:Tag_List = taglist (l:Pattern)
|
||||
let l:Error_List = []
|
||||
"
|
||||
" add symbols
|
||||
"
|
||||
for Tag_Item in l:Tag_List
|
||||
if l:Tag_Item['kind'] == ''
|
||||
let l:Tag_Item['kind'] = 's'
|
||||
endif
|
||||
|
||||
let l:Error_List += [
|
||||
\ l:Tag_Item['filename'] . '|' .
|
||||
\ l:Tag_Item['cmd'] . '|' .
|
||||
\ l:Tag_Item['kind'] . "\t" .
|
||||
\ l:Tag_Item['name'] ]
|
||||
endfor
|
||||
set errorformat=%f\|%l\|%m
|
||||
cexpr l:Error_List
|
||||
cwindow
|
||||
endfunction ada#List_Tag
|
||||
|
||||
" Section: ada#Jump_Tag (Word, Mode) {{{1
|
||||
"
|
||||
" Word tag - include '.' and if Ada make uppercase
|
||||
"
|
||||
function ada#Jump_Tag (Word, Mode)
|
||||
if a:Word == ''
|
||||
" Get current word
|
||||
let l:Word = ada#Word()
|
||||
if l:Word == ''
|
||||
throw "NOT_FOUND: no identifier found."
|
||||
endif
|
||||
else
|
||||
let l:Word = a:Word
|
||||
endif
|
||||
|
||||
echo "Searching for " . l:Word
|
||||
|
||||
try
|
||||
execute a:Mode l:Word
|
||||
catch /.*:E426:.*/
|
||||
let ignorecase = &ignorecase
|
||||
set ignorecase
|
||||
execute a:Mode l:Word
|
||||
let &ignorecase = ignorecase
|
||||
endtry
|
||||
|
||||
return
|
||||
endfunction ada#Jump_Tag
|
||||
|
||||
" Section: ada#Insert_Backspace () {{{1
|
||||
"
|
||||
" Backspace at end of line after auto-inserted commentstring '-- ' wipes it
|
||||
"
|
||||
function ada#Insert_Backspace ()
|
||||
let l:Line = getline ('.')
|
||||
if col ('.') > strlen (l:Line) &&
|
||||
\ match (l:Line, '-- $') != -1 &&
|
||||
\ match (&comments,'--') != -1
|
||||
return "\<bs>\<bs>\<bs>"
|
||||
else
|
||||
return "\<bs>"
|
||||
endif
|
||||
|
||||
return
|
||||
endfunction ada#InsertBackspace
|
||||
|
||||
" Section: Insert Completions {{{1
|
||||
"
|
||||
" Section: ada#User_Complete(findstart, base) {{{2
|
||||
"
|
||||
" This function is used for the 'complete' option.
|
||||
"
|
||||
function! ada#User_Complete(findstart, base)
|
||||
if a:findstart == 1
|
||||
"
|
||||
" locate the start of the word
|
||||
"
|
||||
let line = getline ('.')
|
||||
let start = col ('.') - 1
|
||||
while start > 0 && line[start - 1] =~ '\i\|'''
|
||||
let start -= 1
|
||||
endwhile
|
||||
return start
|
||||
else
|
||||
"
|
||||
" look up matches
|
||||
"
|
||||
let l:Pattern = '^' . a:base . '.*$'
|
||||
"
|
||||
" add keywords
|
||||
"
|
||||
for Tag_Item in g:ada#Keywords
|
||||
if l:Tag_Item['word'] =~? l:Pattern
|
||||
if complete_add (l:Tag_Item) == 0
|
||||
return []
|
||||
endif
|
||||
if complete_check ()
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return []
|
||||
endif
|
||||
endfunction ada#User_Complete
|
||||
|
||||
" Section: ada#Completion (cmd) {{{2
|
||||
"
|
||||
" Word completion (^N/^R/^X^]) - force '.' inclusion
|
||||
function ada#Completion (cmd)
|
||||
set iskeyword+=46
|
||||
return a:cmd . "\<C-R>=ada#Completion_End ()\<CR>"
|
||||
endfunction ada#Completion
|
||||
|
||||
" Section: ada#Completion_End () {{{2
|
||||
"
|
||||
function ada#Completion_End ()
|
||||
set iskeyword-=46
|
||||
return ''
|
||||
endfunction ada#Completion_End
|
||||
|
||||
" Section: ada#Create_Tags {{{1
|
||||
"
|
||||
function ada#Create_Tags (option)
|
||||
if a:option == 'file'
|
||||
let l:Filename = fnamemodify (bufname ('%'), ':p')
|
||||
elseif a:option == 'dir'
|
||||
let l:Filename =
|
||||
\ fnamemodify (bufname ('%'), ':p:h') . "*.ada " .
|
||||
\ fnamemodify (bufname ('%'), ':p:h') . "*.adb " .
|
||||
\ fnamemodify (bufname ('%'), ':p:h') . "*.ads"
|
||||
else
|
||||
let l:Filename = a:option
|
||||
endif
|
||||
execute '!ctags --excmd=number ' . l:Filename
|
||||
endfunction ada#Create_Tags
|
||||
|
||||
" Section: ada#Switch_Session {{{1
|
||||
"
|
||||
function ada#Switch_Session (New_Session)
|
||||
"
|
||||
" you should not save to much date into the seession since they will
|
||||
" be sourced
|
||||
"
|
||||
let l:sessionoptions=&sessionoptions
|
||||
|
||||
try
|
||||
set sessionoptions=buffers,curdir,folds,globals,resize,slash,tabpages,tabpages,unix,winpos,winsize
|
||||
|
||||
if a:New_Session != v:this_session
|
||||
"
|
||||
" We actualy got a new session - otherwise there
|
||||
" is nothing to do.
|
||||
"
|
||||
if strlen (v:this_session) > 0
|
||||
execute 'mksession! ' . v:this_session
|
||||
endif
|
||||
|
||||
let v:this_session = a:New_Session
|
||||
|
||||
"if filereadable (v:this_session)
|
||||
"execute 'source ' . v:this_session
|
||||
"endif
|
||||
|
||||
augroup ada_session
|
||||
autocmd!
|
||||
autocmd VimLeavePre * execute 'mksession! ' . v:this_session
|
||||
augroup END
|
||||
|
||||
"if exists ("g:Tlist_Auto_Open") && g:Tlist_Auto_Open
|
||||
"TlistOpen
|
||||
"endif
|
||||
|
||||
endif
|
||||
finally
|
||||
let &sessionoptions=l:sessionoptions
|
||||
endtry
|
||||
|
||||
return
|
||||
endfunction ada#Switch_Session
|
||||
|
||||
" Section: GNAT Pretty Printer folding {{{1
|
||||
"
|
||||
if exists('g:ada_folding') && g:ada_folding[0] == 'g'
|
||||
"
|
||||
" Lines consisting only of ')' ';' are due to a gnat pretty bug and
|
||||
" have the same level as the line above (can't happen in the first
|
||||
" line).
|
||||
"
|
||||
let s:Fold_Collate = '^\([;)]*$\|'
|
||||
|
||||
"
|
||||
" some lone statements are folded with the line above
|
||||
"
|
||||
if stridx (g:ada_folding, 'i') >= 0
|
||||
let s:Fold_Collate .= '\s\+\<is\>$\|'
|
||||
endif
|
||||
if stridx (g:ada_folding, 'b') >= 0
|
||||
let s:Fold_Collate .= '\s\+\<begin\>$\|'
|
||||
endif
|
||||
if stridx (g:ada_folding, 'p') >= 0
|
||||
let s:Fold_Collate .= '\s\+\<private\>$\|'
|
||||
endif
|
||||
if stridx (g:ada_folding, 'x') >= 0
|
||||
let s:Fold_Collate .= '\s\+\<exception\>$\|'
|
||||
endif
|
||||
|
||||
" We also handle empty lines and
|
||||
" comments here.
|
||||
let s:Fold_Collate .= '--\)'
|
||||
|
||||
function ada#Pretty_Print_Folding (Line) " {{{2
|
||||
let l:Text = getline (a:Line)
|
||||
|
||||
if l:Text =~ s:Fold_Collate
|
||||
"
|
||||
" fold with line above
|
||||
"
|
||||
let l:Level = "="
|
||||
elseif l:Text =~ '^\s\+('
|
||||
"
|
||||
" gnat outdents a line which stards with a ( by one characters so
|
||||
" that parameters which follow are aligned.
|
||||
"
|
||||
let l:Level = (indent (a:Line) + 1) / &shiftwidth
|
||||
else
|
||||
let l:Level = indent (a:Line) / &shiftwidth
|
||||
endif
|
||||
|
||||
return l:Level
|
||||
endfunction ada#Pretty_Print_Folding " }}}2
|
||||
endif
|
||||
|
||||
" Section: Options and Menus {{{1
|
||||
"
|
||||
" Section: ada#Switch_Syntax_Options {{{2
|
||||
"
|
||||
function ada#Switch_Syntax_Option (option)
|
||||
syntax off
|
||||
if exists ('g:ada_' . a:option)
|
||||
unlet g:ada_{a:option}
|
||||
echo a:option . 'now off'
|
||||
else
|
||||
let g:ada_{a:option}=1
|
||||
echo a:option . 'now on'
|
||||
endif
|
||||
syntax on
|
||||
endfunction ada#Switch_Syntax_Option
|
||||
|
||||
" Section: ada#Map_Menu {{{2
|
||||
"
|
||||
function ada#Map_Menu (Text, Keys, Command)
|
||||
if a:Keys[0] == ':'
|
||||
execute
|
||||
\ "50amenu " .
|
||||
\ "Ada." . escape(a:Text, ' ') .
|
||||
\ "<Tab>" . a:Keys .
|
||||
\ " :" . a:Command . "<CR>"
|
||||
execute
|
||||
\ "command -buffer " .
|
||||
\ a:Keys[1:] .
|
||||
\" :" . a:Command . "<CR>"
|
||||
elseif a:Keys[0] == '<'
|
||||
execute
|
||||
\ "50amenu " .
|
||||
\ "Ada." . escape(a:Text, ' ') .
|
||||
\ "<Tab>" . a:Keys .
|
||||
\ " :" . a:Command . "<CR>"
|
||||
execute
|
||||
\ "nnoremap <buffer> " .
|
||||
\ a:Keys .
|
||||
\" :" . a:Command . "<CR>"
|
||||
execute
|
||||
\ "inoremap <buffer> " .
|
||||
\ a:Keys .
|
||||
\" <C-O>:" . a:Command . "<CR>"
|
||||
else
|
||||
if exists("g:mapleader")
|
||||
let l:leader = g:mapleader
|
||||
else
|
||||
let l:leader = '\'
|
||||
endif
|
||||
execute
|
||||
\ "50amenu " .
|
||||
\ "Ada." . escape(a:Text, ' ') .
|
||||
\ "<Tab>" . escape(l:leader . "a" . a:Keys , '\') .
|
||||
\ " :" . a:Command . "<CR>"
|
||||
execute
|
||||
\ "nnoremap <buffer>" .
|
||||
\ escape(l:leader . "a" . a:Keys , '\') .
|
||||
\" :" . a:Command
|
||||
execute
|
||||
\ "inoremap <buffer>" .
|
||||
\ escape(l:leader . "a" . a:Keys , '\') .
|
||||
\" <C-O>:" . a:Command
|
||||
endif
|
||||
return
|
||||
endfunction
|
||||
|
||||
" Section: ada#Map_Popup {{{2
|
||||
"
|
||||
function ada#Map_Popup (Text, Keys, Command)
|
||||
if exists("g:mapleader")
|
||||
let l:leader = g:mapleader
|
||||
else
|
||||
let l:leader = '\'
|
||||
endif
|
||||
execute
|
||||
\ "50amenu " .
|
||||
\ "PopUp." . escape(a:Text, ' ') .
|
||||
\ "<Tab>" . escape(l:leader . "a" . a:Keys , '\') .
|
||||
\ " :" . a:Command . "<CR>"
|
||||
|
||||
call ada#Map_Menu (a:Text, a:Keys, a:Command)
|
||||
return
|
||||
endfunction ada#Map_Popup
|
||||
|
||||
" }}}1
|
||||
|
||||
lockvar g:ada#WordRegex
|
||||
lockvar g:ada#DotWordRegex
|
||||
lockvar g:ada#Comment
|
||||
lockvar! g:ada#Keywords
|
||||
lockvar! g:ada#Ctags_Kinds
|
||||
|
||||
finish " 1}}}
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
109
vim/bundle/ubuntu-vim72/autoload/adacomplete.vim
Normal file
109
vim/bundle/ubuntu-vim72/autoload/adacomplete.vim
Normal file
@@ -0,0 +1,109 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Vim Ada omnicompletion file
|
||||
" Language: Ada (2005)
|
||||
" $Id: adacomplete.vim 887 2008-07-08 14:29:01Z krischik $
|
||||
" Maintainer: Martin Krischik
|
||||
" $Author: krischik $
|
||||
" $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
|
||||
" Version: 4.6
|
||||
" $Revision: 887 $
|
||||
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/adacomplete.vim $
|
||||
" History: 24.05.2006 MK Unified Headers
|
||||
" 26.05.2006 MK improved search for begin of word.
|
||||
" 16.07.2006 MK Ada-Mode as vim-ball
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested not to use include protection for
|
||||
" autoload
|
||||
" 05.11.2006 MK Bram suggested agaist using setlocal omnifunc
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" Help Page: ft-ada-omni
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
if version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
" Section: adacomplete#Complete () {{{1
|
||||
"
|
||||
" This function is used for the 'omnifunc' option.
|
||||
"
|
||||
function! adacomplete#Complete (findstart, base)
|
||||
if a:findstart == 1
|
||||
return ada#User_Complete (a:findstart, a:base)
|
||||
else
|
||||
"
|
||||
" look up matches
|
||||
"
|
||||
if exists ("g:ada_omni_with_keywords")
|
||||
call ada#User_Complete (a:findstart, a:base)
|
||||
endif
|
||||
"
|
||||
" search tag file for matches
|
||||
"
|
||||
let l:Pattern = '^' . a:base . '.*$'
|
||||
let l:Tag_List = taglist (l:Pattern)
|
||||
"
|
||||
" add symbols
|
||||
"
|
||||
for Tag_Item in l:Tag_List
|
||||
if l:Tag_Item['kind'] == ''
|
||||
"
|
||||
" Tag created by gnat xref
|
||||
"
|
||||
let l:Match_Item = {
|
||||
\ 'word': l:Tag_Item['name'],
|
||||
\ 'menu': l:Tag_Item['filename'],
|
||||
\ 'info': "Symbol from file " . l:Tag_Item['filename'] . " line " . l:Tag_Item['cmd'],
|
||||
\ 'kind': 's',
|
||||
\ 'icase': 1}
|
||||
else
|
||||
"
|
||||
" Tag created by ctags
|
||||
"
|
||||
let l:Info = 'Symbol : ' . l:Tag_Item['name'] . "\n"
|
||||
let l:Info .= 'Of type : ' . g:ada#Ctags_Kinds[l:Tag_Item['kind']][1] . "\n"
|
||||
let l:Info .= 'Defined in File : ' . l:Tag_Item['filename'] . "\n"
|
||||
|
||||
if has_key( l:Tag_Item, 'package')
|
||||
let l:Info .= 'Package : ' . l:Tag_Item['package'] . "\n"
|
||||
let l:Menu = l:Tag_Item['package']
|
||||
elseif has_key( l:Tag_Item, 'separate')
|
||||
let l:Info .= 'Separate from Package : ' . l:Tag_Item['separate'] . "\n"
|
||||
let l:Menu = l:Tag_Item['separate']
|
||||
elseif has_key( l:Tag_Item, 'packspec')
|
||||
let l:Info .= 'Package Specification : ' . l:Tag_Item['packspec'] . "\n"
|
||||
let l:Menu = l:Tag_Item['packspec']
|
||||
elseif has_key( l:Tag_Item, 'type')
|
||||
let l:Info .= 'Datetype : ' . l:Tag_Item['type'] . "\n"
|
||||
let l:Menu = l:Tag_Item['type']
|
||||
else
|
||||
let l:Menu = l:Tag_Item['filename']
|
||||
endif
|
||||
|
||||
let l:Match_Item = {
|
||||
\ 'word': l:Tag_Item['name'],
|
||||
\ 'menu': l:Menu,
|
||||
\ 'info': l:Info,
|
||||
\ 'kind': l:Tag_Item['kind'],
|
||||
\ 'icase': 1}
|
||||
endif
|
||||
if complete_add (l:Match_Item) == 0
|
||||
return []
|
||||
endif
|
||||
if complete_check ()
|
||||
return []
|
||||
endif
|
||||
endfor
|
||||
return []
|
||||
endif
|
||||
endfunction adacomplete#Complete
|
||||
|
||||
finish " 1}}}
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
605
vim/bundle/ubuntu-vim72/autoload/ccomplete.vim
Normal file
605
vim/bundle/ubuntu-vim72/autoload/ccomplete.vim
Normal file
@@ -0,0 +1,605 @@
|
||||
" Vim completion script
|
||||
" Language: C
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2007 Aug 30
|
||||
|
||||
|
||||
" This function is used for the 'omnifunc' option.
|
||||
function! ccomplete#Complete(findstart, base)
|
||||
if a:findstart
|
||||
" Locate the start of the item, including ".", "->" and "[...]".
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
let lastword = -1
|
||||
while start > 0
|
||||
if line[start - 1] =~ '\w'
|
||||
let start -= 1
|
||||
elseif line[start - 1] =~ '\.'
|
||||
if lastword == -1
|
||||
let lastword = start
|
||||
endif
|
||||
let start -= 1
|
||||
elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>'
|
||||
if lastword == -1
|
||||
let lastword = start
|
||||
endif
|
||||
let start -= 2
|
||||
elseif line[start - 1] == ']'
|
||||
" Skip over [...].
|
||||
let n = 0
|
||||
let start -= 1
|
||||
while start > 0
|
||||
let start -= 1
|
||||
if line[start] == '['
|
||||
if n == 0
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
elseif line[start] == ']' " nested []
|
||||
let n += 1
|
||||
endif
|
||||
endwhile
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
||||
" Return the column of the last word, which is going to be changed.
|
||||
" Remember the text that comes before it in s:prepended.
|
||||
if lastword == -1
|
||||
let s:prepended = ''
|
||||
return start
|
||||
endif
|
||||
let s:prepended = strpart(line, start, lastword - start)
|
||||
return lastword
|
||||
endif
|
||||
|
||||
" Return list of matches.
|
||||
|
||||
let base = s:prepended . a:base
|
||||
|
||||
" Don't do anything for an empty base, would result in all the tags in the
|
||||
" tags file.
|
||||
if base == ''
|
||||
return []
|
||||
endif
|
||||
|
||||
" init cache for vimgrep to empty
|
||||
let s:grepCache = {}
|
||||
|
||||
" Split item in words, keep empty word after "." or "->".
|
||||
" "aa" -> ['aa'], "aa." -> ['aa', ''], "aa.bb" -> ['aa', 'bb'], etc.
|
||||
" We can't use split, because we need to skip nested [...].
|
||||
let items = []
|
||||
let s = 0
|
||||
while 1
|
||||
let e = match(base, '\.\|->\|\[', s)
|
||||
if e < 0
|
||||
if s == 0 || base[s - 1] != ']'
|
||||
call add(items, strpart(base, s))
|
||||
endif
|
||||
break
|
||||
endif
|
||||
if s == 0 || base[s - 1] != ']'
|
||||
call add(items, strpart(base, s, e - s))
|
||||
endif
|
||||
if base[e] == '.'
|
||||
let s = e + 1 " skip over '.'
|
||||
elseif base[e] == '-'
|
||||
let s = e + 2 " skip over '->'
|
||||
else
|
||||
" Skip over [...].
|
||||
let n = 0
|
||||
let s = e
|
||||
let e += 1
|
||||
while e < len(base)
|
||||
if base[e] == ']'
|
||||
if n == 0
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
elseif base[e] == '[' " nested [...]
|
||||
let n += 1
|
||||
endif
|
||||
let e += 1
|
||||
endwhile
|
||||
let e += 1
|
||||
call add(items, strpart(base, s, e - s))
|
||||
let s = e
|
||||
endif
|
||||
endwhile
|
||||
|
||||
" Find the variable items[0].
|
||||
" 1. in current function (like with "gd")
|
||||
" 2. in tags file(s) (like with ":tag")
|
||||
" 3. in current file (like with "gD")
|
||||
let res = []
|
||||
if searchdecl(items[0], 0, 1) == 0
|
||||
" Found, now figure out the type.
|
||||
" TODO: join previous line if it makes sense
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
if stridx(strpart(line, 0, col), ';') != -1
|
||||
" Handle multiple declarations on the same line.
|
||||
let col2 = col - 1
|
||||
while line[col2] != ';'
|
||||
let col2 -= 1
|
||||
endwhile
|
||||
let line = strpart(line, col2 + 1)
|
||||
let col -= col2
|
||||
endif
|
||||
if stridx(strpart(line, 0, col), ',') != -1
|
||||
" Handle multiple declarations on the same line in a function
|
||||
" declaration.
|
||||
let col2 = col - 1
|
||||
while line[col2] != ','
|
||||
let col2 -= 1
|
||||
endwhile
|
||||
if strpart(line, col2 + 1, col - col2 - 1) =~ ' *[^ ][^ ]* *[^ ]'
|
||||
let line = strpart(line, col2 + 1)
|
||||
let col -= col2
|
||||
endif
|
||||
endif
|
||||
if len(items) == 1
|
||||
" Completing one word and it's a local variable: May add '[', '.' or
|
||||
" '->'.
|
||||
let match = items[0]
|
||||
let kind = 'v'
|
||||
if match(line, '\<' . match . '\s*\[') > 0
|
||||
let match .= '['
|
||||
else
|
||||
let res = s:Nextitem(strpart(line, 0, col), [''], 0, 1)
|
||||
if len(res) > 0
|
||||
" There are members, thus add "." or "->".
|
||||
if match(line, '\*[ \t(]*' . match . '\>') > 0
|
||||
let match .= '->'
|
||||
else
|
||||
let match .= '.'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
let res = [{'match': match, 'tagline' : '', 'kind' : kind, 'info' : line}]
|
||||
else
|
||||
" Completing "var.", "var.something", etc.
|
||||
let res = s:Nextitem(strpart(line, 0, col), items[-1], 0, 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
if len(items) == 1
|
||||
" Only one part, no "." or "->": complete from tags file.
|
||||
let tags = taglist('^' . base)
|
||||
|
||||
" Remove members, these can't appear without something in front.
|
||||
call filter(tags, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1')
|
||||
|
||||
" Remove static matches in other files.
|
||||
call filter(tags, '!has_key(v:val, "static") || !v:val["static"] || bufnr("%") == bufnr(v:val["filename"])')
|
||||
|
||||
call extend(res, map(tags, 's:Tag2item(v:val)'))
|
||||
endif
|
||||
|
||||
if len(res) == 0
|
||||
" Find the variable in the tags file(s)
|
||||
let diclist = taglist('^' . items[0] . '$')
|
||||
|
||||
" Remove members, these can't appear without something in front.
|
||||
call filter(diclist, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1')
|
||||
|
||||
let res = []
|
||||
for i in range(len(diclist))
|
||||
" New ctags has the "typeref" field. Patched version has "typename".
|
||||
if has_key(diclist[i], 'typename')
|
||||
call extend(res, s:StructMembers(diclist[i]['typename'], items[1:], 1))
|
||||
elseif has_key(diclist[i], 'typeref')
|
||||
call extend(res, s:StructMembers(diclist[i]['typeref'], items[1:], 1))
|
||||
endif
|
||||
|
||||
" For a variable use the command, which must be a search pattern that
|
||||
" shows the declaration of the variable.
|
||||
if diclist[i]['kind'] == 'v'
|
||||
let line = diclist[i]['cmd']
|
||||
if line[0] == '/' && line[1] == '^'
|
||||
let col = match(line, '\<' . items[0] . '\>')
|
||||
call extend(res, s:Nextitem(strpart(line, 2, col - 2), items[1:], 0, 1))
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if len(res) == 0 && searchdecl(items[0], 1) == 0
|
||||
" Found, now figure out the type.
|
||||
" TODO: join previous line if it makes sense
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1)
|
||||
endif
|
||||
|
||||
" If the last item(s) are [...] they need to be added to the matches.
|
||||
let last = len(items) - 1
|
||||
let brackets = ''
|
||||
while last >= 0
|
||||
if items[last][0] != '['
|
||||
break
|
||||
endif
|
||||
let brackets = items[last] . brackets
|
||||
let last -= 1
|
||||
endwhile
|
||||
|
||||
return map(res, 's:Tagline2item(v:val, brackets)')
|
||||
endfunc
|
||||
|
||||
function! s:GetAddition(line, match, memarg, bracket)
|
||||
" Guess if the item is an array.
|
||||
if a:bracket && match(a:line, a:match . '\s*\[') > 0
|
||||
return '['
|
||||
endif
|
||||
|
||||
" Check if the item has members.
|
||||
if len(s:SearchMembers(a:memarg, [''], 0)) > 0
|
||||
" If there is a '*' before the name use "->".
|
||||
if match(a:line, '\*[ \t(]*' . a:match . '\>') > 0
|
||||
return '->'
|
||||
else
|
||||
return '.'
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Turn the tag info "val" into an item for completion.
|
||||
" "val" is is an item in the list returned by taglist().
|
||||
" If it is a variable we may add "." or "->". Don't do it for other types,
|
||||
" such as a typedef, by not including the info that s:GetAddition() uses.
|
||||
function! s:Tag2item(val)
|
||||
let res = {'match': a:val['name']}
|
||||
|
||||
let res['extra'] = s:Tagcmd2extra(a:val['cmd'], a:val['name'], a:val['filename'])
|
||||
|
||||
let s = s:Dict2info(a:val)
|
||||
if s != ''
|
||||
let res['info'] = s
|
||||
endif
|
||||
|
||||
let res['tagline'] = ''
|
||||
if has_key(a:val, "kind")
|
||||
let kind = a:val['kind']
|
||||
let res['kind'] = kind
|
||||
if kind == 'v'
|
||||
let res['tagline'] = "\t" . a:val['cmd']
|
||||
let res['dict'] = a:val
|
||||
elseif kind == 'f'
|
||||
let res['match'] = a:val['name'] . '('
|
||||
endif
|
||||
endif
|
||||
|
||||
return res
|
||||
endfunction
|
||||
|
||||
" Use all the items in dictionary for the "info" entry.
|
||||
function! s:Dict2info(dict)
|
||||
let info = ''
|
||||
for k in sort(keys(a:dict))
|
||||
let info .= k . repeat(' ', 10 - len(k))
|
||||
if k == 'cmd'
|
||||
let info .= substitute(matchstr(a:dict['cmd'], '/^\s*\zs.*\ze$/'), '\\\(.\)', '\1', 'g')
|
||||
else
|
||||
let info .= a:dict[k]
|
||||
endif
|
||||
let info .= "\n"
|
||||
endfor
|
||||
return info
|
||||
endfunc
|
||||
|
||||
" Parse a tag line and return a dictionary with items like taglist()
|
||||
function! s:ParseTagline(line)
|
||||
let l = split(a:line, "\t")
|
||||
let d = {}
|
||||
if len(l) >= 3
|
||||
let d['name'] = l[0]
|
||||
let d['filename'] = l[1]
|
||||
let d['cmd'] = l[2]
|
||||
let n = 2
|
||||
if l[2] =~ '^/'
|
||||
" Find end of cmd, it may contain Tabs.
|
||||
while n < len(l) && l[n] !~ '/;"$'
|
||||
let n += 1
|
||||
let d['cmd'] .= " " . l[n]
|
||||
endwhile
|
||||
endif
|
||||
for i in range(n + 1, len(l) - 1)
|
||||
if l[i] == 'file:'
|
||||
let d['static'] = 1
|
||||
elseif l[i] !~ ':'
|
||||
let d['kind'] = l[i]
|
||||
else
|
||||
let d[matchstr(l[i], '[^:]*')] = matchstr(l[i], ':\zs.*')
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return d
|
||||
endfunction
|
||||
|
||||
" Turn a match item "val" into an item for completion.
|
||||
" "val['match']" is the matching item.
|
||||
" "val['tagline']" is the tagline in which the last part was found.
|
||||
function! s:Tagline2item(val, brackets)
|
||||
let line = a:val['tagline']
|
||||
let add = s:GetAddition(line, a:val['match'], [a:val], a:brackets == '')
|
||||
let res = {'word': a:val['match'] . a:brackets . add }
|
||||
|
||||
if has_key(a:val, 'info')
|
||||
" Use info from Tag2item().
|
||||
let res['info'] = a:val['info']
|
||||
else
|
||||
" Parse the tag line and add each part to the "info" entry.
|
||||
let s = s:Dict2info(s:ParseTagline(line))
|
||||
if s != ''
|
||||
let res['info'] = s
|
||||
endif
|
||||
endif
|
||||
|
||||
if has_key(a:val, 'kind')
|
||||
let res['kind'] = a:val['kind']
|
||||
elseif add == '('
|
||||
let res['kind'] = 'f'
|
||||
else
|
||||
let s = matchstr(line, '\t\(kind:\)\=\zs\S\ze\(\t\|$\)')
|
||||
if s != ''
|
||||
let res['kind'] = s
|
||||
endif
|
||||
endif
|
||||
|
||||
if has_key(a:val, 'extra')
|
||||
let res['menu'] = a:val['extra']
|
||||
return res
|
||||
endif
|
||||
|
||||
" Isolate the command after the tag and filename.
|
||||
let s = matchstr(line, '[^\t]*\t[^\t]*\t\zs\(/^.*$/\|[^\t]*\)\ze\(;"\t\|\t\|$\)')
|
||||
if s != ''
|
||||
let res['menu'] = s:Tagcmd2extra(s, a:val['match'], matchstr(line, '[^\t]*\t\zs[^\t]*\ze\t'))
|
||||
endif
|
||||
return res
|
||||
endfunction
|
||||
|
||||
" Turn a command from a tag line to something that is useful in the menu
|
||||
function! s:Tagcmd2extra(cmd, name, fname)
|
||||
if a:cmd =~ '^/^'
|
||||
" The command is a search command, useful to see what it is.
|
||||
let x = matchstr(a:cmd, '^/^\s*\zs.*\ze$/')
|
||||
let x = substitute(x, '\<' . a:name . '\>', '@@', '')
|
||||
let x = substitute(x, '\\\(.\)', '\1', 'g')
|
||||
let x = x . ' - ' . a:fname
|
||||
elseif a:cmd =~ '^\d*$'
|
||||
" The command is a line number, the file name is more useful.
|
||||
let x = a:fname . ' - ' . a:cmd
|
||||
else
|
||||
" Not recognized, use command and file name.
|
||||
let x = a:cmd . ' - ' . a:fname
|
||||
endif
|
||||
return x
|
||||
endfunction
|
||||
|
||||
" Find composing type in "lead" and match items[0] with it.
|
||||
" Repeat this recursively for items[1], if it's there.
|
||||
" When resolving typedefs "depth" is used to avoid infinite recursion.
|
||||
" Return the list of matches.
|
||||
function! s:Nextitem(lead, items, depth, all)
|
||||
|
||||
" Use the text up to the variable name and split it in tokens.
|
||||
let tokens = split(a:lead, '\s\+\|\<')
|
||||
|
||||
" Try to recognize the type of the variable. This is rough guessing...
|
||||
let res = []
|
||||
for tidx in range(len(tokens))
|
||||
|
||||
" Skip tokens starting with a non-ID character.
|
||||
if tokens[tidx] !~ '^\h'
|
||||
continue
|
||||
endif
|
||||
|
||||
" Recognize "struct foobar" and "union foobar".
|
||||
" Also do "class foobar" when it's C++ after all (doesn't work very well
|
||||
" though).
|
||||
if (tokens[tidx] == 'struct' || tokens[tidx] == 'union' || tokens[tidx] == 'class') && tidx + 1 < len(tokens)
|
||||
let res = s:StructMembers(tokens[tidx] . ':' . tokens[tidx + 1], a:items, a:all)
|
||||
break
|
||||
endif
|
||||
|
||||
" TODO: add more reserved words
|
||||
if index(['int', 'short', 'char', 'float', 'double', 'static', 'unsigned', 'extern'], tokens[tidx]) >= 0
|
||||
continue
|
||||
endif
|
||||
|
||||
" Use the tags file to find out if this is a typedef.
|
||||
let diclist = taglist('^' . tokens[tidx] . '$')
|
||||
for tagidx in range(len(diclist))
|
||||
let item = diclist[tagidx]
|
||||
|
||||
" New ctags has the "typeref" field. Patched version has "typename".
|
||||
if has_key(item, 'typeref')
|
||||
call extend(res, s:StructMembers(item['typeref'], a:items, a:all))
|
||||
continue
|
||||
endif
|
||||
if has_key(item, 'typename')
|
||||
call extend(res, s:StructMembers(item['typename'], a:items, a:all))
|
||||
continue
|
||||
endif
|
||||
|
||||
" Only handle typedefs here.
|
||||
if item['kind'] != 't'
|
||||
continue
|
||||
endif
|
||||
|
||||
" Skip matches local to another file.
|
||||
if has_key(item, 'static') && item['static'] && bufnr('%') != bufnr(item['filename'])
|
||||
continue
|
||||
endif
|
||||
|
||||
" For old ctags we recognize "typedef struct aaa" and
|
||||
" "typedef union bbb" in the tags file command.
|
||||
let cmd = item['cmd']
|
||||
let ei = matchend(cmd, 'typedef\s\+')
|
||||
if ei > 1
|
||||
let cmdtokens = split(strpart(cmd, ei), '\s\+\|\<')
|
||||
if len(cmdtokens) > 1
|
||||
if cmdtokens[0] == 'struct' || cmdtokens[0] == 'union' || cmdtokens[0] == 'class'
|
||||
let name = ''
|
||||
" Use the first identifier after the "struct" or "union"
|
||||
for ti in range(len(cmdtokens) - 1)
|
||||
if cmdtokens[ti] =~ '^\w'
|
||||
let name = cmdtokens[ti]
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if name != ''
|
||||
call extend(res, s:StructMembers(cmdtokens[0] . ':' . name, a:items, a:all))
|
||||
endif
|
||||
elseif a:depth < 10
|
||||
" Could be "typedef other_T some_T".
|
||||
call extend(res, s:Nextitem(cmdtokens[0], a:items, a:depth + 1, a:all))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(res) > 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res
|
||||
endfunction
|
||||
|
||||
|
||||
" Search for members of structure "typename" in tags files.
|
||||
" Return a list with resulting matches.
|
||||
" Each match is a dictionary with "match" and "tagline" entries.
|
||||
" When "all" is non-zero find all, otherwise just return 1 if there is any
|
||||
" member.
|
||||
function! s:StructMembers(typename, items, all)
|
||||
" Todo: What about local structures?
|
||||
let fnames = join(map(tagfiles(), 'escape(v:val, " \\#%")'))
|
||||
if fnames == ''
|
||||
return []
|
||||
endif
|
||||
|
||||
let typename = a:typename
|
||||
let qflist = []
|
||||
let cached = 0
|
||||
if a:all == 0
|
||||
let n = '1' " stop at first found match
|
||||
if has_key(s:grepCache, a:typename)
|
||||
let qflist = s:grepCache[a:typename]
|
||||
let cached = 1
|
||||
endif
|
||||
else
|
||||
let n = ''
|
||||
endif
|
||||
if !cached
|
||||
while 1
|
||||
exe 'silent! ' . n . 'vimgrep /\t' . typename . '\(\t\|$\)/j ' . fnames
|
||||
|
||||
let qflist = getqflist()
|
||||
if len(qflist) > 0 || match(typename, "::") < 0
|
||||
break
|
||||
endif
|
||||
" No match for "struct:context::name", remove "context::" and try again.
|
||||
let typename = substitute(typename, ':[^:]*::', ':', '')
|
||||
endwhile
|
||||
|
||||
if a:all == 0
|
||||
" Store the result to be able to use it again later.
|
||||
let s:grepCache[a:typename] = qflist
|
||||
endif
|
||||
endif
|
||||
|
||||
" Put matching members in matches[].
|
||||
let matches = []
|
||||
for l in qflist
|
||||
let memb = matchstr(l['text'], '[^\t]*')
|
||||
if memb =~ '^' . a:items[0]
|
||||
" Skip matches local to another file.
|
||||
if match(l['text'], "\tfile:") < 0 || bufnr('%') == bufnr(matchstr(l['text'], '\t\zs[^\t]*'))
|
||||
let item = {'match': memb, 'tagline': l['text']}
|
||||
|
||||
" Add the kind of item.
|
||||
let s = matchstr(l['text'], '\t\(kind:\)\=\zs\S\ze\(\t\|$\)')
|
||||
if s != ''
|
||||
let item['kind'] = s
|
||||
if s == 'f'
|
||||
let item['match'] = memb . '('
|
||||
endif
|
||||
endif
|
||||
|
||||
call add(matches, item)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if len(matches) > 0
|
||||
" Skip over [...] items
|
||||
let idx = 1
|
||||
while 1
|
||||
if idx >= len(a:items)
|
||||
return matches " No further items, return the result.
|
||||
endif
|
||||
if a:items[idx][0] != '['
|
||||
break
|
||||
endif
|
||||
let idx += 1
|
||||
endwhile
|
||||
|
||||
" More items following. For each of the possible members find the
|
||||
" matching following members.
|
||||
return s:SearchMembers(matches, a:items[idx :], a:all)
|
||||
endif
|
||||
|
||||
" Failed to find anything.
|
||||
return []
|
||||
endfunction
|
||||
|
||||
" For matching members, find matches for following items.
|
||||
" When "all" is non-zero find all, otherwise just return 1 if there is any
|
||||
" member.
|
||||
function! s:SearchMembers(matches, items, all)
|
||||
let res = []
|
||||
for i in range(len(a:matches))
|
||||
let typename = ''
|
||||
if has_key(a:matches[i], 'dict')
|
||||
if has_key(a:matches[i].dict, 'typename')
|
||||
let typename = a:matches[i].dict['typename']
|
||||
elseif has_key(a:matches[i].dict, 'typeref')
|
||||
let typename = a:matches[i].dict['typeref']
|
||||
endif
|
||||
let line = "\t" . a:matches[i].dict['cmd']
|
||||
else
|
||||
let line = a:matches[i]['tagline']
|
||||
let e = matchend(line, '\ttypename:')
|
||||
if e < 0
|
||||
let e = matchend(line, '\ttyperef:')
|
||||
endif
|
||||
if e > 0
|
||||
" Use typename field
|
||||
let typename = matchstr(line, '[^\t]*', e)
|
||||
endif
|
||||
endif
|
||||
|
||||
if typename != ''
|
||||
call extend(res, s:StructMembers(typename, a:items, a:all))
|
||||
else
|
||||
" Use the search command (the declaration itself).
|
||||
let s = match(line, '\t\zs/^')
|
||||
if s > 0
|
||||
let e = match(line, '\<' . a:matches[i]['match'] . '\>', s)
|
||||
if e > 0
|
||||
call extend(res, s:Nextitem(strpart(line, s, e - s), a:items, 0, a:all))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if a:all == 0 && len(res) > 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
endfunc
|
||||
429
vim/bundle/ubuntu-vim72/autoload/csscomplete.vim
Normal file
429
vim/bundle/ubuntu-vim72/autoload/csscomplete.vim
Normal file
@@ -0,0 +1,429 @@
|
||||
" Vim completion script
|
||||
" Language: CSS 2.1
|
||||
" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
|
||||
" Last Change: 2007 May 5
|
||||
|
||||
let s:values = split("azimuth background background-attachment background-color background-image background-position background-repeat border bottom border-collapse border-color border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width caption-side clear clip color content counter-increment counter-reset cue cue-after cue-before cursor display direction elevation empty-cells float font font-family font-size font-style font-variant font-weight height left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-right margin-left margin-top margin-bottom max-height max-width min-height min-width orphans outline outline-color outline-style outline-width overflow padding padding-top padding-right padding-bottom padding-left page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes right richness speak speak-header speak-numeral speak-punctuation speech-rate stress table-layout text-align text-decoration text-indent text-transform top unicode-bidi vertical-align visibility voice-family volume white-space width widows word-spacing z-index")
|
||||
|
||||
function! csscomplete#CompleteCSS(findstart, base)
|
||||
|
||||
if a:findstart
|
||||
" We need whole line to proper checking
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
let compl_begin = col('.') - 2
|
||||
while start >= 0 && line[start - 1] =~ '\%(\k\|-\)'
|
||||
let start -= 1
|
||||
endwhile
|
||||
let b:compl_context = line[0:compl_begin]
|
||||
return start
|
||||
endif
|
||||
|
||||
" There are few chars important for context:
|
||||
" ^ ; : { } /* */
|
||||
" Where ^ is start of line and /* */ are comment borders
|
||||
" Depending on their relative position to cursor we will know what should
|
||||
" be completed.
|
||||
" 1. if nearest are ^ or { or ; current word is property
|
||||
" 2. if : it is value (with exception of pseudo things)
|
||||
" 3. if } we are outside of css definitions
|
||||
" 4. for comments ignoring is be the easiest but assume they are the same
|
||||
" as 1.
|
||||
" 5. if @ complete at-rule
|
||||
" 6. if ! complete important
|
||||
if exists("b:compl_context")
|
||||
let line = b:compl_context
|
||||
unlet! b:compl_context
|
||||
else
|
||||
let line = a:base
|
||||
endif
|
||||
|
||||
let res = []
|
||||
let res2 = []
|
||||
let borders = {}
|
||||
|
||||
" Check last occurrence of sequence
|
||||
|
||||
let openbrace = strridx(line, '{')
|
||||
let closebrace = strridx(line, '}')
|
||||
let colon = strridx(line, ':')
|
||||
let semicolon = strridx(line, ';')
|
||||
let opencomm = strridx(line, '/*')
|
||||
let closecomm = strridx(line, '*/')
|
||||
let style = strridx(line, 'style\s*=')
|
||||
let atrule = strridx(line, '@')
|
||||
let exclam = strridx(line, '!')
|
||||
|
||||
if openbrace > -1
|
||||
let borders[openbrace] = "openbrace"
|
||||
endif
|
||||
if closebrace > -1
|
||||
let borders[closebrace] = "closebrace"
|
||||
endif
|
||||
if colon > -1
|
||||
let borders[colon] = "colon"
|
||||
endif
|
||||
if semicolon > -1
|
||||
let borders[semicolon] = "semicolon"
|
||||
endif
|
||||
if opencomm > -1
|
||||
let borders[opencomm] = "opencomm"
|
||||
endif
|
||||
if closecomm > -1
|
||||
let borders[closecomm] = "closecomm"
|
||||
endif
|
||||
if style > -1
|
||||
let borders[style] = "style"
|
||||
endif
|
||||
if atrule > -1
|
||||
let borders[atrule] = "atrule"
|
||||
endif
|
||||
if exclam > -1
|
||||
let borders[exclam] = "exclam"
|
||||
endif
|
||||
|
||||
|
||||
if len(borders) == 0 || borders[max(keys(borders))] =~ '^\%(openbrace\|semicolon\|opencomm\|closecomm\|style\)$'
|
||||
" Complete properties
|
||||
|
||||
|
||||
let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$')
|
||||
|
||||
for m in s:values
|
||||
if m =~? '^'.entered_property
|
||||
call add(res, m . ':')
|
||||
elseif m =~? entered_property
|
||||
call add(res2, m . ':')
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
elseif borders[max(keys(borders))] == 'colon'
|
||||
" Get name of property
|
||||
let prop = tolower(matchstr(line, '\zs[a-zA-Z-]*\ze\s*:[^:]\{-}$'))
|
||||
|
||||
if prop == 'azimuth'
|
||||
let values = ["left-side", "far-left", "left", "center-left", "center", "center-right", "right", "far-right", "right-side", "behind", "leftwards", "rightwards"]
|
||||
elseif prop == 'background-attachment'
|
||||
let values = ["scroll", "fixed"]
|
||||
elseif prop == 'background-color'
|
||||
let values = ["transparent", "rgb(", "#"]
|
||||
elseif prop == 'background-image'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'background-position'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["top", "center", "bottom"]
|
||||
elseif vals =~ '^[a-zA-Z]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["left", "center", "right"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'background-repeat'
|
||||
let values = ["repeat", "repeat-x", "repeat-y", "no-repeat"]
|
||||
elseif prop == 'background'
|
||||
let values = ["url(", "scroll", "fixed", "transparent", "rgb(", "#", "none", "top", "center", "bottom" , "left", "right", "repeat", "repeat-x", "repeat-y", "no-repeat"]
|
||||
elseif prop == 'border-collapse'
|
||||
let values = ["collapse", "separate"]
|
||||
elseif prop == 'border-color'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
elseif prop == 'border-spacing'
|
||||
return []
|
||||
elseif prop == 'border-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)$'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)-color'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop =~ 'border-\%(top\|right\|bottom\|left\)-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'border-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'border'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z0-9.]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$'
|
||||
let values = ["rgb(", "#", "transparent"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'bottom'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'caption-side'
|
||||
let values = ["top", "bottom"]
|
||||
elseif prop == 'clear'
|
||||
let values = ["none", "left", "right", "both"]
|
||||
elseif prop == 'clip'
|
||||
let values = ["auto", "rect("]
|
||||
elseif prop == 'color'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif prop == 'content'
|
||||
let values = ["normal", "attr(", "open-quote", "close-quote", "no-open-quote", "no-close-quote"]
|
||||
elseif prop =~ 'counter-\%(increment\|reset\)$'
|
||||
let values = ["none"]
|
||||
elseif prop =~ '^\%(cue-after\|cue-before\|cue\)$'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'cursor'
|
||||
let values = ["url(", "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help", "progress"]
|
||||
elseif prop == 'direction'
|
||||
let values = ["ltr", "rtl"]
|
||||
elseif prop == 'display'
|
||||
let values = ["inline", "block", "list-item", "run-in", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group", "table-column", "table-cell", "table-caption", "none"]
|
||||
elseif prop == 'elevation'
|
||||
let values = ["below", "level", "above", "higher", "lower"]
|
||||
elseif prop == 'empty-cells'
|
||||
let values = ["show", "hide"]
|
||||
elseif prop == 'float'
|
||||
let values = ["left", "right", "none"]
|
||||
elseif prop == 'font-family'
|
||||
let values = ["sans-serif", "serif", "monospace", "cursive", "fantasy"]
|
||||
elseif prop == 'font-size'
|
||||
let values = ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller"]
|
||||
elseif prop == 'font-style'
|
||||
let values = ["normal", "italic", "oblique"]
|
||||
elseif prop == 'font-variant'
|
||||
let values = ["normal", "small-caps"]
|
||||
elseif prop == 'font-weight'
|
||||
let values = ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
|
||||
elseif prop == 'font'
|
||||
let values = ["normal", "italic", "oblique", "small-caps", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "larger", "smaller", "sans-serif", "serif", "monospace", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"]
|
||||
elseif prop =~ '^\%(height\|width\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop =~ '^\%(left\|rigth\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'letter-spacing'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'line-height'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'list-style-image'
|
||||
let values = ["url(", "none"]
|
||||
elseif prop == 'list-style-position'
|
||||
let values = ["inside", "outside"]
|
||||
elseif prop == 'list-style-type'
|
||||
let values = ["disc", "circle", "square", "decimal", "decimal-leading-zero", "lower-roman", "upper-roman", "lower-latin", "upper-latin", "none"]
|
||||
elseif prop == 'list-style'
|
||||
return []
|
||||
elseif prop == 'margin'
|
||||
let values = ["auto"]
|
||||
elseif prop =~ 'margin-\%(right\|left\|top\|bottom\)$'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'max-height'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'max-width'
|
||||
let values = ["none"]
|
||||
elseif prop == 'min-height'
|
||||
let values = ["none"]
|
||||
elseif prop == 'min-width'
|
||||
let values = ["none"]
|
||||
elseif prop == 'orphans'
|
||||
return []
|
||||
elseif prop == 'outline-color'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif prop == 'outline-style'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif prop == 'outline-width'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
elseif prop == 'outline'
|
||||
let vals = matchstr(line, '.*:\s*\zs.*')
|
||||
if vals =~ '^\%([a-zA-Z0-9,()#]\+\)\?$'
|
||||
let values = ["rgb(", "#"]
|
||||
elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+\%([a-zA-Z]\+\)\?$'
|
||||
let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
|
||||
elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+[a-zA-Z]\+\s\+\%([a-zA-Z(]\+\)\?$'
|
||||
let values = ["thin", "thick", "medium"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
elseif prop == 'overflow'
|
||||
let values = ["visible", "hidden", "scroll", "auto"]
|
||||
elseif prop == 'padding'
|
||||
return []
|
||||
elseif prop =~ 'padding-\%(top\|right\|bottom\|left\)$'
|
||||
return []
|
||||
elseif prop =~ 'page-break-\%(after\|before\)$'
|
||||
let values = ["auto", "always", "avoid", "left", "right"]
|
||||
elseif prop == 'page-break-inside'
|
||||
let values = ["auto", "avoid"]
|
||||
elseif prop =~ 'pause-\%(after\|before\)$'
|
||||
return []
|
||||
elseif prop == 'pause'
|
||||
return []
|
||||
elseif prop == 'pitch-range'
|
||||
return []
|
||||
elseif prop == 'pitch'
|
||||
let values = ["x-low", "low", "medium", "high", "x-high"]
|
||||
elseif prop == 'play-during'
|
||||
let values = ["url(", "mix", "repeat", "auto", "none"]
|
||||
elseif prop == 'position'
|
||||
let values = ["static", "relative", "absolute", "fixed"]
|
||||
elseif prop == 'quotes'
|
||||
let values = ["none"]
|
||||
elseif prop == 'richness'
|
||||
return []
|
||||
elseif prop == 'speak-header'
|
||||
let values = ["once", "always"]
|
||||
elseif prop == 'speak-numeral'
|
||||
let values = ["digits", "continuous"]
|
||||
elseif prop == 'speak-punctuation'
|
||||
let values = ["code", "none"]
|
||||
elseif prop == 'speak'
|
||||
let values = ["normal", "none", "spell-out"]
|
||||
elseif prop == 'speech-rate'
|
||||
let values = ["x-slow", "slow", "medium", "fast", "x-fast", "faster", "slower"]
|
||||
elseif prop == 'stress'
|
||||
return []
|
||||
elseif prop == 'table-layout'
|
||||
let values = ["auto", "fixed"]
|
||||
elseif prop == 'text-align'
|
||||
let values = ["left", "right", "center", "justify"]
|
||||
elseif prop == 'text-decoration'
|
||||
let values = ["none", "underline", "overline", "line-through", "blink"]
|
||||
elseif prop == 'text-indent'
|
||||
return []
|
||||
elseif prop == 'text-transform'
|
||||
let values = ["capitalize", "uppercase", "lowercase", "none"]
|
||||
elseif prop == 'top'
|
||||
let values = ["auto"]
|
||||
elseif prop == 'unicode-bidi'
|
||||
let values = ["normal", "embed", "bidi-override"]
|
||||
elseif prop == 'vertical-align'
|
||||
let values = ["baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"]
|
||||
elseif prop == 'visibility'
|
||||
let values = ["visible", "hidden", "collapse"]
|
||||
elseif prop == 'voice-family'
|
||||
return []
|
||||
elseif prop == 'volume'
|
||||
let values = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"]
|
||||
elseif prop == 'white-space'
|
||||
let values = ["normal", "pre", "nowrap", "pre-wrap", "pre-line"]
|
||||
elseif prop == 'widows'
|
||||
return []
|
||||
elseif prop == 'word-spacing'
|
||||
let values = ["normal"]
|
||||
elseif prop == 'z-index'
|
||||
let values = ["auto"]
|
||||
else
|
||||
" If no property match it is possible we are outside of {} and
|
||||
" trying to complete pseudo-(class|element)
|
||||
let element = tolower(matchstr(line, '\zs[a-zA-Z1-6]*\ze:[^:[:space:]]\{-}$'))
|
||||
if stridx(',a,abbr,acronym,address,area,b,base,bdo,big,blockquote,body,br,button,caption,cite,code,col,colgroup,dd,del,dfn,div,dl,dt,em,fieldset,form,head,h1,h2,h3,h4,h5,h6,hr,html,i,img,input,ins,kbd,label,legend,li,link,map,meta,noscript,object,ol,optgroup,option,p,param,pre,q,samp,script,select,small,span,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,ul,var,', ','.element.',') > -1
|
||||
let values = ["first-child", "link", "visited", "hover", "active", "focus", "lang", "first-line", "first-letter", "before", "after"]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" Complete values
|
||||
let entered_value = matchstr(line, '.\{-}\zs[a-zA-Z0-9#,.(_-]*$')
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_value
|
||||
call add(res, m)
|
||||
elseif m =~? entered_value
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
elseif borders[max(keys(borders))] == 'closebrace'
|
||||
|
||||
return []
|
||||
|
||||
elseif borders[max(keys(borders))] == 'exclam'
|
||||
|
||||
" Complete values
|
||||
let entered_imp = matchstr(line, '.\{-}!\s*\zs[a-zA-Z ]*$')
|
||||
|
||||
let values = ["important"]
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_imp
|
||||
call add(res, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res
|
||||
|
||||
elseif borders[max(keys(borders))] == 'atrule'
|
||||
|
||||
let afterat = matchstr(line, '.*@\zs.*')
|
||||
|
||||
if afterat =~ '\s'
|
||||
|
||||
let atrulename = matchstr(line, '.*@\zs[a-zA-Z-]\+\ze')
|
||||
|
||||
if atrulename == 'media'
|
||||
let values = ["screen", "tty", "tv", "projection", "handheld", "print", "braille", "aural", "all"]
|
||||
|
||||
let entered_atruleafter = matchstr(line, '.*@media\s\+\zs.*$')
|
||||
|
||||
elseif atrulename == 'import'
|
||||
let entered_atruleafter = matchstr(line, '.*@import\s\+\zs.*$')
|
||||
|
||||
if entered_atruleafter =~ "^[\"']"
|
||||
let filestart = matchstr(entered_atruleafter, '^.\zs.*')
|
||||
let files = split(glob(filestart.'*'), '\n')
|
||||
let values = map(copy(files), '"\"".v:val')
|
||||
|
||||
elseif entered_atruleafter =~ "^url("
|
||||
let filestart = matchstr(entered_atruleafter, "^url([\"']\\?\\zs.*")
|
||||
let files = split(glob(filestart.'*'), '\n')
|
||||
let values = map(copy(files), '"url(".v:val')
|
||||
|
||||
else
|
||||
let values = ['"', 'url(']
|
||||
|
||||
endif
|
||||
|
||||
else
|
||||
return []
|
||||
|
||||
endif
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_atruleafter
|
||||
call add(res, m)
|
||||
elseif m =~? entered_atruleafter
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
endif
|
||||
|
||||
let values = ["charset", "page", "media", "import", "font-face"]
|
||||
|
||||
let entered_atrule = matchstr(line, '.*@\zs[a-zA-Z-]*$')
|
||||
|
||||
for m in values
|
||||
if m =~? '^'.entered_atrule
|
||||
call add(res, m .' ')
|
||||
elseif m =~? entered_atrule
|
||||
call add(res2, m .' ')
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
endif
|
||||
|
||||
return []
|
||||
|
||||
endfunction
|
||||
75
vim/bundle/ubuntu-vim72/autoload/decada.vim
Normal file
75
vim/bundle/ubuntu-vim72/autoload/decada.vim
Normal file
@@ -0,0 +1,75 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Vim Ada/Dec Ada compiler file
|
||||
" Language: Ada (Dec Ada)
|
||||
" $Id: decada.vim 887 2008-07-08 14:29:01Z krischik $
|
||||
" Copyright: Copyright (C) 2006 Martin Krischik
|
||||
" Maintainer: Martin Krischik <krischik@users.sourceforge.net>
|
||||
" $Author: krischik $
|
||||
" $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
|
||||
" Version: 4.6
|
||||
" $Revision: 887 $
|
||||
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/decada.vim $
|
||||
" History: 21.07.2006 MK New Dec Ada
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested not to use include protection for
|
||||
" autoload
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" Help Page: compiler-decada
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
if version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
function decada#Unit_Name () dict " {{{1
|
||||
" Convert filename into acs unit:
|
||||
" 1: remove the file extenstion.
|
||||
" 2: replace all double '_' or '-' with an dot (which denotes a separate)
|
||||
" 3: remove a trailing '_' (wich denotes a specification)
|
||||
return substitute (substitute (expand ("%:t:r"), '__\|-', ".", "g"), '_$', "", '')
|
||||
endfunction decada#Unit_Name " }}}1
|
||||
|
||||
function decada#Make () dict " {{{1
|
||||
let l:make_prg = substitute (g:self.Make_Command, '%<', self.Unit_Name(), '')
|
||||
let &errorformat = g:self.Error_Format
|
||||
let &makeprg = l:make_prg
|
||||
wall
|
||||
make
|
||||
copen
|
||||
set wrap
|
||||
wincmd W
|
||||
endfunction decada#Build " }}}1
|
||||
|
||||
function decada#Set_Session (...) dict " {{{1
|
||||
if a:0 > 0
|
||||
call ada#Switch_Session (a:1)
|
||||
elseif argc() == 0 && strlen (v:servername) > 0
|
||||
call ada#Switch_Session (
|
||||
\ expand('~')[0:-2] . ".vimfiles.session]decada_" .
|
||||
\ v:servername . ".vim")
|
||||
endif
|
||||
return
|
||||
endfunction decada#Set_Session " }}}1
|
||||
|
||||
function decada#New () " }}}1
|
||||
let Retval = {
|
||||
\ 'Make' : function ('decada#Make'),
|
||||
\ 'Unit_Name' : function ('decada#Unit_Name'),
|
||||
\ 'Set_Session' : function ('decada#Set_Session'),
|
||||
\ 'Project_Dir' : '',
|
||||
\ 'Make_Command' : 'ACS COMPILE /Wait /Log /NoPreLoad /Optimize=Development /Debug %<',
|
||||
\ 'Error_Format' : '%+A%%ADAC-%t-%m,%C %#%m,%Zat line number %l in file %f,' .
|
||||
\ '%+I%%ada-I-%m,%C %#%m,%Zat line number %l in file %f'}
|
||||
|
||||
return Retval
|
||||
endfunction decada#New " }}}1
|
||||
|
||||
finish " 1}}}
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=78 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
644
vim/bundle/ubuntu-vim72/autoload/getscript.vim
Normal file
644
vim/bundle/ubuntu-vim72/autoload/getscript.vim
Normal file
@@ -0,0 +1,644 @@
|
||||
" ---------------------------------------------------------------------
|
||||
" getscript.vim
|
||||
" Author: Charles E. Campbell, Jr.
|
||||
" Date: Dec 28, 2009
|
||||
" Version: 32
|
||||
" Installing: :help glvs-install
|
||||
" Usage: :help glvs
|
||||
"
|
||||
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
|
||||
"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
||||
" ---------------------------------------------------------------------
|
||||
" Initialization: {{{1
|
||||
" if you're sourcing this file, surely you can't be
|
||||
" expecting vim to be in its vi-compatible mode!
|
||||
if exists("g:loaded_getscript")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_getscript= "v32"
|
||||
if &cp
|
||||
echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
|
||||
finish
|
||||
endif
|
||||
if v:version < 702
|
||||
echohl WarningMsg
|
||||
echo "***warning*** this version of getscript needs vim 7.2"
|
||||
echohl Normal
|
||||
finish
|
||||
endif
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
"DechoTabOn
|
||||
|
||||
" ---------------------------
|
||||
" Global Variables: {{{1
|
||||
" ---------------------------
|
||||
" Cygwin Detection ------- {{{2
|
||||
if !exists("g:getscript_cygwin")
|
||||
if has("win32") || has("win95") || has("win64") || has("win16")
|
||||
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
|
||||
let g:getscript_cygwin= 1
|
||||
else
|
||||
let g:getscript_cygwin= 0
|
||||
endif
|
||||
else
|
||||
let g:getscript_cygwin= 0
|
||||
endif
|
||||
endif
|
||||
|
||||
" wget vs curl {{{2
|
||||
if !exists("g:GetLatestVimScripts_wget")
|
||||
if executable("wget")
|
||||
let g:GetLatestVimScripts_wget= "wget"
|
||||
elseif executable("curl")
|
||||
let g:GetLatestVimScripts_wget= "curl"
|
||||
else
|
||||
let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"'
|
||||
let g:GetLatestVimScripts_options = ""
|
||||
endif
|
||||
endif
|
||||
|
||||
" options that wget and curl require:
|
||||
if !exists("g:GetLatestVimScripts_options")
|
||||
if g:GetLatestVimScripts_wget == "wget"
|
||||
let g:GetLatestVimScripts_options= "-q -O"
|
||||
elseif g:GetLatestVimScripts_wget == "curl"
|
||||
let g:GetLatestVimScripts_options= "-s -O"
|
||||
else
|
||||
let g:GetLatestVimScripts_options= ""
|
||||
endif
|
||||
endif
|
||||
|
||||
" by default, allow autoinstall lines to work
|
||||
if !exists("g:GetLatestVimScripts_allowautoinstall")
|
||||
let g:GetLatestVimScripts_allowautoinstall= 1
|
||||
endif
|
||||
|
||||
"" For debugging:
|
||||
"let g:GetLatestVimScripts_wget = "echo"
|
||||
"let g:GetLatestVimScripts_options = "options"
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Check If AutoInstall Capable: {{{1
|
||||
let s:autoinstall= ""
|
||||
if g:GetLatestVimScripts_allowautoinstall
|
||||
|
||||
if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash"
|
||||
" windows (but not cygwin/bash)
|
||||
let s:dotvim= "vimfiles"
|
||||
if !exists("g:GetLatestVimScripts_mv")
|
||||
let g:GetLatestVimScripts_mv= "ren"
|
||||
endif
|
||||
|
||||
else
|
||||
" unix
|
||||
let s:dotvim= ".vim"
|
||||
if !exists("g:GetLatestVimScripts_mv")
|
||||
let g:GetLatestVimScripts_mv= "mv"
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists("g:GetLatestVimScripts_autoinstalldir") && isdirectory(g:GetLatestVimScripts_autoinstalldir)
|
||||
let s:autoinstall= g:GetLatestVimScripts_autoinstalldir"
|
||||
elseif exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim)
|
||||
let s:autoinstall= $HOME."/".s:dotvim
|
||||
endif
|
||||
" call Decho("s:autoinstall<".s:autoinstall.">")
|
||||
"else "Decho
|
||||
" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled")
|
||||
endif
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Public Interface: {{{1
|
||||
com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
|
||||
com! -nargs=0 GetScript call getscript#GetLatestVimScripts()
|
||||
silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" GetLatestVimScripts: this function gets the latest versions of {{{1
|
||||
" scripts based on the list in
|
||||
" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
|
||||
fun! getscript#GetLatestVimScripts()
|
||||
" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">")
|
||||
|
||||
" insure that wget is executable
|
||||
if executable(g:GetLatestVimScripts_wget) != 1
|
||||
echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system"
|
||||
" call Dret("GetLatestVimScripts : wget not executable/availble")
|
||||
return
|
||||
endif
|
||||
|
||||
" insure that fnameescape() is available
|
||||
if !exists("*fnameescape")
|
||||
echoerr "GetLatestVimScripts needs fnameescape() (provided by 7.1.299 or later)"
|
||||
return
|
||||
endif
|
||||
|
||||
" Find the .../GetLatest subdirectory under the runtimepath
|
||||
for datadir in split(&rtp,',') + ['']
|
||||
if isdirectory(datadir."/GetLatest")
|
||||
" call Decho("found directory<".datadir.">")
|
||||
let datadir= datadir . "/GetLatest"
|
||||
break
|
||||
endif
|
||||
if filereadable(datadir."GetLatestVimScripts.dat")
|
||||
" call Decho("found ".datadir."/GetLatestVimScripts.dat")
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Sanity checks: readability and writability
|
||||
if datadir == ""
|
||||
echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
|
||||
" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory")
|
||||
return
|
||||
endif
|
||||
if filewritable(datadir) != 2
|
||||
echoerr "(getLatestVimScripts) Your ".datadir." isn't writable"
|
||||
" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">")
|
||||
return
|
||||
endif
|
||||
let datafile= datadir."/GetLatestVimScripts.dat"
|
||||
if !filereadable(datafile)
|
||||
echoerr "Your data file<".datafile."> isn't readable"
|
||||
" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">")
|
||||
return
|
||||
endif
|
||||
if !filewritable(datafile)
|
||||
echoerr "Your data file<".datafile."> isn't writable"
|
||||
" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">")
|
||||
return
|
||||
endif
|
||||
" --------------------
|
||||
" Passed sanity checks
|
||||
" --------------------
|
||||
|
||||
" call Decho("datadir <".datadir.">")
|
||||
" call Decho("datafile <".datafile.">")
|
||||
|
||||
" don't let any event handlers interfere (like winmanager's, taglist's, etc)
|
||||
let eikeep = &ei
|
||||
let hlskeep = &hls
|
||||
let acdkeep = &acd
|
||||
set ei=all hls&vim noacd
|
||||
|
||||
" Edit the datafile (ie. GetLatestVimScripts.dat):
|
||||
" 1. record current directory (origdir),
|
||||
" 2. change directory to datadir,
|
||||
" 3. split window
|
||||
" 4. edit datafile
|
||||
let origdir= getcwd()
|
||||
" call Decho("exe cd ".fnameescape(substitute(datadir,'\','/','ge')))
|
||||
exe "cd ".fnameescape(substitute(datadir,'\','/','ge'))
|
||||
split
|
||||
" call Decho("exe e ".fnameescape(substitute(datafile,'\','/','ge')))
|
||||
exe "e ".fnameescape(substitute(datafile,'\','/','ge'))
|
||||
res 1000
|
||||
let s:downloads = 0
|
||||
let s:downerrors= 0
|
||||
|
||||
" Check on dependencies mentioned in plugins
|
||||
" call Decho(" ")
|
||||
" call Decho("searching plugins for GetLatestVimScripts dependencies")
|
||||
let lastline = line("$")
|
||||
" call Decho("lastline#".lastline)
|
||||
let firstdir = substitute(&rtp,',.*$','','')
|
||||
let plugins = split(globpath(firstdir,"plugin/*.vim"),'\n')
|
||||
let plugins = plugins + split(globpath(firstdir,"AsNeeded/*.vim"),'\n')
|
||||
let foundscript = 0
|
||||
|
||||
" this loop updates the GetLatestVimScripts.dat file
|
||||
" with dependencies explicitly mentioned in the plugins
|
||||
" via GetLatestVimScripts: ... lines
|
||||
" It reads the plugin script at the end of the GetLatestVimScripts.dat
|
||||
" file, examines it, and then removes it.
|
||||
for plugin in plugins
|
||||
" call Decho(" ")
|
||||
" call Decho("plugin<".plugin.">")
|
||||
|
||||
" read plugin in
|
||||
" evidently a :r creates a new buffer (the "#" buffer) that is subsequently unused -- bwiping it
|
||||
$
|
||||
" call Decho(".dependency checking<".plugin."> line$=".line("$"))
|
||||
" call Decho("..exe silent r ".fnameescape(plugin))
|
||||
exe "silent r ".fnameescape(plugin)
|
||||
exe "silent bwipe ".bufnr("#")
|
||||
|
||||
while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
|
||||
let depscript = substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
|
||||
let depscriptid = substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\(\d\+\)\s\+.*$','\1','')
|
||||
let llp1 = lastline+1
|
||||
" call Decho("..depscript<".depscript.">")
|
||||
|
||||
" found a "GetLatestVimScripts: # #" line in the script;
|
||||
" check if its already in the datafile by searching backwards from llp1,
|
||||
" the (prior to reading in the plugin script) last line plus one of the GetLatestVimScripts.dat file,
|
||||
" for the script-id with no wrapping allowed.
|
||||
let curline = line(".")
|
||||
let noai_script = substitute(depscript,'\s*:AutoInstall:\s*','','e')
|
||||
exe llp1
|
||||
let srchline = search('^\s*'.depscriptid.'\s\+\d\+\s\+.*$','bW')
|
||||
if srchline == 0
|
||||
" this second search is taken when, for example, a 0 0 scriptname is to be skipped over
|
||||
let srchline= search('\<'.noai_script.'\>','bW')
|
||||
endif
|
||||
" call Decho("..noai_script<".noai_script."> depscriptid#".depscriptid." srchline#".srchline." curline#".line(".")." lastline#".lastline)
|
||||
|
||||
if srchline == 0
|
||||
" found a new script to permanently include in the datafile
|
||||
let keep_rega = @a
|
||||
let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','')
|
||||
echomsg "Appending <".@a."> to ".datafile." for ".depscript
|
||||
" call Decho("..Appending <".@a."> to ".datafile." for ".depscript)
|
||||
exe lastline."put a"
|
||||
let @a = keep_rega
|
||||
let lastline = llp1
|
||||
let curline = curline + 1
|
||||
let foundscript = foundscript + 1
|
||||
" else " Decho
|
||||
" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
|
||||
endif
|
||||
|
||||
let curline = curline + 1
|
||||
exe curline
|
||||
endwhile
|
||||
|
||||
" llp1: last line plus one
|
||||
let llp1= lastline + 1
|
||||
" call Decho(".deleting lines: ".llp1.",$d")
|
||||
exe "silent! ".llp1.",$d"
|
||||
endfor
|
||||
" call Decho("--- end dependency checking loop --- foundscript=".foundscript)
|
||||
" call Decho(" ")
|
||||
" call Dredir("BUFFER TEST (GetLatestVimScripts 1)","ls!")
|
||||
|
||||
if foundscript == 0
|
||||
setlocal nomod
|
||||
endif
|
||||
|
||||
" --------------------------------------------------------------------
|
||||
" Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
|
||||
" --------------------------------------------------------------------
|
||||
" call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
|
||||
setlocal lz
|
||||
1
|
||||
" /^-----/,$g/^\s*\d/call Decho(getline("."))
|
||||
1
|
||||
/^-----/,$g/^\s*\d/call s:GetOneScript()
|
||||
" call Decho("--- end out-of-date checking --- ")
|
||||
|
||||
" Final report (an echomsg)
|
||||
try
|
||||
silent! ?^-------?
|
||||
catch /^Vim\%((\a\+)\)\=:E114/
|
||||
" call Dret("GetLatestVimScripts : nothing done!")
|
||||
return
|
||||
endtry
|
||||
exe "norm! kz\<CR>"
|
||||
redraw!
|
||||
let s:msg = ""
|
||||
if s:downloads == 1
|
||||
let s:msg = "Downloaded one updated script to <".datadir.">"
|
||||
elseif s:downloads == 2
|
||||
let s:msg= "Downloaded two updated scripts to <".datadir.">"
|
||||
elseif s:downloads > 1
|
||||
let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">"
|
||||
else
|
||||
let s:msg= "Everything was already current"
|
||||
endif
|
||||
if s:downerrors > 0
|
||||
let s:msg= s:msg." (".s:downerrors." downloading errors)"
|
||||
endif
|
||||
echomsg s:msg
|
||||
" save the file
|
||||
if &mod
|
||||
silent! w!
|
||||
endif
|
||||
q
|
||||
|
||||
" restore events and current directory
|
||||
exe "cd ".fnameescape(substitute(origdir,'\','/','ge'))
|
||||
let &ei = eikeep
|
||||
let &hls = hlskeep
|
||||
let &acd = acdkeep
|
||||
setlocal nolz
|
||||
" call Dredir("BUFFER TEST (GetLatestVimScripts 2)","ls!")
|
||||
" call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" GetOneScript: (Get Latest Vim Script) this function operates {{{1
|
||||
" on the current line, interpreting two numbers and text as
|
||||
" ScriptID, SourceID, and Filename.
|
||||
" It downloads any scripts that have newer versions from vim.sourceforge.net.
|
||||
fun! s:GetOneScript(...)
|
||||
" call Dfunc("GetOneScript()")
|
||||
|
||||
" set options to allow progress to be shown on screen
|
||||
let rega= @a
|
||||
let t_ti= &t_ti
|
||||
let t_te= &t_te
|
||||
let rs = &rs
|
||||
set t_ti= t_te= nors
|
||||
|
||||
" put current line on top-of-screen and interpret it into
|
||||
" a script identifer : used to obtain webpage
|
||||
" source identifier : used to identify current version
|
||||
" and an associated comment: used to report on what's being considered
|
||||
if a:0 >= 3
|
||||
let scriptid = a:1
|
||||
let srcid = a:2
|
||||
let fname = a:3
|
||||
let cmmnt = ""
|
||||
" call Decho("scriptid<".scriptid.">")
|
||||
" call Decho("srcid <".srcid.">")
|
||||
" call Decho("fname <".fname.">")
|
||||
else
|
||||
let curline = getline(".")
|
||||
if curline =~ '^\s*#'
|
||||
let @a= rega
|
||||
" call Dret("GetOneScript : skipping a pure comment line")
|
||||
return
|
||||
endif
|
||||
let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$'
|
||||
try
|
||||
let scriptid = substitute(curline,parsepat,'\1','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let scriptid= 0
|
||||
endtry
|
||||
try
|
||||
let srcid = substitute(curline,parsepat,'\2','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let srcid= 0
|
||||
endtry
|
||||
try
|
||||
let fname= substitute(curline,parsepat,'\3','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let fname= ""
|
||||
endtry
|
||||
try
|
||||
let cmmnt= substitute(curline,parsepat,'\4','e')
|
||||
catch /^Vim\%((\a\+)\)\=:E486/
|
||||
let cmmnt= ""
|
||||
endtry
|
||||
" call Decho("curline <".curline.">")
|
||||
" call Decho("parsepat<".parsepat.">")
|
||||
" call Decho("scriptid<".scriptid.">")
|
||||
" call Decho("srcid <".srcid.">")
|
||||
" call Decho("fname <".fname.">")
|
||||
endif
|
||||
|
||||
" plugin author protection from downloading his/her own scripts atop their latest work
|
||||
if scriptid == 0 || srcid == 0
|
||||
" When looking for :AutoInstall: lines, skip scripts that have 0 0 scriptname
|
||||
let @a= rega
|
||||
" call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
|
||||
return
|
||||
endif
|
||||
|
||||
let doautoinstall= 0
|
||||
if fname =~ ":AutoInstall:"
|
||||
" call Decho("case AutoInstall: fname<".fname.">")
|
||||
let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','')
|
||||
" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall)
|
||||
if s:autoinstall != ""
|
||||
let doautoinstall = g:GetLatestVimScripts_allowautoinstall
|
||||
endif
|
||||
else
|
||||
let aicmmnt= fname
|
||||
endif
|
||||
" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall)
|
||||
|
||||
exe "norm z\<CR>"
|
||||
redraw!
|
||||
" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid)
|
||||
echo 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid
|
||||
|
||||
" grab a copy of the plugin's vim.sourceforge.net webpage
|
||||
let scriptaddr = 'http://vim.sourceforge.net/script.php?script_id='.scriptid
|
||||
let tmpfile = tempname()
|
||||
let v:errmsg = ""
|
||||
|
||||
" make up to three tries at downloading the description
|
||||
let itry= 1
|
||||
while itry <= 3
|
||||
" call Decho(".try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr)
|
||||
if has("win32") || has("win16") || has("win95")
|
||||
" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile).' '.shellescape(scriptaddr)."|bw!")
|
||||
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile).' '.shellescape(scriptaddr)|bw!
|
||||
else
|
||||
" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile)." ".shellescape(scriptaddr))
|
||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile)." ".shellescape(scriptaddr)
|
||||
endif
|
||||
if itry == 1
|
||||
exe "silent vsplit ".fnameescape(tmpfile)
|
||||
else
|
||||
silent! e %
|
||||
endif
|
||||
setlocal bh=wipe
|
||||
|
||||
" find the latest source-id in the plugin's webpage
|
||||
silent! 1
|
||||
let findpkg= search('Click on the package to download','W')
|
||||
if findpkg > 0
|
||||
break
|
||||
endif
|
||||
let itry= itry + 1
|
||||
endwhile
|
||||
" call Decho(" --- end downloading tries while loop --- itry=".itry)
|
||||
|
||||
" testing: did finding "Click on the package..." fail?
|
||||
if findpkg == 0 || itry >= 4
|
||||
silent q!
|
||||
call delete(tmpfile)
|
||||
" restore options
|
||||
let &t_ti = t_ti
|
||||
let &t_te = t_te
|
||||
let &rs = rs
|
||||
let s:downerrors = s:downerrors + 1
|
||||
" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
|
||||
echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
|
||||
" call Dret("GetOneScript : srch for /Click on the package/ failed")
|
||||
let @a= rega
|
||||
return
|
||||
endif
|
||||
" call Decho('found "Click on the package to download"')
|
||||
|
||||
let findsrcid= search('src_id=','W')
|
||||
if findsrcid == 0
|
||||
silent q!
|
||||
call delete(tmpfile)
|
||||
" restore options
|
||||
let &t_ti = t_ti
|
||||
let &t_te = t_te
|
||||
let &rs = rs
|
||||
let s:downerrors = s:downerrors + 1
|
||||
" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
|
||||
echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
|
||||
let @a= rega
|
||||
" call Dret("GetOneScript : srch for /src_id/ failed")
|
||||
return
|
||||
endif
|
||||
" call Decho('found "src_id=" in description page')
|
||||
|
||||
let srcidpat = '^\s*<td class.*src_id=\(\d\+\)">\([^<]\+\)<.*$'
|
||||
let latestsrcid= substitute(getline("."),srcidpat,'\1','')
|
||||
let sname = substitute(getline("."),srcidpat,'\2','') " script name actually downloaded
|
||||
" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> sname<".sname.">")
|
||||
silent q!
|
||||
call delete(tmpfile)
|
||||
|
||||
" convert the strings-of-numbers into numbers
|
||||
let srcid = srcid + 0
|
||||
let latestsrcid = latestsrcid + 0
|
||||
" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." sname<".sname.">")
|
||||
|
||||
" has the plugin's most-recent srcid increased, which indicates that it has been updated
|
||||
if latestsrcid > srcid
|
||||
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."]: need to update <".sname.">")
|
||||
|
||||
let s:downloads= s:downloads + 1
|
||||
if sname == bufname("%")
|
||||
" GetLatestVimScript has to be careful about downloading itself
|
||||
let sname= "NEW_".sname
|
||||
endif
|
||||
|
||||
" -----------------------------------------------------------------------------
|
||||
" the plugin has been updated since we last obtained it, so download a new copy
|
||||
" -----------------------------------------------------------------------------
|
||||
" call Decho(".downloading new <".sname.">")
|
||||
echomsg ".downloading new <".sname.">"
|
||||
if has("win32") || has("win16") || has("win95")
|
||||
" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='.latestsrcid)."|q")
|
||||
new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='.latestsrcid)|q
|
||||
else
|
||||
" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='))
|
||||
exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id=').latestsrcid
|
||||
endif
|
||||
|
||||
" --------------------------------------------------------------------------
|
||||
" AutoInstall: only if doautoinstall has been requested by the plugin itself
|
||||
" --------------------------------------------------------------------------
|
||||
if doautoinstall
|
||||
" call Decho(" ")
|
||||
" call Decho("Autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
|
||||
if filereadable(sname)
|
||||
" call Decho("<".sname."> is readable")
|
||||
" call Decho("exe silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall))
|
||||
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall)
|
||||
let curdir = escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #")
|
||||
let installdir= curdir."/Installed"
|
||||
if !isdirectory(installdir)
|
||||
call mkdir(installdir)
|
||||
endif
|
||||
" call Decho("curdir<".curdir."> installdir<".installdir.">")
|
||||
" call Decho("exe cd ".fnameescape(s:autoinstall))
|
||||
exe "cd ".fnameescape(s:autoinstall)
|
||||
|
||||
" determine target directory for moves
|
||||
let firstdir= substitute(&rtp,',.*$','','')
|
||||
let pname = substitute(sname,'\..*','.vim','')
|
||||
" call Decho("determine tgtdir: is <".firstdir.'/AsNeeded/'.pname." readable?")
|
||||
if filereadable(firstdir.'/AsNeeded/'.pname)
|
||||
let tgtdir= "AsNeeded"
|
||||
else
|
||||
let tgtdir= "plugin"
|
||||
endif
|
||||
" call Decho("tgtdir<".tgtdir."> pname<".pname.">")
|
||||
|
||||
" decompress
|
||||
if sname =~ '\.bz2$'
|
||||
" call Decho("decompress: attempt to bunzip2 ".sname)
|
||||
exe "silent !bunzip2 ".shellescape(sname)
|
||||
let sname= substitute(sname,'\.bz2$','','')
|
||||
" call Decho("decompress: new sname<".sname."> after bunzip2")
|
||||
elseif sname =~ '\.gz$'
|
||||
" call Decho("decompress: attempt to gunzip ".sname)
|
||||
exe "silent !gunzip ".shellescape(sname)
|
||||
let sname= substitute(sname,'\.gz$','','')
|
||||
" call Decho("decompress: new sname<".sname."> after gunzip")
|
||||
else
|
||||
" call Decho("no decompression needed")
|
||||
endif
|
||||
|
||||
" distribute archive(.zip, .tar, .vba) contents
|
||||
if sname =~ '\.zip$'
|
||||
" call Decho("dearchive: attempt to unzip ".sname)
|
||||
exe "silent !unzip -o ".shellescape(sname)
|
||||
elseif sname =~ '\.tar$'
|
||||
" call Decho("dearchive: attempt to untar ".sname)
|
||||
exe "silent !tar -xvf ".shellescape(sname)
|
||||
elseif sname =~ '\.vba$'
|
||||
" call Decho("dearchive: attempt to handle a vimball: ".sname)
|
||||
silent 1split
|
||||
if exists("g:vimball_home")
|
||||
let oldvimballhome= g:vimball_home
|
||||
endif
|
||||
let g:vimball_home= s:autoinstall
|
||||
exe "silent e ".fnameescape(sname)
|
||||
silent so %
|
||||
silent q
|
||||
if exists("oldvimballhome")
|
||||
let g:vimball_home= oldvimballhome
|
||||
else
|
||||
unlet g:vimball_home
|
||||
endif
|
||||
else
|
||||
" call Decho("no dearchiving needed")
|
||||
endif
|
||||
|
||||
" ---------------------------------------------
|
||||
" move plugin to plugin/ or AsNeeded/ directory
|
||||
" ---------------------------------------------
|
||||
if sname =~ '.vim$'
|
||||
" call Decho("dearchive: attempt to simply move ".sname." to ".tgtdir)
|
||||
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".tgtdir
|
||||
else
|
||||
" call Decho("dearchive: move <".sname."> to installdir<".installdir.">")
|
||||
exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".installdir
|
||||
endif
|
||||
if tgtdir != "plugin"
|
||||
" call Decho("exe silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir)
|
||||
exe "silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir
|
||||
endif
|
||||
|
||||
" helptags step
|
||||
let docdir= substitute(&rtp,',.*','','e')."/doc"
|
||||
" call Decho("helptags: docdir<".docdir.">")
|
||||
exe "helptags ".fnameescape(docdir)
|
||||
exe "cd ".fnameescape(curdir)
|
||||
endif
|
||||
if fname !~ ':AutoInstall:'
|
||||
let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt
|
||||
else
|
||||
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
|
||||
endif
|
||||
else
|
||||
let modline=scriptid." ".latestsrcid." ".fname.cmmnt
|
||||
endif
|
||||
|
||||
" update the data in the <GetLatestVimScripts.dat> file
|
||||
call setline(line("."),modline)
|
||||
" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
|
||||
" else " Decho
|
||||
" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
|
||||
endif
|
||||
|
||||
" restore options
|
||||
let &t_ti = t_ti
|
||||
let &t_te = t_te
|
||||
let &rs = rs
|
||||
let @a = rega
|
||||
" call Dredir("BUFFER TEST (GetOneScript)","ls!")
|
||||
|
||||
" call Dret("GetOneScript")
|
||||
endfun
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Restore Options: {{{1
|
||||
let &cpo= s:keepcpo
|
||||
unlet s:keepcpo
|
||||
|
||||
" ---------------------------------------------------------------------
|
||||
" Modelines: {{{1
|
||||
" vim: ts=8 sts=2 fdm=marker nowrap
|
||||
147
vim/bundle/ubuntu-vim72/autoload/gnat.vim
Normal file
147
vim/bundle/ubuntu-vim72/autoload/gnat.vim
Normal file
@@ -0,0 +1,147 @@
|
||||
"------------------------------------------------------------------------------
|
||||
" Description: Vim Ada/GNAT compiler file
|
||||
" Language: Ada (GNAT)
|
||||
" $Id: gnat.vim 887 2008-07-08 14:29:01Z krischik $
|
||||
" Copyright: Copyright (C) 2006 Martin Krischik
|
||||
" Maintainer: Martin Krischi <krischik@users.sourceforge.net>k
|
||||
" Ned Okie <nokie@radford.edu>
|
||||
" $Author: krischik $
|
||||
" $Date: 2008-07-08 16:29:01 +0200 (Di, 08 Jul 2008) $
|
||||
" Version: 4.6
|
||||
" $Revision: 887 $
|
||||
" $HeadURL: https://gnuada.svn.sourceforge.net/svnroot/gnuada/trunk/tools/vim/autoload/gnat.vim $
|
||||
" History: 24.05.2006 MK Unified Headers
|
||||
" 16.07.2006 MK Ada-Mode as vim-ball
|
||||
" 05.08.2006 MK Add session support
|
||||
" 15.10.2006 MK Bram's suggestion for runtime integration
|
||||
" 05.11.2006 MK Bram suggested not to use include protection for
|
||||
" autoload
|
||||
" 05.11.2006 MK Bram suggested to save on spaces
|
||||
" 19.09.2007 NO use project file only when there is a project
|
||||
" Help Page: compiler-gnat
|
||||
"------------------------------------------------------------------------------
|
||||
|
||||
if version < 700
|
||||
finish
|
||||
endif
|
||||
|
||||
function gnat#Make () dict " {{{1
|
||||
let &l:makeprg = self.Get_Command('Make')
|
||||
let &l:errorformat = self.Error_Format
|
||||
wall
|
||||
make
|
||||
copen
|
||||
set wrap
|
||||
wincmd W
|
||||
endfunction gnat#Make " }}}1
|
||||
|
||||
function gnat#Pretty () dict " {{{1
|
||||
execute "!" . self.Get_Command('Pretty')
|
||||
endfunction gnat#Make " }}}1
|
||||
|
||||
function gnat#Find () dict " {{{1
|
||||
execute "!" . self.Get_Command('Find')
|
||||
endfunction gnat#Find " }}}1
|
||||
|
||||
function gnat#Tags () dict " {{{1
|
||||
execute "!" . self.Get_Command('Tags')
|
||||
edit tags
|
||||
call gnat#Insert_Tags_Header ()
|
||||
update
|
||||
quit
|
||||
endfunction gnat#Tags " }}}1
|
||||
|
||||
function gnat#Set_Project_File (...) dict " {{{1
|
||||
if a:0 > 0
|
||||
let self.Project_File = a:1
|
||||
|
||||
if ! filereadable (self.Project_File)
|
||||
let self.Project_File = findfile (
|
||||
\ fnamemodify (self.Project_File, ':r'),
|
||||
\ $ADA_PROJECT_PATH,
|
||||
\ 1)
|
||||
endif
|
||||
elseif strlen (self.Project_File) > 0
|
||||
let self.Project_File = browse (0, 'GNAT Project File?', '', self.Project_File)
|
||||
elseif expand ("%:e") == 'gpr'
|
||||
let self.Project_File = browse (0, 'GNAT Project File?', '', expand ("%:e"))
|
||||
else
|
||||
let self.Project_File = browse (0, 'GNAT Project File?', '', 'default.gpr')
|
||||
endif
|
||||
|
||||
if strlen (v:this_session) > 0
|
||||
execute 'mksession! ' . v:this_session
|
||||
endif
|
||||
|
||||
"if strlen (self.Project_File) > 0
|
||||
"if has("vms")
|
||||
"call ada#Switch_Session (
|
||||
"\ expand('~')[0:-2] . ".vimfiles.session]gnat_" .
|
||||
"\ fnamemodify (self.Project_File, ":t:r") . ".vim")
|
||||
"else
|
||||
"call ada#Switch_Session (
|
||||
"\ expand('~') . "/vimfiles/session/gnat_" .
|
||||
"\ fnamemodify (self.Project_File, ":t:r") . ".vim")
|
||||
"endif
|
||||
"else
|
||||
"call ada#Switch_Session ('')
|
||||
"endif
|
||||
|
||||
return
|
||||
endfunction gnat#Set_Project_File " }}}1
|
||||
|
||||
function gnat#Get_Command (Command) dict " {{{1
|
||||
let l:Command = eval ('self.' . a:Command . '_Command')
|
||||
return eval (l:Command)
|
||||
endfunction gnat#Get_Command " }}}1
|
||||
|
||||
function gnat#Set_Session (...) dict " {{{1
|
||||
if argc() == 1 && fnamemodify (argv(0), ':e') == 'gpr'
|
||||
call self.Set_Project_File (argv(0))
|
||||
elseif strlen (v:servername) > 0
|
||||
call self.Set_Project_File (v:servername . '.gpr')
|
||||
endif
|
||||
endfunction gnat#Set_Session " }}}1
|
||||
|
||||
function gnat#New () " {{{1
|
||||
let l:Retval = {
|
||||
\ 'Make' : function ('gnat#Make'),
|
||||
\ 'Pretty' : function ('gnat#Pretty'),
|
||||
\ 'Find' : function ('gnat#Find'),
|
||||
\ 'Tags' : function ('gnat#Tags'),
|
||||
\ 'Set_Project_File' : function ('gnat#Set_Project_File'),
|
||||
\ 'Set_Session' : function ('gnat#Set_Session'),
|
||||
\ 'Get_Command' : function ('gnat#Get_Command'),
|
||||
\ 'Project_File' : '',
|
||||
\ 'Make_Command' : '"gnat make -P " . self.Project_File . " -F -gnatef "',
|
||||
\ 'Pretty_Command' : '"gnat pretty -P " . self.Project_File . " "',
|
||||
\ 'Find_Program' : '"gnat find -P " . self.Project_File . " -F "',
|
||||
\ 'Tags_Command' : '"gnat xref -P " . self.Project_File . " -v *.AD*"',
|
||||
\ 'Error_Format' : '%f:%l:%c: %trror: %m,' .
|
||||
\ '%f:%l:%c: %tarning: %m,' .
|
||||
\ '%f:%l:%c: (%ttyle) %m'}
|
||||
|
||||
return l:Retval
|
||||
endfunction gnat#New " }}}1
|
||||
|
||||
function gnat#Insert_Tags_Header () " {{{1
|
||||
1insert
|
||||
!_TAG_FILE_FORMAT 1 /extended format; --format=1 will not append ;" to lines/
|
||||
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
||||
!_TAG_PROGRAM_AUTHOR AdaCore /info@adacore.com/
|
||||
!_TAG_PROGRAM_NAME gnatxref //
|
||||
!_TAG_PROGRAM_URL http://www.adacore.com /official site/
|
||||
!_TAG_PROGRAM_VERSION 5.05w //
|
||||
.
|
||||
return
|
||||
endfunction gnat#Insert_Tags_Header " }}}1
|
||||
|
||||
finish " 1}}}
|
||||
|
||||
"------------------------------------------------------------------------------
|
||||
" Copyright (C) 2006 Martin Krischik
|
||||
"
|
||||
" Vim is Charityware - see ":help license" or uganda.txt for licence details.
|
||||
"------------------------------------------------------------------------------
|
||||
" vim: textwidth=0 wrap tabstop=8 shiftwidth=3 softtabstop=3 noexpandtab
|
||||
" vim: foldmethod=marker
|
||||
212
vim/bundle/ubuntu-vim72/autoload/gzip.vim
Normal file
212
vim/bundle/ubuntu-vim72/autoload/gzip.vim
Normal file
@@ -0,0 +1,212 @@
|
||||
" Vim autoload file for editing compressed files.
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2008 Jul 04
|
||||
|
||||
" These functions are used by the gzip plugin.
|
||||
|
||||
" Function to check that executing "cmd [-f]" works.
|
||||
" The result is cached in s:have_"cmd" for speed.
|
||||
fun s:check(cmd)
|
||||
let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
|
||||
if !exists("s:have_" . name)
|
||||
let e = executable(name)
|
||||
if e < 0
|
||||
let r = system(name . " --version")
|
||||
let e = (r !~ "not found" && r != "")
|
||||
endif
|
||||
exe "let s:have_" . name . "=" . e
|
||||
endif
|
||||
exe "return s:have_" . name
|
||||
endfun
|
||||
|
||||
" Set b:gzip_comp_arg to the gzip argument to be used for compression, based on
|
||||
" the flags in the compressed file.
|
||||
" The only compression methods that can be detected are max speed (-1) and max
|
||||
" compression (-9).
|
||||
fun s:set_compression(line)
|
||||
" get the Compression Method
|
||||
let l:cm = char2nr(a:line[2])
|
||||
" if it's 8 (DEFLATE), we can check for the compression level
|
||||
if l:cm == 8
|
||||
" get the eXtra FLags
|
||||
let l:xfl = char2nr(a:line[8])
|
||||
" max compression
|
||||
if l:xfl == 2
|
||||
let b:gzip_comp_arg = "-9"
|
||||
" min compression
|
||||
elseif l:xfl == 4
|
||||
let b:gzip_comp_arg = "-1"
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
|
||||
" After reading compressed file: Uncompress text in buffer with "cmd"
|
||||
fun gzip#read(cmd)
|
||||
" don't do anything if the cmd is not supported
|
||||
if !s:check(a:cmd)
|
||||
return
|
||||
endif
|
||||
|
||||
" for gzip check current compression level and set b:gzip_comp_arg.
|
||||
silent! unlet b:gzip_comp_arg
|
||||
if a:cmd[0] == 'g'
|
||||
call s:set_compression(getline(1))
|
||||
endif
|
||||
|
||||
" make 'patchmode' empty, we don't want a copy of the written file
|
||||
let pm_save = &pm
|
||||
set pm=
|
||||
" remove 'a' and 'A' from 'cpo' to avoid the alternate file changes
|
||||
let cpo_save = &cpo
|
||||
set cpo-=a cpo-=A
|
||||
" set 'modifiable'
|
||||
let ma_save = &ma
|
||||
setlocal ma
|
||||
" Reset 'foldenable', otherwise line numbers get adjusted.
|
||||
if has("folding")
|
||||
let fen_save = &fen
|
||||
setlocal nofen
|
||||
endif
|
||||
|
||||
" when filtering the whole buffer, it will become empty
|
||||
let empty = line("'[") == 1 && line("']") == line("$")
|
||||
let tmp = tempname()
|
||||
let tmpe = tmp . "." . expand("<afile>:e")
|
||||
if exists('*fnameescape')
|
||||
let tmp_esc = fnameescape(tmp)
|
||||
let tmpe_esc = fnameescape(tmpe)
|
||||
else
|
||||
let tmp_esc = escape(tmp, ' ')
|
||||
let tmpe_esc = escape(tmpe, ' ')
|
||||
endif
|
||||
" write the just read lines to a temp file "'[,']w tmp.gz"
|
||||
execute "silent '[,']w " . tmpe_esc
|
||||
" uncompress the temp file: call system("gzip -dn tmp.gz")
|
||||
call system(a:cmd . " " . s:escape(tmpe))
|
||||
if !filereadable(tmp)
|
||||
" uncompress didn't work! Keep the compressed file then.
|
||||
echoerr "Error: Could not read uncompressed file"
|
||||
let ok = 0
|
||||
else
|
||||
let ok = 1
|
||||
" delete the compressed lines; remember the line number
|
||||
let l = line("'[") - 1
|
||||
if exists(":lockmarks")
|
||||
lockmarks '[,']d _
|
||||
else
|
||||
'[,']d _
|
||||
endif
|
||||
" read in the uncompressed lines "'[-1r tmp"
|
||||
" Use ++edit if the buffer was empty, keep the 'ff' and 'fenc' options.
|
||||
setlocal nobin
|
||||
if exists(":lockmarks")
|
||||
if empty
|
||||
execute "silent lockmarks " . l . "r ++edit " . tmp_esc
|
||||
else
|
||||
execute "silent lockmarks " . l . "r " . tmp_esc
|
||||
endif
|
||||
else
|
||||
execute "silent " . l . "r " . tmp_esc
|
||||
endif
|
||||
|
||||
" if buffer became empty, delete trailing blank line
|
||||
if empty
|
||||
silent $delete _
|
||||
1
|
||||
endif
|
||||
" delete the temp file and the used buffers
|
||||
call delete(tmp)
|
||||
silent! exe "bwipe " . tmp_esc
|
||||
silent! exe "bwipe " . tmpe_esc
|
||||
endif
|
||||
|
||||
" Restore saved option values.
|
||||
let &pm = pm_save
|
||||
let &cpo = cpo_save
|
||||
let &l:ma = ma_save
|
||||
if has("folding")
|
||||
let &l:fen = fen_save
|
||||
endif
|
||||
|
||||
" When uncompressed the whole buffer, do autocommands
|
||||
if ok && empty
|
||||
if exists('*fnameescape')
|
||||
let fname = fnameescape(expand("%:r"))
|
||||
else
|
||||
let fname = escape(expand("%:r"), " \t\n*?[{`$\\%#'\"|!<")
|
||||
endif
|
||||
if &verbose >= 8
|
||||
execute "doau BufReadPost " . fname
|
||||
else
|
||||
execute "silent! doau BufReadPost " . fname
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" After writing compressed file: Compress written file with "cmd"
|
||||
fun gzip#write(cmd)
|
||||
" don't do anything if the cmd is not supported
|
||||
if s:check(a:cmd)
|
||||
" Rename the file before compressing it.
|
||||
let nm = resolve(expand("<afile>"))
|
||||
let nmt = s:tempname(nm)
|
||||
if rename(nm, nmt) == 0
|
||||
if exists("b:gzip_comp_arg")
|
||||
call system(a:cmd . " " . b:gzip_comp_arg . " -- " . s:escape(nmt))
|
||||
else
|
||||
call system(a:cmd . " -- " . s:escape(nmt))
|
||||
endif
|
||||
call rename(nmt . "." . expand("<afile>:e"), nm)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Before appending to compressed file: Uncompress file with "cmd"
|
||||
fun gzip#appre(cmd)
|
||||
" don't do anything if the cmd is not supported
|
||||
if s:check(a:cmd)
|
||||
let nm = expand("<afile>")
|
||||
|
||||
" for gzip check current compression level and set b:gzip_comp_arg.
|
||||
silent! unlet b:gzip_comp_arg
|
||||
if a:cmd[0] == 'g'
|
||||
call s:set_compression(readfile(nm, "b", 1)[0])
|
||||
endif
|
||||
|
||||
" Rename to a weird name to avoid the risk of overwriting another file
|
||||
let nmt = expand("<afile>:p:h") . "/X~=@l9q5"
|
||||
let nmte = nmt . "." . expand("<afile>:e")
|
||||
if rename(nm, nmte) == 0
|
||||
if &patchmode != "" && getfsize(nm . &patchmode) == -1
|
||||
" Create patchmode file by creating the decompressed file new
|
||||
call system(a:cmd . " -c -- " . s:escape(nmte) . " > " . s:escape(nmt))
|
||||
call rename(nmte, nm . &patchmode)
|
||||
else
|
||||
call system(a:cmd . " -- " . s:escape(nmte))
|
||||
endif
|
||||
call rename(nmt, nm)
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
" find a file name for the file to be compressed. Use "name" without an
|
||||
" extension if possible. Otherwise use a weird name to avoid overwriting an
|
||||
" existing file.
|
||||
fun s:tempname(name)
|
||||
let fn = fnamemodify(a:name, ":r")
|
||||
if !filereadable(fn) && !isdirectory(fn)
|
||||
return fn
|
||||
endif
|
||||
return fnamemodify(a:name, ":p:h") . "/X~=@l9q5"
|
||||
endfun
|
||||
|
||||
fun s:escape(name)
|
||||
" shellescape() was added by patch 7.0.111
|
||||
if exists("*shellescape")
|
||||
return shellescape(a:name)
|
||||
endif
|
||||
return "'" . a:name . "'"
|
||||
endfun
|
||||
|
||||
" vim: set sw=2 :
|
||||
765
vim/bundle/ubuntu-vim72/autoload/htmlcomplete.vim
Normal file
765
vim/bundle/ubuntu-vim72/autoload/htmlcomplete.vim
Normal file
@@ -0,0 +1,765 @@
|
||||
" Vim completion script
|
||||
" Language: HTML and XHTML
|
||||
" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
|
||||
" Last Change: 2006 Oct 19
|
||||
|
||||
function! htmlcomplete#CompleteTags(findstart, base)
|
||||
if a:findstart
|
||||
" locate the start of the word
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
let curline = line('.')
|
||||
let compl_begin = col('.') - 2
|
||||
while start >= 0 && line[start - 1] =~ '\(\k\|[!:.-]\)'
|
||||
let start -= 1
|
||||
endwhile
|
||||
" Handling of entities {{{
|
||||
if start >= 0 && line[start - 1] =~ '&'
|
||||
let b:entitiescompl = 1
|
||||
let b:compl_context = ''
|
||||
return start
|
||||
endif
|
||||
" }}}
|
||||
" Handling of <style> tag {{{
|
||||
let stylestart = searchpair('<style\>', '', '<\/style\>', "bnW")
|
||||
let styleend = searchpair('<style\>', '', '<\/style\>', "nW")
|
||||
if stylestart != 0 && styleend != 0
|
||||
if stylestart <= curline && styleend >= curline
|
||||
let start = col('.') - 1
|
||||
let b:csscompl = 1
|
||||
while start >= 0 && line[start - 1] =~ '\(\k\|-\)'
|
||||
let start -= 1
|
||||
endwhile
|
||||
endif
|
||||
endif
|
||||
" }}}
|
||||
" Handling of <script> tag {{{
|
||||
let scriptstart = searchpair('<script\>', '', '<\/script\>', "bnW")
|
||||
let scriptend = searchpair('<script\>', '', '<\/script\>', "nW")
|
||||
if scriptstart != 0 && scriptend != 0
|
||||
if scriptstart <= curline && scriptend >= curline
|
||||
let start = col('.') - 1
|
||||
let b:jscompl = 1
|
||||
let b:jsrange = [scriptstart, scriptend]
|
||||
while start >= 0 && line[start - 1] =~ '\k'
|
||||
let start -= 1
|
||||
endwhile
|
||||
" We are inside of <script> tag. But we should also get contents
|
||||
" of all linked external files and (secondary, less probably) other <script> tags
|
||||
" This logic could possible be done in separate function - may be
|
||||
" reused in events scripting (also with option could be reused for
|
||||
" CSS
|
||||
let b:js_extfiles = []
|
||||
let l = line('.')
|
||||
let c = col('.')
|
||||
call cursor(1,1)
|
||||
while search('<\@<=script\>', 'W') && line('.') <= l
|
||||
if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment'
|
||||
let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1')
|
||||
if filereadable(sname)
|
||||
let b:js_extfiles += readfile(sname)
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
call cursor(1,1)
|
||||
let js_scripttags = []
|
||||
while search('<script\>', 'W') && line('.') < l
|
||||
if matchstr(getline('.'), '<script[^>]*src') == ''
|
||||
let js_scripttag = getline(line('.'), search('</script>', 'W'))
|
||||
let js_scripttags += js_scripttag
|
||||
endif
|
||||
endwhile
|
||||
let b:js_extfiles += js_scripttags
|
||||
call cursor(l,c)
|
||||
unlet! l c
|
||||
endif
|
||||
endif
|
||||
" }}}
|
||||
if !exists("b:csscompl") && !exists("b:jscompl")
|
||||
let b:compl_context = getline('.')[0:(compl_begin)]
|
||||
if b:compl_context !~ '<[^>]*$'
|
||||
" Look like we may have broken tag. Check previous lines.
|
||||
let i = 1
|
||||
while 1
|
||||
let context_line = getline(curline-i)
|
||||
if context_line =~ '<[^>]*$'
|
||||
" Yep, this is this line
|
||||
let context_lines = getline(curline-i, curline-1) + [b:compl_context]
|
||||
let b:compl_context = join(context_lines, ' ')
|
||||
break
|
||||
elseif context_line =~ '>[^<]*$' || i == curline
|
||||
" We are in normal tag line, no need for completion at all
|
||||
" OR reached first line without tag at all
|
||||
let b:compl_context = ''
|
||||
break
|
||||
endif
|
||||
let i += 1
|
||||
endwhile
|
||||
" Make sure we don't have counter
|
||||
unlet! i
|
||||
endif
|
||||
let b:compl_context = matchstr(b:compl_context, '.*\zs<.*')
|
||||
|
||||
" Return proper start for on-events. Without that beginning of
|
||||
" completion will be badly reported
|
||||
if b:compl_context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$'
|
||||
let start = col('.') - 1
|
||||
while start >= 0 && line[start - 1] =~ '\k'
|
||||
let start -= 1
|
||||
endwhile
|
||||
endif
|
||||
" If b:compl_context begins with <? we are inside of PHP code. It
|
||||
" wasn't closed so PHP completion passed it to HTML
|
||||
if &filetype =~? 'php' && b:compl_context =~ '^<?'
|
||||
let b:phpcompl = 1
|
||||
let start = col('.') - 1
|
||||
while start >= 0 && line[start - 1] =~ '[a-zA-Z_0-9\x7f-\xff$]'
|
||||
let start -= 1
|
||||
endwhile
|
||||
endif
|
||||
else
|
||||
let b:compl_context = getline('.')[0:compl_begin]
|
||||
endif
|
||||
return start
|
||||
else
|
||||
" Initialize base return lists
|
||||
let res = []
|
||||
let res2 = []
|
||||
" a:base is very short - we need context
|
||||
let context = b:compl_context
|
||||
" Check if we should do CSS completion inside of <style> tag
|
||||
" or JS completion inside of <script> tag or PHP completion in case of <?
|
||||
" tag AND &ft==php
|
||||
if exists("b:csscompl")
|
||||
unlet! b:csscompl
|
||||
let context = b:compl_context
|
||||
unlet! b:compl_context
|
||||
return csscomplete#CompleteCSS(0, context)
|
||||
elseif exists("b:jscompl")
|
||||
unlet! b:jscompl
|
||||
return javascriptcomplete#CompleteJS(0, a:base)
|
||||
elseif exists("b:phpcompl")
|
||||
unlet! b:phpcompl
|
||||
let context = b:compl_context
|
||||
return phpcomplete#CompletePHP(0, a:base)
|
||||
else
|
||||
if len(b:compl_context) == 0 && !exists("b:entitiescompl")
|
||||
return []
|
||||
endif
|
||||
let context = matchstr(b:compl_context, '.\zs.*')
|
||||
endif
|
||||
unlet! b:compl_context
|
||||
" Entities completion {{{
|
||||
if exists("b:entitiescompl")
|
||||
unlet! b:entitiescompl
|
||||
|
||||
if !exists("b:html_doctype")
|
||||
call htmlcomplete#CheckDoctype()
|
||||
endif
|
||||
if !exists("b:html_omni")
|
||||
"runtime! autoload/xml/xhtml10s.vim
|
||||
call htmlcomplete#LoadData()
|
||||
endif
|
||||
|
||||
let entities = b:html_omni['vimxmlentities']
|
||||
|
||||
if len(a:base) == 1
|
||||
for m in entities
|
||||
if m =~ '^'.a:base
|
||||
call add(res, m.';')
|
||||
endif
|
||||
endfor
|
||||
return res
|
||||
else
|
||||
for m in entities
|
||||
if m =~? '^'.a:base
|
||||
call add(res, m.';')
|
||||
elseif m =~? a:base
|
||||
call add(res2, m.';')
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
endif
|
||||
|
||||
|
||||
endif
|
||||
" }}}
|
||||
if context =~ '>'
|
||||
" Generally if context contains > it means we are outside of tag and
|
||||
" should abandon action - with one exception: <style> span { bo
|
||||
if context =~ 'style[^>]\{-}>[^<]\{-}$'
|
||||
return csscomplete#CompleteCSS(0, context)
|
||||
elseif context =~ 'script[^>]\{-}>[^<]\{-}$'
|
||||
let b:jsrange = [line('.'), search('<\/script\>', 'nW')]
|
||||
return javascriptcomplete#CompleteJS(0, context)
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" If context contains > it means we are already outside of tag and we
|
||||
" should abandon action
|
||||
" If context contains white space it is attribute.
|
||||
" It can be also value of attribute.
|
||||
" We have to get first word to offer proper completions
|
||||
if context == ''
|
||||
let tag = ''
|
||||
else
|
||||
let tag = split(context)[0]
|
||||
" Detect if tag is uppercase to return in proper case,
|
||||
" we need to make it lowercase for processing
|
||||
if tag =~ '^[A-Z]*$'
|
||||
let uppercase_tag = 1
|
||||
let tag = tolower(tag)
|
||||
else
|
||||
let uppercase_tag = 0
|
||||
endif
|
||||
endif
|
||||
" Get last word, it should be attr name
|
||||
let attr = matchstr(context, '.*\s\zs.*')
|
||||
" Possible situations where any prediction would be difficult:
|
||||
" 1. Events attributes
|
||||
if context =~ '\s'
|
||||
" Sort out style, class, and on* cases
|
||||
if context =~? "\\(on[a-z]*\\|id\\|style\\|class\\)\\s*=\\s*[\"']"
|
||||
" Id, class completion {{{
|
||||
if context =~? "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
|
||||
if context =~? "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
|
||||
let search_for = "class"
|
||||
elseif context =~? "id\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
|
||||
let search_for = "id"
|
||||
endif
|
||||
" Handle class name completion
|
||||
" 1. Find lines of <link stylesheet>
|
||||
" 1a. Check file for @import
|
||||
" 2. Extract filename(s?) of stylesheet,
|
||||
call cursor(1,1)
|
||||
let head = getline(search('<head\>'), search('<\/head>'))
|
||||
let headjoined = join(copy(head), ' ')
|
||||
if headjoined =~ '<style'
|
||||
" Remove possibly confusing CSS operators
|
||||
let stylehead = substitute(headjoined, '+>\*[,', ' ', 'g')
|
||||
if search_for == 'class'
|
||||
let styleheadlines = split(stylehead)
|
||||
let headclasslines = filter(copy(styleheadlines), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'")
|
||||
else
|
||||
let stylesheet = split(headjoined, '[{}]')
|
||||
" Get all lines which fit id syntax
|
||||
let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
||||
" Filter out possible color definitions
|
||||
call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
|
||||
" Filter out complex border definitions
|
||||
call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'")
|
||||
let templines = join(classlines, ' ')
|
||||
let headclasslines = split(templines)
|
||||
call filter(headclasslines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
||||
endif
|
||||
let internal = 1
|
||||
else
|
||||
let internal = 0
|
||||
endif
|
||||
let styletable = []
|
||||
let secimportfiles = []
|
||||
let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'")
|
||||
for line in filestable
|
||||
if line =~ "@import"
|
||||
let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")]
|
||||
elseif line =~ "<link"
|
||||
let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")]
|
||||
endif
|
||||
endfor
|
||||
for file in styletable
|
||||
if filereadable(file)
|
||||
let stylesheet = readfile(file)
|
||||
let secimport = filter(copy(stylesheet), "v:val =~ '@import'")
|
||||
if len(secimport) > 0
|
||||
for line in secimport
|
||||
let secfile = matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")
|
||||
let secfile = fnamemodify(file, ":p:h").'/'.secfile
|
||||
let secimportfiles += [secfile]
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let cssfiles = styletable + secimportfiles
|
||||
let classes = []
|
||||
for file in cssfiles
|
||||
if filereadable(file)
|
||||
let stylesheet = readfile(file)
|
||||
let stylefile = join(stylesheet, ' ')
|
||||
let stylefile = substitute(stylefile, '+>\*[,', ' ', 'g')
|
||||
if search_for == 'class'
|
||||
let stylesheet = split(stylefile)
|
||||
let classlines = filter(copy(stylesheet), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'")
|
||||
else
|
||||
let stylesheet = split(stylefile, '[{}]')
|
||||
" Get all lines which fit id syntax
|
||||
let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
||||
" Filter out possible color definitions
|
||||
call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
|
||||
" Filter out complex border definitions
|
||||
call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'")
|
||||
let templines = join(classlines, ' ')
|
||||
let stylelines = split(templines)
|
||||
let classlines = filter(stylelines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
||||
|
||||
endif
|
||||
endif
|
||||
" We gathered classes definitions from all external files
|
||||
let classes += classlines
|
||||
endfor
|
||||
if internal == 1
|
||||
let classes += headclasslines
|
||||
endif
|
||||
|
||||
if search_for == 'class'
|
||||
let elements = {}
|
||||
for element in classes
|
||||
if element =~ '^\.'
|
||||
let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
|
||||
let class = substitute(class, ':.*', '', '')
|
||||
if has_key(elements, 'common')
|
||||
let elements['common'] .= ' '.class
|
||||
else
|
||||
let elements['common'] = class
|
||||
endif
|
||||
else
|
||||
let class = matchstr(element, '[a-zA-Z1-6]*\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
|
||||
let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.'))
|
||||
if tagname != ''
|
||||
if has_key(elements, tagname)
|
||||
let elements[tagname] .= ' '.class
|
||||
else
|
||||
let elements[tagname] = class
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if has_key(elements, tag) && has_key(elements, 'common')
|
||||
let values = split(elements[tag]." ".elements['common'])
|
||||
elseif has_key(elements, tag) && !has_key(elements, 'common')
|
||||
let values = split(elements[tag])
|
||||
elseif !has_key(elements, tag) && has_key(elements, 'common')
|
||||
let values = split(elements['common'])
|
||||
else
|
||||
return []
|
||||
endif
|
||||
|
||||
elseif search_for == 'id'
|
||||
" Find used IDs
|
||||
" 1. Catch whole file
|
||||
let filelines = getline(1, line('$'))
|
||||
" 2. Find lines with possible id
|
||||
let used_id_lines = filter(filelines, 'v:val =~ "id\\s*=\\s*[\"''][a-zA-Z0-9_-]\\+"')
|
||||
" 3a. Join all filtered lines
|
||||
let id_string = join(used_id_lines, ' ')
|
||||
" 3b. And split them to be sure each id is in separate item
|
||||
let id_list = split(id_string, 'id\s*=\s*')
|
||||
" 4. Extract id values
|
||||
let used_id = map(id_list, 'matchstr(v:val, "[\"'']\\zs[a-zA-Z0-9_-]\\+\\ze")')
|
||||
let joined_used_id = ','.join(used_id, ',').','
|
||||
|
||||
let allvalues = map(classes, 'matchstr(v:val, ".*#\\zs[a-zA-Z0-9_-]\\+")')
|
||||
|
||||
let values = []
|
||||
|
||||
for element in classes
|
||||
if joined_used_id !~ ','.element.','
|
||||
let values += [element]
|
||||
endif
|
||||
|
||||
endfor
|
||||
|
||||
endif
|
||||
|
||||
" We need special version of sbase
|
||||
let classbase = matchstr(context, ".*[\"']")
|
||||
let classquote = matchstr(classbase, '.$')
|
||||
|
||||
let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*")
|
||||
|
||||
for m in sort(values)
|
||||
if m =~? '^'.entered_class
|
||||
call add(res, m . classquote)
|
||||
elseif m =~? entered_class
|
||||
call add(res2, m . classquote)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
elseif context =~? "style\\s*=\\s*[\"'][^\"']*$"
|
||||
return csscomplete#CompleteCSS(0, context)
|
||||
|
||||
endif
|
||||
" }}}
|
||||
" Complete on-events {{{
|
||||
if context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$'
|
||||
" We have to:
|
||||
" 1. Find external files
|
||||
let b:js_extfiles = []
|
||||
let l = line('.')
|
||||
let c = col('.')
|
||||
call cursor(1,1)
|
||||
while search('<\@<=script\>', 'W') && line('.') <= l
|
||||
if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment'
|
||||
let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1')
|
||||
if filereadable(sname)
|
||||
let b:js_extfiles += readfile(sname)
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
" 2. Find at least one <script> tag
|
||||
call cursor(1,1)
|
||||
let js_scripttags = []
|
||||
while search('<script\>', 'W') && line('.') < l
|
||||
if matchstr(getline('.'), '<script[^>]*src') == ''
|
||||
let js_scripttag = getline(line('.'), search('</script>', 'W'))
|
||||
let js_scripttags += js_scripttag
|
||||
endif
|
||||
endwhile
|
||||
let b:js_extfiles += js_scripttags
|
||||
|
||||
" 3. Proper call for javascriptcomplete#CompleteJS
|
||||
call cursor(l,c)
|
||||
let js_context = matchstr(a:base, '\k\+$')
|
||||
let js_shortcontext = substitute(a:base, js_context.'$', '', '')
|
||||
let b:compl_context = context
|
||||
let b:jsrange = [l, l]
|
||||
unlet! l c
|
||||
return javascriptcomplete#CompleteJS(0, js_context)
|
||||
|
||||
endif
|
||||
|
||||
" }}}
|
||||
let stripbase = matchstr(context, ".*\\(on[a-zA-Z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*")
|
||||
" Now we have context stripped from all chars up to style/class.
|
||||
" It may fail with some strange style value combinations.
|
||||
if stripbase !~ "[\"']"
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
" Value of attribute completion {{{
|
||||
" If attr contains =\s*[\"'] we catched value of attribute
|
||||
if attr =~ "=\s*[\"']" || attr =~ "=\s*$"
|
||||
" Let do attribute specific completion
|
||||
let attrname = matchstr(attr, '.*\ze\s*=')
|
||||
let entered_value = matchstr(attr, ".*=\\s*[\"']\\?\\zs.*")
|
||||
let values = []
|
||||
" Load data {{{
|
||||
if !exists("b:html_doctype")
|
||||
call htmlcomplete#CheckDoctype()
|
||||
endif
|
||||
if !exists("b:html_omni")
|
||||
"runtime! autoload/xml/xhtml10s.vim
|
||||
call htmlcomplete#LoadData()
|
||||
endif
|
||||
" }}}
|
||||
if attrname == 'href'
|
||||
" Now we are looking for local anchors defined by name or id
|
||||
if entered_value =~ '^#'
|
||||
let file = join(getline(1, line('$')), ' ')
|
||||
" Split it be sure there will be one id/name element in
|
||||
" item, it will be also first word [a-zA-Z0-9_-] in element
|
||||
let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']")
|
||||
for i in oneelement
|
||||
let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")]
|
||||
endfor
|
||||
endif
|
||||
else
|
||||
if has_key(b:html_omni, tag) && has_key(b:html_omni[tag][1], attrname)
|
||||
let values = b:html_omni[tag][1][attrname]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
if len(values) == 0
|
||||
return []
|
||||
endif
|
||||
|
||||
" We need special version of sbase
|
||||
let attrbase = matchstr(context, ".*[\"']")
|
||||
let attrquote = matchstr(attrbase, '.$')
|
||||
if attrquote !~ "['\"]"
|
||||
let attrquoteopen = '"'
|
||||
let attrquote = '"'
|
||||
else
|
||||
let attrquoteopen = ''
|
||||
endif
|
||||
|
||||
for m in values
|
||||
" This if is needed to not offer all completions as-is
|
||||
" alphabetically but sort them. Those beginning with entered
|
||||
" part will be as first choices
|
||||
if m =~ '^'.entered_value
|
||||
call add(res, attrquoteopen . m . attrquote)
|
||||
elseif m =~ entered_value
|
||||
call add(res2, attrquoteopen . m . attrquote)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return res + res2
|
||||
|
||||
endif
|
||||
" }}}
|
||||
" Attribute completion {{{
|
||||
" Shorten context to not include last word
|
||||
let sbase = matchstr(context, '.*\ze\s.*')
|
||||
|
||||
" Load data {{{
|
||||
if !exists("b:html_doctype")
|
||||
call htmlcomplete#CheckDoctype()
|
||||
endif
|
||||
if !exists("b:html_omni")
|
||||
call htmlcomplete#LoadData()
|
||||
endif
|
||||
" }}}
|
||||
|
||||
if has_key(b:html_omni, tag)
|
||||
let attrs = keys(b:html_omni[tag][1])
|
||||
else
|
||||
return []
|
||||
endif
|
||||
|
||||
for m in sort(attrs)
|
||||
if m =~ '^'.attr
|
||||
call add(res, m)
|
||||
elseif m =~ attr
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
let menu = res + res2
|
||||
if has_key(b:html_omni, 'vimxmlattrinfo')
|
||||
let final_menu = []
|
||||
for i in range(len(menu))
|
||||
let item = menu[i]
|
||||
if has_key(b:html_omni['vimxmlattrinfo'], item)
|
||||
let m_menu = b:html_omni['vimxmlattrinfo'][item][0]
|
||||
let m_info = b:html_omni['vimxmlattrinfo'][item][1]
|
||||
else
|
||||
let m_menu = ''
|
||||
let m_info = ''
|
||||
endif
|
||||
if len(b:html_omni[tag][1][item]) > 0 && b:html_omni[tag][1][item][0] =~ '^\(BOOL\|'.item.'\)$'
|
||||
let item = item
|
||||
let m_menu = 'Bool'
|
||||
else
|
||||
let item .= '="'
|
||||
endif
|
||||
let final_menu += [{'word':item, 'menu':m_menu, 'info':m_info}]
|
||||
endfor
|
||||
else
|
||||
let final_menu = []
|
||||
for i in range(len(menu))
|
||||
let item = menu[i]
|
||||
if len(b:html_omni[tag][1][item]) > 0 && b:html_omni[tag][1][item][0] =~ '^\(BOOL\|'.item.'\)$'
|
||||
let item = item
|
||||
else
|
||||
let item .= '="'
|
||||
endif
|
||||
let final_menu += [item]
|
||||
endfor
|
||||
return final_menu
|
||||
|
||||
endif
|
||||
return final_menu
|
||||
|
||||
endif
|
||||
" }}}
|
||||
" Close tag {{{
|
||||
let b:unaryTagsStack = "base meta link hr br param img area input col"
|
||||
if context =~ '^\/'
|
||||
if context =~ '^\/.'
|
||||
return []
|
||||
else
|
||||
let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
|
||||
return [opentag.">"]
|
||||
endif
|
||||
endif
|
||||
" }}}
|
||||
" Load data {{{
|
||||
if !exists("b:html_doctype")
|
||||
call htmlcomplete#CheckDoctype()
|
||||
endif
|
||||
if !exists("b:html_omni")
|
||||
"runtime! autoload/xml/xhtml10s.vim
|
||||
call htmlcomplete#LoadData()
|
||||
endif
|
||||
" }}}
|
||||
" Tag completion {{{
|
||||
" Deal with tag completion.
|
||||
let opentag = tolower(xmlcomplete#GetLastOpenTag("b:unaryTagsStack"))
|
||||
" MM: TODO: GLOT works always the same but with some weird situation it
|
||||
" behaves as intended in HTML but screws in PHP
|
||||
if opentag == '' || &filetype == 'php' && !has_key(b:html_omni, opentag)
|
||||
" Hack for sometimes failing GetLastOpenTag.
|
||||
" As far as I tested fail isn't GLOT fault but problem
|
||||
" of invalid document - not properly closed tags and other mish-mash.
|
||||
" Also when document is empty. Return list of *all* tags.
|
||||
let tags = keys(b:html_omni)
|
||||
call filter(tags, 'v:val !~ "^vimxml"')
|
||||
else
|
||||
if has_key(b:html_omni, opentag)
|
||||
let tags = b:html_omni[opentag][0]
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
" }}}
|
||||
|
||||
if exists("uppercase_tag") && uppercase_tag == 1
|
||||
let context = tolower(context)
|
||||
endif
|
||||
" Handle XML keywords: DOCTYPE
|
||||
if opentag == ''
|
||||
let tags += [
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
\ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/1999/xhtml">'
|
||||
\ ]
|
||||
endif
|
||||
|
||||
for m in sort(tags)
|
||||
if m =~ '^'.context
|
||||
call add(res, m)
|
||||
elseif m =~ context
|
||||
call add(res2, m)
|
||||
endif
|
||||
endfor
|
||||
let menu = res + res2
|
||||
if has_key(b:html_omni, 'vimxmltaginfo')
|
||||
let final_menu = []
|
||||
for i in range(len(menu))
|
||||
let item = menu[i]
|
||||
if has_key(b:html_omni['vimxmltaginfo'], item)
|
||||
let m_menu = b:html_omni['vimxmltaginfo'][item][0]
|
||||
let m_info = b:html_omni['vimxmltaginfo'][item][1]
|
||||
else
|
||||
let m_menu = ''
|
||||
let m_info = ''
|
||||
endif
|
||||
if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE'
|
||||
let item = toupper(item)
|
||||
endif
|
||||
if item =~ 'DOCTYPE'
|
||||
let abbr = 'DOCTYPE '.matchstr(item, 'DTD \zsX\?HTML .\{-}\ze\/\/')
|
||||
else
|
||||
let abbr = item
|
||||
endif
|
||||
let final_menu += [{'abbr':abbr, 'word':item, 'menu':m_menu, 'info':m_info}]
|
||||
endfor
|
||||
else
|
||||
let final_menu = menu
|
||||
endif
|
||||
return final_menu
|
||||
|
||||
" }}}
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! htmlcomplete#LoadData() " {{{
|
||||
if !exists("b:html_omni_flavor")
|
||||
if &filetype == 'html'
|
||||
let b:html_omni_flavor = 'html401t'
|
||||
else
|
||||
let b:html_omni_flavor = 'xhtml10s'
|
||||
endif
|
||||
endif
|
||||
" With that if we still have bloated memory but create new buffer
|
||||
" variables only by linking to existing g:variable, not sourcing whole
|
||||
" file.
|
||||
if exists('g:xmldata_'.b:html_omni_flavor)
|
||||
exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
|
||||
else
|
||||
exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim'
|
||||
exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
function! htmlcomplete#CheckDoctype() " {{{
|
||||
if exists('b:html_omni_flavor')
|
||||
let old_flavor = b:html_omni_flavor
|
||||
else
|
||||
let old_flavor = ''
|
||||
endif
|
||||
let i = 1
|
||||
while i < 10 && i < line("$")
|
||||
let line = getline(i)
|
||||
if line =~ '<!DOCTYPE.*\<DTD HTML 3\.2'
|
||||
let b:html_omni_flavor = 'html32'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Transitional'
|
||||
let b:html_omni_flavor = 'html40t'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Frameset'
|
||||
let b:html_omni_flavor = 'html40f'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0'
|
||||
let b:html_omni_flavor = 'html40s'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Transitional'
|
||||
let b:html_omni_flavor = 'html401t'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Frameset'
|
||||
let b:html_omni_flavor = 'html401f'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01'
|
||||
let b:html_omni_flavor = 'html401s'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Transitional'
|
||||
let b:html_omni_flavor = 'xhtml10t'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Frameset'
|
||||
let b:html_omni_flavor = 'xhtml10f'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Strict'
|
||||
let b:html_omni_flavor = 'xhtml10s'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.1'
|
||||
let b:html_omni_flavor = 'xhtml11'
|
||||
let b:html_doctype = 1
|
||||
break
|
||||
endif
|
||||
let i += 1
|
||||
endwhile
|
||||
if !exists("b:html_doctype")
|
||||
return
|
||||
else
|
||||
" Tie g:xmldata with b:html_omni this way we need to sourca data file only
|
||||
" once, not every time per buffer.
|
||||
if old_flavor == b:html_omni_flavor
|
||||
return
|
||||
else
|
||||
if exists('g:xmldata_'.b:html_omni_flavor)
|
||||
exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
|
||||
else
|
||||
exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim'
|
||||
exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
" vim:set foldmethod=marker:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user