Merging upstream, wiping syntastic.
This commit is contained in:
commit
4541dd93ef
402 changed files with 12339 additions and 22184 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,3 +3,5 @@ sources_non_forked/ack.vim/.netrwhist
|
|||
temp_dirs/yankring_history_v2.txt
|
||||
sources_forked/yankring/doc/tags
|
||||
sources_non_forked/tlib/doc/tags
|
||||
my_configs.vim
|
||||
tags
|
||||
|
|
24
README.md
24
README.md
|
@ -27,6 +27,7 @@ The awesome version includes a lot of great plugins, configurations and color sc
|
|||
git clone git://github.com/amix/vimrc.git ~/.vim_runtime
|
||||
sh ~/.vim_runtime/install_awesome_vimrc.sh
|
||||
|
||||
I also recommend using [Source Code Pro font from Adobe](http://store1.adobe.com/cfusion/store/html/index.cfm?event=displayFontPackage&code=1960) (it's free and awesome font for writing and programming). The Awesome vimrc is already setup to try to use it
|
||||
|
||||
## How to install on Windows?
|
||||
|
||||
|
@ -55,8 +56,11 @@ Opening recently opened files [mru.vim](https://github.com/vim-scripts/mru.vim):
|
|||
This vimrc even works on Windows!
|
||||
![Screenshot 4](http://files1.wedoist.com/4e85163d97b81422240c822c82022f2f/as/screenshot_4.png)
|
||||
|
||||
Distraction free mode (using goyo.vim and vim-zenroom2):
|
||||
![Screenshot 5](https://d2dq6e731uoz0t.cloudfront.net/a5182977c3d6c2a6cd3f9e97398ca8ca/as/zen_mode.jpg)
|
||||
|
||||
## What plugins are included?
|
||||
|
||||
## Included Plugins
|
||||
|
||||
I recommend reading the docs of these plugins to understand them better. Each of them provide a much better Vim experience!
|
||||
|
||||
|
@ -69,16 +73,20 @@ I recommend reading the docs of these plugins to understand them better. Each of
|
|||
* [ctrlp.vim](https://github.com/kien/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. In my config it's mapped to `<Ctrl+F>`, because `<Ctrl+P>` is used by YankRing
|
||||
* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. Includes my own fork which adds syntax highlighting to MRU. This plugin can be opened with `<leader+f>`
|
||||
* [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf`
|
||||
* [zencoding](https://github.com/mattn/zencoding-vim): Expanding abbreviation like zen-coding, very useful for editing XML, HTML.
|
||||
* [zencoding](https://github.com/mattn/emmet-vim): Expanding abbreviation like zen-coding, very useful for editing XML, HTML.
|
||||
* [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object): Defines a new text object representing lines of code at the same indent level. Useful for python/vim scripts
|
||||
* [taglist.vim](https://github.com/vim-scripts/taglist.vim): Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
|
||||
* [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors): Sublime Text style multiple selections for Vim, CTRL+N is remapped to CTRL+S (due to YankRing)
|
||||
* [vim-expand-region](https://github.com/terryma/vim-expand-region): Allows you to visually select increasingly larger regions of text using the same key combination.
|
||||
* [vim-airline](https://github.com/bling/vim-airline): Lean & mean status/tabline for vim that's light as air (replacing powerline)
|
||||
* [vim-fugitive](https://github.com/tpope/vim-fugitive): A Git wrapper so awesome, it should be illegal
|
||||
* [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2):
|
||||
Remove all clutter and focus only on the essential. Similar to iA Writer or Write Room [Read more here](http://amix.dk/blog/post/19744)
|
||||
* [vim-commentary](https://github.com/tpope/vim-commentary): Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion. `gcu` uncomments a set of adjacent commented lines.
|
||||
* [syntastic](https://github.com/scrooloose/syntastic): Syntax checking hacks for vim
|
||||
|
||||
|
||||
## What color schemes are included?
|
||||
## Included color schemes
|
||||
|
||||
* [peaksea](https://github.com/vim-scripts/peaksea): My favorite!
|
||||
* [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized)
|
||||
|
@ -87,13 +95,14 @@ I recommend reading the docs of these plugins to understand them better. Each of
|
|||
* [vim-pyte](https://github.com/therubymug/vim-pyte)
|
||||
|
||||
|
||||
## What modes are included?
|
||||
## Included modes
|
||||
|
||||
* [vim-coffee-script](https://github.com/kchmck/vim-coffee-script)
|
||||
* [vim-less](https://github.com/groenewege/vim-less)
|
||||
* [vim-bundle-mako](https://github.com/sophacles/vim-bundle-mako)
|
||||
* [vim-markdown](https://github.com/tpope/vim-markdown)
|
||||
* [nginx.vim](https://github.com/vim-scripts/nginx.vim): Highlights configuration files for nginx
|
||||
* [vim-golang](https://github.com/jnwhiteh/vim-golang)
|
||||
|
||||
|
||||
## How to include your own stuff?
|
||||
|
@ -138,6 +147,10 @@ Managing the [NERD Tree](https://github.com/scrooloose/nerdtree) plugin:
|
|||
map <leader>nb :NERDTreeFromBookmark
|
||||
map <leader>nf :NERDTreeFind<cr>
|
||||
|
||||
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping.
|
||||
|
||||
map <leader>z :Goyo<cr>
|
||||
|
||||
### Normal mode mappings
|
||||
|
||||
Fast saving of a buffer:
|
||||
|
@ -303,7 +316,6 @@ Vimscript mappings:
|
|||
map <leader>n :cn<cr>
|
||||
map <leader>p :cp<cr>
|
||||
|
||||
|
||||
## Useful blog tips regarding my Vim setup
|
||||
|
||||
* [Vim: Annotate strings with gettext (the macro way)](http://amix.dk/blog/post/19678#Vim-Annotate-strings-with-gettext-the-macro-way)
|
||||
|
@ -313,3 +325,5 @@ Vimscript mappings:
|
|||
* [Vim 7.3: Persistent undo and encryption!](http://amix.dk/blog/post/19548#Vim-7-3-Persistent-undo-and-encryption)
|
||||
* [Vim tips: Visual Search](http://amix.dk/blog/post/19334#Vim-tips-Visual-Search)
|
||||
* [Folding in Vim](http://amix.dk/blog/post/19132#Folding-in-Vim)
|
||||
* [
|
||||
Zen room for Vim: Focusing only on the essential](http://amix.dk/blog/post/19744#zenroom-for-Vim-Focsuing-only-on-the-essential)
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
10
|
||||
|
||||
dir
|
||||
24
|
||||
svn://orangoo.com/vim/autoload
|
||||
svn://orangoo.com/vim
|
||||
|
||||
|
||||
|
||||
2010-01-15T19:53:13.037300Z
|
||||
2
|
||||
amix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
f0bd9f4a-2ac3-40fc-bab3-7711922a5bd5
|
||||
|
||||
fuf
|
||||
dir
|
||||
|
||||
fuf.vim
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2009-12-03T15:37:36.000000Z
|
||||
cd795290ec0c8e87d61563c8553f6a5a
|
||||
2010-01-15T19:52:41.083563Z
|
||||
1
|
||||
amix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
34950
|
||||
|
||||
snipMate.vim
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-01-15T16:14:44.000000Z
|
||||
935ed920e29eeb56885cba09798db5ce
|
||||
2010-01-15T19:52:41.083563Z
|
||||
1
|
||||
amix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14083
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,433 +0,0 @@
|
|||
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.
|
||||
" 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, '`.\{-}`',
|
||||
\ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
|
||||
\ "\n\\%$", '', ''), '')
|
||||
endw
|
||||
let snippet = substitute(snippet, "\r", "\n", '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
|
161
autoload/pathogen.vim
Normal file → Executable file
161
autoload/pathogen.vim
Normal file → Executable file
|
@ -1,12 +1,12 @@
|
|||
" pathogen.vim - path option manipulation
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" Version: 2.0
|
||||
" Version: 2.2
|
||||
|
||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
||||
"
|
||||
" For management of individually installed plugins in ~/.vim/bundle (or
|
||||
" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
|
||||
" prior to `filetype plugin indent on` is the only other setup necessary.
|
||||
" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
|
||||
" .vimrc is the only other setup necessary.
|
||||
"
|
||||
" The API is documented inline below. For maximum ease of reading,
|
||||
" :set foldmethod=marker
|
||||
|
@ -16,18 +16,33 @@ if exists("g:loaded_pathogen") || &cp
|
|||
endif
|
||||
let g:loaded_pathogen = 1
|
||||
|
||||
" Point of entry for basic default usage. Give a directory name to invoke
|
||||
" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
|
||||
" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
|
||||
" pathogen#cycle_filetype() is invoked.
|
||||
function! s:warn(msg)
|
||||
echohl WarningMsg
|
||||
echomsg a:msg
|
||||
echohl NONE
|
||||
endfunction
|
||||
|
||||
" Point of entry for basic default usage. Give a relative path to invoke
|
||||
" pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke
|
||||
" pathogen#surround(). For backwards compatibility purposes, a full path that
|
||||
" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories()
|
||||
" instead.
|
||||
function! pathogen#infect(...) abort " {{{1
|
||||
let source_path = a:0 ? a:1 : 'bundle'
|
||||
if source_path =~# '[\\/]'
|
||||
call pathogen#runtime_prepend_subdirectories(source_path)
|
||||
for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}']
|
||||
if path =~# '^[^\\/]\+$'
|
||||
call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
|
||||
call pathogen#incubate(path . '/{}')
|
||||
elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$'
|
||||
call pathogen#incubate(path)
|
||||
elseif path =~# '[\\/]\%({}\|\*\)$'
|
||||
call pathogen#surround(path)
|
||||
else
|
||||
call pathogen#runtime_append_all_bundles(source_path)
|
||||
call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
|
||||
call pathogen#surround(path . '/{}')
|
||||
endif
|
||||
endfor
|
||||
call pathogen#cycle_filetype()
|
||||
return ''
|
||||
endfunction " }}}1
|
||||
|
||||
" Split a path into a list.
|
||||
|
@ -111,8 +126,9 @@ function! pathogen#cycle_filetype() " {{{1
|
|||
endif
|
||||
endfunction " }}}1
|
||||
|
||||
" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
|
||||
" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
|
||||
" Check if a bundle is disabled. A bundle is considered disabled if it ends
|
||||
" in a tilde or its basename or full name is included in the list
|
||||
" g:pathogen_disabled.
|
||||
function! pathogen#is_disabled(path) " {{{1
|
||||
if a:path =~# '\~$'
|
||||
return 1
|
||||
|
@ -120,29 +136,48 @@ function! pathogen#is_disabled(path) " {{{1
|
|||
return 0
|
||||
endif
|
||||
let sep = pathogen#separator()
|
||||
return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
|
||||
let blacklist = g:pathogen_disabled
|
||||
return index(blacklist, strpart(a:path, strridx(a:path, sep)+1)) != -1 && index(blacklist, a:path) != 1
|
||||
endfunction "}}}1
|
||||
|
||||
" Prepend all subdirectories of path to the rtp, and append all 'after'
|
||||
" directories in those subdirectories.
|
||||
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
|
||||
" Prepend the given directory to the runtime path and append its corresponding
|
||||
" after directory. If the directory is already included, move it to the
|
||||
" outermost position. Wildcards are added as is. Ending a path in /{} causes
|
||||
" all subdirectories to be added (except those in g:pathogen_disabled).
|
||||
function! pathogen#surround(path) abort " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
|
||||
let rtp = pathogen#split(&rtp)
|
||||
let path = expand(a:path)
|
||||
if a:path =~# '[\\/]{}$'
|
||||
let path = fnamemodify(a:path[0:-4], ':p:s?[\\/]\=$??')
|
||||
let before = filter(pathogen#glob_directories(path.sep.'*'), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(reverse(pathogen#glob_directories(path.sep."*".sep."after")), '!pathogen#is_disabled(v:val[0:-7])')
|
||||
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
|
||||
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
|
||||
else
|
||||
let path = fnamemodify(a:path, ':p:s?[\\/]\=$??')
|
||||
let before = [path]
|
||||
let after = [path . sep . 'after']
|
||||
call filter(rtp, 'index(before + after, v:val) == -1')
|
||||
endif
|
||||
let &rtp = pathogen#join(before, rtp, after)
|
||||
return &rtp
|
||||
endfunction " }}}1
|
||||
|
||||
" For each directory in rtp, check for a subdirectory named dir. If it
|
||||
" exists, add all subdirectories of that subdirectory to the rtp, immediately
|
||||
" after the original directory. If no argument is given, 'bundle' is used.
|
||||
" Repeated calls with the same arguments are ignored.
|
||||
function! pathogen#runtime_append_all_bundles(...) " {{{1
|
||||
" Prepend all subdirectories of path to the rtp, and append all 'after'
|
||||
" directories in those subdirectories. Deprecated.
|
||||
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
|
||||
call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#surround('.string(a:path.'/{}').')')
|
||||
return pathogen#surround(a:path . pathogen#separator() . '{}')
|
||||
endfunction " }}}1
|
||||
|
||||
" For each directory in the runtime path, add a second entry with the given
|
||||
" argument appended. If the argument ends in '/{}', add a separate entry for
|
||||
" each subdirectory. The default argument is 'bundle/{}', which means that
|
||||
" .vim/bundle/*, $VIM/vimfiles/bundle/*, $VIMRUNTIME/bundle/*,
|
||||
" $VIM/vim/files/bundle/*/after, and .vim/bundle/*/after will be added (on
|
||||
" UNIX).
|
||||
function! pathogen#incubate(...) abort " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let name = a:0 ? a:1 : 'bundle'
|
||||
let name = a:0 ? a:1 : 'bundle/{}'
|
||||
if "\n".s:done_bundles =~# "\\M\n".name."\n"
|
||||
return ""
|
||||
endif
|
||||
|
@ -150,38 +185,71 @@ function! pathogen#runtime_append_all_bundles(...) " {{{1
|
|||
let list = []
|
||||
for dir in pathogen#split(&rtp)
|
||||
if dir =~# '\<after$'
|
||||
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
|
||||
if name =~# '{}$'
|
||||
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name[0:-3],'').'*'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
|
||||
else
|
||||
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
|
||||
let list += [dir, substitute(dir, 'after$', '', '') . name . sep . 'after']
|
||||
endif
|
||||
else
|
||||
if name =~# '{}$'
|
||||
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name[0:-3].'*'), '!pathogen#is_disabled(v:val)')
|
||||
else
|
||||
let list += [dir . sep . name, dir]
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
||||
return 1
|
||||
endfunction " }}}1
|
||||
|
||||
" Deprecated alias for pathogen#incubate().
|
||||
function! pathogen#runtime_append_all_bundles(...) abort " {{{1
|
||||
if a:0
|
||||
call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#incubate('.string(a:1.'/{}').')')
|
||||
else
|
||||
call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#incubate()')
|
||||
endif
|
||||
return call('pathogen#incubate', map(copy(a:000),'v:val . "/{}"'))
|
||||
endfunction
|
||||
|
||||
let s:done_bundles = ''
|
||||
" }}}1
|
||||
|
||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
||||
function! pathogen#helptags() " {{{1
|
||||
function! pathogen#helptags() abort " {{{1
|
||||
let sep = pathogen#separator()
|
||||
for dir in pathogen#split(&rtp)
|
||||
for glob in pathogen#split(&rtp)
|
||||
for dir in split(glob(glob), "\n")
|
||||
if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
|
||||
helptags `=dir.'/doc'`
|
||||
silent! execute 'helptags' pathogen#fnameescape(dir.'/doc')
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction " }}}1
|
||||
|
||||
command! -bar Helptags :call pathogen#helptags()
|
||||
|
||||
" Execute the given command. This is basically a backdoor for --remote-expr.
|
||||
function! pathogen#execute(...) abort " {{{1
|
||||
for command in a:000
|
||||
execute command
|
||||
endfor
|
||||
return ''
|
||||
endfunction " }}}1
|
||||
|
||||
" Like findfile(), but hardcoded to use the runtimepath.
|
||||
function! pathogen#runtime_findfile(file,count) "{{{1
|
||||
function! pathogen#runtime_findfile(file,count) abort "{{{1
|
||||
let rtp = pathogen#join(1,pathogen#split(&rtp))
|
||||
return fnamemodify(findfile(a:file,rtp,a:count),':p')
|
||||
let file = findfile(a:file,rtp,a:count)
|
||||
if file ==# ''
|
||||
return ''
|
||||
else
|
||||
return fnamemodify(file,':p')
|
||||
endif
|
||||
endfunction " }}}1
|
||||
|
||||
" Backport of fnameescape().
|
||||
function! pathogen#fnameescape(string) " {{{1
|
||||
function! pathogen#fnameescape(string) abort " {{{1
|
||||
if exists('*fnameescape')
|
||||
return fnameescape(a:string)
|
||||
elseif a:string ==# '-'
|
||||
|
@ -191,17 +259,30 @@ function! pathogen#fnameescape(string) " {{{1
|
|||
endif
|
||||
endfunction " }}}1
|
||||
|
||||
if exists(':Vedit')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:vopen_warning = 0
|
||||
|
||||
function! s:find(count,cmd,file,lcd) " {{{1
|
||||
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
|
||||
let file = pathogen#runtime_findfile(a:file,a:count)
|
||||
if file ==# ''
|
||||
return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
|
||||
elseif a:lcd
|
||||
endif
|
||||
if !s:vopen_warning
|
||||
let s:vopen_warning = 1
|
||||
let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
|
||||
else
|
||||
let warning = ''
|
||||
endif
|
||||
if a:lcd
|
||||
let path = file[0:-strlen(a:file)-2]
|
||||
execute 'lcd `=path`'
|
||||
return a:cmd.' '.pathogen#fnameescape(a:file)
|
||||
return a:cmd.' '.pathogen#fnameescape(a:file) . warning
|
||||
else
|
||||
return a:cmd.' '.pathogen#fnameescape(file)
|
||||
return a:cmd.' '.pathogen#fnameescape(file) . warning
|
||||
endif
|
||||
endfunction " }}}1
|
||||
|
||||
|
@ -219,7 +300,7 @@ function! s:Findcomplete(A,L,P) " {{{1
|
|||
else
|
||||
let request = a:A
|
||||
endif
|
||||
let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
|
||||
let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
|
||||
let found = {}
|
||||
for path in pathogen#split(&runtimepath)
|
||||
let path = expand(path, ':p')
|
||||
|
@ -242,4 +323,4 @@ command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabed
|
|||
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
|
||||
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
|
||||
|
||||
" vim:set ft=vim ts=8 sw=2 sts=2:
|
||||
" vim:set et sw=2:
|
||||
|
|
|
@ -36,7 +36,7 @@ if exists("syntax_on")
|
|||
syntax reset
|
||||
endif
|
||||
|
||||
let g:colors_name = expand("<sfile>:t:r")
|
||||
let g:colors_name = "peaksea"
|
||||
|
||||
" I don't want to abuse folding, but here folding is used to avoid confusion.
|
||||
if &background=='light'
|
||||
|
@ -281,7 +281,7 @@ elseif &background=='dark'
|
|||
hi ModeMsg guifg=fg guibg=#000080 gui=NONE
|
||||
hi VisualNOS guifg=fg guibg=#000080 gui=NONE
|
||||
hi SpecialKey guifg=#b0d0f0 guibg=NONE gui=NONE
|
||||
hi NonText guifg=#6080f0 guibg=#101010 gui=NONE
|
||||
hi NonText guifg=#202020 guibg=#202020 gui=NONE
|
||||
hi Directory guifg=#80c0e0 guibg=NONE gui=NONE
|
||||
hi ErrorMsg guifg=#d0d090 guibg=#800000 gui=NONE
|
||||
hi MoreMsg guifg=#c0e080 guibg=NONE gui=NONE
|
||||
|
@ -294,7 +294,7 @@ elseif &background=='dark'
|
|||
hi DiffChange guifg=NONE guibg=#800080 gui=NONE
|
||||
hi DiffDelete guifg=#6080f0 guibg=#202020 gui=NONE
|
||||
hi DiffText guifg=#000000 guibg=#c0e080 gui=NONE
|
||||
hi SignColumn guifg=#e0e0e0 guibg=#008000 gui=NONE
|
||||
hi SignColumn guifg=#e0e0e0 guibg=#202020 gui=NONE
|
||||
hi IncSearch guifg=White guibg=DarkRed gui=NONE
|
||||
hi StatusLineNC guifg=#000000 guibg=#c0c0c0 gui=NONE
|
||||
hi VertSplit guifg=#000000 guibg=#c0c0c0 gui=NONE
|
||||
|
|
|
@ -1,101 +1,60 @@
|
|||
# ack.vim #
|
||||
# ack.vim
|
||||
|
||||
This plugin is a front for the Perl module
|
||||
[App::Ack](http://search.cpan.org/~petdance/ack/ack). Ack can be used as a
|
||||
replacement for 99% of the uses of _grep_. This plugin will allow you to run
|
||||
ack from vim, and shows the results in a split window.
|
||||
|
||||
The *Official Version* of this plugin is available at [vim.org](http://www.vim.org/scripts/script.php?script_id=2572).
|
||||
|
||||
## Installation ##
|
||||
|
||||
## Installation
|
||||
|
||||
### Ack
|
||||
|
||||
You have to install [ack](http://betterthangrep.com/), of course.
|
||||
|
||||
Install on Debian / Ubuntu with:
|
||||
|
||||
sudo apt-get install ack-grep
|
||||
|
||||
Install on Fedora with:
|
||||
|
||||
su -l -c 'yum install ack'
|
||||
|
||||
Install on openSUSE with:
|
||||
|
||||
sudo zypper install ack
|
||||
|
||||
Install on Gentoo with:
|
||||
|
||||
sudo emerge ack
|
||||
|
||||
Install with Homebrew:
|
||||
|
||||
brew install ack
|
||||
|
||||
Install with MacPorts:
|
||||
|
||||
sudo port install p5-app-ack
|
||||
|
||||
Install with Gentoo Prefix:
|
||||
|
||||
emerge ack
|
||||
|
||||
Install on FreeBSD with:
|
||||
|
||||
cd /usr/ports/textproc/p5-ack/ && make install clean
|
||||
|
||||
You can specify a custom ack name and path in your .vimrc like so:
|
||||
|
||||
let g:ackprg="<custom-ack-path-goes-here> -H --nocolor --nogroup --column"
|
||||
|
||||
Otherwise, you are on your own.
|
||||
You will need the ack(>= 2.0), of course, to install it follow the
|
||||
[manual](http://beyondgrep.com/install/)
|
||||
|
||||
### The Plugin
|
||||
|
||||
If you have [Rake](http://rake.rubyforge.org/) installed, you can just run: `rake install`.
|
||||
To install it is recommended to use one of the popular package managers for Vim,
|
||||
rather than installing by drag and drop all required files into your `.vim` folder.
|
||||
|
||||
Otherwise, the file ack.vim goes in ~/.vim/plugin, and the ack.txt file belongs in ~/.vim/doc. Be sure to run
|
||||
#### Manual (not recommended)
|
||||
|
||||
:helptags ~/.vim/doc
|
||||
Just
|
||||
[download](https://github.com/mileszs/ack.vim/archive/kb-improve-readme.zip) the
|
||||
plugin and put it in your `~/.vim/`(or `%PROGRAMFILES%/Vim/vimfiles` on windows)
|
||||
|
||||
afterwards.
|
||||
#### Vundle
|
||||
|
||||
Bundle 'mileszs/ack.vim'
|
||||
|
||||
## Usage ##
|
||||
#### NeoBundle
|
||||
|
||||
:Ack [options] {pattern} [{directory}]
|
||||
NeoBundle 'mileszs/ack.vim'
|
||||
|
||||
Search recursively in {directory} (which defaults to the current directory) for the {pattern}.
|
||||
## Usage
|
||||
|
||||
:Ack [options] {pattern} [{directories}]
|
||||
|
||||
Search recursively in {directory} (which defaults to the current directory) for
|
||||
the {pattern}.
|
||||
|
||||
Files containing the search term will be listed in the split window, along with
|
||||
the line number of the occurrence, once for each occurrence. [Enter] on a line
|
||||
in this window will open the file, and place the cursor on the matching line.
|
||||
|
||||
Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `doc/ack.txt`, or install and `:h Ack` for more information.)
|
||||
Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use
|
||||
`:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively.
|
||||
(See `doc/ack.txt`, or install and `:h Ack` for more information.)
|
||||
|
||||
**From the [ack docs](http://betterthangrep.com/)** (my favorite feature):
|
||||
For more ack options see
|
||||
[ack documentation](http://beyondgrep.com/documentation/)
|
||||
|
||||
--type=TYPE, --type=noTYPE
|
||||
|
||||
Specify the types of files to include or exclude from a search. TYPE is a filetype, like perl or xml. --type=perl can also be specified as --perl, and --type=noperl can be done as --noperl.
|
||||
|
||||
If a file is of both type "foo" and "bar", specifying --foo and --nobar will exclude the file, because an exclusion takes precedence over an inclusion.
|
||||
|
||||
Type specifications can be repeated and are ORed together.
|
||||
|
||||
See ack --help=types for a list of valid types.
|
||||
|
||||
### Gotchas ###
|
||||
|
||||
Some characters have special meaning, and need to be escaped your search pattern. For instance, '#'. You have to escape it like this `:Ack '\\\#define foo'` to search for `#define foo`. (From [blueyed in issue #5](https://github.com/mileszs/ack.vim/issues/5).)
|
||||
|
||||
### Keyboard Shortcuts ###
|
||||
### Keyboard Shortcuts
|
||||
|
||||
In the quickfix window, you can use:
|
||||
|
||||
o to open (same as enter)
|
||||
O to open and close quickfix window
|
||||
go to preview file (open but maintain focus on ack.vim results)
|
||||
t to open in new tab
|
||||
T to open in new tab silently
|
||||
|
@ -106,9 +65,67 @@ In the quickfix window, you can use:
|
|||
q to close the quickfix window
|
||||
|
||||
This Vim plugin is derived (and by derived, I mean copied, essentially) from
|
||||
Antoine Imbert's blog post [Ack and Vim
|
||||
Integration](http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html) (in
|
||||
particular, the function at the bottom of the post). I added a help file that
|
||||
Antoine Imbert's blog post
|
||||
[Ack and Vim Integration](http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html)
|
||||
(in particular, the function at the bottom of the post). I added a help file that
|
||||
provides just enough reference to get you going. I also highly recommend you
|
||||
check out the docs for the Perl script 'ack', for obvious reasons: [ack -
|
||||
grep-like text finder](http://betterthangrep.com/).
|
||||
check out the docs for the Perl script 'ack', for obvious reasons:
|
||||
[ack - grep-like text finder](http://beyondgrep.com/).
|
||||
|
||||
### Gotchas
|
||||
|
||||
Some characters have special meaning, and need to be escaped your search
|
||||
pattern. For instance, '#'. You have to escape it like this `:Ack '\\\#define
|
||||
foo'` to search for '#define foo'. (From blueyed in issue #5.)
|
||||
|
||||
## Changelog
|
||||
|
||||
### 1.0
|
||||
|
||||
* Remove support to ack 1.x
|
||||
* Start to use a Changelog
|
||||
* Use `autoload` directory to define functions, instead of `plugin`.
|
||||
* Add option to auto fold the results(`g:ack_autofold_results`)
|
||||
* Improve documentation, list all options and shortcuts
|
||||
* Improve highlight option to work when passes directories or use quotes.
|
||||
* Add g:ack_mapping
|
||||
* Add g:ack_default_options
|
||||
* Add a help toggle `?`(like NERDTree)
|
||||
|
||||
### 1.0.1
|
||||
|
||||
* Fixes #124. Bug with `g:ack_autofold_results`
|
||||
|
||||
### 1.0.2
|
||||
|
||||
* Add compatibility with [vim-dispatch](https://github.com/tpope/vim-dispatch)
|
||||
|
||||
### 1.0.3
|
||||
|
||||
* Fixes #127. Use `&l:hlsearch` instead of `v:hlsearch` to keep compatibility
|
||||
with versions that does not have this variable.
|
||||
|
||||
### 1.0.4
|
||||
|
||||
* Fixes #128. Always apply mappings, even when using vim-dispatch.
|
||||
|
||||
### 1.0.5
|
||||
|
||||
* Fixes #128. Fixes the `errorformat` for ack when using vim-dispatch.
|
||||
* Do not use vim-dispatch by default. To use vim-dispath must set
|
||||
`g:ack_use_dispatch`
|
||||
|
||||
### 1.0.6
|
||||
|
||||
* Fixes highlight function to work when user passes options. Ex.: Ack -i test
|
||||
Thank's @mannih. (#131, #134)
|
||||
|
||||
### 1.0.7
|
||||
|
||||
* Fixes highlight function to work when passes more than one option, or options
|
||||
with double dashes(--option) Thank's to @MiguelLatorre and @mannih
|
||||
|
||||
### 1.0.8
|
||||
|
||||
* Fixes (again) highlight, now using negative look behind.
|
||||
* Change mappings `o` and `O` to behave as documented
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# Added by Josh Nichols, a.k.a. technicalpickles
|
||||
require 'rake'
|
||||
|
||||
files = ['doc/ack.txt', 'plugin/ack.vim']
|
||||
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts " Copied #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
154
sources_non_forked/ack.vim/autoload/ack.vim
Normal file
154
sources_non_forked/ack.vim/autoload/ack.vim
Normal file
|
@ -0,0 +1,154 @@
|
|||
function! ack#Ack(cmd, args)
|
||||
redraw
|
||||
echo "Searching ..."
|
||||
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
if empty(a:args)
|
||||
let l:grepargs = expand("<cword>")
|
||||
else
|
||||
let l:grepargs = a:args . join(a:000, ' ')
|
||||
end
|
||||
echom l:grepargs
|
||||
let l:ackprg_run = g:ackprg
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
let l:ackprg_run = substitute(l:ackprg_run, '-H\|--column', '', 'g')
|
||||
else
|
||||
let g:ackformat="%f:%l:%c:%m,%f:%l:%m"
|
||||
endif
|
||||
|
||||
let grepprg_bak = &grepprg
|
||||
let grepformat_bak = &grepformat
|
||||
let &grepprg=l:ackprg_run
|
||||
let &grepformat=g:ackformat
|
||||
|
||||
try
|
||||
" NOTE: we escape special chars, but not everything using shellescape to
|
||||
" allow for passing arguments etc
|
||||
if g:ack_use_dispatch
|
||||
let &l:errorformat = g:ackformat
|
||||
let &l:makeprg=g:ackprg." " . escape(l:grepargs, '|#%')
|
||||
Make
|
||||
else
|
||||
silent execute a:cmd . " " . escape(l:grepargs, '|#%')
|
||||
endif
|
||||
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
endtry
|
||||
|
||||
if a:cmd =~# '^l'
|
||||
let s:handler = g:ack_lhandler
|
||||
let s:apply_mappings = g:ack_apply_lmappings
|
||||
let s:close_cmd = ':lclose<CR>'
|
||||
else
|
||||
let s:handler = g:ack_qhandler
|
||||
let s:apply_mappings = g:ack_apply_qmappings
|
||||
let s:close_cmd = ':cclose<CR>'
|
||||
endif
|
||||
|
||||
if !g:ack_use_dispatch
|
||||
call ack#show_results()
|
||||
else
|
||||
copen
|
||||
endif
|
||||
call <SID>apply_maps()
|
||||
call <SID>highlight(l:grepargs)
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! ack#show_results()
|
||||
execute s:handler
|
||||
endfunction
|
||||
|
||||
function! s:apply_maps()
|
||||
let g:ack_mappings.q = s:close_cmd
|
||||
|
||||
execute "nnoremap <buffer> <silent> ? :call ack#quick_help()<CR>"
|
||||
|
||||
if s:apply_mappings && &ft == "qf"
|
||||
if g:ack_autoclose
|
||||
for key_map in items(g:ack_mappings)
|
||||
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1) . s:close_cmd)
|
||||
endfor
|
||||
execute "nnoremap <buffer> <silent> <CR> <CR>" . s:close_cmd
|
||||
else
|
||||
for key_map in items(g:ack_mappings)
|
||||
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1))
|
||||
endfor
|
||||
endif
|
||||
|
||||
if exists("g:ackpreview") " if auto preview in on, remap j and k keys
|
||||
execute "nnoremap <buffer> <silent> j j<CR><C-W><C-W>"
|
||||
execute "nnoremap <buffer> <silent> k k<CR><C-W><C-W>"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ack#quick_help()
|
||||
execute "edit " . globpath(&rtp, "doc/ack_quick_help.txt")
|
||||
|
||||
silent normal gg
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=hide
|
||||
setlocal noswapfile
|
||||
setlocal nobuflisted
|
||||
setlocal nomodifiable
|
||||
setlocal filetype=help
|
||||
setlocal nonumber
|
||||
setlocal norelativenumber
|
||||
setlocal nowrap
|
||||
setlocal foldlevel=20
|
||||
setlocal foldmethod=diff
|
||||
nnoremap <buffer> <silent> ? :q!<CR>:call ack#show_results()<CR>
|
||||
endfunction
|
||||
|
||||
function! s:highlight(args)
|
||||
if !g:ackhighlight
|
||||
return
|
||||
endif
|
||||
|
||||
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
|
||||
call feedkeys(":let &l:hlsearch=1 \| echo \<CR>", "n")
|
||||
endfunction
|
||||
|
||||
function! ack#AckFromSearch(cmd, args)
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g')
|
||||
call ack#Ack(a:cmd, '"' . search . '" ' . a:args)
|
||||
endfunction
|
||||
|
||||
function! s:GetDocLocations()
|
||||
let dp = ''
|
||||
for p in split(&rtp, ',')
|
||||
let p = p . '/doc/'
|
||||
if isdirectory(p)
|
||||
let dp = p . '*.txt ' . dp
|
||||
endif
|
||||
endfor
|
||||
|
||||
return dp
|
||||
endfunction
|
||||
|
||||
function! ack#AckHelp(cmd, args)
|
||||
let args = a:args . ' ' . s:GetDocLocations()
|
||||
call ack#Ack(a:cmd, args)
|
||||
endfunction
|
||||
|
||||
function! ack#AckWindow(cmd, args)
|
||||
let files = tabpagebuflist()
|
||||
" remove duplicated filenames (files appearing in more than one window)
|
||||
let files = filter(copy(sort(files)), 'index(files,v:val,v:key+1)==-1')
|
||||
call map(files, "bufname(v:val)")
|
||||
" remove unnamed buffers as quickfix (empty strings before shellescape)
|
||||
call filter(files, 'v:val != ""')
|
||||
" expand to full path (avoid problems with cd/lcd in au QuickFixCmdPre)
|
||||
let files = map(files, "shellescape(fnamemodify(v:val, ':p'))")
|
||||
let args = a:args . ' ' . join(files)
|
||||
call ack#Ack(a:cmd, args)
|
||||
endfunction
|
|
@ -16,7 +16,7 @@ shows the results in a split window.
|
|||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for the {pattern}. Behaves just like the |:grep| command, but
|
||||
will open the |Quickfix| window for you. If [!] is not given the first
|
||||
error is jumped to.
|
||||
occurence is jumped to.
|
||||
|
||||
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
|
||||
|
||||
|
@ -53,6 +53,16 @@ shows the results in a split window.
|
|||
Just like |:AckHelp| but instead of the |quickfix| list, matches are placed
|
||||
in the current |location-list|.
|
||||
|
||||
:AckWindow[!] [options] {pattern} *:AckWindow*
|
||||
|
||||
Search all buffers visible in the screen (current tab page only) files for
|
||||
the {pattern}.
|
||||
|
||||
:LAckWindow [options] {pattern} *:LAckWindow*
|
||||
|
||||
Just like |:AckWindow| but instead of the |quickfix| list, matches are
|
||||
placed in the current |location-list|.
|
||||
|
||||
Files containing the search term will be listed in the split window, along
|
||||
with the line number of the occurrence, once for each occurrence. <Enter> on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
|
@ -60,6 +70,151 @@ line.
|
|||
|
||||
See http://betterthangrep.com/ for more information.
|
||||
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *ack-configuration*
|
||||
|
||||
*g:ackprg*
|
||||
g:ackprg
|
||||
Default for ubuntu: "ack-grep"
|
||||
Default for other systems: "ack"
|
||||
|
||||
Use this option to specify the ack command and its options
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ackprg = "other-bin-ack"
|
||||
<
|
||||
|
||||
*g:ack_default_options*
|
||||
g:ack_default_options
|
||||
Default: " -s -H --nocolor --nogroup --column"
|
||||
|
||||
Use this option to specify the options used by ack
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_default_options =
|
||||
\ " -s -H --nocolor --nogroup --column --smart-case --follow"
|
||||
<
|
||||
|
||||
*g:ack_apply_qmappings*
|
||||
g:ack_apply_qmappings
|
||||
Default: 1
|
||||
|
||||
This option enable mappings on quickview window.
|
||||
|
||||
*g:ack_apply_lmappings*
|
||||
g:ack_apply_lmappings
|
||||
Default: 1
|
||||
|
||||
This option enable mappings on Location list window.
|
||||
|
||||
*g:ack_mappings*
|
||||
g:ack_mappings
|
||||
Default: {
|
||||
\ "t": "<C-W><CR><C-W>T",
|
||||
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
|
||||
\ "o": "<CR>",
|
||||
\ "O": "<CR><C-W><C-W>:ccl<CR>",
|
||||
\ "go": "<CR><C-W>j",
|
||||
\ "h": "<C-W><CR><C-W>K",
|
||||
\ "H": "<C-W><CR><C-W>K<C-W>b",
|
||||
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
|
||||
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
|
||||
|
||||
This option list all maps create on quickfix/Location list window.
|
||||
|
||||
Example, if you want to open the result in the middle of the screen:
|
||||
>
|
||||
let g:ack_mappings = { "o": "<CR>zz" }
|
||||
<
|
||||
|
||||
*g:ack_qhandler*
|
||||
g:ack_qhandler
|
||||
Default: "botright copen"
|
||||
|
||||
Command to open the quickview window.
|
||||
|
||||
If you want to open a quickview window with 30 lines you can do:
|
||||
>
|
||||
let g:ack_qhandler = "botright copen 30"
|
||||
<
|
||||
|
||||
*g:ack_lhandler*
|
||||
g:ack_lhandler
|
||||
Default: "botright lopen"
|
||||
|
||||
Command to open the Location list window.
|
||||
|
||||
If you want to open a Location list window with 30 lines you can do:
|
||||
>
|
||||
let g:ack_lhandler = "botright lopen 30"
|
||||
<
|
||||
|
||||
*g:ackhighlight*
|
||||
|
||||
g:ackhighlight
|
||||
Default: 0
|
||||
|
||||
Use this option to highlight the searched term.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ackhighlight = 1
|
||||
<
|
||||
|
||||
*g:ack_autoclose*
|
||||
g:ack_autoclose
|
||||
Default: 0
|
||||
|
||||
Use this option to specify whether to close the quickfix window after
|
||||
using any of the shortcuts.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_autoclose = 1
|
||||
<
|
||||
|
||||
*g:ack_autofold_results*
|
||||
|
||||
g:ack_autofold_results
|
||||
Default: 0
|
||||
|
||||
Use this option to fold the results in quickfix by file name. Only the current
|
||||
fold will be open by default and while you press 'j' and 'k' to move between the
|
||||
results if you hit other fold the last one will be closed and the current will
|
||||
be open.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_autofold_results = 1
|
||||
<
|
||||
|
||||
*g:ackpreview*
|
||||
|
||||
g:ackpreview
|
||||
Default: 0
|
||||
|
||||
Use this option to automagically open the file with 'j' or 'k'.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ackpreview = 1
|
||||
<
|
||||
|
||||
*g:ack_use_dispatch*
|
||||
|
||||
g:ack_use_dispatch
|
||||
Default: 0
|
||||
|
||||
Use this option to use vim-dispatch to search the results in background
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_use_dispatch = 1
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
MAPPINGS *ack-mappings*
|
||||
|
||||
|
@ -67,6 +222,8 @@ The following keyboard shortcuts are available in the quickfix window:
|
|||
|
||||
o open file (same as enter).
|
||||
|
||||
O open file and close quickfix window.
|
||||
|
||||
go preview file (open but maintain focus on ack.vim results).
|
||||
|
||||
t open in a new tab.
|
||||
|
|
14
sources_non_forked/ack.vim/doc/ack_quick_help.txt
Normal file
14
sources_non_forked/ack.vim/doc/ack_quick_help.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
==== ack.vim quick help ===============
|
||||
|
||||
*?:* Show this help
|
||||
*t:* Open in a new tab
|
||||
*T:* Open in a new tab silently
|
||||
*o:* Open
|
||||
*O:* Open and close result window
|
||||
*go:* Preview
|
||||
*h:* Horizontal open
|
||||
*H:* Horizontal open silently
|
||||
*v:* Vertical open
|
||||
*gv:* Vertical open silently
|
||||
|
||||
========================================
|
9
sources_non_forked/ack.vim/ftplugin/qf.vim
Normal file
9
sources_non_forked/ack.vim/ftplugin/qf.vim
Normal file
|
@ -0,0 +1,9 @@
|
|||
if exists("g:ack_autofold_results") && g:ack_autofold_results
|
||||
setlocal foldlevel=0
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=matchstr(getline(v:lnum),'^[^\|]\\+')==#matchstr(getline(v:lnum+1),'^[^\|]\\+')?1:'<1'
|
||||
setlocal foldenable
|
||||
setlocal foldclose=all
|
||||
setlocal foldopen=all
|
||||
nnoremap <buffer> j jzz
|
||||
endif
|
|
@ -1,16 +1,17 @@
|
|||
" NOTE: You must, of course, install the ack script
|
||||
" in your path.
|
||||
" On Debian / Ubuntu:
|
||||
" sudo apt-get install ack-grep
|
||||
" With MacPorts:
|
||||
" sudo port install p5-app-ack
|
||||
" With Homebrew:
|
||||
" brew install ack
|
||||
if !exists("g:ack_default_options")
|
||||
let g:ack_default_options = " -s -H --nocolor --nogroup --column"
|
||||
endif
|
||||
|
||||
" Location of the ack utility
|
||||
if !exists("g:ackprg")
|
||||
let s:ackcommand = executable('ack-grep') ? 'ack-grep' : 'ack'
|
||||
let g:ackprg=s:ackcommand." -H --nocolor --nogroup --column"
|
||||
if executable('ack')
|
||||
let g:ackprg = "ack"
|
||||
elseif executable('ack-grep')
|
||||
let g:ackprg = "ack-grep"
|
||||
else
|
||||
finish
|
||||
endif
|
||||
let g:ackprg .= g:ack_default_options
|
||||
endif
|
||||
|
||||
if !exists("g:ack_apply_qmappings")
|
||||
|
@ -21,6 +22,27 @@ if !exists("g:ack_apply_lmappings")
|
|||
let g:ack_apply_lmappings = !exists("g:ack_lhandler")
|
||||
endif
|
||||
|
||||
if !exists("g:ack_use_dispatch")
|
||||
let g:ack_use_dispatch = 0
|
||||
end
|
||||
|
||||
let s:ack_mappings = {
|
||||
\ "t": "<C-W><CR><C-W>T",
|
||||
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
|
||||
\ "o": "<CR>",
|
||||
\ "O": "<CR><C-W>p<C-W>c",
|
||||
\ "go": "<CR><C-W>p",
|
||||
\ "h": "<C-W><CR><C-W>K",
|
||||
\ "H": "<C-W><CR><C-W>K<C-W>b",
|
||||
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
|
||||
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
|
||||
|
||||
if exists("g:ack_mappings")
|
||||
let g:ack_mappings = extend(s:ack_mappings, g:ack_mappings)
|
||||
else
|
||||
let g:ack_mappings = s:ack_mappings
|
||||
endif
|
||||
|
||||
if !exists("g:ack_qhandler")
|
||||
let g:ack_qhandler = "botright copen"
|
||||
endif
|
||||
|
@ -29,92 +51,25 @@ if !exists("g:ack_lhandler")
|
|||
let g:ack_lhandler = "botright lopen"
|
||||
endif
|
||||
|
||||
function! s:Ack(cmd, args)
|
||||
redraw
|
||||
echo "Searching ..."
|
||||
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
if empty(a:args)
|
||||
let l:grepargs = expand("<cword>")
|
||||
else
|
||||
let l:grepargs = a:args . join(a:000, ' ')
|
||||
end
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
else
|
||||
let g:ackformat="%f:%l:%c:%m"
|
||||
end
|
||||
|
||||
let grepprg_bak=&grepprg
|
||||
let grepformat_bak=&grepformat
|
||||
try
|
||||
let &grepprg=g:ackprg
|
||||
let &grepformat=g:ackformat
|
||||
silent execute a:cmd . " " . escape(l:grepargs, '|')
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
endtry
|
||||
|
||||
if a:cmd =~# '^l'
|
||||
exe g:ack_lhandler
|
||||
let l:apply_mappings = g:ack_apply_lmappings
|
||||
else
|
||||
exe g:ack_qhandler
|
||||
let l:apply_mappings = g:ack_apply_qmappings
|
||||
if !exists("g:ackhighlight")
|
||||
let g:ackhighlight = 0
|
||||
endif
|
||||
|
||||
if l:apply_mappings
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
|
||||
exec "nnoremap <silent> <buffer> T <C-W><CR><C-W>TgT<C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> o <CR>"
|
||||
exec "nnoremap <silent> <buffer> go <CR><C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> h <C-W><CR><C-W>K"
|
||||
exec "nnoremap <silent> <buffer> H <C-W><CR><C-W>K<C-W>b"
|
||||
exec "nnoremap <silent> <buffer> v <C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t"
|
||||
exec "nnoremap <silent> <buffer> gv <C-W><CR><C-W>H<C-W>b<C-W>J"
|
||||
if !exists("g:ack_autoclose")
|
||||
let g:ack_autoclose = 0
|
||||
endif
|
||||
|
||||
" If highlighting is on, highlight the search keyword.
|
||||
if exists("g:ackhighlight")
|
||||
let @/=a:args
|
||||
set hlsearch
|
||||
end
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! s:AckFromSearch(cmd, args)
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search,'\(\\<\|\\>\)','\\b','g')
|
||||
call s:Ack(a:cmd, '"' . search .'" '. a:args)
|
||||
endfunction
|
||||
|
||||
function! s:GetDocLocations()
|
||||
let dp = ''
|
||||
for p in split(&rtp,',')
|
||||
let p = p.'/doc/'
|
||||
if isdirectory(p)
|
||||
let dp = p.'*.txt '.dp
|
||||
if !exists("g:ack_autofold_results")
|
||||
let g:ack_autofold_results = 0
|
||||
endif
|
||||
endfor
|
||||
return dp
|
||||
endfunction
|
||||
|
||||
function! s:AckHelp(cmd,args)
|
||||
let args = a:args.' '.s:GetDocLocations()
|
||||
call s:Ack(a:cmd,args)
|
||||
endfunction
|
||||
|
||||
command! -bang -nargs=* -complete=file Ack call s:Ack('grep<bang>',<q-args>)
|
||||
command! -bang -nargs=* -complete=file AckAdd call s:Ack('grepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFile call s:Ack('grep<bang> -g', <q-args>)
|
||||
command! -bang -nargs=* -complete=help AckHelp call s:AckHelp('grep<bang>',<q-args>)
|
||||
command! -bang -nargs=* -complete=help LAckHelp call s:AckHelp('lgrep<bang>',<q-args>)
|
||||
command! -bang -nargs=* -complete=file Ack call ack#Ack('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep<bang> -g', <q-args>)
|
||||
command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=help LAckHelp call ack#AckHelp('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=help AckWindow call ack#AckWindow('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=help LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
bufexplorer bufexplorer.txt /*bufexplorer*
|
||||
bufexplorer-changelog bufexplorer.txt /*bufexplorer-changelog*
|
||||
bufexplorer-credits bufexplorer.txt /*bufexplorer-credits*
|
||||
bufexplorer-customization bufexplorer.txt /*bufexplorer-customization*
|
||||
bufexplorer-installation bufexplorer.txt /*bufexplorer-installation*
|
||||
bufexplorer-todo bufexplorer.txt /*bufexplorer-todo*
|
||||
bufexplorer-usage bufexplorer.txt /*bufexplorer-usage*
|
||||
bufexplorer-windowlayout bufexplorer.txt /*bufexplorer-windowlayout*
|
||||
bufexplorer.txt bufexplorer.txt /*bufexplorer.txt*
|
||||
buffer-explorer bufexplorer.txt /*buffer-explorer*
|
||||
g:bufExplorerChgWin bufexplorer.txt /*g:bufExplorerChgWin*
|
||||
g:bufExplorerDefaultHelp bufexplorer.txt /*g:bufExplorerDefaultHelp*
|
||||
g:bufExplorerDetailedHelp bufexplorer.txt /*g:bufExplorerDetailedHelp*
|
||||
g:bufExplorerFindActive bufexplorer.txt /*g:bufExplorerFindActive*
|
||||
g:bufExplorerFuncRef bufexplorer.txt /*g:bufExplorerFuncRef*
|
||||
g:bufExplorerReverseSort bufexplorer.txt /*g:bufExplorerReverseSort*
|
||||
g:bufExplorerShowDirectories bufexplorer.txt /*g:bufExplorerShowDirectories*
|
||||
g:bufExplorerShowRelativePath bufexplorer.txt /*g:bufExplorerShowRelativePath*
|
||||
g:bufExplorerShowTabBuffer bufexplorer.txt /*g:bufExplorerShowTabBuffer*
|
||||
g:bufExplorerShowUnlisted bufexplorer.txt /*g:bufExplorerShowUnlisted*
|
||||
g:bufExplorerSortBy bufexplorer.txt /*g:bufExplorerSortBy*
|
||||
g:bufExplorerSplitBelow bufexplorer.txt /*g:bufExplorerSplitBelow*
|
||||
g:bufExplorerSplitOutPathName bufexplorer.txt /*g:bufExplorerSplitOutPathName*
|
||||
g:bufExplorerSplitRight bufexplorer.txt /*g:bufExplorerSplitRight*
|
340
sources_non_forked/goyo.vim/plugin/goyo.vim
Normal file
340
sources_non_forked/goyo.vim/plugin/goyo.vim
Normal file
|
@ -0,0 +1,340 @@
|
|||
" Copyright (c) 2013 Junegunn Choi
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
" 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.
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! s:get_color(group, attr)
|
||||
return synIDattr(synIDtrans(hlID(a:group)), a:attr)
|
||||
endfunction
|
||||
|
||||
function! s:set_color(group, attr, color)
|
||||
let gui = has('gui_running')
|
||||
execute printf("hi %s %s%s=%s", a:group, gui ? 'gui' : 'cterm', a:attr, a:color)
|
||||
endfunction
|
||||
|
||||
function! s:blank()
|
||||
let main = bufwinnr(t:goyo_master)
|
||||
if main != -1
|
||||
execute main . 'wincmd w'
|
||||
else
|
||||
call s:goyo_off()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:init_pad(command)
|
||||
execute a:command
|
||||
|
||||
setlocal buftype=nofile bufhidden=wipe nomodifiable nobuflisted noswapfile
|
||||
\ nonu nocursorline nocursorcolumn winfixwidth winfixheight statusline=\
|
||||
if exists('&rnu')
|
||||
setlocal nornu
|
||||
endif
|
||||
if exists('&colorcolumn')
|
||||
setlocal colorcolumn=
|
||||
endif
|
||||
let bufnr = winbufnr(0)
|
||||
|
||||
execute winnr('#') . 'wincmd w'
|
||||
return bufnr
|
||||
endfunction
|
||||
|
||||
function! s:setup_pad(bufnr, vert, size)
|
||||
let win = bufwinnr(a:bufnr)
|
||||
execute win . 'wincmd w'
|
||||
execute (a:vert ? 'vertical ' : '') . 'resize ' . max([0, a:size])
|
||||
augroup goyop
|
||||
autocmd WinEnter,CursorMoved <buffer> call s:blank()
|
||||
augroup END
|
||||
|
||||
" To hide scrollbars of pad windows in GVim
|
||||
let diff = winheight(0) - line('$') - (has('gui_running') ? 2 : 0)
|
||||
if diff > 0
|
||||
setlocal modifiable
|
||||
call append(0, map(range(1, diff), '""'))
|
||||
normal! gg
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
execute winnr('#') . 'wincmd w'
|
||||
endfunction
|
||||
|
||||
function! s:hmargin()
|
||||
let nwidth = max([len(string(line('$'))) + 1, &numberwidth])
|
||||
let width = t:goyo_width + (&number ? nwidth : 0)
|
||||
return (&columns - width)
|
||||
endfunction
|
||||
|
||||
function! s:resize_pads()
|
||||
let hmargin = s:hmargin()
|
||||
let tmargin = get(g:, 'goyo_margin_top', 4)
|
||||
let bmargin = get(g:, 'goyo_margin_bottom', 4)
|
||||
|
||||
augroup goyop
|
||||
autocmd!
|
||||
augroup END
|
||||
call s:setup_pad(t:goyo_pads.t, 0, tmargin - 1)
|
||||
call s:setup_pad(t:goyo_pads.b, 0, bmargin - 2)
|
||||
call s:setup_pad(t:goyo_pads.l, 1, hmargin / 2 - 1)
|
||||
call s:setup_pad(t:goyo_pads.r, 1, hmargin / 2 - 1)
|
||||
endfunction
|
||||
|
||||
function! s:tranquilize()
|
||||
let bg = s:get_color('Normal', 'bg')
|
||||
for grp in ['NonText', 'FoldColumn', 'ColorColumn', 'VertSplit',
|
||||
\ 'StatusLine', 'StatusLineNC', 'SignColumn']
|
||||
" -1 on Vim / '' on GVim
|
||||
if bg == -1 || empty(bg)
|
||||
call s:set_color(grp, 'fg', get(g:, 'goyo_bg', 'black'))
|
||||
call s:set_color(grp, 'bg', 'NONE')
|
||||
else
|
||||
call s:set_color(grp, 'fg', bg)
|
||||
call s:set_color(grp, 'bg', bg)
|
||||
endif
|
||||
call s:set_color(grp, '', 'NONE')
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:goyo_on(width)
|
||||
let s:orig_tab = tabpagenr()
|
||||
|
||||
" New tab
|
||||
tab split
|
||||
|
||||
let t:goyo_master = winbufnr(0)
|
||||
let t:goyo_width = a:width
|
||||
let t:goyo_pads = {}
|
||||
let t:goyo_revert =
|
||||
\ { 'laststatus': &laststatus,
|
||||
\ 'showtabline': &showtabline,
|
||||
\ 'fillchars': &fillchars,
|
||||
\ 'winminwidth': &winminwidth,
|
||||
\ 'winwidth': &winwidth,
|
||||
\ 'winminheight': &winminheight,
|
||||
\ 'winheight': &winheight,
|
||||
\ 'statusline': &statusline,
|
||||
\ 'ruler': &ruler,
|
||||
\ 'sidescroll': &sidescroll,
|
||||
\ 'sidescrolloff': &sidescrolloff
|
||||
\ }
|
||||
if has('gui_running')
|
||||
let t:goyo_revert.guioptions = &guioptions
|
||||
endif
|
||||
|
||||
" vim-gitgutter
|
||||
let t:goyo_disabled_gitgutter = get(g:, 'gitgutter_enabled', 0)
|
||||
if t:goyo_disabled_gitgutter
|
||||
silent! GitGutterDisable
|
||||
endif
|
||||
|
||||
" vim-signify
|
||||
let t:goyo_disabled_signify = exists('b:sy') && b:sy.active
|
||||
if t:goyo_disabled_signify
|
||||
SignifyToggle
|
||||
endif
|
||||
|
||||
" vim-airline
|
||||
let t:goyo_disabled_airline = exists("#airline")
|
||||
if t:goyo_disabled_airline
|
||||
AirlineToggle
|
||||
endif
|
||||
|
||||
" vim-powerline
|
||||
let t:goyo_disabled_powerline = exists("#PowerlineMain")
|
||||
if t:goyo_disabled_powerline
|
||||
augroup PowerlineMain
|
||||
autocmd!
|
||||
augroup END
|
||||
augroup! PowerlineMain
|
||||
endif
|
||||
|
||||
" lightline.vim
|
||||
let t:goyo_disabled_lightline = exists('#LightLine')
|
||||
if t:goyo_disabled_lightline
|
||||
silent! call lightline#disable()
|
||||
endif
|
||||
|
||||
if !get(g:, 'goyo_linenr', 0)
|
||||
setlocal nonu
|
||||
if exists('&rnu')
|
||||
setlocal nornu
|
||||
endif
|
||||
endif
|
||||
if exists('&colorcolumn')
|
||||
setlocal colorcolumn=
|
||||
endif
|
||||
|
||||
" Global options
|
||||
let &winheight = max([&winminheight, 1])
|
||||
set winminheight=1
|
||||
set winheight=1
|
||||
set winminwidth=1 winwidth=1
|
||||
set laststatus=0
|
||||
set showtabline=0
|
||||
set noruler
|
||||
set fillchars+=vert:\
|
||||
set fillchars+=stl:.
|
||||
set fillchars+=stlnc:\
|
||||
set sidescroll=1
|
||||
set sidescrolloff=0
|
||||
|
||||
" Hide left-hand scrollbars
|
||||
if has('gui_running')
|
||||
set guioptions-=l
|
||||
set guioptions-=L
|
||||
endif
|
||||
|
||||
let t:goyo_pads.l = s:init_pad('vertical topleft new')
|
||||
let t:goyo_pads.r = s:init_pad('vertical botright new')
|
||||
let t:goyo_pads.t = s:init_pad('topleft new')
|
||||
let t:goyo_pads.b = s:init_pad('botright new')
|
||||
|
||||
call s:resize_pads()
|
||||
call s:tranquilize()
|
||||
|
||||
let &statusline = repeat(' ', winwidth(0))
|
||||
|
||||
augroup goyo
|
||||
autocmd!
|
||||
autocmd BufWinLeave <buffer> call s:goyo_off()
|
||||
autocmd TabLeave * call s:goyo_off()
|
||||
autocmd VimResized * call s:resize_pads()
|
||||
autocmd ColorScheme * call s:tranquilize()
|
||||
augroup END
|
||||
|
||||
if exists('g:goyo_callbacks[0]')
|
||||
call g:goyo_callbacks[0]()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:goyo_off()
|
||||
if !exists('#goyo')
|
||||
return
|
||||
endif
|
||||
|
||||
" Oops, not this tab
|
||||
if !exists('t:goyo_revert')
|
||||
return
|
||||
endif
|
||||
|
||||
" Clear auto commands
|
||||
augroup goyo
|
||||
autocmd!
|
||||
augroup END
|
||||
augroup! goyo
|
||||
augroup goyop
|
||||
autocmd!
|
||||
augroup END
|
||||
augroup! goyop
|
||||
|
||||
let goyo_revert = t:goyo_revert
|
||||
let goyo_disabled_gitgutter = t:goyo_disabled_gitgutter
|
||||
let goyo_disabled_signify = t:goyo_disabled_signify
|
||||
let goyo_disabled_airline = t:goyo_disabled_airline
|
||||
let goyo_disabled_powerline = t:goyo_disabled_powerline
|
||||
let goyo_disabled_lightline = t:goyo_disabled_lightline
|
||||
let goyo_orig_buffer = t:goyo_master
|
||||
let [line, col] = [line('.'), col('.')]
|
||||
|
||||
if tabpagenr() == 1
|
||||
tabnew
|
||||
normal! gt
|
||||
bd
|
||||
endif
|
||||
tabclose
|
||||
execute 'normal! '.s:orig_tab.'gt'
|
||||
if winbufnr(0) == goyo_orig_buffer
|
||||
execute printf('normal! %dG%d|', line, col)
|
||||
endif
|
||||
|
||||
let wmw = remove(goyo_revert, 'winminwidth')
|
||||
let ww = remove(goyo_revert, 'winwidth')
|
||||
let &winwidth = ww
|
||||
let &winminwidth = wmw
|
||||
let wmh = remove(goyo_revert, 'winminheight')
|
||||
let wh = remove(goyo_revert, 'winheight')
|
||||
let &winheight = max([wmh, 1])
|
||||
let &winminheight = wmh
|
||||
let &winheight = wh
|
||||
|
||||
for [k, v] in items(goyo_revert)
|
||||
execute printf("let &%s = %s", k, string(v))
|
||||
endfor
|
||||
execute 'colo '. get(g:, 'colors_name', 'default')
|
||||
|
||||
if goyo_disabled_gitgutter
|
||||
silent! GitGutterEnable
|
||||
endif
|
||||
|
||||
if goyo_disabled_signify
|
||||
silent! if !b:sy.active
|
||||
SignifyToggle
|
||||
endif
|
||||
endif
|
||||
|
||||
if goyo_disabled_airline && !exists("#airline")
|
||||
AirlineToggle
|
||||
silent! AirlineRefresh
|
||||
endif
|
||||
|
||||
if goyo_disabled_powerline && !exists("#PowerlineMain")
|
||||
doautocmd PowerlineStartup VimEnter
|
||||
silent! PowerlineReloadColorscheme
|
||||
endif
|
||||
|
||||
if goyo_disabled_lightline
|
||||
silent! call lightline#enable()
|
||||
endif
|
||||
|
||||
if exists('#Powerline')
|
||||
doautocmd Powerline ColorScheme
|
||||
endif
|
||||
|
||||
if exists('g:goyo_callbacks[1]')
|
||||
call g:goyo_callbacks[1]()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:goyo(bang, ...)
|
||||
let width = a:0 > 0 ? a:1 : get(g:, 'goyo_width', 80)
|
||||
|
||||
if a:bang
|
||||
if exists('#goyo')
|
||||
call s:goyo_off()
|
||||
endif
|
||||
else
|
||||
if exists('#goyo') == 0
|
||||
call s:goyo_on(width)
|
||||
elseif a:0 > 0
|
||||
let t:goyo_width = width
|
||||
call s:resize_pads()
|
||||
else
|
||||
call s:goyo_off()
|
||||
end
|
||||
end
|
||||
endfunction
|
||||
|
||||
command! -nargs=? -bar -bang Goyo call s:goyo('<bang>' == '!', <args>)
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
|
@ -60,7 +60,7 @@ Installation
|
|||
cd ~/.vim/bundle
|
||||
git clone https://github.com/scrooloose/nerdtree.git
|
||||
|
||||
Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`.
|
||||
Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`.
|
||||
|
||||
|
||||
Faq
|
||||
|
@ -80,7 +80,10 @@ A. Stick this in your vimrc: `autocmd vimenter * NERDTree`
|
|||
|
||||
__Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__
|
||||
|
||||
A. Stick this in your vimrc `autocmd vimenter * if !argc() | NERDTree | endif`
|
||||
A. Stick this in your vimrc
|
||||
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
||||
|
||||
__Q. How can I map a specific key or shortcut to open NERDTree?__
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
644
sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim
Normal file
644
sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim
Normal file
|
@ -0,0 +1,644 @@
|
|||
if exists("g:loaded_nerdtree_ui_glue_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_ui_glue_autoload = 1
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1
|
||||
function! nerdtree#ui_glue#createDefaultBindings()
|
||||
let s = '<SNR>' . s:SID() . '_'
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': '<MiddleRelease>', 'scope': "all", 'callback': s."handleMiddleMouse" })
|
||||
call NERDTreeAddKeyMap({ 'key': '<LeftRelease>', 'scope': "all", 'callback': s."handleLeftClick" })
|
||||
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" })
|
||||
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" })
|
||||
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" })
|
||||
call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" })
|
||||
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': "nerdtree#ui_glue#chRootCwd" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" })
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" })
|
||||
|
||||
call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" })
|
||||
endfunction
|
||||
|
||||
|
||||
"SECTION: Interface bindings {{{1
|
||||
"============================================================
|
||||
|
||||
"FUNCTION: s:activateAll() {{{1
|
||||
"handle the user activating the updir line
|
||||
function! s:activateAll()
|
||||
if getline(".") ==# nerdtree#treeUpDirLine()
|
||||
return nerdtree#ui_glue#upDir(0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:activateDirNode() {{{1
|
||||
"handle the user activating a tree node
|
||||
function! s:activateDirNode(node)
|
||||
call a:node.activate({'reuse': 1})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:activateFileNode() {{{1
|
||||
"handle the user activating a tree node
|
||||
function! s:activateFileNode(node)
|
||||
call a:node.activate({'reuse': 1, 'where': 'p'})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:activateBookmark() {{{1
|
||||
"handle the user activating a bookmark
|
||||
function! s:activateBookmark(bm)
|
||||
call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
|
||||
" Associate the current node with the given name
|
||||
function! nerdtree#ui_glue#bookmarkNode(...)
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
if currentNode != {}
|
||||
let name = a:1
|
||||
if empty(name)
|
||||
let name = currentNode.path.getLastPathComponent(0)
|
||||
endif
|
||||
try
|
||||
call currentNode.bookmark(name)
|
||||
call b:NERDTree.render()
|
||||
catch /^NERDTree.IllegalBookmarkNameError/
|
||||
call nerdtree#echo("bookmark names must not contain spaces")
|
||||
endtry
|
||||
else
|
||||
call nerdtree#echo("select a node first")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:chCwd(node) {{{1
|
||||
function! s:chCwd(node)
|
||||
try
|
||||
call a:node.path.changeToDir()
|
||||
catch /^NERDTree.PathChangeError/
|
||||
call nerdtree#echoWarning("could not change cwd")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:chRoot(node) {{{1
|
||||
" changes the current root to the selected one
|
||||
function! s:chRoot(node)
|
||||
call a:node.makeRoot()
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTreeRoot.putCursorHere(0, 0)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
||||
" changes the current root to CWD
|
||||
function! nerdtree#ui_glue#chRootCwd()
|
||||
try
|
||||
let cwd = g:NERDTreePath.New(getcwd())
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
call nerdtree#echo("current directory does not exist.")
|
||||
return
|
||||
endtry
|
||||
if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str()
|
||||
return
|
||||
endif
|
||||
call s:chRoot(g:NERDTreeDirNode.New(cwd))
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
|
||||
function! nerdtree#ui_glue#clearBookmarks(bookmarks)
|
||||
if a:bookmarks ==# ''
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
if currentNode != {}
|
||||
call currentNode.clearBookmarks()
|
||||
endif
|
||||
else
|
||||
for name in split(a:bookmarks, ' ')
|
||||
let bookmark = g:NERDTreeBookmark.BookmarkFor(name)
|
||||
call bookmark.delete()
|
||||
endfor
|
||||
endif
|
||||
call b:NERDTree.render()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:closeChildren(node) {{{1
|
||||
" closes all childnodes of the current node
|
||||
function! s:closeChildren(node)
|
||||
call a:node.closeChildren()
|
||||
call b:NERDTree.render()
|
||||
call a:node.putCursorHere(0, 0)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:closeCurrentDir(node) {{{1
|
||||
" closes the parent dir of the current node
|
||||
function! s:closeCurrentDir(node)
|
||||
let parent = a:node.parent
|
||||
if parent ==# {} || parent.isRoot()
|
||||
call nerdtree#echo("cannot close tree root")
|
||||
else
|
||||
while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot()
|
||||
if parent.parent.getVisibleChildCount() == 1
|
||||
call parent.close()
|
||||
let parent = parent.parent
|
||||
else
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
call parent.close()
|
||||
call b:NERDTree.render()
|
||||
call parent.putCursorHere(0, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:closeTreeWindow() {{{1
|
||||
" close the tree window
|
||||
function! s:closeTreeWindow()
|
||||
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
|
||||
exec "buffer " . b:NERDTreePreviousBuf
|
||||
else
|
||||
if winnr("$") > 1
|
||||
call nerdtree#closeTree()
|
||||
else
|
||||
call nerdtree#echo("Cannot close last window")
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:deleteBookmark(bm) {{{1
|
||||
" if the cursor is on a bookmark, prompt to delete
|
||||
function! s:deleteBookmark(bm)
|
||||
echo "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):"
|
||||
|
||||
if nr2char(getchar()) ==# 'y'
|
||||
try
|
||||
call a:bm.delete()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call nerdtree#echoWarning("Could not remove bookmark")
|
||||
endtry
|
||||
else
|
||||
call nerdtree#echo("delete aborted" )
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:displayHelp() {{{1
|
||||
" toggles the help display
|
||||
function! s:displayHelp()
|
||||
let b:treeShowHelp = b:treeShowHelp ? 0 : 1
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:findAndRevealPath() {{{1
|
||||
function! s:findAndRevealPath()
|
||||
try
|
||||
let p = g:NERDTreePath.New(expand("%:p"))
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
call nerdtree#echo("no file for the current buffer")
|
||||
return
|
||||
endtry
|
||||
|
||||
if p.isUnixHiddenPath()
|
||||
let showhidden=g:NERDTreeShowHidden
|
||||
let g:NERDTreeShowHidden = 1
|
||||
endif
|
||||
|
||||
if !g:NERDTree.ExistsForTab()
|
||||
try
|
||||
let cwd = g:NERDTreePath.New(getcwd())
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
call nerdtree#echo("current directory does not exist.")
|
||||
let cwd = p.getParent()
|
||||
endtry
|
||||
|
||||
if p.isUnder(cwd)
|
||||
call g:NERDTreeCreator.CreatePrimary(cwd.str())
|
||||
else
|
||||
call g:NERDTreeCreator.CreatePrimary(p.getParent().str())
|
||||
endif
|
||||
else
|
||||
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
|
||||
if !nerdtree#isTreeOpen()
|
||||
call g:NERDTreeCreator.TogglePrimary('')
|
||||
else
|
||||
call nerdtree#putCursorInTreeWin()
|
||||
endif
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
|
||||
else
|
||||
if !nerdtree#isTreeOpen()
|
||||
call g:NERDTreeCreator.TogglePrimary("")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
call nerdtree#putCursorInTreeWin()
|
||||
call b:NERDTreeRoot.reveal(p)
|
||||
|
||||
if p.isUnixHiddenFile()
|
||||
let g:NERDTreeShowHidden = showhidden
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:handleLeftClick() {{{1
|
||||
"Checks if the click should open the current node
|
||||
function! s:handleLeftClick()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
if currentNode != {}
|
||||
|
||||
"the dir arrows are multibyte chars, and vim's string functions only
|
||||
"deal with single bytes - so split the line up with the hack below and
|
||||
"take the line substring manually
|
||||
let line = split(getline(line(".")), '\zs')
|
||||
let startToCur = ""
|
||||
for i in range(0,len(line)-1)
|
||||
let startToCur .= line[i]
|
||||
endfor
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
if startToCur =~# nerdtree#treeMarkupReg() && startToCur =~# '[+~▾▸] \?$'
|
||||
call currentNode.activate()
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
|
||||
let char = strpart(startToCur, strlen(startToCur)-1, 1)
|
||||
if char !~# nerdtree#treeMarkupReg()
|
||||
if currentNode.path.isDirectory
|
||||
call currentNode.activate()
|
||||
else
|
||||
call currentNode.activate({'reuse': 1, 'where': 'p'})
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:handleMiddleMouse() {{{1
|
||||
function! s:handleMiddleMouse()
|
||||
let curNode = g:NERDTreeFileNode.GetSelected()
|
||||
if curNode ==# {}
|
||||
call nerdtree#echo("Put the cursor on a node first" )
|
||||
return
|
||||
endif
|
||||
|
||||
if curNode.path.isDirectory
|
||||
call nerdtree#openExplorer(curNode)
|
||||
else
|
||||
call curNode.open({'where': 'h'})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToChild(direction) {{{2
|
||||
" Args:
|
||||
" direction: 0 if going to first child, 1 if going to last
|
||||
function! s:jumpToChild(currentNode, direction)
|
||||
if a:currentNode.isRoot()
|
||||
return nerdtree#echo("cannot jump to " . (a:direction ? "last" : "first") . " child")
|
||||
end
|
||||
let dirNode = a:currentNode.parent
|
||||
let childNodes = dirNode.getVisibleChildren()
|
||||
|
||||
let targetNode = childNodes[0]
|
||||
if a:direction
|
||||
let targetNode = childNodes[len(childNodes) - 1]
|
||||
endif
|
||||
|
||||
if targetNode.equals(a:currentNode)
|
||||
let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction)
|
||||
if siblingDir != {}
|
||||
let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0
|
||||
let targetNode = siblingDir.getChildByIndex(indx, 1)
|
||||
endif
|
||||
endif
|
||||
|
||||
call targetNode.putCursorHere(1, 0)
|
||||
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1
|
||||
"this is needed since I cant figure out how to invoke dict functions from a
|
||||
"key map
|
||||
function! nerdtree#ui_glue#invokeKeyMap(key)
|
||||
call g:NERDTreeKeyMap.Invoke(a:key)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToFirstChild() {{{1
|
||||
" wrapper for the jump to child method
|
||||
function! s:jumpToFirstChild(node)
|
||||
call s:jumpToChild(a:node, 0)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToLastChild() {{{1
|
||||
" wrapper for the jump to child method
|
||||
function! s:jumpToLastChild(node)
|
||||
call s:jumpToChild(a:node, 1)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToParent(node) {{{1
|
||||
" moves the cursor to the parent of the current node
|
||||
function! s:jumpToParent(node)
|
||||
if !empty(a:node.parent)
|
||||
call a:node.parent.putCursorHere(1, 0)
|
||||
call b:NERDTree.ui.centerView()
|
||||
else
|
||||
call nerdtree#echo("cannot jump to parent")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToRoot() {{{1
|
||||
" moves the cursor to the root node
|
||||
function! s:jumpToRoot()
|
||||
call b:NERDTreeRoot.putCursorHere(1, 0)
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToNextSibling(node) {{{1
|
||||
function! s:jumpToNextSibling(node)
|
||||
call s:jumpToSibling(a:node, 1)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToPrevSibling(node) {{{1
|
||||
function! s:jumpToPrevSibling(node)
|
||||
call s:jumpToSibling(a:node, 0)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2
|
||||
" moves the cursor to the sibling of the current node in the given direction
|
||||
"
|
||||
" Args:
|
||||
" forward: 1 if the cursor should move to the next sibling, 0 if it should
|
||||
" move back to the previous sibling
|
||||
function! s:jumpToSibling(currentNode, forward)
|
||||
let sibling = a:currentNode.findSibling(a:forward)
|
||||
|
||||
if !empty(sibling)
|
||||
call sibling.putCursorHere(1, 0)
|
||||
call b:NERDTree.ui.centerView()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1
|
||||
" put the cursor on the given bookmark and, if its a file, open it
|
||||
function! nerdtree#ui_glue#openBookmark(name)
|
||||
try
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
|
||||
call targetNode.putCursorHere(0, 1)
|
||||
redraw!
|
||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||
call nerdtree#echo("note - target node is not cached")
|
||||
let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
|
||||
let targetNode = g:NERDTreeFileNode.New(bookmark.path)
|
||||
endtry
|
||||
if targetNode.path.isDirectory
|
||||
call targetNode.openExplorer()
|
||||
else
|
||||
call targetNode.open({'where': 'p'})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openHSplit(target) {{{1
|
||||
function! s:openHSplit(target)
|
||||
call a:target.activate({'where': 'h'})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openVSplit(target) {{{1
|
||||
function! s:openVSplit(target)
|
||||
call a:target.activate({'where': 'v'})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openExplorer(node) {{{1
|
||||
function! s:openExplorer(node)
|
||||
call a:node.openExplorer()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openInNewTab(target) {{{1
|
||||
function! s:openInNewTab(target)
|
||||
call a:target.activate({'where': 't'})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openInNewTabSilent(target) {{{1
|
||||
function! s:openInNewTabSilent(target)
|
||||
call a:target.activate({'where': 't', 'stay': 1})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:openNodeRecursively(node) {{{1
|
||||
function! s:openNodeRecursively(node)
|
||||
call nerdtree#echo("Recursively opening node. Please wait...")
|
||||
call a:node.openRecursively()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
call nerdtree#echo("Recursively opening node. Please wait... DONE")
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:previewNodeCurrent(node) {{{1
|
||||
function! s:previewNodeCurrent(node)
|
||||
call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:previewNodeHSplit(node) {{{1
|
||||
function! s:previewNodeHSplit(node)
|
||||
call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1})
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:previewNodeVSplit(node) {{{1
|
||||
function! s:previewNodeVSplit(node)
|
||||
call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1
|
||||
" put the cursor on the node associate with the given name
|
||||
function! nerdtree#ui_glue#revealBookmark(name)
|
||||
try
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
|
||||
call targetNode.putCursorHere(0, 1)
|
||||
catch /^NERDTree.BookmarkNotFoundError/
|
||||
call nerdtree#echo("Bookmark isnt cached under the current root")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:refreshRoot() {{{1
|
||||
" Reloads the current root. All nodes below this will be lost and the root dir
|
||||
" will be reloaded.
|
||||
function! s:refreshRoot()
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while...")
|
||||
call b:NERDTreeRoot.refresh()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:refreshCurrent(node) {{{1
|
||||
" refreshes the root for the current node
|
||||
function! s:refreshCurrent(node)
|
||||
let node = a:node
|
||||
if !node.path.isDirectory
|
||||
let node = node.parent
|
||||
endif
|
||||
|
||||
call nerdtree#echo("Refreshing node. This could take a while...")
|
||||
call node.refresh()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
call nerdtree#echo("Refreshing node. This could take a while... DONE")
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
|
||||
function! nerdtree#ui_glue#setupCommands()
|
||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen()
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
|
||||
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
||||
command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
|
||||
endfunction
|
||||
|
||||
" Function: s:SID() {{{1
|
||||
function s:SID()
|
||||
if !exists("s:sid")
|
||||
let s:sid = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
|
||||
endif
|
||||
return s:sid
|
||||
endfun
|
||||
|
||||
" FUNCTION: s:showMenu(node) {{{1
|
||||
function! s:showMenu(node)
|
||||
let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled())
|
||||
call mc.showMenu()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:toggleIgnoreFilter() {{{1
|
||||
function! s:toggleIgnoreFilter()
|
||||
call b:NERDTree.ui.toggleIgnoreFilter()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:toggleShowBookmarks() {{{1
|
||||
function! s:toggleShowBookmarks()
|
||||
call b:NERDTree.ui.toggleShowBookmarks()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:toggleShowFiles() {{{1
|
||||
function! s:toggleShowFiles()
|
||||
call b:NERDTree.ui.toggleShowFiles()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:toggleShowHidden() {{{1
|
||||
" toggles the display of hidden files
|
||||
function! s:toggleShowHidden()
|
||||
call b:NERDTree.ui.toggleShowHidden()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:toggleZoom() {{{1
|
||||
function! s:toggleZoom()
|
||||
call b:NERDTree.ui.toggleZoom()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#ui_glue#upDir(keepState) {{{1
|
||||
"moves the tree up a level
|
||||
"
|
||||
"Args:
|
||||
"keepState: 1 if the current root should be left open when the tree is
|
||||
"re-rendered
|
||||
function! nerdtree#ui_glue#upDir(keepState)
|
||||
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
|
||||
if cwd ==# "/" || cwd =~# '^[^/]..$'
|
||||
call nerdtree#echo("already at top dir")
|
||||
else
|
||||
if !a:keepState
|
||||
call b:NERDTreeRoot.close()
|
||||
endif
|
||||
|
||||
let oldRoot = b:NERDTreeRoot
|
||||
|
||||
if empty(b:NERDTreeRoot.parent)
|
||||
let path = b:NERDTreeRoot.path.getParent()
|
||||
let newRoot = g:NERDTreeDirNode.New(path)
|
||||
call newRoot.open()
|
||||
call newRoot.transplantChild(b:NERDTreeRoot)
|
||||
let b:NERDTreeRoot = newRoot
|
||||
else
|
||||
let b:NERDTreeRoot = b:NERDTreeRoot.parent
|
||||
endif
|
||||
|
||||
if g:NERDTreeChDirMode ==# 2
|
||||
call b:NERDTreeRoot.path.changeToDir()
|
||||
endif
|
||||
|
||||
call b:NERDTree.render()
|
||||
call oldRoot.putCursorHere(0, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:upDirCurrentRootOpen() {{{1
|
||||
function! s:upDirCurrentRootOpen()
|
||||
call nerdtree#ui_glue#upDir(1)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:upDirCurrentRootClosed() {{{1
|
||||
function! s:upDirCurrentRootClosed()
|
||||
call nerdtree#ui_glue#upDir(0)
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -109,7 +109,7 @@ The following features and functionality are provided by the NERD tree:
|
|||
<
|
||||
:NERDTreeFromBookmark <bookmark> *:NERDTreeFromBookmark*
|
||||
Opens a fresh NERD tree with the root initialized to the dir for
|
||||
<bookmark>. This only reason to use this command over :NERDTree is for
|
||||
<bookmark>. The only reason to use this command over :NERDTree is for
|
||||
the completion (which is for bookmarks rather than directories).
|
||||
|
||||
:NERDTreeToggle [<start-directory> | <bookmark>] *:NERDTreeToggle*
|
||||
|
@ -160,7 +160,7 @@ click bookmarks or use the |NERDTree-o| mapping to activate them. See also,
|
|||
|
||||
Note that the following commands are only available in the NERD tree buffer.
|
||||
|
||||
:Bookmark <name>
|
||||
:Bookmark [<name>]
|
||||
Bookmark the current node as <name>. If there is already a <name>
|
||||
bookmark, it is overwritten. <name> must not contain spaces.
|
||||
If <name> is not provided, it defaults to the file or directory name.
|
||||
|
@ -358,7 +358,7 @@ Default key: O
|
|||
Map option: NERDTreeMapOpenRecursively
|
||||
Applies to: directories.
|
||||
|
||||
Recursively opens the selelected directory.
|
||||
Recursively opens the selected directory.
|
||||
|
||||
All files and directories are cached, but if a directory would not be
|
||||
displayed due to file filters (see |'NERDTreeIgnore'| |NERDTree-f|) or the
|
||||
|
@ -609,17 +609,19 @@ NERD tree. These options should be set in your vimrc.
|
|||
|
||||
|'loaded_nerd_tree'| Turns off the script.
|
||||
|
||||
|'NERDChristmasTree'| Tells the NERD tree to make itself colourful
|
||||
and pretty.
|
||||
|
||||
|'NERDTreeAutoCenter'| Controls whether the NERD tree window centers
|
||||
when the cursor moves within a specified
|
||||
distance to the top/bottom of the window.
|
||||
|
||||
|'NERDTreeAutoCenterThreshold'| Controls the sensitivity of autocentering.
|
||||
|
||||
|'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case
|
||||
sensitive or not when sorting nodes.
|
||||
|
||||
|'NERDTreeSortHiddenFirst'| Tells the NERD tree whether to take the dot
|
||||
at the beginning of the hidden file names
|
||||
into account when sorting nodes.
|
||||
|
||||
|'NERDTreeChDirMode'| Tells the NERD tree if/when it should change
|
||||
vim's current working directory.
|
||||
|
||||
|
@ -631,8 +633,13 @@ NERD tree. These options should be set in your vimrc.
|
|||
|
||||
|'NERDTreeIgnore'| Tells the NERD tree which files to ignore.
|
||||
|
||||
|'NERDTreeRespectWildIgnore'| Tells the NERD tree to respect |'wildignore'|.
|
||||
|
||||
|'NERDTreeBookmarksFile'| Where the bookmarks are stored.
|
||||
|
||||
|'NERDTreeBookmarksSort'| Whether the bookmarks list is sorted on
|
||||
display.
|
||||
|
||||
|'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse
|
||||
clicks.
|
||||
|
||||
|
@ -667,8 +674,8 @@ NERD tree. These options should be set in your vimrc.
|
|||
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
||||
+ ~ chars when displaying directories.
|
||||
|
||||
|'NERDTreeCasadeOpenSingleChildDir'|
|
||||
Casade open while selected directory has only
|
||||
|'NERDTreeCascadeOpenSingleChildDir'|
|
||||
Cascade open while selected directory has only
|
||||
one child that also is a directory.
|
||||
|
||||
|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove
|
||||
|
@ -686,15 +693,6 @@ If this plugin is making you feel homicidal, it may be a good idea to turn it
|
|||
off with this line in your vimrc: >
|
||||
let loaded_nerd_tree=1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDChristmasTree'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
If this option is set to 1 then some extra syntax highlighting elements are
|
||||
added to the nerd tree to make it more colourful.
|
||||
|
||||
Set it to 0 for a more vanilla looking tree.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeAutoCenter'*
|
||||
|
@ -817,6 +815,13 @@ line: >
|
|||
The file filters can be turned on and off dynamically with the |NERDTree-f|
|
||||
mapping.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeRespectWildIgnore'*
|
||||
Values: 0 or 1.
|
||||
Default: 0.
|
||||
|
||||
If set to 1, the |'wildignore'| setting is respected.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeBookmarksFile'*
|
||||
Values: a path
|
||||
|
@ -824,6 +829,14 @@ Default: $HOME/.NERDTreeBookmarks
|
|||
|
||||
This is where bookmarks are saved. See |NERDTreeBookmarkCommands|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeBookmarksSort'*
|
||||
Values: 0 or 1
|
||||
Default: 1
|
||||
|
||||
If set to 0 then the bookmarks list is not sorted.
|
||||
If set to 1 the bookmarks list is sorted.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeMouseMode'*
|
||||
Values: 1, 2 or 3.
|
||||
|
@ -987,16 +1000,17 @@ option: >
|
|||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeCasadeOpenSingleChildDir'*
|
||||
*'NERDTreeCascadeOpenSingleChildDir'*
|
||||
Values: 0 or 1
|
||||
Default: 1.
|
||||
|
||||
When opening dir nodes, this option tells NERDTree to recursively open dirs
|
||||
that have only one child which is also a dir. NERDTree will stop when it finds
|
||||
a dir that contains anything but another single dir. This option may be useful
|
||||
for Java projects. Use one of the follow lines to set this option: >
|
||||
let NERDTreeCasadeOpenSingleChildDir=0
|
||||
let NERDTreeCasadeOpenSingleChildDir=1
|
||||
a dir that contains anything but another single dir. This option also causes
|
||||
the |NERDTree-x| mapping to close dirs in the same manner. This option may be
|
||||
useful for Java projects. Use one of the follow lines to set this option: >
|
||||
let NERDTreeCascadeOpenSingleChildDir=0
|
||||
let NERDTreeCascadeOpenSingleChildDir=1
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
@ -1046,6 +1060,9 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
|
|||
"callback" - the function the new mapping will be bound to
|
||||
"quickhelpText" - the text that will appear in the quickhelp (see
|
||||
|NERDTree-?|)
|
||||
"override" - if 1 then this new mapping will override whatever previous
|
||||
mapping was defined for the key/scope combo. Useful for overriding the
|
||||
default mappings.
|
||||
|
||||
Additionally, a "scope" argument may be supplied. This constrains the
|
||||
mapping so that it is only activated if the cursor is on a certain object.
|
||||
|
@ -1062,8 +1079,8 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()*
|
|||
call NERDTreeAddKeyMap({
|
||||
\ 'key': 'foo',
|
||||
\ 'callback': 'NERDTreeCDHandler',
|
||||
\ 'quickhelpText': 'echo full path of current node' })
|
||||
\ 'scope': 'DirNode'
|
||||
\ 'quickhelpText': 'echo full path of current node',
|
||||
\ 'scope': 'DirNode' })
|
||||
|
||||
function! NERDTreeCDHandler(dirnode)
|
||||
call a:dirnode.changeToDir()
|
||||
|
|
|
@ -19,7 +19,9 @@ function! s:Bookmark.AddBookmark(name, path)
|
|||
endif
|
||||
endfor
|
||||
call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
|
||||
if g:NERDTreeBookmarksSort ==# 1
|
||||
call s:Bookmark.Sort()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.Bookmarks() {{{1
|
||||
|
@ -101,8 +103,10 @@ function! s:Bookmark.CacheBookmarks(silent)
|
|||
call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
|
||||
endif
|
||||
endif
|
||||
if g:NERDTreeBookmarksSort ==# 1
|
||||
call s:Bookmark.Sort()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.compareTo(otherbookmark) {{{1
|
||||
|
@ -271,7 +275,7 @@ function! s:Bookmark.toRoot()
|
|||
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
|
||||
endtry
|
||||
call targetNode.makeRoot()
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call targetNode.putCursorHere(0, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
@ -289,7 +293,7 @@ function! s:Bookmark.validate()
|
|||
return 1
|
||||
else
|
||||
call s:Bookmark.CacheBookmarks(1)
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
|
||||
return 0
|
||||
endif
|
||||
|
|
|
@ -7,18 +7,18 @@ let g:NERDTreeCreator = s:Creator
|
|||
|
||||
"FUNCTION: s:Creator._bindMappings() {{{1
|
||||
function! s:Creator._bindMappings()
|
||||
"make <cr> do the same as the default 'o' mapping
|
||||
exec "nnoremap <silent> <buffer> <cr> :call nerdtree#invokeKeyMap('". g:NERDTreeMapActivateNode ."')<cr>"
|
||||
"make <cr> do the same as the activate node mapping
|
||||
nnoremap <silent> <buffer> <cr> :call nerdtree#ui_glue#invokeKeyMap(g:NERDTreeMapActivateNode)<cr>
|
||||
|
||||
call g:NERDTreeKeyMap.BindAll()
|
||||
|
||||
command! -buffer -nargs=? Bookmark :call nerdtree#bookmarkNode('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#revealBookmark('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#openBookmark('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#clearBookmarks('<args>')
|
||||
command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>')
|
||||
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call nerdtree#renderView()
|
||||
command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call nerdtree#renderView()
|
||||
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
|
||||
command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call b:NERDTree.render()
|
||||
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
|
||||
endfunction
|
||||
|
||||
|
@ -49,26 +49,23 @@ function! s:Creator.createPrimary(name)
|
|||
call path.changeToDir()
|
||||
endif
|
||||
|
||||
if nerdtree#treeExistsForTab()
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if nerdtree#isTreeOpen()
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
unlet t:NERDTreeBufName
|
||||
endif
|
||||
|
||||
let newRoot = g:NERDTreeDirNode.New(path)
|
||||
call newRoot.open()
|
||||
|
||||
call self._createTreeWin()
|
||||
call self._createNERDTree(path)
|
||||
let b:NERDTreeType = "primary"
|
||||
let b:treeShowHelp = 0
|
||||
let b:NERDTreeIgnoreEnabled = 1
|
||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||
let b:NERDTreeRoot = newRoot
|
||||
let b:NERDTreeType = "primary"
|
||||
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTreeRoot.putCursorHere(0, 0)
|
||||
|
||||
call self._broadcastInitEvent()
|
||||
|
@ -99,18 +96,26 @@ function! s:Creator.createSecondary(dir)
|
|||
exec "silent edit " . self._nextBufferName()
|
||||
|
||||
let b:NERDTreePreviousBuf = bufnr(previousBuf)
|
||||
|
||||
let b:NERDTreeRoot = g:NERDTreeDirNode.New(path)
|
||||
call b:NERDTreeRoot.open()
|
||||
|
||||
call self._createNERDTree(path)
|
||||
call self._setCommonBufOptions()
|
||||
let b:NERDTreeType = "secondary"
|
||||
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
|
||||
call self._broadcastInitEvent()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._createNERDTree(path) {{{1
|
||||
function! s:Creator._createNERDTree(path)
|
||||
let b:NERDTree = g:NERDTree.New(a:path)
|
||||
"TODO: This is kept for compatability only since many things use
|
||||
"b:NERDTreeRoot instead of the new NERDTree.root
|
||||
"Remove this one day
|
||||
let b:NERDTreeRoot = b:NERDTree.root
|
||||
|
||||
call b:NERDTree.root.open()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator.CreateMirror() {{{1
|
||||
function! s:Creator.CreateMirror()
|
||||
let creator = s:Creator.New()
|
||||
|
@ -122,12 +127,12 @@ function! s:Creator.createMirror()
|
|||
"get the names off all the nerd tree buffers
|
||||
let treeBufNames = []
|
||||
for i in range(1, tabpagenr("$"))
|
||||
let nextName = nerdtree#tabpagevar(i, 'NERDTreeBufName')
|
||||
let nextName = self._tabpagevar(i, 'NERDTreeBufName')
|
||||
if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName)
|
||||
call add(treeBufNames, nextName)
|
||||
endif
|
||||
endfor
|
||||
let treeBufNames = nerdtree#unique(treeBufNames)
|
||||
let treeBufNames = self._uniq(treeBufNames)
|
||||
|
||||
"map the option names (that the user will be prompted with) to the nerd
|
||||
"tree buffer names
|
||||
|
@ -158,7 +163,7 @@ function! s:Creator.createMirror()
|
|||
return
|
||||
endif
|
||||
|
||||
if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen()
|
||||
if g:NERDTree.ExistsForTab() && nerdtree#isTreeOpen()
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
|
||||
|
@ -166,7 +171,7 @@ function! s:Creator.createMirror()
|
|||
call self._createTreeWin()
|
||||
exec 'buffer ' . bufferName
|
||||
if !&hidden
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -279,8 +284,8 @@ function! s:Creator._setCommonBufOptions()
|
|||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||
setfiletype nerdtree
|
||||
call self._bindMappings()
|
||||
setlocal filetype=nerdtree
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator._setupStatusline() {{{1
|
||||
|
@ -290,6 +295,24 @@ function! s:Creator._setupStatusline()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1
|
||||
function! s:Creator._tabpagevar(tabnr, var)
|
||||
let currentTab = tabpagenr()
|
||||
let old_ei = &ei
|
||||
set ei=all
|
||||
|
||||
exec "tabnext " . a:tabnr
|
||||
let v = -1
|
||||
if exists('t:' . a:var)
|
||||
exec 'let v = t:' . a:var
|
||||
endif
|
||||
exec "tabnext " . currentTab
|
||||
|
||||
let &ei = old_ei
|
||||
|
||||
return v
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
|
||||
function! s:Creator.TogglePrimary(dir)
|
||||
let creator = s:Creator.New()
|
||||
|
@ -304,13 +327,13 @@ endfunction
|
|||
"dir: the full path for the root node (is only used if the NERD tree is being
|
||||
"initialized.
|
||||
function! s:Creator.togglePrimary(dir)
|
||||
if nerdtree#treeExistsForTab()
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if !nerdtree#isTreeOpen()
|
||||
call self._createTreeWin()
|
||||
if !&hidden
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
endif
|
||||
call nerdtree#restoreScreenState()
|
||||
call b:NERDTree.ui.restoreScreenState()
|
||||
else
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
|
@ -319,4 +342,16 @@ function! s:Creator.togglePrimary(dir)
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:Creator._uniq(list) {{{1
|
||||
" returns a:list without duplicates
|
||||
function! s:Creator._uniq(list)
|
||||
let uniqlist = []
|
||||
for elem in a:list
|
||||
if index(uniqlist, elem) ==# -1
|
||||
let uniqlist += [elem]
|
||||
endif
|
||||
endfor
|
||||
return uniqlist
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
|
13
sources_non_forked/nerdtree/lib/nerdtree/event.vim
Normal file
13
sources_non_forked/nerdtree/lib/nerdtree/event.vim
Normal file
|
@ -0,0 +1,13 @@
|
|||
"CLASS: Event
|
||||
"============================================================
|
||||
let s:Event = {}
|
||||
let g:NERDTreeEvent = s:Event
|
||||
|
||||
function! s:Event.New(nerdtree, subject, action, params) abort
|
||||
let newObj = copy(self)
|
||||
let newObj.nerdtree = a:nerdtree
|
||||
let newObj.subject = a:subject
|
||||
let newObj.action = a:action
|
||||
let newObj.params = a:params
|
||||
return newObj
|
||||
endfunction
|
56
sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim
Normal file
56
sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim
Normal file
|
@ -0,0 +1,56 @@
|
|||
"CLASS: FlagSet
|
||||
"============================================================
|
||||
let s:FlagSet = {}
|
||||
let g:NERDTreeFlagSet = s:FlagSet
|
||||
|
||||
"FUNCTION: FlagSet.addFlag(scope, flag) {{{1
|
||||
function! s:FlagSet.addFlag(scope, flag)
|
||||
let flags = self._flagsForScope(a:scope)
|
||||
if index(flags, a:flag) == -1
|
||||
call add(flags, a:flag)
|
||||
end
|
||||
endfunction
|
||||
|
||||
"FUNCTION: FlagSet.clearFlags(scope) {{{1
|
||||
function! s:FlagSet.clearFlags(scope)
|
||||
let self._flags[a:scope] = []
|
||||
endfunction
|
||||
|
||||
"FUNCTION: FlagSet._flagsForScope(scope) {{{1
|
||||
function! s:FlagSet._flagsForScope(scope)
|
||||
if !has_key(self._flags, a:scope)
|
||||
let self._flags[a:scope] = []
|
||||
endif
|
||||
return self._flags[a:scope]
|
||||
endfunction
|
||||
|
||||
"FUNCTION: FlagSet.New() {{{1
|
||||
function! s:FlagSet.New()
|
||||
let newObj = copy(self)
|
||||
let newObj._flags = {}
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
"FUNCTION: FlagSet.removeFlag(scope, flag) {{{1
|
||||
function! s:FlagSet.removeFlag(scope, flag)
|
||||
let flags = self._flagsForScope(a:scope)
|
||||
|
||||
let i = index(flags, a:flag)
|
||||
if i >= 0
|
||||
call remove(flags, i)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: FlagSet.renderToString() {{{1
|
||||
function! s:FlagSet.renderToString()
|
||||
let flagstring = ""
|
||||
for i in values(self._flags)
|
||||
let flagstring .= join(i)
|
||||
endfor
|
||||
|
||||
if len(flagstring) == 0
|
||||
return ""
|
||||
endif
|
||||
|
||||
return '[' . flagstring . ']'
|
||||
endfunction
|
|
@ -44,7 +44,7 @@ function! s:KeyMap.bind()
|
|||
|
||||
let premap = self.key == "<LeftRelease>" ? " <LeftRelease>" : " "
|
||||
|
||||
exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#invokeKeyMap("'. keymapInvokeString .'")<cr>'
|
||||
exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")<cr>'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: KeyMap.Remove(key, scope) {{{1
|
||||
|
@ -79,6 +79,16 @@ endfunction
|
|||
"If a keymap has the scope of "all" then it will be called if no other keymap
|
||||
"is found for a:key and the scope.
|
||||
function! s:KeyMap.Invoke(key)
|
||||
|
||||
"required because clicking the command window below another window still
|
||||
"invokes the <LeftRelease> mapping - but changes the window cursor
|
||||
"is in first
|
||||
"
|
||||
"TODO: remove this check when the vim bug is fixed
|
||||
if !g:NERDTree.ExistsForBuf()
|
||||
return {}
|
||||
endif
|
||||
|
||||
let node = g:NERDTreeFileNode.GetSelected()
|
||||
if !empty(node)
|
||||
|
||||
|
@ -124,8 +134,14 @@ endfunction
|
|||
|
||||
"FUNCTION: KeyMap.Create(options) {{{1
|
||||
function! s:KeyMap.Create(options)
|
||||
let newKeyMap = copy(self)
|
||||
let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
|
||||
|
||||
"dont override other mappings unless the 'override' option is given
|
||||
if get(opts, 'override', 0) == 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope']))
|
||||
return
|
||||
end
|
||||
|
||||
let newKeyMap = copy(self)
|
||||
let newKeyMap.key = opts['key']
|
||||
let newKeyMap.quickhelpText = opts['quickhelpText']
|
||||
let newKeyMap.callback = opts['callback']
|
||||
|
|
|
@ -90,7 +90,7 @@ endfunction
|
|||
"callback
|
||||
function! s:MenuItem.execute()
|
||||
if len(self.children)
|
||||
let mc = s:MenuController.New(self.children)
|
||||
let mc = g:NERDTreeMenuController.New(self.children)
|
||||
call mc.showMenu()
|
||||
else
|
||||
if self.callback != -1
|
||||
|
|
39
sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim
Normal file
39
sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim
Normal file
|
@ -0,0 +1,39 @@
|
|||
"CLASS: NERDTree
|
||||
"============================================================
|
||||
let s:NERDTree = {}
|
||||
let g:NERDTree = s:NERDTree
|
||||
|
||||
" Function: s:NERDTree.ExistsForBuffer() {{{1
|
||||
" Returns 1 if a nerd tree root exists in the current buffer
|
||||
function! s:NERDTree.ExistsForBuf()
|
||||
return exists("b:NERDTreeRoot")
|
||||
endfunction
|
||||
|
||||
" Function: s:NERDTree.ExistsForTab() {{{1
|
||||
" Returns 1 if a nerd tree root exists in the current tab
|
||||
function! s:NERDTree.ExistsForTab()
|
||||
return exists("t:NERDTreeBufName")
|
||||
endfunction
|
||||
|
||||
function! s:NERDTree.ForCurrentBuf()
|
||||
if s:NERDTree.ExistsForBuf()
|
||||
return b:NERDTree
|
||||
else
|
||||
return {}
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:NERDTree.New(path)
|
||||
let newObj = copy(self)
|
||||
let newObj.ui = g:NERDTreeUI.New(newObj)
|
||||
let newObj.root = g:NERDTreeDirNode.New(a:path)
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.render() {{{1
|
||||
"A convenience function - since this is called often
|
||||
function! s:NERDTree.render()
|
||||
call self.ui.render()
|
||||
endfunction
|
||||
|
35
sources_non_forked/nerdtree/lib/nerdtree/notifier.vim
Normal file
35
sources_non_forked/nerdtree/lib/nerdtree/notifier.vim
Normal file
|
@ -0,0 +1,35 @@
|
|||
"CLASS: Notifier
|
||||
"============================================================
|
||||
let s:Notifier = {}
|
||||
|
||||
function! s:Notifier.AddListener(event, funcname)
|
||||
let listeners = s:Notifier.GetListenersForEvent(a:event)
|
||||
if listeners == []
|
||||
let listenersMap = s:Notifier.GetListenersMap()
|
||||
let listenersMap[a:event] = listeners
|
||||
endif
|
||||
call add(listeners, a:funcname)
|
||||
endfunction
|
||||
|
||||
function! s:Notifier.NotifyListeners(event, path, params)
|
||||
let event = g:NERDTreeEvent.New(b:NERDTree, a:path, a:event, a:params)
|
||||
|
||||
for listener in s:Notifier.GetListenersForEvent(a:event)
|
||||
call {listener}(event)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:Notifier.GetListenersMap()
|
||||
if !exists("s:refreshListenersMap")
|
||||
let s:refreshListenersMap = {}
|
||||
endif
|
||||
return s:refreshListenersMap
|
||||
endfunction
|
||||
|
||||
function! s:Notifier.GetListenersForEvent(name)
|
||||
let listenersMap = s:Notifier.GetListenersMap()
|
||||
return get(listenersMap, a:name, [])
|
||||
endfunction
|
||||
|
||||
let g:NERDTreePathNotifier = deepcopy(s:Notifier)
|
||||
|
|
@ -3,6 +3,29 @@
|
|||
let s:Opener = {}
|
||||
let g:NERDTreeOpener = s:Opener
|
||||
|
||||
"FUNCTION: s:Opener._bufInWindows(bnum){{{1
|
||||
"[[STOLEN FROM VTREEEXPLORER.VIM]]
|
||||
"Determine the number of windows open to this buffer number.
|
||||
"Care of Yegappan Lakshman. Thanks!
|
||||
"
|
||||
"Args:
|
||||
"bnum: the subject buffers buffer number
|
||||
function! s:Opener._bufInWindows(bnum)
|
||||
let cnt = 0
|
||||
let winnum = 1
|
||||
while 1
|
||||
let bufnum = winbufnr(winnum)
|
||||
if bufnum < 0
|
||||
break
|
||||
endif
|
||||
if bufnum ==# a:bnum
|
||||
let cnt = cnt + 1
|
||||
endif
|
||||
let winnum = winnum + 1
|
||||
endwhile
|
||||
|
||||
return cnt
|
||||
endfunction
|
||||
"FUNCTION: Opener._checkToCloseTree(newtab) {{{1
|
||||
"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
|
||||
"if the tree should be closed now.
|
||||
|
@ -21,6 +44,24 @@ function! s:Opener._checkToCloseTree(newtab)
|
|||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
"FUNCTION: s:Opener._firstUsableWindow(){{{1
|
||||
"find the window number of the first normal window
|
||||
function! s:Opener._firstUsableWindow()
|
||||
let i = 1
|
||||
while i <= winnr("$")
|
||||
let bnum = winbufnr(i)
|
||||
if bnum != -1 && getbufvar(bnum, '&buftype') ==# ''
|
||||
\ && !getwinvar(i, '&previewwindow')
|
||||
\ && (!getbufvar(bnum, '&modified') || &hidden)
|
||||
return i
|
||||
endif
|
||||
|
||||
let i += 1
|
||||
endwhile
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Opener._gotoTargetWin() {{{1
|
||||
function! s:Opener._gotoTargetWin()
|
||||
if b:NERDTreeType ==# "secondary"
|
||||
|
@ -48,6 +89,37 @@ function! s:Opener._gotoTargetWin()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1
|
||||
"Returns 0 if opening a file from the tree in the given window requires it to
|
||||
"be split, 1 otherwise
|
||||
"
|
||||
"Args:
|
||||
"winnumber: the number of the window in question
|
||||
function! s:Opener._isWindowUsable(winnumber)
|
||||
"gotta split if theres only one window (i.e. the NERD tree)
|
||||
if winnr("$") ==# 1
|
||||
return 0
|
||||
endif
|
||||
|
||||
let oldwinnr = winnr()
|
||||
call nerdtree#exec(a:winnumber . "wincmd p")
|
||||
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
|
||||
let modified = &modified
|
||||
call nerdtree#exec(oldwinnr . "wincmd p")
|
||||
|
||||
"if its a special window e.g. quickfix or another explorer plugin then we
|
||||
"have to split
|
||||
if specialWindow
|
||||
return 0
|
||||
endif
|
||||
|
||||
if &hidden
|
||||
return 1
|
||||
endif
|
||||
|
||||
return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Opener.New(path, opts) {{{1
|
||||
"Args:
|
||||
"
|
||||
|
@ -190,7 +262,7 @@ function! s:Opener._openDirectory(node)
|
|||
call self._gotoTargetWin()
|
||||
if empty(self._where)
|
||||
call a:node.makeRoot()
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call a:node.putCursorHere(0, 0)
|
||||
elseif self._where == 't'
|
||||
call g:NERDTreeCreator.CreatePrimary(a:node.path.str())
|
||||
|
@ -206,12 +278,12 @@ endfunction
|
|||
|
||||
"FUNCTION: Opener._previousWindow() {{{1
|
||||
function! s:Opener._previousWindow()
|
||||
if !nerdtree#isWindowUsable(winnr("#")) && nerdtree#firstUsableWindow() ==# -1
|
||||
if !self._isWindowUsable(winnr("#")) && self._firstUsableWindow() ==# -1
|
||||
call self._newSplit()
|
||||
else
|
||||
try
|
||||
if !nerdtree#isWindowUsable(winnr("#"))
|
||||
call nerdtree#exec(nerdtree#firstUsableWindow() . "wincmd w")
|
||||
if !self._isWindowUsable(winnr("#"))
|
||||
call nerdtree#exec(self._firstUsableWindow() . "wincmd w")
|
||||
else
|
||||
call nerdtree#exec('wincmd p')
|
||||
endif
|
||||
|
|
|
@ -33,8 +33,10 @@ function! s:Path.bookmarkNames()
|
|||
endfunction
|
||||
|
||||
"FUNCTION: Path.cacheDisplayString() {{{1
|
||||
function! s:Path.cacheDisplayString()
|
||||
let self.cachedDisplayString = self.getLastPathComponent(1)
|
||||
function! s:Path.cacheDisplayString() abort
|
||||
let self.cachedDisplayString = self.flagSet.renderToString()
|
||||
|
||||
let self.cachedDisplayString .= self.getLastPathComponent(1)
|
||||
|
||||
if self.isExecutable
|
||||
let self.cachedDisplayString = self.cachedDisplayString . '*'
|
||||
|
@ -103,6 +105,10 @@ function! s:Path.compareTo(path)
|
|||
elseif thisSS > thatSS
|
||||
return 1
|
||||
else
|
||||
if !g:NERDTreeSortHiddenFirst
|
||||
let thisPath = substitute(thisPath, '^[._]', '', '')
|
||||
let thatPath = substitute(thatPath, '^[._]', '', '')
|
||||
endif
|
||||
"if the sort sequences are the same then compare the paths
|
||||
"alphabetically
|
||||
let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
|
||||
|
@ -141,6 +147,7 @@ function! s:Path.Create(fullpath)
|
|||
|
||||
"assume its a file and create
|
||||
else
|
||||
call s:Path.createParentDirectories(a:fullpath)
|
||||
call writefile([], a:fullpath)
|
||||
endif
|
||||
catch
|
||||
|
@ -161,9 +168,11 @@ function! s:Path.copy(dest)
|
|||
throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS"
|
||||
endif
|
||||
|
||||
call s:Path.createParentDirectories(a:dest)
|
||||
|
||||
let dest = s:Path.WinToUnixPath(a:dest)
|
||||
|
||||
let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), nerdtree#escChars()) . " " . escape(dest, nerdtree#escChars())
|
||||
let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars())
|
||||
let success = system(cmd)
|
||||
if success != 0
|
||||
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
|
||||
|
@ -197,6 +206,20 @@ function! s:Path.copyingWillOverwrite(dest)
|
|||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path.createParentDirectories(path) {{{1
|
||||
"
|
||||
"create parent directories for this path if needed
|
||||
"without throwing any errors is those directories already exist
|
||||
"
|
||||
"Args:
|
||||
"path: full path of the node whose parent directories may need to be created
|
||||
function! s:Path.createParentDirectories(path)
|
||||
let dir_path = fnamemodify(a:path, ':h')
|
||||
if !isdirectory(dir_path)
|
||||
call mkdir(dir_path, 'p')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path.delete() {{{1
|
||||
"
|
||||
"Deletes the file represented by this path.
|
||||
|
@ -268,6 +291,15 @@ function! s:Path.exists()
|
|||
return filereadable(p) || isdirectory(p)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path._escChars() {{{1
|
||||
function! s:Path._escChars()
|
||||
if nerdtree#runningWindows()
|
||||
return " `\|\"#%&,?()\*^<>"
|
||||
endif
|
||||
|
||||
return " \\`\|\"#%&,?()\*^<>[]"
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path.getDir() {{{1
|
||||
"
|
||||
"Returns this path if it is a directory, else this paths parent.
|
||||
|
@ -439,6 +471,7 @@ function! s:Path.New(path)
|
|||
call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path))
|
||||
|
||||
let newPath.cachedDisplayString = ""
|
||||
let newPath.flagSet = g:NERDTreeFlagSet.New()
|
||||
|
||||
return newPath
|
||||
endfunction
|
||||
|
@ -516,6 +549,13 @@ endfunction
|
|||
"FUNCTION: Path.refresh() {{{1
|
||||
function! s:Path.refresh()
|
||||
call self.readInfoFromDisk(self.str())
|
||||
call g:NERDTreePathNotifier.NotifyListeners('refresh', self, {})
|
||||
call self.cacheDisplayString()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path.refreshFlags() {{{1
|
||||
function! s:Path.refreshFlags()
|
||||
call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, {})
|
||||
call self.cacheDisplayString()
|
||||
endfunction
|
||||
|
||||
|
@ -604,7 +644,7 @@ endfunction
|
|||
"
|
||||
" returns a string that can be used with :cd
|
||||
function! s:Path._strForCd()
|
||||
return escape(self.str(), nerdtree#escChars())
|
||||
return escape(self.str(), self._escChars())
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path._strForEdit() {{{1
|
||||
|
@ -612,7 +652,7 @@ endfunction
|
|||
"Return: the string for this path that is suitable to be used with the :edit
|
||||
"command
|
||||
function! s:Path._strForEdit()
|
||||
let p = escape(self.str({'format': 'UI'}), nerdtree#escChars())
|
||||
let p = escape(self.str({'format': 'UI'}), self._escChars())
|
||||
let cwd = getcwd() . s:Path.Slash()
|
||||
|
||||
"return a relative path if we can
|
||||
|
@ -652,7 +692,7 @@ function! s:Path._strForGlob()
|
|||
let toReturn = lead . join(self.pathSegments, s:Path.Slash())
|
||||
|
||||
if !nerdtree#runningWindows()
|
||||
let toReturn = escape(toReturn, nerdtree#escChars())
|
||||
let toReturn = escape(toReturn, self._escChars())
|
||||
endif
|
||||
return toReturn
|
||||
endfunction
|
||||
|
|
|
@ -21,7 +21,7 @@ unlet s:TreeDirNode.activate
|
|||
function! s:TreeDirNode.activate(...)
|
||||
let opts = a:0 ? a:1 : {}
|
||||
call self.toggleOpen(opts)
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call self.putCursorHere(0, 0)
|
||||
endfunction
|
||||
|
||||
|
@ -229,7 +229,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||
let globDir = dir.str({'format': 'Glob'})
|
||||
|
||||
if version >= 703
|
||||
let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1)
|
||||
let filesStr = globpath(globDir, '*', !g:NERDTreeRespectWildIgnore) . "\n" . globpath(globDir, '.*', !g:NERDTreeRespectWildIgnore)
|
||||
else
|
||||
let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*')
|
||||
endif
|
||||
|
@ -252,6 +252,7 @@ function! s:TreeDirNode._initChildren(silent)
|
|||
try
|
||||
let path = g:NERDTreePath.New(i)
|
||||
call self.createChild(path, 0)
|
||||
call g:NERDTreePathNotifier.NotifyListeners('init', path, {})
|
||||
catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
|
||||
let invalidFilesFound += 1
|
||||
endtry
|
||||
|
@ -438,6 +439,20 @@ function! s:TreeDirNode.refresh()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeDirNode.refreshFlags() {{{1
|
||||
unlet s:TreeDirNode.refreshFlags
|
||||
function! s:TreeDirNode.refreshFlags()
|
||||
call self.path.refreshFlags()
|
||||
for i in self.children
|
||||
call i.refreshFlags()
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeDirNode.refreshDirFlags() {{{1
|
||||
function! s:TreeDirNode.refreshDirFlags()
|
||||
call self.path.refreshFlags()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeDirNode.reveal(path) {{{1
|
||||
"reveal the given path, i.e. cache and open all treenodes needed to display it
|
||||
"in the UI
|
||||
|
@ -450,7 +465,7 @@ function! s:TreeDirNode.reveal(path)
|
|||
|
||||
if self.path.equals(a:path.getParent())
|
||||
let n = self.findNode(a:path)
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call n.putCursorHere(1,0)
|
||||
return
|
||||
endif
|
||||
|
@ -500,7 +515,7 @@ function! s:TreeDirNode.toggleOpen(...)
|
|||
if self.isOpen ==# 1
|
||||
call self.close()
|
||||
else
|
||||
if g:NERDTreeCasadeOpenSingleChildDir == 0
|
||||
if g:NERDTreeCascadeOpenSingleChildDir == 0
|
||||
call self.open(opts)
|
||||
else
|
||||
call self.openAlong(opts)
|
||||
|
|
|
@ -178,79 +178,20 @@ function! s:TreeFileNode.findSibling(direction)
|
|||
return {}
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.getLineNum(){{{1
|
||||
"returns the line number this node is rendered on, or -1 if it isnt rendered
|
||||
function! s:TreeFileNode.getLineNum()
|
||||
"if the node is the root then return the root line no.
|
||||
if self.isRoot()
|
||||
return s:TreeFileNode.GetRootLineNum()
|
||||
endif
|
||||
|
||||
let totalLines = line("$")
|
||||
|
||||
"the path components we have matched so far
|
||||
let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')]
|
||||
"the index of the component we are searching for
|
||||
let curPathComponent = 1
|
||||
|
||||
let fullpath = self.path.str({'format': 'UI'})
|
||||
|
||||
|
||||
let lnum = s:TreeFileNode.GetRootLineNum()
|
||||
while lnum > 0
|
||||
let lnum = lnum + 1
|
||||
"have we reached the bottom of the tree?
|
||||
if lnum ==# totalLines+1
|
||||
return -1
|
||||
endif
|
||||
|
||||
let curLine = getline(lnum)
|
||||
|
||||
let indent = nerdtree#indentLevelFor(curLine)
|
||||
if indent ==# curPathComponent
|
||||
let curLine = nerdtree#stripMarkupFromLine(curLine, 1)
|
||||
|
||||
let curPath = join(pathcomponents, '/') . '/' . curLine
|
||||
if stridx(fullpath, curPath, 0) ==# 0
|
||||
if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
|
||||
let curLine = substitute(curLine, '/ *$', '', '')
|
||||
call add(pathcomponents, curLine)
|
||||
let curPathComponent = curPathComponent + 1
|
||||
|
||||
if fullpath ==# curPath
|
||||
return lnum
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
|
||||
"get the root node for this tab
|
||||
function! s:TreeFileNode.GetRootForTab()
|
||||
if nerdtree#treeExistsForTab()
|
||||
if g:NERDTree.ExistsForTab()
|
||||
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
|
||||
end
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.GetRootLineNum(){{{1
|
||||
"gets the line number of the root node
|
||||
function! s:TreeFileNode.GetRootLineNum()
|
||||
let rootLine = 1
|
||||
while getline(rootLine) !~# '^\(/\|<\)'
|
||||
let rootLine = rootLine + 1
|
||||
endwhile
|
||||
return rootLine
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.GetSelected() {{{1
|
||||
"gets the treenode that the cursor is currently over
|
||||
function! s:TreeFileNode.GetSelected()
|
||||
try
|
||||
let path = nerdtree#getPath(line("."))
|
||||
let path = b:NERDTree.ui.getPath(line("."))
|
||||
if path ==# {}
|
||||
return {}
|
||||
endif
|
||||
|
@ -270,7 +211,7 @@ endfunction
|
|||
"FUNCTION: TreeFileNode.isRoot() {{{1
|
||||
"returns 1 if this node is b:NERDTreeRoot
|
||||
function! s:TreeFileNode.isRoot()
|
||||
if !nerdtree#treeExistsForBuf()
|
||||
if !g:NERDTree.ExistsForBuf()
|
||||
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
|
||||
endif
|
||||
|
||||
|
@ -348,7 +289,7 @@ endfunction
|
|||
"recurseUpward: try to put the cursor on the parent if the this node isnt
|
||||
"visible
|
||||
function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
|
||||
let ln = self.getLineNum()
|
||||
let ln = b:NERDTree.ui.getLineNum(self)
|
||||
if ln != -1
|
||||
if a:isJump
|
||||
mark '
|
||||
|
@ -357,11 +298,11 @@ function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
|
|||
else
|
||||
if a:recurseUpward
|
||||
let node = self
|
||||
while node != {} && node.getLineNum() ==# -1
|
||||
while node != {} && b:NERDTree.ui.getLineNum(node) ==# -1
|
||||
let node = node.parent
|
||||
call node.open()
|
||||
endwhile
|
||||
call nerdtree#renderView()
|
||||
call b:NERDTree.render()
|
||||
call node.putCursorHere(a:isJump, 0)
|
||||
endif
|
||||
endif
|
||||
|
@ -372,6 +313,11 @@ function! s:TreeFileNode.refresh()
|
|||
call self.path.refresh()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.refreshFlags() {{{1
|
||||
function! s:TreeFileNode.refreshFlags()
|
||||
call self.path.refreshFlags()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: TreeFileNode.rename() {{{1
|
||||
"Calls the rename method for this nodes path obj
|
||||
function! s:TreeFileNode.rename(newName)
|
||||
|
|
332
sources_non_forked/nerdtree/lib/nerdtree/ui.vim
Normal file
332
sources_non_forked/nerdtree/lib/nerdtree/ui.vim
Normal file
|
@ -0,0 +1,332 @@
|
|||
"CLASS: UI
|
||||
"============================================================
|
||||
let s:UI = {}
|
||||
let g:NERDTreeUI = s:UI
|
||||
|
||||
|
||||
function! s:UI.lolcats()
|
||||
echomsg "lolcats"
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.centerView() {{{2
|
||||
"centers the nerd tree window around the cursor (provided the nerd tree
|
||||
"options permit)
|
||||
function! s:UI.centerView()
|
||||
if g:NERDTreeAutoCenter
|
||||
let current_line = winline()
|
||||
let lines_to_top = current_line
|
||||
let lines_to_bottom = winheight(nerdtree#getTreeWinNum()) - current_line
|
||||
if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold
|
||||
normal! zz
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.new(nerdtree) {{{1
|
||||
function! s:UI.New(nerdtree)
|
||||
let newObj = copy(self)
|
||||
let newObj.nerdtree = a:nerdtree
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.getPath(ln) {{{1
|
||||
"Gets the full path to the node that is rendered on the given line number
|
||||
"
|
||||
"Args:
|
||||
"ln: the line number to get the path for
|
||||
"
|
||||
"Return:
|
||||
"A path if a node was selected, {} if nothing is selected.
|
||||
"If the 'up a dir' line was selected then the path to the parent of the
|
||||
"current root is returned
|
||||
function! s:UI.getPath(ln)
|
||||
let line = getline(a:ln)
|
||||
|
||||
let rootLine = self.getRootLineNum()
|
||||
|
||||
"check to see if we have the root node
|
||||
if a:ln == rootLine
|
||||
return b:NERDTreeRoot.path
|
||||
endif
|
||||
|
||||
if !g:NERDTreeDirArrows
|
||||
" in case called from outside the tree
|
||||
if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
|
||||
return {}
|
||||
endif
|
||||
endif
|
||||
|
||||
if line ==# nerdtree#treeUpDirLine()
|
||||
return b:NERDTreeRoot.path.getParent()
|
||||
endif
|
||||
|
||||
let indent = self._indentLevelFor(line)
|
||||
|
||||
"remove the tree parts and the leading space
|
||||
let curFile = nerdtree#stripMarkupFromLine(line, 0)
|
||||
|
||||
let wasdir = 0
|
||||
if curFile =~# '/$'
|
||||
let wasdir = 1
|
||||
let curFile = substitute(curFile, '/\?$', '/', "")
|
||||
endif
|
||||
|
||||
let dir = ""
|
||||
let lnum = a:ln
|
||||
while lnum > 0
|
||||
let lnum = lnum - 1
|
||||
let curLine = getline(lnum)
|
||||
let curLineStripped = nerdtree#stripMarkupFromLine(curLine, 1)
|
||||
|
||||
"have we reached the top of the tree?
|
||||
if lnum == rootLine
|
||||
let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
|
||||
break
|
||||
endif
|
||||
if curLineStripped =~# '/$'
|
||||
let lpindent = self._indentLevelFor(curLine)
|
||||
if lpindent < indent
|
||||
let indent = indent - 1
|
||||
|
||||
let dir = substitute (curLineStripped,'^\\', "", "") . dir
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
let curFile = b:NERDTreeRoot.path.drive . dir . curFile
|
||||
let toReturn = g:NERDTreePath.New(curFile)
|
||||
return toReturn
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.getLineNum(file_node){{{1
|
||||
"returns the line number this node is rendered on, or -1 if it isnt rendered
|
||||
function! s:UI.getLineNum(file_node)
|
||||
"if the node is the root then return the root line no.
|
||||
if a:file_node.isRoot()
|
||||
return b:NERDTree.ui.getRootLineNum()
|
||||
endif
|
||||
|
||||
let totalLines = line("$")
|
||||
|
||||
"the path components we have matched so far
|
||||
let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')]
|
||||
"the index of the component we are searching for
|
||||
let curPathComponent = 1
|
||||
|
||||
let fullpath = a:file_node.path.str({'format': 'UI'})
|
||||
|
||||
let lnum = b:NERDTree.ui.getRootLineNum()
|
||||
while lnum > 0
|
||||
let lnum = lnum + 1
|
||||
"have we reached the bottom of the tree?
|
||||
if lnum ==# totalLines+1
|
||||
return -1
|
||||
endif
|
||||
|
||||
let curLine = getline(lnum)
|
||||
|
||||
let indent = self._indentLevelFor(curLine)
|
||||
if indent ==# curPathComponent
|
||||
let curLine = nerdtree#stripMarkupFromLine(curLine, 1)
|
||||
|
||||
let curPath = join(pathcomponents, '/') . '/' . curLine
|
||||
if stridx(fullpath, curPath, 0) ==# 0
|
||||
if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
|
||||
let curLine = substitute(curLine, '/ *$', '', '')
|
||||
call add(pathcomponents, curLine)
|
||||
let curPathComponent = curPathComponent + 1
|
||||
|
||||
if fullpath ==# curPath
|
||||
return lnum
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
|
||||
"FUNCTION: s:UI.getRootLineNum(){{{1
|
||||
"gets the line number of the root node
|
||||
function! s:UI.getRootLineNum()
|
||||
let rootLine = 1
|
||||
while getline(rootLine) !~# '^\(/\|<\)'
|
||||
let rootLine = rootLine + 1
|
||||
endwhile
|
||||
return rootLine
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI._indentLevelFor(line) {{{2
|
||||
function! s:UI._indentLevelFor(line)
|
||||
let level = match(a:line, '[^ \-+~▸▾`|]') / nerdtree#treeWid()
|
||||
" check if line includes arrows
|
||||
if match(a:line, '[▸▾]') > -1
|
||||
" decrement level as arrow uses 3 ascii chars
|
||||
let level = level - 1
|
||||
endif
|
||||
return level
|
||||
endfunction
|
||||
|
||||
|
||||
"FUNCTION: s:UI.restoreScreenState() {{{2
|
||||
"
|
||||
"Sets the screen state back to what it was when nerdtree#saveScreenState was last
|
||||
"called.
|
||||
"
|
||||
"Assumes the cursor is in the NERDTree window
|
||||
function! s:UI.restoreScreenState()
|
||||
if !has_key(self, '_screenState')
|
||||
return
|
||||
endif
|
||||
exec("silent vertical resize " . self._screenState['oldWindowSize'])
|
||||
|
||||
let old_scrolloff=&scrolloff
|
||||
let &scrolloff=0
|
||||
call cursor(self._screenState['oldTopLine'], 0)
|
||||
normal! zt
|
||||
call setpos(".", self._screenState['oldPos'])
|
||||
let &scrolloff=old_scrolloff
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.saveScreenState() {{{2
|
||||
"Saves the current cursor position in the current buffer and the window
|
||||
"scroll position
|
||||
function! s:UI.saveScreenState()
|
||||
let win = winnr()
|
||||
try
|
||||
call nerdtree#putCursorInTreeWin()
|
||||
let self._screenState = {}
|
||||
let self._screenState['oldPos'] = getpos(".")
|
||||
let self._screenState['oldTopLine'] = line("w0")
|
||||
let self._screenState['oldWindowSize']= winwidth("")
|
||||
call nerdtree#exec(win . "wincmd w")
|
||||
catch /^NERDTree.InvalidOperationError/
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:UI.render() {{{2
|
||||
function! s:UI.render()
|
||||
setlocal modifiable
|
||||
|
||||
"remember the top line of the buffer and the current line so we can
|
||||
"restore the view exactly how it was
|
||||
let curLine = line(".")
|
||||
let curCol = col(".")
|
||||
let topLine = line("w0")
|
||||
|
||||
"delete all lines in the buffer (being careful not to clobber a register)
|
||||
silent 1,$delete _
|
||||
|
||||
call nerdtree#dumpHelp()
|
||||
|
||||
"delete the blank line before the help and add one after it
|
||||
if g:NERDTreeMinimalUI == 0
|
||||
call setline(line(".")+1, "")
|
||||
call cursor(line(".")+1, col("."))
|
||||
endif
|
||||
|
||||
if b:NERDTreeShowBookmarks
|
||||
call nerdtree#renderBookmarks()
|
||||
endif
|
||||
|
||||
"add the 'up a dir' line
|
||||
if !g:NERDTreeMinimalUI
|
||||
call setline(line(".")+1, nerdtree#treeUpDirLine())
|
||||
call cursor(line(".")+1, col("."))
|
||||
endif
|
||||
|
||||
"draw the header line
|
||||
let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
|
||||
call setline(line(".")+1, header)
|
||||
call cursor(line(".")+1, col("."))
|
||||
|
||||
"draw the tree
|
||||
let old_o = @o
|
||||
let @o = b:NERDTreeRoot.renderToString()
|
||||
silent put o
|
||||
let @o = old_o
|
||||
|
||||
"delete the blank line at the top of the buffer
|
||||
silent 1,1delete _
|
||||
|
||||
"restore the view
|
||||
let old_scrolloff=&scrolloff
|
||||
let &scrolloff=0
|
||||
call cursor(topLine, 1)
|
||||
normal! zt
|
||||
call cursor(curLine, curCol)
|
||||
let &scrolloff = old_scrolloff
|
||||
|
||||
setlocal nomodifiable
|
||||
endfunction
|
||||
|
||||
|
||||
"FUNCTION: UI.renderViewSavingPosition {{{1
|
||||
"Renders the tree and ensures the cursor stays on the current node or the
|
||||
"current nodes parent if it is no longer available upon re-rendering
|
||||
function! s:UI.renderViewSavingPosition()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
|
||||
"go up the tree till we find a node that will be visible or till we run
|
||||
"out of nodes
|
||||
while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot()
|
||||
let currentNode = currentNode.parent
|
||||
endwhile
|
||||
|
||||
call b:NERDTree.render()
|
||||
|
||||
if currentNode != {}
|
||||
call currentNode.putCursorHere(0, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleIgnoreFilter() {{{1
|
||||
" toggles the use of the NERDTreeIgnore option
|
||||
function! s:UI.toggleIgnoreFilter()
|
||||
let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled
|
||||
call b:NERDTree.ui.renderViewSavingPosition()
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleShowBookmarks() {{{1
|
||||
" toggles the display of bookmarks
|
||||
function! s:UI.toggleShowBookmarks()
|
||||
let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks
|
||||
if b:NERDTreeShowBookmarks
|
||||
call b:NERDTree.render()
|
||||
call nerdtree#putCursorOnBookmarkTable()
|
||||
else
|
||||
call b:NERDTree.ui.renderViewSavingPosition()
|
||||
endif
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleShowFiles() {{{1
|
||||
" toggles the display of hidden files
|
||||
function! s:UI.toggleShowFiles()
|
||||
let b:NERDTreeShowFiles = !b:NERDTreeShowFiles
|
||||
call b:NERDTree.ui.renderViewSavingPosition()
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleShowHidden() {{{1
|
||||
" toggles the display of hidden files
|
||||
function! s:UI.toggleShowHidden()
|
||||
let b:NERDTreeShowHidden = !b:NERDTreeShowHidden
|
||||
call b:NERDTree.ui.renderViewSavingPosition()
|
||||
call self.centerView()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:UI.toggleZoom() {{{1
|
||||
" zoom (maximize/minimize) the NERDTree window
|
||||
function! s:UI.toggleZoom()
|
||||
if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
|
||||
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
|
||||
exec "silent vertical resize ". size
|
||||
let b:NERDTreeZoomed = 0
|
||||
else
|
||||
exec "vertical resize"
|
||||
let b:NERDTreeZoomed = 1
|
||||
endif
|
||||
endfunction
|
|
@ -82,13 +82,14 @@ endfunction
|
|||
function! s:promptToRenameBuffer(bufnum, msg, newFileName)
|
||||
echo a:msg
|
||||
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
|
||||
let quotedFileName = "'" . a:newFileName . "'"
|
||||
" 1. ensure that a new buffer is loaded
|
||||
exec "badd " . a:newFileName
|
||||
exec "badd " . quotedFileName
|
||||
" 2. ensure that all windows which display the just deleted filename
|
||||
" display a buffer for a new filename.
|
||||
let s:originalTabNumber = tabpagenr()
|
||||
let s:originalWindowNumber = winnr()
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . a:newFileName . "' | endif"
|
||||
exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec \":e! " . quotedFileName . "\" | endif"
|
||||
exec "tabnext " . s:originalTabNumber
|
||||
exec s:originalWindowNumber . "wincmd w"
|
||||
" 3. We don't need a previous buffer anymore
|
||||
|
@ -114,7 +115,10 @@ function! NERDTreeAddNode()
|
|||
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
|
||||
|
||||
let newTreeNode = g:NERDTreeFileNode.New(newPath)
|
||||
if parentNode.isOpen || !empty(parentNode.children)
|
||||
if empty(parentNode)
|
||||
call b:NERDTreeRoot.refresh()
|
||||
call b:NERDTree.render()
|
||||
elseif parentNode.isOpen || !empty(parentNode.children)
|
||||
call parentNode.addChild(newTreeNode, 1)
|
||||
call NERDTreeRender()
|
||||
call newTreeNode.putCursorHere(1, 0)
|
||||
|
@ -138,7 +142,7 @@ function! NERDTreeMoveNode()
|
|||
endif
|
||||
|
||||
try
|
||||
let bufnum = bufnr(curNode.path.str())
|
||||
let bufnum = bufnr("^".curNode.path.str()."$")
|
||||
|
||||
call curNode.rename(newNodePath)
|
||||
call NERDTreeRender()
|
||||
|
@ -186,7 +190,7 @@ function! NERDTreeDeleteNode()
|
|||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
let bufnum = bufnr(currentNode.path.str())
|
||||
let bufnum = bufnr("^".currentNode.path.str()."$")
|
||||
if buflisted(bufnum)
|
||||
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
|
@ -224,7 +228,10 @@ function! NERDTreeCopyNode()
|
|||
if confirmed
|
||||
try
|
||||
let newNode = currentNode.copy(newNodePath)
|
||||
if !empty(newNode)
|
||||
if empty(newNode)
|
||||
call b:NERDTreeRoot.refresh()
|
||||
call b:NERDTree.render()
|
||||
else
|
||||
call NERDTreeRender()
|
||||
call newNode.putCursorHere(0, 0)
|
||||
endif
|
||||
|
|
|
@ -45,28 +45,30 @@ function! s:initVariable(var, value)
|
|||
endfunction
|
||||
|
||||
"SECTION: Init variable calls and other random constants {{{2
|
||||
call s:initVariable("g:NERDChristmasTree", 1)
|
||||
call s:initVariable("g:NERDTreeAutoCenter", 1)
|
||||
call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
|
||||
call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
|
||||
call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
|
||||
call s:initVariable("g:NERDTreeChDirMode", 0)
|
||||
call s:initVariable("g:NERDTreeMinimalUI", 0)
|
||||
if !exists("g:NERDTreeIgnore")
|
||||
let g:NERDTreeIgnore = ['\~$']
|
||||
endif
|
||||
call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
|
||||
call s:initVariable("g:NERDTreeBookmarksSort", 1)
|
||||
call s:initVariable("g:NERDTreeHighlightCursorline", 1)
|
||||
call s:initVariable("g:NERDTreeHijackNetrw", 1)
|
||||
call s:initVariable("g:NERDTreeMouseMode", 1)
|
||||
call s:initVariable("g:NERDTreeNotificationThreshold", 100)
|
||||
call s:initVariable("g:NERDTreeQuitOnOpen", 0)
|
||||
call s:initVariable("g:NERDTreeRespectWildIgnore", 0)
|
||||
call s:initVariable("g:NERDTreeShowBookmarks", 0)
|
||||
call s:initVariable("g:NERDTreeShowFiles", 1)
|
||||
call s:initVariable("g:NERDTreeShowHidden", 0)
|
||||
call s:initVariable("g:NERDTreeShowLineNumbers", 0)
|
||||
call s:initVariable("g:NERDTreeSortDirs", 1)
|
||||
call s:initVariable("g:NERDTreeDirArrows", !nerdtree#runningWindows())
|
||||
call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 1)
|
||||
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
|
||||
|
||||
if !exists("g:NERDTreeSortOrder")
|
||||
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
|
||||
|
@ -140,20 +142,13 @@ call nerdtree#loadClassFiles()
|
|||
|
||||
" SECTION: Commands {{{1
|
||||
"============================================================
|
||||
"init the command that users start the nerd tree with
|
||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen()
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||
command! -n=0 -bar NERDTreeFind call nerdtree#findAndRevealPath()
|
||||
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
||||
command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
|
||||
call nerdtree#ui_glue#setupCommands()
|
||||
|
||||
" SECTION: Auto commands {{{1
|
||||
"============================================================
|
||||
augroup NERDTree
|
||||
"Save the cursor position whenever we close the nerd tree
|
||||
exec "autocmd BufWinLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call nerdtree#saveScreenState()"
|
||||
exec "autocmd BufLeave ". g:NERDTreeCreator.BufNamePrefix() ."* call b:NERDTree.ui.saveScreenState()"
|
||||
|
||||
"disallow insert mode in the NERDTree
|
||||
exec "autocmd BufEnter ". g:NERDTreeCreator.BufNamePrefix() ."* stopinsert"
|
||||
|
@ -199,7 +194,7 @@ endfunction
|
|||
|
||||
function! NERDTreeCWD()
|
||||
call NERDTreeFocus()
|
||||
call nerdtree#chRootCwd()
|
||||
call nerdtree#ui_glue#chRootCwd()
|
||||
endfunction
|
||||
" SECTION: Post Source Actions {{{1
|
||||
call nerdtree#postSourceActions()
|
||||
|
|
|
@ -1,12 +1,41 @@
|
|||
let s:tree_up_dir_line = '.. (up a dir)'
|
||||
"NERDTreeFlags are syntax items that should be invisible, but give clues as to
|
||||
"how things should be highlighted
|
||||
syn match NERDTreeFlag #\~#
|
||||
syn match NERDTreeFlag #\[RO\]#
|
||||
syn match NERDTreeIgnore #\~#
|
||||
syn match NERDTreeIgnore #\[RO\]#
|
||||
|
||||
"highlighting for the .. (up dir) line at the top of the tree
|
||||
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
|
||||
|
||||
"quickhelp syntax elements
|
||||
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1
|
||||
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1
|
||||
syn match NERDTreeHelpTitle #" .*\~#ms=s+2,me=e-1
|
||||
syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1
|
||||
syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1
|
||||
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
|
||||
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeIgnore,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
|
||||
|
||||
"highlighting for sym links
|
||||
syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile
|
||||
syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile
|
||||
syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir
|
||||
|
||||
"highlighing for directory nodes and file nodes
|
||||
syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
|
||||
|
||||
if g:NERDTreeDirArrows
|
||||
syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile
|
||||
syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile
|
||||
|
||||
syn match NERDTreeDir #[^▾▸ ].*/#
|
||||
syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark
|
||||
syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile
|
||||
|
||||
"highlighting for readonly files
|
||||
syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile
|
||||
|
||||
syn match NERDTreeFlags #^ *\zs\[.\]# containedin=NERDTreeFile
|
||||
syn match NERDTreeFlags #\[.\]# containedin=NERDTreeDir
|
||||
else
|
||||
"highlighting for the ~/+ symbols for the directory nodes
|
||||
syn match NERDTreeClosable #\~\<#
|
||||
syn match NERDTreeClosable #\~\.#
|
||||
|
@ -18,27 +47,18 @@ syn match NERDTreePart #|#
|
|||
syn match NERDTreePart #`#
|
||||
syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
|
||||
|
||||
"quickhelp syntax elements
|
||||
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
|
||||
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
|
||||
syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
|
||||
syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
|
||||
syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
|
||||
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
|
||||
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
|
||||
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable
|
||||
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark
|
||||
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||
|
||||
"highlighting for readonly files
|
||||
syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
|
||||
syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
|
||||
|
||||
"highlighting for sym links
|
||||
syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
|
||||
syn match NERDTreeFlags #-\[.\]# containedin=NERDTreeFile,NERDTreePartFile
|
||||
syn match NERDTreeFlags #[+~]\zs\[.\]# containedin=NERDTreeDir
|
||||
endif
|
||||
|
||||
"highlighing for directory nodes and file nodes
|
||||
syn match NERDTreeDirSlash #/#
|
||||
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
|
||||
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
|
||||
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||
syn match NERDTreeCWD #^[</].*$#
|
||||
|
||||
"highlighting for bookmarks
|
||||
|
@ -50,19 +70,10 @@ syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmark
|
|||
syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
|
||||
syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
|
||||
|
||||
if exists("g:NERDChristmasTree") && g:NERDChristmasTree
|
||||
hi def link NERDTreePart Special
|
||||
hi def link NERDTreePartFile Type
|
||||
hi def link NERDTreeFile Normal
|
||||
hi def link NERDTreeExecFile Title
|
||||
hi def link NERDTreeDirSlash Identifier
|
||||
hi def link NERDTreeClosable Type
|
||||
else
|
||||
hi def link NERDTreePart Normal
|
||||
hi def link NERDTreePartFile Normal
|
||||
hi def link NERDTreeFile Normal
|
||||
hi def link NERDTreeClosable Title
|
||||
endif
|
||||
|
||||
hi def link NERDTreeBookmarksHeader statement
|
||||
hi def link NERDTreeBookmarksLeader ignore
|
||||
|
@ -76,13 +87,19 @@ hi def link NERDTreeHelpTitle Macro
|
|||
hi def link NERDTreeToggleOn Question
|
||||
hi def link NERDTreeToggleOff WarningMsg
|
||||
|
||||
hi def link NERDTreeLinkTarget Type
|
||||
hi def link NERDTreeLinkFile Macro
|
||||
hi def link NERDTreeLinkDir Macro
|
||||
|
||||
hi def link NERDTreeDir Directory
|
||||
hi def link NERDTreeUp Directory
|
||||
hi def link NERDTreeFile Normal
|
||||
hi def link NERDTreeCWD Statement
|
||||
hi def link NERDTreeLink Macro
|
||||
hi def link NERDTreeOpenable Title
|
||||
hi def link NERDTreeFlag ignore
|
||||
hi def link NERDTreeClosable Title
|
||||
hi def link NERDTreeIgnore ignore
|
||||
hi def link NERDTreeRO WarningMsg
|
||||
hi def link NERDTreeBookmark Statement
|
||||
hi def link NERDTreeFlags Number
|
||||
|
||||
hi def link NERDTreeCurrentNode Search
|
||||
|
|
4
sources_non_forked/syntastic/.gitignore
vendored
4
sources_non_forked/syntastic/.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
*~
|
||||
*.swp
|
||||
tags
|
||||
.DS_Store
|
|
@ -1,49 +0,0 @@
|
|||
# Bug reports / Github issues
|
||||
|
||||
When reporting a bug make sure you search the existing github issues for the
|
||||
same/similar issues. If you find one, feel free to add a `+1` comment with any
|
||||
additional information that may help us solve the issue.
|
||||
|
||||
When creating a new issue be sure to state the following:
|
||||
|
||||
* Steps to reproduce the bug.
|
||||
* The version of vim you are using.
|
||||
* The version of syntastic you are using.
|
||||
|
||||
For syntax checker bugs also state the version of the checker executable that you are using.
|
||||
|
||||
# Submitting a patch
|
||||
|
||||
* Fork the repo on github
|
||||
* Make a [topic branch](https://github.com/dchelimsky/rspec/wiki/Topic-Branches#using-topic-branches-when-contributing-patches) and start hacking
|
||||
* Submit a pull request based off your topic branch
|
||||
|
||||
Small focused patches are preferred.
|
||||
|
||||
Large changes to the code should be discussed with the core team first. Create an issue and explain your plan and see what we say.
|
||||
|
||||
# General style notes
|
||||
|
||||
Following the coding conventions/styles used in the syntastic core:
|
||||
|
||||
* Use 4 space indents.
|
||||
* Don't use abbreviated keywords - e.g. use `endfunction`, not `endfun` (there's always room for more fun!).
|
||||
* Don't use `l:` prefixes for variables unless actually required (i.e. almost never).
|
||||
* Code for maintainability. We would rather a function be a couple of lines longer and have (for example) some [explaining variables](http://www.refactoring.com/catalog/introduceExplainingVariable.html) to aid readability.
|
||||
|
||||
# Syntax checker style notes
|
||||
|
||||
The preferred style for error format strings is one "clause" per line. E.g.
|
||||
(from the coffeelint checker):
|
||||
|
||||
```viml
|
||||
let errorformat = '%E%f:%l:%c: %trror: %m,' .
|
||||
\ '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,' .
|
||||
\ '%W%f(%l): warning: %m,' .
|
||||
\ '%E%f(%l): SyntaxError: %m,' .
|
||||
\ '%-Z%p^,' .
|
||||
\ '%-G%.%#'
|
||||
```
|
|
@ -1,13 +0,0 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
@ -1,175 +0,0 @@
|
|||
,
|
||||
/ \,,_ .'|
|
||||
,{{| /}}}}/_.' _____________________________________________
|
||||
}}}}` '{{' '. / \
|
||||
{{{{{ _ ;, \ / Ladies and 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 Ada,
|
||||
AppleScript, Bourne shell, C, C++, C#, CoffeeScript, Coco, Coq, CSS,
|
||||
Cucumber, CUDA, D, Dart, DocBook, Elixir, Erlang, eRuby, Fortran,
|
||||
Gentoo metadata, Go, Haml, Haskell, Haxe, HSS, HTML, Java, JavaScript,
|
||||
JSON, LESS, LISP, LLVM intermediate language, Lua, MATLAB, NASM,
|
||||
Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, Puppet, Python,
|
||||
reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX,
|
||||
Twig, TypeScript, Vala, VHDL, xHtml, XML, XSLT, YAML, z80, Zope page
|
||||
templates, zsh.
|
||||
|
||||
## 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.
|
||||
|
||||
![Screenshot 1](https://github.com/scrooloose/syntastic/raw/master/_assets/screenshot_1.png)
|
||||
|
||||
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
|
||||
|
||||
Installing syntastic is easy but first you need to have the pathogen plugin installed. If you already
|
||||
have pathogen working then skip Step 1 and go to Step 2.
|
||||
|
||||
### Step 1: Install pathogen.vim
|
||||
|
||||
First I'll show you how to install tpope's [pathogen.vim](https://github.com/tpope/vim-pathogen) so that
|
||||
it's easy to install syntastic. Do this in your Terminal so that you get the pathogen.vim file
|
||||
and the directories it needs:
|
||||
|
||||
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
|
||||
curl -so ~/.vim/autoload/pathogen.vim \
|
||||
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
|
||||
|
||||
Next you *need to add this* to your ~/.vimrc:
|
||||
|
||||
execute pathogen#infect()
|
||||
|
||||
### Step 2: Install syntastic as a pathogen bundle
|
||||
|
||||
You now have pathogen installed and can put syntastic into ~/.vim/bundle like this:
|
||||
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/scrooloose/syntastic.git
|
||||
|
||||
Quit vim and start it back up to reload it, then type:
|
||||
|
||||
:Helptags
|
||||
|
||||
If you get an error when you do this, then you probably didn't install pathogen right. Go back to
|
||||
step 1 and make sure you did the following:
|
||||
|
||||
1. Created both the ~/.vim/autoload and ~/.vim/bundle directories.
|
||||
2. Added the "call pathogen#infect()" line to your ~/.vimrc file
|
||||
3. Did the git clone of syntastic inside ~/.vim/bundle
|
||||
4. Have permissions to access all of these directories.
|
||||
|
||||
|
||||
## Google group
|
||||
|
||||
To get information or make suggestions check out the [google group](https://groups.google.com/group/vim-syntastic).
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
__Q. I installed syntastic but it isn't reporting any errors...__
|
||||
|
||||
A. The most likely reason is that none of the syntax checkers that it requires is installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executables are supported, just look in `syntax_checkers/<filetype>/*.vim`. Note that aliases do not work; the actual executable must be available in your `$PATH`. Symbolic links are okay. You can see syntastic's idea of available checkers by running `:SyntasticInfo`.
|
||||
|
||||
Another reason it could fail is that either the command line options or the error output for a syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then create an issue - or better yet, create a pull request.
|
||||
|
||||
__Q. Recently some of my syntax checker options have stopped working...__
|
||||
|
||||
A. The options are still there, they have just been renamed. Recently, almost all syntax checkers were refactored to use the new `syntastic#makeprg#build()` function. This made a lot of the old explicit options redundant - as they are now implied. The new implied options usually have slightly different names to the old options.
|
||||
|
||||
e.g. Previously there was `g:syntastic_phpcs_conf`, now you must use `g:syntastic_php_phpcs_args`.
|
||||
|
||||
See `:help syntastic-checker-options` for more information.
|
||||
|
||||
__Q. I run a checker and the location list is not updated...__
|
||||
|
||||
A. By default, the location list is changed only when you run the `:Errors` command, in order to minimise conflicts with other plugins. If you want the location list to always be updated when you run the checkers, add this line to your vimrc:
|
||||
```vim
|
||||
let g:syntastic_always_populate_loc_list=1
|
||||
```
|
||||
|
||||
__Q. How can I pass additional arguments to a checker?__
|
||||
|
||||
A. Almost all syntax checkers use the `syntastic#makeprg#build()` function. Those checkers that do can be configured using global variables. The general form of the global args variables are:
|
||||
```vim
|
||||
syntastic_<filetype>_<subchecker>_args
|
||||
```
|
||||
|
||||
So, If you wanted to pass "--my --args --here" to the ruby mri checker you would add this line to your vimrc:
|
||||
```vim
|
||||
let g:syntastic_ruby_mri_args="--my --args --here"
|
||||
```
|
||||
|
||||
See `:help syntastic-checker-options` for more information.
|
||||
|
||||
__Q. Syntastic supports several checkers for my filetype - how do I tell it which one(s) to use?__
|
||||
|
||||
A. Stick a line like this in your vimrc:
|
||||
```vim
|
||||
let g:syntastic_<filetype>_checkers=['<checker-name>']
|
||||
```
|
||||
|
||||
To see the list of checkers for your filetype, look in `syntax_checkers/<filetype>/`.
|
||||
|
||||
e.g. Python has the following checkers: `flake8`, `pyflakes`, `pylint` and a native `python` checker.
|
||||
|
||||
To tell syntastic to use `pylint`, you would use this setting:
|
||||
```vim
|
||||
let g:syntastic_python_checkers=['pylint']
|
||||
```
|
||||
|
||||
Some filetypes, like PHP, have style checkers as well as syntax checkers. These can be chained together like this:
|
||||
```vim
|
||||
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']
|
||||
```
|
||||
|
||||
This is telling syntastic to run the `php` checker first, and if no errors are found, run `phpcs`, and then `phpmd`.
|
||||
|
||||
__Q. How can I jump between the different errors without using the location list at the bottom of the window?__
|
||||
|
||||
A. Vim provides several built in commands for this. See `:help :lnext` and `:help :lprev`.
|
||||
|
||||
If you use these commands a lot then you may want to add shortcut mappings to your vimrc, or install something like [unimpaired](https://github.com/tpope/vim-unimpaired), which provides such mappings (among other things).
|
||||
|
||||
__Q. A syntax checker is giving me unwanted/strange style tips?__
|
||||
|
||||
A. Some filetypes (e.g. php) have style checkers as well as syntax checkers. You can usually configure the options that are passed to the style checkers, or just disable them. Take a look at the [wiki](https://github.com/scrooloose/syntastic/wiki/Syntaxcheckers) to see what options are available.
|
||||
|
||||
__Q. The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?__
|
||||
|
||||
A. There is no safe way to handle that situation automatically, but you can work around it:
|
||||
|
||||
```vim
|
||||
nnoremap <silent> <C-d> :lclose<CR>:bdelete<CR>
|
||||
cabbrev <silent> bd lclose\|bdelete
|
||||
```
|
Binary file not shown.
Before Width: | Height: | Size: 90 KiB |
|
@ -1,239 +0,0 @@
|
|||
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
|
||||
|
||||
" default include directories
|
||||
let s:default_includes = [ '.', '..', 'include', 'includes',
|
||||
\ '../include', '../includes' ]
|
||||
|
||||
" convenience function to determine the 'null device' parameter
|
||||
" based on the current operating system
|
||||
function! syntastic#c#GetNullDevice()
|
||||
if has('win32')
|
||||
return '-o nul'
|
||||
elseif has('unix') || has('mac')
|
||||
return '-o /dev/null'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" get the gcc include directory argument depending on the default
|
||||
" includes and the optional user-defined 'g:syntastic_c_include_dirs'
|
||||
function! syntastic#c#GetIncludeDirs(filetype)
|
||||
let include_dirs = []
|
||||
|
||||
if !exists('g:syntastic_'.a:filetype.'_no_default_include_dirs') ||
|
||||
\ !g:syntastic_{a:filetype}_no_default_include_dirs
|
||||
let include_dirs = copy(s:default_includes)
|
||||
endif
|
||||
|
||||
if exists('g:syntastic_'.a:filetype.'_include_dirs')
|
||||
call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
|
||||
endif
|
||||
|
||||
return join(map(syntastic#util#unique(include_dirs), '"-I" . v:val'), ' ')
|
||||
endfunction
|
||||
|
||||
" read additional compiler flags from the given configuration file
|
||||
" the file format and its parsing mechanism is inspired by clang_complete
|
||||
function! syntastic#c#ReadConfig(file)
|
||||
" search in the current file's directory upwards
|
||||
let config = findfile(a:file, '.;')
|
||||
if config == '' || !filereadable(config) | return '' | endif
|
||||
|
||||
" convert filename into absolute path
|
||||
let filepath = substitute(fnamemodify(config, ':p:h'), '\', '/', 'g')
|
||||
|
||||
" try to read config file
|
||||
try
|
||||
let lines = map(readfile(config),
|
||||
\ 'substitute(v:val, ''\'', ''/'', ''g'')')
|
||||
catch /E484/
|
||||
return ''
|
||||
endtry
|
||||
|
||||
let parameters = []
|
||||
for line in lines
|
||||
let matches = matchlist(line, '\C^\s*-I\s*\(\S\+\)')
|
||||
if matches != [] && matches[1] != ''
|
||||
" this one looks like an absolute path
|
||||
if match(matches[1], '^\%(/\|\a:\)') != -1
|
||||
call add(parameters, '-I' . matches[1])
|
||||
else
|
||||
call add(parameters, '-I' . filepath . '/' . matches[1])
|
||||
endif
|
||||
else
|
||||
call add(parameters, line)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return join(parameters, ' ')
|
||||
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') ?
|
||||
\ '\' : '/') . 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; import sys; sys.stdout.write(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:
|
|
@ -1,50 +0,0 @@
|
|||
if exists("g:loaded_syntastic_makeprg_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_makeprg_autoload = 1
|
||||
|
||||
"Returns a makeprg of the form
|
||||
"
|
||||
"[exe] [args] [filename] [post_args] [tail]
|
||||
"
|
||||
"A (made up) example:
|
||||
" ruby -a -b -c test_file.rb --more --args > /tmp/output
|
||||
"
|
||||
"To generate this you would call:
|
||||
"
|
||||
" let makeprg = syntastic#makeprg#build({
|
||||
" \ 'exe': 'ruby',
|
||||
" \ 'args': '-a -b -c',
|
||||
" \ 'post_args': '--more --args',
|
||||
" \ 'tail': '> /tmp/output',
|
||||
" \ 'filetype': 'ruby',
|
||||
" \ 'subchecker': 'mri' })
|
||||
"
|
||||
"Note that the current filename is added by default - but can be overridden by
|
||||
"passing in an 'fname' arg.
|
||||
"
|
||||
"Arguments 'filetype' and 'subchecker' are mandatory, handling of composite
|
||||
"types and user-defined variables breaks if you omit them.
|
||||
"
|
||||
"All other options can be overriden by the user with global variables - even
|
||||
"when not specified by the checker in syntastic#makeprg#build().
|
||||
"
|
||||
"E.g. They could override the checker exe with
|
||||
"
|
||||
" let g:syntastic_ruby_mri_exe="another_ruby_checker_exe.rb"
|
||||
"
|
||||
"The general form of the override option is:
|
||||
" syntastic_[filetype]_[subchecker]_[option-name]
|
||||
"
|
||||
function! syntastic#makeprg#build(opts)
|
||||
let builder = g:SyntasticMakeprgBuilder.New(
|
||||
\ get(a:opts, 'exe', ''),
|
||||
\ get(a:opts, 'args', ''),
|
||||
\ get(a:opts, 'fname', ''),
|
||||
\ get(a:opts, 'post_args', ''),
|
||||
\ get(a:opts, 'tail', ''),
|
||||
\ get(a:opts, 'filetype', ''),
|
||||
\ get(a:opts, 'subchecker', '') )
|
||||
|
||||
return builder.makeprg()
|
||||
endfunction
|
|
@ -1,58 +0,0 @@
|
|||
if exists("g:loaded_syntastic_postprocess_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_postprocess_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! s:compareErrorItems(a, b)
|
||||
if a:a['bufnr'] != a:b['bufnr']
|
||||
" group by files
|
||||
return a:a['bufnr'] - a:b['bufnr']
|
||||
elseif a:a['lnum'] != a:b['lnum']
|
||||
return a:a['lnum'] - a:b['lnum']
|
||||
elseif a:a['type'] !=? a:b['type']
|
||||
" errors take precedence over warnings
|
||||
return a:a['type'] ==? 'e' ? -1 : 1
|
||||
else
|
||||
return get(a:a, 'col') - get(a:b, 'col')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" natural sort
|
||||
function! syntastic#postprocess#sort(errors)
|
||||
return sort(a:errors, 's:compareErrorItems')
|
||||
endfunction
|
||||
|
||||
function syntastic#postprocess#compressWhitespace(errors)
|
||||
let llist = []
|
||||
|
||||
for e in a:errors
|
||||
let e['text'] = substitute(e['text'], '\n', ' ', 'g')
|
||||
let e['text'] = substitute(e['text'], '\s\{2,}', ' ', 'g')
|
||||
call add(llist, e)
|
||||
endfor
|
||||
|
||||
return llist
|
||||
endfunction
|
||||
|
||||
" remove spurious CR under Cygwin
|
||||
function! syntastic#postprocess#cygwinRemoveCR(errors)
|
||||
if has('win32unix')
|
||||
let llist = []
|
||||
|
||||
for e in a:errors
|
||||
let e['text'] = substitute(e['text'], '\r', '', 'g')
|
||||
call add(llist, e)
|
||||
endfor
|
||||
else
|
||||
let llist = a:errors
|
||||
endif
|
||||
|
||||
return llist
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -1,201 +0,0 @@
|
|||
if exists("g:loaded_syntastic_util_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_util_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists("g:syntastic_debug")
|
||||
let g:syntastic_debug = 0
|
||||
endif
|
||||
|
||||
let s:deprecationNoticesIssued = []
|
||||
|
||||
function! syntastic#util#DevNull()
|
||||
if has('win32')
|
||||
return 'NUL'
|
||||
endif
|
||||
return '/dev/null'
|
||||
endfunction
|
||||
|
||||
"search the first 5 lines of the file for a magic number and return a map
|
||||
"containing the args and the executable
|
||||
"
|
||||
"e.g.
|
||||
"
|
||||
"#!/usr/bin/perl -f -bar
|
||||
"
|
||||
"returns
|
||||
"
|
||||
"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
|
||||
function! syntastic#util#parseShebang()
|
||||
for lnum in range(1,5)
|
||||
let line = getline(lnum)
|
||||
|
||||
if line =~ '^#!'
|
||||
let exe = matchstr(line, '^#!\s*\zs[^ \t]*')
|
||||
let args = split(matchstr(line, '^#!\s*[^ \t]*\zs.*'))
|
||||
return {'exe': exe, 'args': args}
|
||||
endif
|
||||
endfor
|
||||
|
||||
return {'exe': '', 'args': []}
|
||||
endfunction
|
||||
|
||||
" Run 'command' in a shell and parse output as a version string.
|
||||
" Returns an array of version components.
|
||||
function! syntastic#util#parseVersion(command)
|
||||
return split(matchstr( system(a:command), '\v^\D*\zs\d+(\.\d+)+\ze' ), '\.')
|
||||
endfunction
|
||||
|
||||
" Verify that the 'installed' version is at least the 'required' version.
|
||||
"
|
||||
" 'installed' and 'required' must be arrays. If they have different lengths,
|
||||
" the "missing" elements will be assumed to be 0 for the purposes of checking.
|
||||
"
|
||||
" See http://semver.org for info about version numbers.
|
||||
function! syntastic#util#versionIsAtLeast(installed, required)
|
||||
for index in range(max([len(a:installed), len(a:required)]))
|
||||
if len(a:installed) <= index
|
||||
let installed_element = 0
|
||||
else
|
||||
let installed_element = a:installed[index]
|
||||
endif
|
||||
if len(a:required) <= index
|
||||
let required_element = 0
|
||||
else
|
||||
let required_element = a:required[index]
|
||||
endif
|
||||
if installed_element != required_element
|
||||
return installed_element > required_element
|
||||
endif
|
||||
endfor
|
||||
" Everything matched, so it is at least the required version.
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"print as much of a:msg as possible without "Press Enter" prompt appearing
|
||||
function! syntastic#util#wideMsg(msg)
|
||||
let old_ruler = &ruler
|
||||
let old_showcmd = &showcmd
|
||||
|
||||
"convert tabs to spaces so that the tabs count towards the window width
|
||||
"as the proper amount of characters
|
||||
let msg = substitute(a:msg, "\t", repeat(" ", &tabstop), "g")
|
||||
let msg = strpart(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
|
||||
|
||||
" Check whether a buffer is loaded, listed, and not hidden
|
||||
function! syntastic#util#bufIsActive(buffer)
|
||||
" convert to number, or hell breaks loose
|
||||
let buf = str2nr(a:buffer)
|
||||
|
||||
if !bufloaded(buf) || !buflisted(buf)
|
||||
return 0
|
||||
endif
|
||||
|
||||
" get rid of hidden buffers
|
||||
for tab in range(1, tabpagenr('$'))
|
||||
if index(tabpagebuflist(tab), buf) >= 0
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" start in directory a:where and walk up the parent folders until it
|
||||
" finds a file matching a:what; return path to that file
|
||||
function! syntastic#util#findInParent(what, where)
|
||||
let here = fnamemodify(a:where, ':p')
|
||||
|
||||
while !empty(here)
|
||||
let p = split(globpath(here, a:what), '\n')
|
||||
|
||||
if !empty(p)
|
||||
return fnamemodify(p[0], ':p')
|
||||
elseif here == '/'
|
||||
break
|
||||
endif
|
||||
|
||||
" we use ':h:h' rather than ':h' since ':p' adds a trailing '/'
|
||||
" if 'here' is a directory
|
||||
let here = fnamemodify(here, ':p:h:h')
|
||||
endwhile
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Returns unique elements in a list
|
||||
function! syntastic#util#unique(list)
|
||||
let seen = {}
|
||||
let uniques = []
|
||||
for e in a:list
|
||||
if !has_key(seen, e)
|
||||
let seen[e] = 1
|
||||
call add(uniques, e)
|
||||
endif
|
||||
endfor
|
||||
return uniques
|
||||
endfunction
|
||||
|
||||
" A less noisy shellescape()
|
||||
function! syntastic#util#shescape(string)
|
||||
return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string, 1)
|
||||
endfunction
|
||||
|
||||
" A less noisy shellescape(expand())
|
||||
function! syntastic#util#shexpand(string)
|
||||
return syntastic#util#shescape(escape(expand(a:string), '|'))
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#debug(msg)
|
||||
if g:syntastic_debug
|
||||
echomsg "syntastic: debug: " . a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#info(msg)
|
||||
echomsg "syntastic: info: " . a:msg
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#warn(msg)
|
||||
echohl WarningMsg
|
||||
echomsg "syntastic: warning: " . a:msg
|
||||
echohl None
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#error(msg)
|
||||
execute "normal \<Esc>"
|
||||
echohl ErrorMsg
|
||||
echomsg "syntastic: error: " . a:msg
|
||||
echohl None
|
||||
endfunction
|
||||
|
||||
function! syntastic#util#deprecationWarn(msg)
|
||||
if index(s:deprecationNoticesIssued, a:msg) >= 0
|
||||
return
|
||||
endif
|
||||
|
||||
call add(s:deprecationNoticesIssued, a:msg)
|
||||
call syntastic#util#warn(a:msg)
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -1,455 +0,0 @@
|
|||
*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.Global Options..........................|syntastic-global-options|
|
||||
5.Checker Options.........................|syntastic-checker-options|
|
||||
6.About...................................|syntastic-about|
|
||||
7.License.................................|syntastic-license|
|
||||
|
||||
|
||||
==============================================================================
|
||||
1. Intro *syntastic-intro*
|
||||
|
||||
Note: This doc only deals with using syntastic. To learn how to write syntax
|
||||
checker integrations, see the guide on the github wiki:
|
||||
|
||||
https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide
|
||||
|
||||
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. 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.
|
||||
|
||||
Take a look in the syntax_checkers directory for a list of supported filetypes
|
||||
and checkers.
|
||||
|
||||
|
||||
==============================================================================
|
||||
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 statusline flag
|
||||
* Signs beside lines with errors
|
||||
* The |location-list| can be populated with the errors for the associated
|
||||
buffer.
|
||||
* Erroneous 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.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
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.
|
||||
|
||||
Signs are colored using the Error and Todo syntax highlight groups by default.
|
||||
If you wish to customize the colors for the signs, you can use the following
|
||||
groups:
|
||||
SyntasticErrorSign - For syntax errors, links to 'error' by default
|
||||
SyntasticWarningSign - For syntax warnings, links to 'todo' by default
|
||||
SyntasticStyleErrorSign - For style errors, links to 'SyntasticErrorSign'
|
||||
by default
|
||||
SyntasticStyleWarningSign - For style warnings, links to
|
||||
'SyntasticWarningSign' by default
|
||||
|
||||
Example: >
|
||||
highlight SyntasticErrorSign guifg=white guibg=red
|
||||
<
|
||||
To set up highlighting for the line where a sign resides, you can use the
|
||||
following highlight groups:
|
||||
SyntasticErrorLine
|
||||
SyntasticWarningLine
|
||||
SyntasticStyleErrorLine - Links to 'SyntasticErrorLine' by default
|
||||
SyntasticStyleWarningLine - Links to 'SyntasticWarningLine' by default
|
||||
|
||||
Example: >
|
||||
highlight SyntasticErrorLine guibg=#2f0000
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
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.
|
||||
|
||||
:SyntasticInfo *:SyntasticInfo*
|
||||
|
||||
Output info about what checkers are available and in use for the current
|
||||
filetype.
|
||||
|
||||
|
||||
==============================================================================
|
||||
4. Global Options *syntastic-global-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_check_on_wq'*
|
||||
Default: 1
|
||||
Normally syntastic runs syntax checks whenever buffers are written to disk.
|
||||
If you want to skip these checks when you issue |:wq|, |:x|, and |:ZZ|, set this
|
||||
variable to 0. >
|
||||
let g:syntastic_check_on_wq=0
|
||||
<
|
||||
|
||||
*'syntastic_echo_current_error'*
|
||||
Default: 1
|
||||
If enabled, syntastic will echo the error 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_error_symbol'* *'syntastic_style_error_symbol'*
|
||||
*'syntastic_warning_symbol'* *'syntastic_style_warning_symbol'*
|
||||
Use this option to control what the syntastic |:sign| text contains. Several
|
||||
error symobls can be customized:
|
||||
syntastic_error_symbol - For syntax errors, defaults to '>>'
|
||||
syntastic_style_error_symbol - For style errors, defaults to 'S>'
|
||||
syntastic_warning_symbol - For syntax warnings, defaults to '>>'
|
||||
syntastic_style_warning_symbol - For style warnings, defaults to 'S>'
|
||||
|
||||
Example: >
|
||||
let g:syntastic_error_symbol='✗'
|
||||
let g:syntastic_warning_symbol='⚠'
|
||||
<
|
||||
|
||||
*'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_always_populate_loc_list'*
|
||||
Default: 0
|
||||
Enable this option to tell syntastic to always stick any detected errors into
|
||||
the loclist: >
|
||||
let g:syntastic_always_populate_loc_list=1
|
||||
<
|
||||
*'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_loc_list_height'*
|
||||
Default: 10
|
||||
Use this option to specify the height of the location lists that syntastic
|
||||
opens. >
|
||||
let g:syntastic_loc_list_height=5
|
||||
<
|
||||
|
||||
*'syntastic_ignore_files'*
|
||||
Default: []
|
||||
Use this option to specify files that syntastic should neither check, nor
|
||||
include in error lists. It has to be a list of |regular-expression| patterns.
|
||||
The full paths of files (see |::p|) are matched against these patterns, and
|
||||
the matches are case sensitive. Use |\c| if you need case insensitive
|
||||
patterns. >
|
||||
let g:syntastic_ignore_files=['^/usr/include/', '\c\.h$']
|
||||
<
|
||||
|
||||
*'syntastic_filetype_map'*
|
||||
Default: {}
|
||||
Use this option to map non-standard filetypes to standard ones. Corresponding
|
||||
checkers are mapped accordingly, which allows syntastic to check files with
|
||||
non-standard filetypes: >
|
||||
let g:syntastic_filetype_map = { 'latex': 'tex',
|
||||
\ 'gentoo-metadata': 'xml' }
|
||||
<
|
||||
|
||||
*'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 available 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]
|
||||
<
|
||||
*'syntastic_full_redraws'*
|
||||
Default: 0 in GUI Vim and MacVim, 1 otherwise
|
||||
Controls whether syntastic calls |:redraw| or |:redraw!| for screen redraws.
|
||||
Changing it can in principle make screen redraws smoother, but it can also
|
||||
cause screen flicker, or ghost characters. Leaving it to the default should
|
||||
be safe.
|
||||
|
||||
*'syntastic_debug'*
|
||||
Default: 0
|
||||
Set this to 1 to enable debugging: >
|
||||
let g:syntastic_debug = 1
|
||||
<
|
||||
Checkers will then add debugging messages to Vim's |message-history|. You can
|
||||
examine these messages with |:mes|.
|
||||
|
||||
|
||||
==============================================================================
|
||||
5. Checker Options *syntastic-checker-options*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.1 Telling syntastic which checker to use.
|
||||
|
||||
Stick a line like this in your vimrc: >
|
||||
let g:syntastic_<filetype>_checkers = ['<checker-name>']
|
||||
<
|
||||
e.g. >
|
||||
let g:syntastic_python_checkers = ['flake8']
|
||||
<
|
||||
|
||||
There's also a per-buffer version of this setting, b:syntastic_checkers. Use
|
||||
this in an autocmd to configure specific checkers for particular paths: >
|
||||
autocmd FileType python if stridx(expand('%:p'), '/some/path/') == 0 |
|
||||
\ let b:syntastic_checkers = ['pylint'] | endif
|
||||
<
|
||||
|
||||
To see the list of available checkers for your filetype, look in
|
||||
`syntax_checkers/<filetype>/`. The names of the files here correspond to
|
||||
'<checker-name>' above.
|
||||
|
||||
e.g. Python has the following checkers: flake8, pyflakes, pylint and a
|
||||
native python checker.
|
||||
|
||||
Some filetypes, like PHP, have style checkers as well as syntax checkers. These
|
||||
can be chained together like this: >
|
||||
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']`
|
||||
<
|
||||
This is telling syntastic to run the 'php' checker first, and if no errors are
|
||||
found, run 'phpcs', and then 'phpmd'.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.2 Configuring specific checkers *syntastic-config-makeprg*
|
||||
|
||||
Most checkers use the 'syntastic#makeprg#build()' function and provide many
|
||||
options by default - in fact you can customise every part of the command
|
||||
that gets called.
|
||||
|
||||
Checkers that use 'syntastic#makeprg#build()' look like this: >
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'ruby',
|
||||
\ 'args': '-a -b -c',
|
||||
\ 'post_args': '--more --args',
|
||||
\ 'tail': '> /tmp/output',
|
||||
\ 'filetype': 'ruby',
|
||||
\ 'subchecker': 'mri' })
|
||||
<
|
||||
|
||||
The 'filetype' and 'subchecker' parameters are mandatory. All of the other
|
||||
parameters above are optional (well, you probably need at least 'exe'), and
|
||||
can be overriden by setting global variables - even parameters not specified
|
||||
in the call to syntastic#makeprg#build().
|
||||
|
||||
E.g. To override the checker exe above, you could do this: >
|
||||
let g:syntastic_ruby_mri_exe="another_ruby_checker_exe.rb"
|
||||
<
|
||||
To override the args and the tail: >
|
||||
let g:syntastic_ruby_mri_args="--my --args --here"
|
||||
let g:syntastic_ruby_mri_tail="> /tmp/my-output-file-biatch"
|
||||
<
|
||||
|
||||
The general form of the override options is: >
|
||||
syntastic_[filetype]_[subchecker]_[option-name]
|
||||
<
|
||||
|
||||
For checkers that do not use the 'syntastic#makeprg#build()' function you
|
||||
will have to look at the source code of the checker in question. If there are
|
||||
specific options that can be set, these are usually documented at the top of
|
||||
the script.
|
||||
|
||||
==============================================================================
|
||||
6. About *syntastic-about*
|
||||
|
||||
The core maintainers of syntastic are:
|
||||
Martin Grenfell (github: scrooloose)
|
||||
Gregor Uhlenheuer (github: kongo2002)
|
||||
|
||||
Find the latest version of syntastic here:
|
||||
http://github.com/scrooloose/syntastic
|
||||
|
||||
==============================================================================
|
||||
7. License *syntastic-license*
|
||||
|
||||
Syntastic is released under the wtfpl.
|
||||
See http://sam.zoy.org/wtfpl/COPYING.
|
||||
|
||||
vim:tw=78:sw=4:ft=help:norl:
|
|
@ -1,423 +0,0 @@
|
|||
"============================================================================
|
||||
"File: syntastic.vim
|
||||
"Description: Vim plugin for on the fly syntax checking.
|
||||
"Version: 3.0.0
|
||||
"Released On: 13 April, 2013
|
||||
"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
|
||||
|
||||
runtime! plugin/syntastic/*.vim
|
||||
|
||||
let s:running_windows = has("win16") || has("win32")
|
||||
|
||||
if !exists("g:syntastic_always_populate_loc_list")
|
||||
let g:syntastic_always_populate_loc_list = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_auto_jump")
|
||||
let g: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_check_on_open")
|
||||
let g:syntastic_check_on_open = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_check_on_wq")
|
||||
let g:syntastic_check_on_wq = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_loc_list_height")
|
||||
let g:syntastic_loc_list_height = 10
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_ignore_files")
|
||||
let g:syntastic_ignore_files = []
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_filetype_map")
|
||||
let g:syntastic_filetype_map = {}
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_full_redraws")
|
||||
let g:syntastic_full_redraws = !( has('gui_running') || has('gui_macvim'))
|
||||
endif
|
||||
|
||||
let s:registry = g:SyntasticRegistry.Instance()
|
||||
let s:notifiers = g:SyntasticNotifiers.Instance()
|
||||
let s:modemap = g:SyntasticModeMap.Instance()
|
||||
|
||||
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
|
||||
let checker_names = []
|
||||
for ft in s:CurrentFiletypes()
|
||||
for checker in s:registry.availableCheckersFor(ft)
|
||||
call add(checker_names, checker.getName())
|
||||
endfor
|
||||
endfor
|
||||
return join(checker_names, "\n")
|
||||
endfunction
|
||||
|
||||
command! SyntasticToggleMode call s:ToggleMode()
|
||||
command! -nargs=? -complete=custom,s:CompleteCheckerName SyntasticCheck call s:UpdateErrors(0, <f-args>) <bar> call s:Redraw()
|
||||
command! Errors call s:ShowLocList()
|
||||
command! SyntasticInfo call s:registry.echoInfoFor(s:CurrentFiletypes())
|
||||
|
||||
highlight link SyntasticError SpellBad
|
||||
highlight link SyntasticWarning SpellCap
|
||||
|
||||
augroup syntastic
|
||||
autocmd BufReadPost * if g:syntastic_check_on_open | call s:UpdateErrors(1) | endif
|
||||
autocmd BufWritePost * call s:UpdateErrors(1)
|
||||
|
||||
autocmd BufWinEnter * call s:BufWinEnterHook()
|
||||
|
||||
" TODO: the next autocmd should be "autocmd BufWinLeave * if empty(&bt) | lclose | endif"
|
||||
" but in recent versions of Vim lclose can no longer be called from BufWinLeave
|
||||
autocmd BufEnter * call s:BufEnterHook()
|
||||
augroup END
|
||||
|
||||
if v:version > 703 || (v:version == 703 && has('patch544'))
|
||||
" QuitPre was added in Vim 7.3.544
|
||||
augroup syntastic
|
||||
autocmd QuitPre * call s:QuitPreHook()
|
||||
augroup END
|
||||
endif
|
||||
|
||||
|
||||
function! s:BufWinEnterHook()
|
||||
if empty(&bt)
|
||||
let loclist = g:SyntasticLoclist.current()
|
||||
call s:notifiers.refresh(loclist)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:BufEnterHook()
|
||||
" TODO: at this point there is no b:syntastic_loclist
|
||||
let loclist = filter(getloclist(0), 'v:val["valid"] == 1')
|
||||
let buffers = syntastic#util#unique(map( loclist, 'v:val["bufnr"]' ))
|
||||
if &bt=='quickfix' && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
|
||||
call g:SyntasticLoclistHide()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:QuitPreHook()
|
||||
let b:syntastic_skip_checks = !g:syntastic_check_on_wq
|
||||
call g:SyntasticLoclistHide()
|
||||
endfunction
|
||||
|
||||
"refresh and redraw all the error info for this buf when saving or reading
|
||||
function! s:UpdateErrors(auto_invoked, ...)
|
||||
if s:SkipFile()
|
||||
return
|
||||
endif
|
||||
|
||||
let run_checks = !a:auto_invoked || s:modemap.allowsAutoChecking(&filetype)
|
||||
if run_checks
|
||||
if a:0 >= 1
|
||||
call s:CacheErrors(a:1)
|
||||
else
|
||||
call s:CacheErrors()
|
||||
endif
|
||||
end
|
||||
|
||||
let loclist = g:SyntasticLoclist.current()
|
||||
|
||||
if g:syntastic_always_populate_loc_list || g:syntastic_auto_jump
|
||||
call setloclist(0, loclist.filteredRaw())
|
||||
if run_checks && g:syntastic_auto_jump && loclist.hasErrorsOrWarningsToDisplay()
|
||||
silent! lrewind
|
||||
endif
|
||||
endif
|
||||
|
||||
call s:notifiers.refresh(loclist)
|
||||
endfunction
|
||||
|
||||
"clear the loc list for the buffer
|
||||
function! s:ClearCache()
|
||||
call s:notifiers.reset(g:SyntasticLoclist.current())
|
||||
unlet! b:syntastic_loclist
|
||||
endfunction
|
||||
|
||||
function! s:CurrentFiletypes()
|
||||
return split(&filetype, '\.')
|
||||
endfunction
|
||||
|
||||
"detect and cache all syntax errors in this buffer
|
||||
function! s:CacheErrors(...)
|
||||
call s:ClearCache()
|
||||
let newLoclist = g:SyntasticLoclist.New([])
|
||||
|
||||
if !s:SkipFile()
|
||||
let active_checkers = 0
|
||||
for ft in s:CurrentFiletypes()
|
||||
if a:0
|
||||
let checker = s:registry.getChecker(ft, a:1)
|
||||
let checkers = !empty(checker) ? [checker] : []
|
||||
else
|
||||
let checkers = s:registry.getActiveCheckers(ft)
|
||||
endif
|
||||
|
||||
for checker in checkers
|
||||
let active_checkers += 1
|
||||
call syntastic#util#debug("CacheErrors: Invoking checker: " . checker.getName())
|
||||
|
||||
let loclist = checker.getLocList()
|
||||
|
||||
if !loclist.isEmpty()
|
||||
let newLoclist = newLoclist.extend(loclist)
|
||||
call newLoclist.setName( checker.getName() . ' ('. checker.getFiletype() . ')' )
|
||||
|
||||
"only get errors from one checker at a time
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
if !active_checkers
|
||||
if a:0
|
||||
call syntastic#util#warn('checker ' . a:1 . ' is not active for filetype ' . &filetype)
|
||||
else
|
||||
call syntastic#util#debug('no active checkers for filetype ' . &filetype)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let b:syntastic_loclist = newLoclist
|
||||
endfunction
|
||||
|
||||
function! s:ToggleMode()
|
||||
call s:modemap.toggleMode()
|
||||
call s:ClearCache()
|
||||
call s:UpdateErrors(1)
|
||||
call s:modemap.echoMode()
|
||||
endfunction
|
||||
|
||||
"display the cached errors for this buf in the location list
|
||||
function! s:ShowLocList()
|
||||
let loclist = g:SyntasticLoclist.current()
|
||||
call loclist.show()
|
||||
endfunction
|
||||
|
||||
"the script changes &shellpipe and &shell to stop the screen flicking when
|
||||
"shelling out to syntax checkers. Not all OSs support the hacks though
|
||||
function! s:OSSupportsShellpipeHack()
|
||||
return !s:running_windows && executable('/bin/bash') && (s:uname() !~ "FreeBSD") && (s:uname() !~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
function! s:IsRedrawRequiredAfterMake()
|
||||
return !s:running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
"Redraw in a way that doesnt make the screen flicker or leave anomalies behind.
|
||||
"
|
||||
"Some terminal versions of vim require `redraw!` - otherwise there can be
|
||||
"random anomalies left behind.
|
||||
"
|
||||
"However, on some versions of gvim using `redraw!` causes the screen to
|
||||
"flicker - so use redraw.
|
||||
function! s:Redraw()
|
||||
if g:syntastic_full_redraws
|
||||
redraw!
|
||||
else
|
||||
redraw
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:IgnoreFile(filename)
|
||||
let fname = fnamemodify(a:filename, ':p')
|
||||
for p in g:syntastic_ignore_files
|
||||
if fname =~# p
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Skip running in special buffers
|
||||
function! s:SkipFile()
|
||||
let force_skip = exists('b:syntastic_skip_checks') ? b:syntastic_skip_checks : 0
|
||||
let fname = expand('%')
|
||||
return force_skip || !empty(&buftype) || !filereadable(fname) || getwinvar(0, '&diff') || s:IgnoreFile(fname)
|
||||
endfunction
|
||||
|
||||
function! s:uname()
|
||||
if !exists('s:uname')
|
||||
let s:uname = system('uname')
|
||||
endif
|
||||
return s:uname
|
||||
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()
|
||||
let loclist = g:SyntasticLoclist.current()
|
||||
let issues = loclist.filteredRaw()
|
||||
let num_issues = loclist.getLength()
|
||||
if loclist.hasErrorsOrWarningsToDisplay()
|
||||
let errors = loclist.errors()
|
||||
let warnings = loclist.warnings()
|
||||
|
||||
let num_errors = len(errors)
|
||||
let num_warnings = len(warnings)
|
||||
|
||||
let output = g:syntastic_stl_format
|
||||
|
||||
"hide stuff wrapped in %E(...) unless there are errors
|
||||
let output = substitute(output, '\C%E{\([^}]*\)}', num_errors ? '\1' : '' , 'g')
|
||||
|
||||
"hide stuff wrapped in %W(...) unless there are warnings
|
||||
let output = substitute(output, '\C%W{\([^}]*\)}', num_warnings ? '\1' : '' , 'g')
|
||||
|
||||
"hide stuff wrapped in %B(...) unless there are both errors and warnings
|
||||
let output = substitute(output, '\C%B{\([^}]*\)}', (num_warnings && num_errors) ? '\1' : '' , 'g')
|
||||
|
||||
|
||||
"sub in the total errors/warnings/both
|
||||
let output = substitute(output, '\C%w', num_warnings, 'g')
|
||||
let output = substitute(output, '\C%e', num_errors, 'g')
|
||||
let output = substitute(output, '\C%t', num_issues, 'g')
|
||||
|
||||
"first error/warning line num
|
||||
let output = substitute(output, '\C%F', num_issues ? issues[0]['lnum'] : '', 'g')
|
||||
|
||||
"first error line num
|
||||
let output = substitute(output, '\C%fe', num_errors ? errors[0]['lnum'] : '', 'g')
|
||||
|
||||
"first warning line num
|
||||
let output = substitute(output, '\C%fw', num_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
|
||||
" 'subtype' - all errors will be assigned the given subtype
|
||||
" 'postprocess' - a list of functions to be applied to the error list
|
||||
" 'cwd' - change directory to the given path before running the checker
|
||||
" 'returns' - a list of valid exit codes for the checker
|
||||
function! SyntasticMake(options)
|
||||
call syntastic#util#debug('SyntasticMake: called with options: '. string(a:options))
|
||||
|
||||
let old_loclist = getloclist(0)
|
||||
let old_makeprg = &l:makeprg
|
||||
let old_shellpipe = &shellpipe
|
||||
let old_shell = &shell
|
||||
let old_errorformat = &l:errorformat
|
||||
let old_cwd = getcwd()
|
||||
let old_lc_all = $LC_ALL
|
||||
|
||||
if s:OSSupportsShellpipeHack()
|
||||
"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 &l:makeprg = a:options['makeprg']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &l:errorformat = a:options['errorformat']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'cwd')
|
||||
exec 'lcd ' . fnameescape(a:options['cwd'])
|
||||
endif
|
||||
|
||||
let $LC_ALL = 'C'
|
||||
silent lmake!
|
||||
let $LC_ALL = old_lc_all
|
||||
|
||||
let errors = getloclist(0)
|
||||
|
||||
if has_key(a:options, 'cwd')
|
||||
exec 'lcd ' . fnameescape(old_cwd)
|
||||
endif
|
||||
|
||||
call setloclist(0, old_loclist)
|
||||
let &l:makeprg = old_makeprg
|
||||
let &l:errorformat = old_errorformat
|
||||
let &shellpipe=old_shellpipe
|
||||
let &shell=old_shell
|
||||
|
||||
if s:IsRedrawRequiredAfterMake()
|
||||
call s:Redraw()
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'returns') && index(a:options['returns'], v:shell_error) == -1
|
||||
throw 'Syntastic: checker error'
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'defaults')
|
||||
call SyntasticAddToErrors(errors, a:options['defaults'])
|
||||
endif
|
||||
|
||||
" Apply ignore patterns
|
||||
let ignore = {}
|
||||
for buf in syntastic#util#unique(map(copy(errors), 'v:val["bufnr"]'))
|
||||
let ignore[buf] = s:IgnoreFile(bufname(str2nr(buf)))
|
||||
endfor
|
||||
call filter(errors, '!ignore[v:val["bufnr"]]')
|
||||
|
||||
" Add subtype info if present.
|
||||
if has_key(a:options, 'subtype')
|
||||
call SyntasticAddToErrors(errors, {'subtype': a:options['subtype']})
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'postprocess') && !empty(a:options['postprocess'])
|
||||
for rule in a:options['postprocess']
|
||||
let errors = call('syntastic#postprocess#' . rule, [errors])
|
||||
endfor
|
||||
endif
|
||||
|
||||
return errors
|
||||
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 !has_key(a:errors[i], key) || 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:
|
|
@ -1,38 +0,0 @@
|
|||
if exists("g:loaded_syntastic_notifier_autoloclist")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_autoloclist = 1
|
||||
|
||||
if !exists("g:syntastic_auto_loc_list")
|
||||
let g:syntastic_auto_loc_list = 2
|
||||
endif
|
||||
|
||||
let g:SyntasticAutoloclistNotifier = {}
|
||||
|
||||
" Public methods {{{1
|
||||
"
|
||||
function! g:SyntasticAutoloclistNotifier.New()
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticAutoloclistNotifier.refresh(loclist)
|
||||
call g:SyntasticAutoloclistNotifier.AutoToggle(a:loclist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist)
|
||||
if a:loclist.hasErrorsOrWarningsToDisplay()
|
||||
if g:syntastic_auto_loc_list == 1
|
||||
call a:loclist.show()
|
||||
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
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,64 +0,0 @@
|
|||
if exists("g:loaded_syntastic_notifier_balloons")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_balloons = 1
|
||||
|
||||
if !exists("g:syntastic_enable_balloons")
|
||||
let g:syntastic_enable_balloons = 1
|
||||
endif
|
||||
|
||||
if !has('balloon_eval')
|
||||
let g:syntastic_enable_balloons = 0
|
||||
endif
|
||||
|
||||
let g:SyntasticBalloonsNotifier = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticBalloonsNotifier.New()
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticBalloonsNotifier.enabled()
|
||||
return
|
||||
\ has('balloon_eval') &&
|
||||
\ (exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons)
|
||||
endfunction
|
||||
|
||||
" Update the error balloons
|
||||
function! g:SyntasticBalloonsNotifier.refresh(loclist)
|
||||
let b:syntastic_balloons = {}
|
||||
if self.enabled() && a:loclist.hasErrorsOrWarningsToDisplay()
|
||||
let buf = bufnr('')
|
||||
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
|
||||
if !empty(issues)
|
||||
for i in issues
|
||||
if has_key(b:syntastic_balloons, i['lnum'])
|
||||
let b:syntastic_balloons[i['lnum']] .= "\n" . i['text']
|
||||
else
|
||||
let b:syntastic_balloons[i['lnum']] = i['text']
|
||||
endif
|
||||
endfor
|
||||
set beval bexpr=SyntasticBalloonsExprNotifier()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Reset the error balloons
|
||||
function! g:SyntasticBalloonsNotifier.reset(loclist)
|
||||
if has('balloon_eval')
|
||||
set nobeval
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
function! SyntasticBalloonsExprNotifier()
|
||||
if !exists('b:syntastic_balloons')
|
||||
return ''
|
||||
endif
|
||||
return get(b:syntastic_balloons, v:beval_lnum, '')
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,79 +0,0 @@
|
|||
if exists("g:loaded_syntastic_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_checker = 1
|
||||
|
||||
let g:SyntasticChecker = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticChecker.New(args)
|
||||
let newObj = copy(self)
|
||||
|
||||
let newObj._filetype = a:args['filetype']
|
||||
let newObj._name = a:args['name']
|
||||
|
||||
|
||||
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
|
||||
let newObj._locListFunc = function(prefix . 'GetLocList')
|
||||
let newObj._isAvailableFunc = function(prefix . 'IsAvailable')
|
||||
|
||||
if exists('*' . prefix . 'GetHighlightRegex')
|
||||
let newObj._highlightRegexFunc = function(prefix. 'GetHighlightRegex')
|
||||
else
|
||||
let newObj._highlightRegexFunc = ''
|
||||
endif
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticChecker.getFiletype()
|
||||
return self._filetype
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticChecker.getName()
|
||||
return self._name
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticChecker.getLocList()
|
||||
try
|
||||
let list = self._locListFunc()
|
||||
call syntastic#util#debug('getLocList: checker ' . self._filetype . '/' . self._name . ' returned ' . v:shell_error)
|
||||
catch /\m\C^Syntastic: checker error$/
|
||||
let list = []
|
||||
call syntastic#util#error('checker ' . self._filetype . '/' . self._name . ' returned abnormal status ' . v:shell_error)
|
||||
endtry
|
||||
call self._populateHighlightRegexes(list)
|
||||
return g:SyntasticLoclist.New(list)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticChecker.getHighlightRegexFor(error)
|
||||
if empty(self._highlightRegexFunc)
|
||||
return []
|
||||
endif
|
||||
|
||||
return self._highlightRegexFunc(error)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticChecker.isAvailable()
|
||||
return self._isAvailableFunc()
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticChecker._populateHighlightRegexes(list)
|
||||
let list = a:list
|
||||
if !empty(self._highlightRegexFunc)
|
||||
for i in range(0, len(list)-1)
|
||||
if list[i]['valid']
|
||||
let term = self._highlightRegexFunc(list[i])
|
||||
if len(term) > 0
|
||||
let list[i]['hl'] = term
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return list
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,63 +0,0 @@
|
|||
if exists("g:loaded_syntastic_notifier_cursor")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_cursor = 1
|
||||
|
||||
if !exists('g:syntastic_echo_current_error')
|
||||
let g:syntastic_echo_current_error = 1
|
||||
endif
|
||||
|
||||
let g:SyntasticCursorNotifier = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticCursorNotifier.New()
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticCursorNotifier.enabled()
|
||||
return exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticCursorNotifier.refresh(loclist)
|
||||
if self.enabled() && a:loclist.hasErrorsOrWarningsToDisplay()
|
||||
let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
|
||||
let b:oldLine = -1
|
||||
autocmd! syntastic CursorMoved
|
||||
autocmd syntastic CursorMoved * call g:SyntasticRefreshCursor()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticCursorNotifier.reset(loclist)
|
||||
autocmd! syntastic CursorMoved
|
||||
unlet! b:syntastic_messages
|
||||
let b:oldLine = -1
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
" The following defensive nonsense is needed because of the nature of autocmd
|
||||
function! g:SyntasticRefreshCursor()
|
||||
if !exists('b:syntastic_messages') || empty(b:syntastic_messages)
|
||||
" file not checked
|
||||
return
|
||||
endif
|
||||
|
||||
if !exists('b:oldLine')
|
||||
let b:oldLine = -1
|
||||
endif
|
||||
let l = line('.')
|
||||
if l == b:oldLine
|
||||
return
|
||||
endif
|
||||
let b:oldLine = l
|
||||
|
||||
if has_key(b:syntastic_messages, l)
|
||||
call syntastic#util#wideMsg(b:syntastic_messages[l])
|
||||
else
|
||||
echo
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,66 +0,0 @@
|
|||
if exists("g:loaded_syntastic_notifier_highlighting")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_highlighting = 1
|
||||
|
||||
" Highlighting requires getmatches introduced in 7.1.040
|
||||
let s:has_highlighting = v:version > 701 || (v:version == 701 && has('patch040'))
|
||||
|
||||
if !exists("g:syntastic_enable_highlighting")
|
||||
let g:syntastic_enable_highlighting = 1
|
||||
endif
|
||||
|
||||
let g:SyntasticHighlightingNotifier = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticHighlightingNotifier.New()
|
||||
let newObj = copy(self)
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticHighlightingNotifier.enabled()
|
||||
return
|
||||
\ s:has_highlighting &&
|
||||
\ (exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting)
|
||||
endfunction
|
||||
|
||||
" Sets error highlights in the cuirrent window
|
||||
function! g:SyntasticHighlightingNotifier.refresh(loclist)
|
||||
if self.enabled()
|
||||
call self.reset(a:loclist)
|
||||
let buf = bufnr('')
|
||||
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
|
||||
for item in issues
|
||||
let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
|
||||
|
||||
" The function `Syntastic_{filetype}_{checker}_GetHighlightRegex` is
|
||||
" used to override default highlighting.
|
||||
if has_key(item, 'hl')
|
||||
call matchadd(group, '\%' . item['lnum'] . 'l' . item['hl'])
|
||||
elseif get(item, 'col')
|
||||
let lastcol = col([item['lnum'], '$'])
|
||||
let lcol = min([lastcol, item['col']])
|
||||
|
||||
" a bug in vim can sometimes cause there to be no 'vcol' key,
|
||||
" so check for its existence
|
||||
let coltype = has_key(item, 'vcol') && item['vcol'] ? 'v' : 'c'
|
||||
|
||||
call matchadd(group, '\%' . item['lnum'] . 'l\%' . lcol . coltype)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Remove all error highlights from the window
|
||||
function! g:SyntasticHighlightingNotifier.reset(loclist)
|
||||
if s:has_highlighting
|
||||
for match in getmatches()
|
||||
if stridx(match['group'], 'Syntastic') == 0
|
||||
call matchdelete(match['id'])
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,173 +0,0 @@
|
|||
if exists("g:loaded_syntastic_loclist")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_loclist = 1
|
||||
|
||||
let g:SyntasticLoclist = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticLoclist.New(rawLoclist)
|
||||
let newObj = copy(self)
|
||||
let newObj._quietWarnings = g:syntastic_quiet_warnings
|
||||
|
||||
let llist = copy(a:rawLoclist)
|
||||
let llist = filter(llist, 'v:val["valid"] == 1')
|
||||
|
||||
for e in llist
|
||||
if empty(e['type'])
|
||||
let e['type'] = 'E'
|
||||
endif
|
||||
endfor
|
||||
|
||||
let newObj._rawLoclist = llist
|
||||
let newObj._hasErrorsOrWarningsToDisplay = -1
|
||||
|
||||
let newObj._name = ''
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.current()
|
||||
if !exists("b:syntastic_loclist")
|
||||
let b:syntastic_loclist = g:SyntasticLoclist.New([])
|
||||
endif
|
||||
return b:syntastic_loclist
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.extend(other)
|
||||
let list = self.toRaw()
|
||||
call extend(list, a:other.toRaw())
|
||||
return g:SyntasticLoclist.New(list)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.toRaw()
|
||||
return copy(self._rawLoclist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.filteredRaw()
|
||||
return copy(self._quietWarnings ? self.errors() : self._rawLoclist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.quietWarnings()
|
||||
return self._quietWarnings
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.isEmpty()
|
||||
return empty(self._rawLoclist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.getLength()
|
||||
return len(self._rawLoclist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.getName()
|
||||
return len(self._name)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.setName(name)
|
||||
let self._name = a:name
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay()
|
||||
if self._hasErrorsOrWarningsToDisplay >= 0
|
||||
return self._hasErrorsOrWarningsToDisplay
|
||||
endif
|
||||
let self._hasErrorsOrWarningsToDisplay = empty(self._rawLoclist) ? 0 : (!self._quietWarnings || len(self.errors()))
|
||||
return self._hasErrorsOrWarningsToDisplay
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.errors()
|
||||
if !exists("self._cachedErrors")
|
||||
let self._cachedErrors = self.filter({'type': "E"})
|
||||
endif
|
||||
return self._cachedErrors
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticLoclist.warnings()
|
||||
if !exists("self._cachedWarnings")
|
||||
let self._cachedWarnings = self.filter({'type': "W"})
|
||||
endif
|
||||
return self._cachedWarnings
|
||||
endfunction
|
||||
|
||||
" cache used by EchoCurrentError()
|
||||
function! g:SyntasticLoclist.messages(buf)
|
||||
if !exists("self._cachedMessages")
|
||||
let self._cachedMessages = {}
|
||||
let errors = self.errors() + (self._quietWarnings ? [] : self.warnings())
|
||||
|
||||
for e in errors
|
||||
let b = e['bufnr']
|
||||
let l = e['lnum']
|
||||
|
||||
if !has_key(self._cachedMessages, b)
|
||||
let self._cachedMessages[b] = {}
|
||||
endif
|
||||
|
||||
if !has_key(self._cachedMessages[b], l)
|
||||
let self._cachedMessages[b][l] = e['text']
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return get(self._cachedMessages, a:buf, {})
|
||||
endfunction
|
||||
|
||||
"Filter the list and return new native loclist
|
||||
"e.g.
|
||||
" .filter({'bufnr': 10, 'type': 'e'})
|
||||
"
|
||||
"would return all errors for buffer 10.
|
||||
"
|
||||
"Note that all comparisons are done with ==?
|
||||
function! g:SyntasticLoclist.filter(filters)
|
||||
let rv = []
|
||||
|
||||
for error in self._rawLoclist
|
||||
|
||||
let passes_filters = 1
|
||||
for key in keys(a:filters)
|
||||
if error[key] !=? a:filters[key]
|
||||
let passes_filters = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if passes_filters
|
||||
call add(rv, error)
|
||||
endif
|
||||
endfor
|
||||
return rv
|
||||
endfunction
|
||||
|
||||
"display the cached errors for this buf in the location list
|
||||
function! g:SyntasticLoclist.show()
|
||||
call setloclist(0, self.filteredRaw())
|
||||
if self.hasErrorsOrWarningsToDisplay()
|
||||
let num = winnr()
|
||||
exec "lopen " . g:syntastic_loc_list_height
|
||||
if num != winnr()
|
||||
wincmd p
|
||||
endif
|
||||
|
||||
" try to find the loclist window and set w:quickfix_title
|
||||
for buf in tabpagebuflist()
|
||||
if buflisted(buf) && bufloaded(buf) && getbufvar(buf, '&buftype') ==# 'quickfix'
|
||||
let win = bufwinnr(buf)
|
||||
let title = getwinvar(win, 'quickfix_title')
|
||||
if title ==# ':setloclist()' || strpart(title, 0, 16) ==# ':SyntasticCheck '
|
||||
call setwinvar(win, 'quickfix_title', ':SyntasticCheck ' . self._name)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Non-method functions {{{1
|
||||
|
||||
function! g:SyntasticLoclistHide()
|
||||
silent! lclose
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,72 +0,0 @@
|
|||
if exists("g:loaded_syntastic_makeprg_builder")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_makeprg_builder = 1
|
||||
|
||||
let g:SyntasticMakeprgBuilder = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.New(exe, args, fname, post_args, tail, filetype, subchecker)
|
||||
let newObj = copy(self)
|
||||
let newObj._exe = a:exe
|
||||
let newObj._args = a:args
|
||||
let newObj._fname = a:fname
|
||||
let newObj._post_args = a:post_args
|
||||
let newObj._tail = a:tail
|
||||
let newObj._filetype = empty(a:filetype) ? &filetype : a:filetype
|
||||
let newObj._subchecker = a:subchecker
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.makeprg()
|
||||
return join([self.exe(), self.args(), self.fname(), self.post_args(), self.tail()])
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.exe()
|
||||
return self._getOpt('exe')
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.args()
|
||||
return self._getOpt('args')
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.fname()
|
||||
if empty(self._fname)
|
||||
return syntastic#util#shexpand('%')
|
||||
else
|
||||
return self._fname
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.post_args()
|
||||
return self._getOpt('post_args')
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder.tail()
|
||||
return self._getOpt('tail')
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function g:SyntasticMakeprgBuilder._getOpt(name)
|
||||
if self._optExists(a:name)
|
||||
return {self._optName(a:name)}
|
||||
endif
|
||||
|
||||
return self['_' . a:name]
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder._optExists(name)
|
||||
return exists(self._optName(a:name))
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticMakeprgBuilder._optName(name)
|
||||
let setting = "g:syntastic_" . self._filetype
|
||||
if !empty(self._subchecker)
|
||||
let setting .= '_' . self._subchecker
|
||||
endif
|
||||
return setting . '_' . a:name
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,67 +0,0 @@
|
|||
if exists("g:loaded_syntastic_modemap")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_modemap = 1
|
||||
|
||||
let g:SyntasticModeMap = {}
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticModeMap.Instance()
|
||||
if !exists('s:SyntasticModeMapInstance')
|
||||
let s:SyntasticModeMapInstance = copy(self)
|
||||
call s:SyntasticModeMapInstance._initModeMapFromGlobalOpts()
|
||||
endif
|
||||
|
||||
return s:SyntasticModeMapInstance
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticModeMap.allowsAutoChecking(filetype)
|
||||
let fts = split(a:filetype, '\.')
|
||||
|
||||
if self.isPassive()
|
||||
return self._isOneFiletypeActive(fts)
|
||||
else
|
||||
return self._noFiletypesArePassive(fts)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticModeMap.isPassive()
|
||||
return self._mode == "passive"
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticModeMap.toggleMode()
|
||||
if self._mode == "active"
|
||||
let self._mode = "passive"
|
||||
else
|
||||
let self._mode = "active"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticModeMap.echoMode()
|
||||
echo "Syntastic: " . self._mode . " mode enabled"
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticModeMap._initModeMapFromGlobalOpts()
|
||||
let self._mode = "active"
|
||||
let self._activeFiletypes = []
|
||||
let self._passiveFiletypes = []
|
||||
|
||||
if exists("g:syntastic_mode_map")
|
||||
let self._mode = get(g:syntastic_mode_map, 'mode', self._mode)
|
||||
let self._activeFiletypes = get(g:syntastic_mode_map, 'active_filetypes', self._activeFiletypes)
|
||||
let self._passiveFiletypes = get(g:syntastic_mode_map, 'passive_filetypes', self._passiveFiletypes)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes)
|
||||
return !empty(filter(a:filetypes, 'index(self._activeFiletypes, v:val) != -1'))
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes)
|
||||
return empty(filter(a:filetypes, 'index(self._passiveFiletypes, v:val) != -1'))
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,55 +0,0 @@
|
|||
if exists("g:loaded_syntastic_notifiers")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifiers = 1
|
||||
|
||||
let g:SyntasticNotifiers = {}
|
||||
|
||||
let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autoloclist']
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticNotifiers.Instance()
|
||||
if !exists('s:SyntasticNotifiersInstance')
|
||||
let s:SyntasticNotifiersInstance = copy(self)
|
||||
call s:SyntasticNotifiersInstance._initNotifiers()
|
||||
endif
|
||||
|
||||
return s:SyntasticNotifiersInstance
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifiers.refresh(loclist)
|
||||
for type in self._enabled_types
|
||||
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
|
||||
if !has_key(g:{class}, 'enabled') || self._notifier[type].enabled()
|
||||
call self._notifier[type].refresh(a:loclist)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticNotifiers.reset(loclist)
|
||||
for type in self._enabled_types
|
||||
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
|
||||
|
||||
" reset notifiers regardless if they are enabled or not, since
|
||||
" the user might have disabled them since the last refresh();
|
||||
" notifiers MUST be prepared to deal with reset() when disabled
|
||||
if has_key(g:{class}, 'reset')
|
||||
call self._notifier[type].reset(a:loclist)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticNotifiers._initNotifiers()
|
||||
let self._notifier = {}
|
||||
for type in s:notifier_types
|
||||
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
|
||||
let self._notifier[type] = g:{class}.New()
|
||||
endfor
|
||||
|
||||
let self._enabled_types = copy(s:notifier_types)
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,213 +0,0 @@
|
|||
if exists("g:loaded_syntastic_registry")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_registry = 1
|
||||
|
||||
let s:defaultCheckers = {
|
||||
\ 'c': ['gcc'],
|
||||
\ 'coffee': ['coffee', 'coffeelint'],
|
||||
\ 'cpp': ['gcc'],
|
||||
\ 'css': ['csslint', 'phpcs'],
|
||||
\ 'go': ['go'],
|
||||
\ 'html': ['tidy'],
|
||||
\ 'java': ['javac'],
|
||||
\ 'javascript': ['jshint', 'jslint'],
|
||||
\ 'json': ['jsonlint', 'jsonval'],
|
||||
\ 'objc': ['gcc'],
|
||||
\ 'objcpp': ['gcc'],
|
||||
\ 'perl': ['perl', 'perlcritic'],
|
||||
\ 'php': ['php', 'phpcs', 'phpmd'],
|
||||
\ 'puppet': ['puppet', 'puppetlint'],
|
||||
\ 'python': ['python', 'flake8', 'pylint'],
|
||||
\ 'ruby': ['mri'],
|
||||
\ 'sh': ['sh'],
|
||||
\ 'tex': ['lacheck']
|
||||
\ }
|
||||
|
||||
let s:defaultFiletypeMap = {
|
||||
\ 'gentoo-metadata': 'xml',
|
||||
\ 'lhaskell': 'haskell'
|
||||
\ }
|
||||
|
||||
let g:SyntasticRegistry = {}
|
||||
|
||||
" TODO: Handling of filetype aliases: all public methods take aliases as
|
||||
" parameters, all private methods take normalized filetypes. Public methods
|
||||
" are thus supposed to normalize filetypes before calling private methods.
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticRegistry.Instance()
|
||||
if !exists('s:SyntasticRegistryInstance')
|
||||
let s:SyntasticRegistryInstance = copy(self)
|
||||
let s:SyntasticRegistryInstance._checkerMap = {}
|
||||
endif
|
||||
|
||||
return s:SyntasticRegistryInstance
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.CreateAndRegisterChecker(args)
|
||||
let checker = g:SyntasticChecker.New(a:args)
|
||||
let registry = g:SyntasticRegistry.Instance()
|
||||
call registry.registerChecker(checker)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.registerChecker(checker) abort
|
||||
let ft = a:checker.getFiletype()
|
||||
|
||||
if !has_key(self._checkerMap, ft)
|
||||
let self._checkerMap[ft] = []
|
||||
endif
|
||||
|
||||
call self._validateUniqueName(a:checker)
|
||||
|
||||
call add(self._checkerMap[ft], a:checker)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.checkable(ftalias)
|
||||
return !empty(self.getActiveCheckers(a:ftalias))
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.getActiveCheckers(ftalias)
|
||||
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
|
||||
let checkers = self.availableCheckersFor(a:ftalias)
|
||||
|
||||
if self._userHasFiletypeSettings(filetype)
|
||||
return self._filterCheckersByUserSettings(checkers, filetype)
|
||||
endif
|
||||
|
||||
if has_key(s:defaultCheckers, filetype)
|
||||
return self._filterCheckersByDefaultSettings(checkers, filetype)
|
||||
endif
|
||||
|
||||
let checkers = self.availableCheckersFor(filetype)
|
||||
|
||||
if !empty(checkers)
|
||||
return [checkers[0]]
|
||||
endif
|
||||
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.getChecker(ftalias, name)
|
||||
for checker in self.availableCheckersFor(a:ftalias)
|
||||
if checker.getName() == a:name
|
||||
return checker
|
||||
endif
|
||||
endfor
|
||||
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.availableCheckersFor(ftalias)
|
||||
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
|
||||
let checkers = copy(self._allCheckersFor(filetype))
|
||||
return self._filterCheckersByAvailability(checkers)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry.echoInfoFor(ftalias_list)
|
||||
echomsg "Syntastic info for filetype: " . join(a:ftalias_list, '.')
|
||||
|
||||
let available = []
|
||||
let active = []
|
||||
for ftalias in a:ftalias_list
|
||||
call extend(available, self.availableCheckersFor(ftalias))
|
||||
call extend(active, self.getActiveCheckers(ftalias))
|
||||
endfor
|
||||
|
||||
echomsg "Available checkers: " . join(syntastic#util#unique(map(available, "v:val.getName()")))
|
||||
echomsg "Currently active checker(s): " . join(syntastic#util#unique(map(active, "v:val.getName()")))
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
function! g:SyntasticRegistry._allCheckersFor(filetype)
|
||||
call self._loadCheckers(a:filetype)
|
||||
if empty(self._checkerMap[a:filetype])
|
||||
return []
|
||||
endif
|
||||
|
||||
return self._checkerMap[a:filetype]
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
|
||||
if has_key(s:defaultCheckers, a:filetype)
|
||||
return self._filterCheckersByName(a:checkers, s:defaultCheckers[a:filetype])
|
||||
endif
|
||||
|
||||
return a:checkers
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByUserSettings(checkers, filetype)
|
||||
if exists("b:syntastic_checkers")
|
||||
let whitelist = b:syntastic_checkers
|
||||
else
|
||||
let whitelist = g:syntastic_{a:filetype}_checkers
|
||||
endif
|
||||
return self._filterCheckersByName(a:checkers, whitelist)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByName(checkers, list)
|
||||
let checkers_by_name = {}
|
||||
for c in a:checkers
|
||||
let checkers_by_name[c.getName()] = c
|
||||
endfor
|
||||
|
||||
let filtered = []
|
||||
for name in a:list
|
||||
if has_key(checkers_by_name, name)
|
||||
call add(filtered, checkers_by_name[name])
|
||||
endif
|
||||
endfor
|
||||
|
||||
return filtered
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
|
||||
return filter(copy(a:checkers), "v:val.isAvailable()")
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._loadCheckers(filetype)
|
||||
if self._haveLoadedCheckers(a:filetype)
|
||||
return
|
||||
endif
|
||||
|
||||
exec "runtime! syntax_checkers/" . a:filetype . "/*.vim"
|
||||
|
||||
if !has_key(self._checkerMap, a:filetype)
|
||||
let self._checkerMap[a:filetype] = []
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._haveLoadedCheckers(filetype)
|
||||
return has_key(self._checkerMap, a:filetype)
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._userHasFiletypeSettings(filetype)
|
||||
if exists("g:syntastic_" . a:filetype . "_checker") && !exists("g:syntastic_" . a:filetype . "_checkers")
|
||||
let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker]
|
||||
call syntastic#util#deprecationWarn("variable g:syntastic_" . a:filetype . "_checker is deprecated")
|
||||
endif
|
||||
return exists("b:syntastic_checkers") || exists("g:syntastic_" . a:filetype . "_checkers")
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticRegistry._validateUniqueName(checker) abort
|
||||
for checker in self._allCheckersFor(a:checker.getFiletype())
|
||||
if checker.getName() == a:checker.getName()
|
||||
throw "Syntastic: Duplicate syntax checker name for: " . a:checker.getName()
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Private functions {{{1
|
||||
|
||||
"resolve filetype aliases, and replace - with _ otherwise we cant name
|
||||
"syntax checker functions legally for filetypes like "gentoo-metadata"
|
||||
function! s:SyntasticRegistryNormaliseFiletype(ftalias)
|
||||
let ft = get(s:defaultFiletypeMap, a:ftalias, a:ftalias)
|
||||
let ft = get(g:syntastic_filetype_map, ft, ft)
|
||||
let ft = substitute(ft, '-', '_', 'g')
|
||||
return ft
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,149 +0,0 @@
|
|||
if exists("g:loaded_syntastic_notifier_signs")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_notifier_signs = 1
|
||||
|
||||
if !exists("g:syntastic_enable_signs")
|
||||
let g:syntastic_enable_signs = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_error_symbol")
|
||||
let g:syntastic_error_symbol = '>>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_warning_symbol")
|
||||
let g:syntastic_warning_symbol = '>>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_style_error_symbol")
|
||||
let g:syntastic_style_error_symbol = 'S>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_style_warning_symbol")
|
||||
let g:syntastic_style_warning_symbol = 'S>'
|
||||
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
|
||||
|
||||
let g:SyntasticSignsNotifier = {}
|
||||
|
||||
let s:setup_done = 0
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticSignsNotifier.New()
|
||||
let newObj = copy(self)
|
||||
|
||||
if !s:setup_done
|
||||
call self._setup()
|
||||
let s:setup_done = 1
|
||||
endif
|
||||
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticSignsNotifier.enabled()
|
||||
return
|
||||
\ has('signs') &&
|
||||
\ exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
|
||||
endfunction
|
||||
|
||||
function! g:SyntasticSignsNotifier.refresh(loclist)
|
||||
let old_signs = copy(self._bufSignIds())
|
||||
if self.enabled()
|
||||
call self._signErrors(a:loclist)
|
||||
endif
|
||||
call self._removeSigns(old_signs)
|
||||
let s:first_sign_id = s:next_sign_id
|
||||
endfunction
|
||||
|
||||
" Private methods {{{1
|
||||
|
||||
" One time setup: define our own sign types and highlighting
|
||||
function! g:SyntasticSignsNotifier._setup()
|
||||
if has('signs')
|
||||
if !hlexists('SyntasticErrorSign')
|
||||
highlight link SyntasticErrorSign error
|
||||
endif
|
||||
if !hlexists('SyntasticWarningSign')
|
||||
highlight link SyntasticWarningSign todo
|
||||
endif
|
||||
if !hlexists('SyntasticStyleErrorSign')
|
||||
highlight link SyntasticStyleErrorSign SyntasticErrorSign
|
||||
endif
|
||||
if !hlexists('SyntasticStyleWarningSign')
|
||||
highlight link SyntasticStyleWarningSign SyntasticWarningSign
|
||||
endif
|
||||
if !hlexists('SyntasticStyleErrorLine')
|
||||
highlight link SyntasticStyleErrorLine SyntasticErrorLine
|
||||
endif
|
||||
if !hlexists('SyntasticStyleWarningLine')
|
||||
highlight link SyntasticStyleWarningLine SyntasticWarningLine
|
||||
endif
|
||||
|
||||
" define the signs used to display syntax and style errors/warns
|
||||
exe 'sign define SyntasticError text=' . g:syntastic_error_symbol .
|
||||
\ ' texthl=SyntasticErrorSign linehl=SyntasticErrorLine'
|
||||
exe 'sign define SyntasticWarning text=' . g:syntastic_warning_symbol .
|
||||
\ ' texthl=SyntasticWarningSign linehl=SyntasticWarningLine'
|
||||
exe 'sign define SyntasticStyleError text=' . g:syntastic_style_error_symbol .
|
||||
\ ' texthl=SyntasticStyleErrorSign linehl=SyntasticStyleErrorLine'
|
||||
exe 'sign define SyntasticStyleWarning text=' . g:syntastic_style_warning_symbol .
|
||||
\ ' texthl=SyntasticStyleWarningSign linehl=SyntasticStyleWarningLine'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Place signs by all syntax errors in the buffer
|
||||
function! g:SyntasticSignsNotifier._signErrors(loclist)
|
||||
let loclist = a:loclist
|
||||
if loclist.hasErrorsOrWarningsToDisplay()
|
||||
|
||||
" errors some first, so that they are not masked by warnings
|
||||
let buf = bufnr('')
|
||||
let issues = copy(loclist.errors())
|
||||
if !loclist.quietWarnings()
|
||||
call extend(issues, loclist.warnings())
|
||||
endif
|
||||
call filter(issues, 'v:val["bufnr"] == buf')
|
||||
let seen = {}
|
||||
|
||||
for i in issues
|
||||
if !has_key(seen, i['lnum'])
|
||||
let seen[i['lnum']] = 1
|
||||
|
||||
let sign_severity = i['type'] ==? 'W' ? 'Warning' : 'Error'
|
||||
let sign_subtype = get(i, 'subtype', '')
|
||||
let sign_type = 'Syntastic' . sign_subtype . sign_severity
|
||||
|
||||
exec "sign place " . s:next_sign_id . " line=" . i['lnum'] . " name=" . sign_type . " buffer=" . i['bufnr']
|
||||
call add(self._bufSignIds(), s:next_sign_id)
|
||||
let s:next_sign_id += 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Remove the signs with the given ids from this buffer
|
||||
function! g:SyntasticSignsNotifier._removeSigns(ids)
|
||||
if has('signs')
|
||||
for i in a:ids
|
||||
exec "sign unplace " . i
|
||||
call remove(self._bufSignIds(), index(self._bufSignIds(), i))
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Get all the ids of the SyntaxError signs in the buffer
|
||||
function! g:SyntasticSignsNotifier._bufSignIds()
|
||||
if !exists("b:syntastic_sign_ids")
|
||||
let b:syntastic_sign_ids = []
|
||||
endif
|
||||
return b:syntastic_sign_ids
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
|
@ -1,168 +0,0 @@
|
|||
"============================================================================
|
||||
"File: ada.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Alfredo Di Napoli <alfredo.dinapoli@gmail.com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" In order to also check header files add this to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_ada_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_ada_no_include_search = 1
|
||||
"
|
||||
" To disable the include of the default include dirs (such as /usr/include)
|
||||
" add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_ada_no_default_include_dirs = 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_ada_includes. Then the header files are being re-checked
|
||||
" on the next file write.
|
||||
"
|
||||
" let g:syntastic_ada_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_ada_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_ada_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_ada_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_ada_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_ada_compiler_options':
|
||||
"
|
||||
" let g:syntastic_ada_compiler_options = ' -std=c++0x'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_ada_config_file' allows you to define
|
||||
" a file that contains additional compiler arguments like include directories
|
||||
" or CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_ada_config':
|
||||
"
|
||||
" let g:syntastic_ada_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_ada_remove_include_errors' you can
|
||||
" specify whether errors of files included via the
|
||||
" g:syntastic_ada_include_dirs' setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_ada_remove_include_errors = 1
|
||||
"
|
||||
" Use the variable 'g:syntastic_ada_errorformat' to override the default error
|
||||
" format:
|
||||
"
|
||||
" let g:syntastic_ada_errorformat = '%f:%l:%c: %trror: %m'
|
||||
"
|
||||
" Set your compiler executable with e.g. (defaults to gcc)
|
||||
"
|
||||
" let g:syntastic_ada_compiler = 'gcc'
|
||||
|
||||
if exists('g:loaded_syntastic_ada_gcc_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_ada_gcc_checker = 1
|
||||
|
||||
if !exists('g:syntastic_ada_compiler')
|
||||
let g:syntastic_ada_compiler = 'gcc'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_ada_gcc_IsAvailable()
|
||||
return executable(g:syntastic_ada_compiler)
|
||||
endfunction
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_ada_compiler_options')
|
||||
let g:syntastic_ada_compiler_options = ''
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_ada_config_file')
|
||||
let g:syntastic_ada_config_file = '.syntastic_ada_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_ada_gcc_GetLocList()
|
||||
let makeprg = g:syntastic_ada_compiler . ' -c -x ada -fsyntax-only '
|
||||
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_c_errorformat')
|
||||
let errorformat = g:syntastic_c_errorformat
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
let makeprg .= g:syntastic_ada_compiler_options
|
||||
|
||||
let makeprg .= ' ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('ada')
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '\.ads$'
|
||||
if exists('g:syntastic_ada_check_header')
|
||||
let makeprg = g:syntastic_ada_compiler .
|
||||
\ ' -c ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . g:syntastic_ada_compiler_options .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('ada')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_ada_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_ada_no_include_search') ||
|
||||
\ g:syntastic_ada_no_include_search != 1
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_ada_auto_refresh_includes') &&
|
||||
\ g:syntastic_ada_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_ada_includes')
|
||||
let b:syntastic_ada_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_ada_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= b:syntastic_ada_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_ada_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_ada_remove_include_errors') &&
|
||||
\ g:syntastic_ada_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'ada',
|
||||
\ 'name': 'gcc'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -1,50 +0,0 @@
|
|||
"==============================================================================
|
||||
" 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("g:loaded_syntastic_applescript_osacompile_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_applescript_osacompile_checker=1
|
||||
|
||||
function! SyntaxCheckers_applescript_osacompile_IsAvailable()
|
||||
return executable('osacompile')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_applescript_osacompile_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'osacompile',
|
||||
\ 'args': '-o ' . tempname() . '.scpt ',
|
||||
\ 'filetype': 'applescript',
|
||||
\ 'subchecker': 'osacompile' })
|
||||
let errorformat = '%f:%l:%m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'applescript',
|
||||
\ 'name': 'osacompile'})
|
|
@ -1,48 +0,0 @@
|
|||
"============================================================================
|
||||
"File: checkpatch.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim using checkpatch.pl
|
||||
"Maintainer: Daniel Walker <dwalker at fifo99 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:loaded_syntastic_c_checkpatch_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_checkpatch_checker = 1
|
||||
|
||||
" Bail if the user doesn't have `checkpatch.pl` or ./scripts/checkpatch.pl installed.
|
||||
if executable("checkpatch.pl")
|
||||
let g:syntastic_c_checker_checkpatch_location = 'checkpatch.pl'
|
||||
elseif executable("./scripts/checkpatch.pl")
|
||||
let g:syntastic_c_checker_checkpatch_location = './scripts/checkpatch.pl'
|
||||
endif
|
||||
|
||||
function SyntaxCheckers_c_checkpatch_IsAvailable()
|
||||
return exists("g:syntastic_c_checker_checkpatch_location")
|
||||
endfunction
|
||||
|
||||
|
||||
function! SyntaxCheckers_c_checkpatch_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': g:syntastic_c_checker_checkpatch_location,
|
||||
\ 'args': '--no-summary --no-tree --terse --file',
|
||||
\ 'filetype': 'c',
|
||||
\ 'subchecker': 'checkpatch' })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l: %tARNING: %m,' .
|
||||
\ '%f:%l: %tRROR: %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'returns': [0],
|
||||
\ 'subtype': 'Style' })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'checkpatch'})
|
|
@ -1,183 +0,0 @@
|
|||
"============================================================================
|
||||
"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:
|
||||
"
|
||||
" 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 disable the include of the default include dirs (such as /usr/include)
|
||||
" add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_c_no_default_include_dirs = 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'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_c_config_file' allows you to define a
|
||||
" file that contains additional compiler arguments like include directories or
|
||||
" CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_c_config':
|
||||
"
|
||||
" let g:syntastic_c_config_file = '.config'
|
||||
"
|
||||
" 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
|
||||
"
|
||||
" Use the variable 'g:syntastic_c_errorformat' to override the default error
|
||||
" format:
|
||||
"
|
||||
" let g:syntastic_c_errorformat = '%f:%l:%c: %trror: %m'
|
||||
"
|
||||
" Set your compiler executable with e.g. (defaults to gcc)
|
||||
"
|
||||
" let g:syntastic_c_compiler = 'clang'
|
||||
|
||||
if exists('g:loaded_syntastic_c_gcc_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_gcc_checker = 1
|
||||
|
||||
if !exists('g:syntastic_c_compiler')
|
||||
let g:syntastic_c_compiler = 'gcc'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_gcc_IsAvailable()
|
||||
return executable(g:syntastic_c_compiler)
|
||||
endfunction
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_c_compiler_options')
|
||||
let g:syntastic_c_compiler_options = '-std=gnu99'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_c_config_file')
|
||||
let g:syntastic_c_config_file = '.syntastic_c_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_gcc_GetLocList()
|
||||
let makeprg = g:syntastic_c_compiler . ' -x c -fsyntax-only '
|
||||
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: %trror: %m,' .
|
||||
\ '%f:%l:%c: %tarning: %m,' .
|
||||
\ '%f:%l:%c: %m,' .
|
||||
\ '%f:%l: %trror: %m,' .
|
||||
\ '%f:%l: %tarning: %m,'.
|
||||
\ '%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_c_errorformat')
|
||||
let errorformat = g:syntastic_c_errorformat
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
let makeprg .= g:syntastic_c_compiler_options
|
||||
|
||||
let makeprg .= ' ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('c')
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '\.h$'
|
||||
if exists('g:syntastic_c_check_header')
|
||||
let makeprg = g:syntastic_c_compiler .
|
||||
\ ' -c ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . g:syntastic_c_compiler_options .
|
||||
\ ' ' . syntastic#c#GetNullDevice() .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('c')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
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
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_c_config_file)
|
||||
|
||||
" 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
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'gcc'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -1,65 +0,0 @@
|
|||
"============================================================================
|
||||
"File: make.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('g:loaded_syntastic_c_make_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_make_checker = 1
|
||||
|
||||
function SyntaxCheckers_c_make_IsAvailable()
|
||||
return executable('make')
|
||||
endfunction
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_c_make_GetLocList()
|
||||
|
||||
let makeprg = 'make -sk'
|
||||
|
||||
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: %trror: %m,' .
|
||||
\ '%f:%l:%c: %tarning: %m,' .
|
||||
\ '%f:%l:%c: %m,' .
|
||||
\ '%f:%l: %trror: %m,' .
|
||||
\ '%f:%l: %tarning: %m,'.
|
||||
\ '%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_c_errorformat')
|
||||
let errorformat = g:syntastic_c_errorformat
|
||||
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
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'make'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
|
@ -1,58 +0,0 @@
|
|||
"============================================================================
|
||||
"File: oclint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: "UnCO" Lin <undercooled aT lavabit 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 setting 'g:syntastic_oclint_config_file' allows you to define a file
|
||||
" that contains additional compiler arguments like include directories or
|
||||
" CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_oclint_config':
|
||||
"
|
||||
" let g:syntastic_oclint_config_file = '.config'
|
||||
|
||||
if exists("g:loaded_syntastic_c_oclint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_oclint_checker = 1
|
||||
|
||||
function! SyntaxCheckers_c_oclint_IsAvailable()
|
||||
return executable("oclint")
|
||||
endfunction
|
||||
|
||||
if !exists('g:syntastic_oclint_config_file')
|
||||
let g:syntastic_oclint_config_file = '.syntastic_oclint_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_oclint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'oclint',
|
||||
\ 'args': '-text',
|
||||
\ 'post_args': '-- -c ' . syntastic#c#ReadConfig(g:syntastic_oclint_config_file),
|
||||
\ 'filetype': 'c',
|
||||
\ 'subchecker': 'oclint' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E%f:%l:%c: %m P1 ,' .
|
||||
\ '%E%f:%l:%c: %m P2 ,' .
|
||||
\ '%W%f:%l:%c: %m P3 ,' .
|
||||
\ '%E%f:%l:%c: fatal error: %m,' .
|
||||
\ '%E%f:%l:%c: error: %m,' .
|
||||
\ '%W%f:%l:%c: warning: %m,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'postprocess': ['compressWhitespace', 'sort'] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'oclint'})
|
|
@ -1,51 +0,0 @@
|
|||
"============================================================================
|
||||
"File: sparse.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim using sparse.pl
|
||||
"Maintainer: Daniel Walker <dwalker at fifo99 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 setting 'g:syntastic_sparse_config_file' allows you to define a file
|
||||
" that contains additional compiler arguments like include directories or
|
||||
" CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_sparse_config':
|
||||
"
|
||||
" let g:syntastic_sparse_config_file = '.config'
|
||||
|
||||
if exists("g:loaded_syntastic_c_sparse_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_sparse_checker = 1
|
||||
|
||||
function! SyntaxCheckers_c_sparse_IsAvailable()
|
||||
return executable("sparse")
|
||||
endfunction
|
||||
|
||||
if !exists('g:syntastic_sparse_config_file')
|
||||
let g:syntastic_sparse_config_file = '.syntastic_sparse_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_sparse_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'sparse',
|
||||
\ 'args': '-ftabstop=' . &ts . ' ' . syntastic#c#ReadConfig(g:syntastic_sparse_config_file),
|
||||
\ 'filetype': 'c',
|
||||
\ 'subchecker': 'sparse' })
|
||||
|
||||
let errorformat = '%f:%l:%v: %trror: %m,%f:%l:%v: %tarning: %m,'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")},
|
||||
\ 'returns': [0] })
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'sparse'})
|
|
@ -1,57 +0,0 @@
|
|||
"============================================================================
|
||||
"File: splint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 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 setting 'g:syntastic_splint_config_file' allows you to define a file
|
||||
" that contains additional compiler arguments like include directories or
|
||||
" CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_splint_config':
|
||||
"
|
||||
" let g:syntastic_splint_config_file = '.config'
|
||||
|
||||
if exists("g:loaded_syntastic_c_splint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_splint_checker = 1
|
||||
|
||||
function! SyntaxCheckers_c_splint_IsAvailable()
|
||||
return executable("splint")
|
||||
endfunction
|
||||
|
||||
if !exists('g:syntastic_splint_config_file')
|
||||
let g:syntastic_splint_config_file = '.syntastic_splint_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_splint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'splint',
|
||||
\ 'post_args': '-showfunc -hints +quiet ' . syntastic#c#ReadConfig(g:syntastic_splint_config_file),
|
||||
\ 'filetype': 'c',
|
||||
\ 'subchecker': 'splint' })
|
||||
|
||||
let errorformat =
|
||||
\ '%-G%f:%l:%v: %[%#]%[%#]%[%#] Internal Bug %.%#,' .
|
||||
\ '%W%f:%l:%v: %m,' .
|
||||
\ '%W%f:%l: %m,' .
|
||||
\ '%-C %\+In file included from %.%#,' .
|
||||
\ '%-C %\+from %.%#,' .
|
||||
\ '%+C %.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'postprocess': ['compressWhitespace'],
|
||||
\ 'defaults': {'type': 'W'} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'splint'})
|
|
@ -1,32 +0,0 @@
|
|||
"============================================================================
|
||||
"File: ycm.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Val Markovic <val at markovic dot io>
|
||||
"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_c_ycm_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_ycm_checker = 1
|
||||
|
||||
function! SyntaxCheckers_c_ycm_IsAvailable()
|
||||
return exists('g:loaded_youcompleteme')
|
||||
endfunction
|
||||
|
||||
if !exists('g:loaded_youcompleteme')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_ycm_GetLocList()
|
||||
return youcompleteme#CurrentFileDiagnostics()
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'c',
|
||||
\ 'name': 'ycm'})
|
|
@ -1,44 +0,0 @@
|
|||
"============================================================================
|
||||
"File: co.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Andrew Kelley <superjoe30@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("g:loaded_syntastic_co_coco_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_co_coco_checker=1
|
||||
|
||||
"bail if the user doesnt have coco installed
|
||||
if !executable("coco")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_co_coco_GetLocList()
|
||||
return executable('coco')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_co_coco_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'coco',
|
||||
\ 'args': '-c -o /tmp',
|
||||
\ 'filetype': 'co',
|
||||
\ 'subchecker': 'coco' })
|
||||
|
||||
let errorformat =
|
||||
\ '%EFailed at: %f,' .
|
||||
\ '%ZSyntax%trror: %m on line %l,'.
|
||||
\ '%EFailed at: %f,'.
|
||||
\ '%Z%trror: Parse error on line %l: %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'co',
|
||||
\ 'name': 'coco'})
|
|
@ -1,48 +0,0 @@
|
|||
"============================================================================
|
||||
"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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" Note: this script requires CoffeeScript version 1.6.2 or newer.
|
||||
"
|
||||
if exists("g:loaded_syntastic_coffee_coffee_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_coffee_coffee_checker=1
|
||||
|
||||
function! SyntaxCheckers_coffee_coffee_IsAvailable()
|
||||
return executable("coffee") &&
|
||||
\ syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('coffee --version 2>' . syntastic#util#DevNull()), [1,6,2])
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_coffee_coffee_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'coffee',
|
||||
\ 'args': '-cp',
|
||||
\ 'filetype': 'coffee',
|
||||
\ 'subchecker': 'coffee' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E%f:%l:%c: %trror: %m,' .
|
||||
\ '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,' .
|
||||
\ '%W%f(%l): warning: %m,' .
|
||||
\ '%E%f(%l): SyntaxError: %m,' .
|
||||
\ '%-Z%p^,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'coffee',
|
||||
\ 'name': 'coffee'})
|
|
@ -1,38 +0,0 @@
|
|||
"============================================================================
|
||||
"File: coffeelint.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("g:loaded_syntastic_coffee_coffeelint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_coffee_coffeelint_checker=1
|
||||
|
||||
function! SyntaxCheckers_coffee_coffeelint_IsAvailable()
|
||||
return executable('coffeelint')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_coffee_coffeelint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'coffeelint',
|
||||
\ 'args': '--csv',
|
||||
\ 'filetype': 'coffee',
|
||||
\ 'subchecker': 'coffeelint' })
|
||||
|
||||
let errorformat = '%f\,%l\,%trror\,%m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style' })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'coffee',
|
||||
\ 'name': 'coffeelint'})
|
|
@ -1,40 +0,0 @@
|
|||
"============================================================================
|
||||
"File: coqtop.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Matvey Aksenov <matvey.aksenov 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:loaded_syntastic_coq_coqtop_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_coq_coqtop_checker=1
|
||||
|
||||
function! SyntaxCheckers_coq_coqtop_IsAvailable()
|
||||
return executable('coqtop')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_coq_coqtop_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'coqtop',
|
||||
\ 'args': '-noglob -batch -load-vernac-source',
|
||||
\ 'filetype': 'coq',
|
||||
\ 'subchecker': 'coqtop' })
|
||||
|
||||
let errorformat =
|
||||
\ '%AFile \"%f\"\, line %l\, characters %c\-%.%#\:,'.
|
||||
\ '%C%m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'coq',
|
||||
\ 'name': 'coqtop'})
|
|
@ -1,65 +0,0 @@
|
|||
"============================================================================
|
||||
"File: cpplint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" For details about cpplint see:
|
||||
" https://code.google.com/p/google-styleguide/
|
||||
"
|
||||
" Checker options:
|
||||
"
|
||||
" - g:syntastic_cpp_cpplint_thres (integer; default: 5)
|
||||
" error threshold: policy violations with a severity above this
|
||||
" value are highlighted as errors, the others are warnings
|
||||
"
|
||||
" - g:syntastic_cpp_cpplint_args (string; default: '--verbose=3')
|
||||
" command line options to pass to cpplint
|
||||
|
||||
if exists("g:loaded_syntastic_cpp_cpplint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_cpplint_checker = 1
|
||||
|
||||
if !exists('g:syntastic_cpp_cpplint_thres')
|
||||
let g:syntastic_cpp_cpplint_thres = 5
|
||||
endif
|
||||
|
||||
if ! exists('g:syntastic_cpp_cpplint_args')
|
||||
let g:syntastic_cpp_cpplint_args = '--verbose=3'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cpp_cpplint_IsAvailable()
|
||||
return executable('cpplint.py')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_cpp_cpplint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'cpplint.py',
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'subchecker': 'cpplint' })
|
||||
|
||||
let errorformat = '%A%f:%l: %m [%t],%-G%.%#'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style' })
|
||||
|
||||
" change error types according to the prescribed threshold
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = loclist[n]['type'] < g:syntastic_cpp_cpplint_thres ? 'W' : 'E'
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'cpplint'})
|
|
@ -1,179 +0,0 @@
|
|||
"============================================================================
|
||||
"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:
|
||||
"
|
||||
" 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 disable the include of the default include dirs (such as /usr/include)
|
||||
" add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_cpp_no_default_include_dirs = 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'
|
||||
"
|
||||
" 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_cpp_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_cpp_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" 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'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_cpp_config_file' allows you to define
|
||||
" a file that contains additional compiler arguments like include directories
|
||||
" or CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_cpp_config':
|
||||
"
|
||||
" let g:syntastic_cpp_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_cpp_remove_include_errors' you can
|
||||
" specify whether errors of files included via the
|
||||
" g:syntastic_cpp_include_dirs' setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_cpp_remove_include_errors = 1
|
||||
"
|
||||
" Use the variable 'g:syntastic_cpp_errorformat' to override the default error
|
||||
" format:
|
||||
"
|
||||
" let g:syntastic_cpp_errorformat = '%f:%l:%c: %trror: %m'
|
||||
"
|
||||
" Set your compiler executable with e.g. (defaults to g++)
|
||||
"
|
||||
" let g:syntastic_cpp_compiler = 'clang++'
|
||||
|
||||
if exists('g:loaded_syntastic_cpp_gcc_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_gcc_checker = 1
|
||||
|
||||
if !exists('g:syntastic_cpp_compiler')
|
||||
let g:syntastic_cpp_compiler = 'g++'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cpp_gcc_IsAvailable()
|
||||
return executable(g:syntastic_cpp_compiler)
|
||||
endfunction
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_cpp_compiler_options')
|
||||
let g:syntastic_cpp_compiler_options = ''
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_cpp_config_file')
|
||||
let g:syntastic_cpp_config_file = '.syntastic_cpp_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cpp_gcc_GetLocList()
|
||||
let makeprg = g:syntastic_cpp_compiler . ' -x c++ -fsyntax-only '
|
||||
let errorformat =
|
||||
\ '%-G%f:%s:,' .
|
||||
\ '%f:%l:%c: %trror: %m,' .
|
||||
\ '%f:%l:%c: %tarning: %m,' .
|
||||
\ '%f:%l:%c: %m,'.
|
||||
\ '%f:%l: %trror: %m,'.
|
||||
\ '%f:%l: %tarning: %m,'.
|
||||
\ '%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_cpp_errorformat')
|
||||
let errorformat = g:syntastic_cpp_errorformat
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
let makeprg .= g:syntastic_cpp_compiler_options
|
||||
|
||||
let makeprg .= ' ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '\.\(h\|hpp\|hh\)$'
|
||||
if exists('g:syntastic_cpp_check_header')
|
||||
let makeprg = g:syntastic_cpp_compiler .
|
||||
\ ' -c ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . g:syntastic_cpp_compiler_options .
|
||||
\ ' ' . syntastic#c#GetNullDevice() .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_cpp_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_cpp_no_include_search') ||
|
||||
\ g:syntastic_cpp_no_include_search != 1
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_cpp_auto_refresh_includes') &&
|
||||
\ g:syntastic_cpp_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_cpp_includes')
|
||||
let b:syntastic_cpp_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_cpp_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= b:syntastic_cpp_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_cpp_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_cpp_remove_include_errors') &&
|
||||
\ g:syntastic_cpp_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'gcc'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -1,36 +0,0 @@
|
|||
"============================================================================
|
||||
"File: oclint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: "UnCO" Lin <undercooled aT lavabit 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 setting 'g:syntastic_oclint_config_file' allows you to define a file
|
||||
" that contains additional compiler arguments like include directories or
|
||||
" CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_oclint_config':
|
||||
"
|
||||
" let g:syntastic_oclint_config_file = '.config'
|
||||
|
||||
if exists("g:loaded_syntastic_cpp_oclint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_oclint_checker = 1
|
||||
|
||||
function! SyntaxCheckers_cpp_oclint_IsAvailable()
|
||||
return SyntaxCheckers_c_oclint_IsAvailable()
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_cpp_oclint_GetLocList()
|
||||
return SyntaxCheckers_c_oclint_GetLocList()
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'oclint'})
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
|
@ -1,34 +0,0 @@
|
|||
"============================================================================
|
||||
"File: ycm.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Val Markovic <val at markovic dot io>
|
||||
"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_cpp_ycm_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cpp_ycm_checker = 1
|
||||
|
||||
function! SyntaxCheckers_cpp_ycm_IsAvailable()
|
||||
return SyntaxCheckers_c_ycm_IsAvailable()
|
||||
endfunction
|
||||
|
||||
if !exists('g:loaded_youcompleteme')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cpp_ycm_GetLocList()
|
||||
return SyntaxCheckers_c_ycm_GetLocList()
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cpp',
|
||||
\ 'name': 'ycm'})
|
||||
|
||||
runtime! syntax_checkers/c/*.vim
|
|
@ -1,39 +0,0 @@
|
|||
"============================================================================
|
||||
"File: cs.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Daniel Walker <dwalker@fifo99.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:loaded_syntastic_cs_mcs_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cs_mcs_checker=1
|
||||
|
||||
function! SyntaxCheckers_cs_mcs_IsAvailable()
|
||||
return executable('mcs')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_cs_mcs_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'mcs',
|
||||
\ 'args': '--parse',
|
||||
\ 'filetype': 'cs',
|
||||
\ 'subchecker': 'mcs' })
|
||||
|
||||
let errorformat = '%f(%l\,%c): %trror %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cs',
|
||||
\ 'name': 'mcs'})
|
|
@ -1,54 +0,0 @@
|
|||
"============================================================================
|
||||
"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.
|
||||
"============================================================================
|
||||
"
|
||||
" Specify additional options to csslint with this option. e.g. to disable
|
||||
" warnings:
|
||||
"
|
||||
" let g:syntastic_csslint_options = "--warnings=none"
|
||||
|
||||
if exists("g:loaded_syntastic_css_csslint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_css_csslint_checker=1
|
||||
|
||||
if !exists('g:syntastic_csslint_options')
|
||||
let g:syntastic_csslint_options = ""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_css_csslint_IsAvailable()
|
||||
return executable('csslint')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_css_csslint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'csslint',
|
||||
\ 'args': '--format=compact ' . g:syntastic_csslint_options,
|
||||
\ 'filetype': 'css',
|
||||
\ 'subchecker': 'csslint' })
|
||||
|
||||
" 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
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'css',
|
||||
\ 'name': 'csslint'})
|
|
@ -1,33 +0,0 @@
|
|||
"============================================================================
|
||||
"File: phpcs.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" See here for details of phpcs
|
||||
" - phpcs (see http://pear.php.net/package/PHP_CodeSniffer)
|
||||
"
|
||||
if exists("g:loaded_syntastic_css_phpcs_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_css_phpcs_checker=1
|
||||
|
||||
function! SyntaxCheckers_css_phpcs_IsAvailable()
|
||||
return SyntaxCheckers_php_phpcs_IsAvailable()
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_css_phpcs_GetLocList()
|
||||
return SyntaxCheckers_php_phpcs_GetLocList()
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'css',
|
||||
\ 'name': 'phpcs'})
|
||||
|
||||
runtime! syntax_checkers/php/*.vim
|
|
@ -1,62 +0,0 @@
|
|||
"============================================================================
|
||||
"File: prettycss.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" For details about PrettyCSS see:
|
||||
"
|
||||
" - http://fidian.github.io/PrettyCSS/
|
||||
" - https://github.com/fidian/PrettyCSS
|
||||
|
||||
if exists("g:loaded_syntastic_css_prettycss_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_css_prettycss_checker=1
|
||||
|
||||
function! SyntaxCheckers_css_prettycss_IsAvailable()
|
||||
return executable('prettycss')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_css_prettycss_GetHighlightRegex(item)
|
||||
let term = matchstr(a:item["text"], ' (\zs[^)]\+\ze)$')
|
||||
if term != ''
|
||||
let term = '\V' . term
|
||||
endif
|
||||
return term
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_css_prettycss_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'prettycss',
|
||||
\ 'filetype': 'css',
|
||||
\ 'subchecker': 'prettycss' })
|
||||
|
||||
" Print CSS Lint's error/warning messages from compact format. Ignores blank lines.
|
||||
let errorformat =
|
||||
\ '%EError: %m\, line %l\, char %c),' .
|
||||
\ '%WWarning: %m\, line %l\, char %c),' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")},
|
||||
\ 'postprocess': ['sort'] })
|
||||
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]["text"] .= ')'
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'css',
|
||||
\ 'name': 'prettycss'})
|
|
@ -1,42 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_cucumber_cucumber_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cucumber_cucumber_checker=1
|
||||
|
||||
function! SyntaxCheckers_cucumber_cucumber_IsAvailable()
|
||||
return executable('cucumber')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_cucumber_cucumber_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'cucumber',
|
||||
\ 'args': '--dry-run --quiet --strict --format pretty',
|
||||
\ 'filetype': 'cucumber',
|
||||
\ 'subchecker': 'cucumber' })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c:%m,' .
|
||||
\ '%W %.%# (%m),' .
|
||||
\ '%-Z%f:%l:%.%#,'.
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cucumber',
|
||||
\ 'name': 'cucumber'})
|
|
@ -1,72 +0,0 @@
|
|||
"============================================================================
|
||||
"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
|
||||
|
||||
" By default, nvcc and thus syntastic, defaults to the most basic architecture.
|
||||
" This can produce false errors if the developer intends to compile for newer
|
||||
" hardware and use newer features, eg. double precision numbers. To pass a
|
||||
" specific target arch to nvcc, e.g. add the following to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_cuda_arch = "sm_20"
|
||||
|
||||
|
||||
if exists("g:loaded_syntastic_cuda_nvcc_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_cuda_nvcc_checker=1
|
||||
|
||||
function! SyntaxCheckers_cuda_nvcc_IsAvailable()
|
||||
return executable('nvcc')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_cuda_nvcc_GetLocList()
|
||||
if exists('g:syntastic_cuda_arch')
|
||||
let arch_flag = '-arch=' . g:syntastic_cuda_arch
|
||||
else
|
||||
let arch_flag = ''
|
||||
endif
|
||||
let makeprg =
|
||||
\ 'nvcc ' . arch_flag . ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' .
|
||||
\ syntastic#util#shexpand('%') . ' ' . syntastic#c#GetNullDevice()
|
||||
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 ' . arch_flag . ' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include ' .
|
||||
\ syntastic#util#shexpand('%') . ' ' . syntastic#c#GetNullDevice()
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'cuda',
|
||||
\ 'name': 'nvcc'})
|
|
@ -1,177 +0,0 @@
|
|||
"============================================================================
|
||||
"File: d.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Alfredo Di Napoli <alfredo dot dinapoli at gmail dot com>
|
||||
"License: Based on the original work of Gregor Uhlenheuer and his
|
||||
" cpp.vim checker so credits are dued.
|
||||
" 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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" In order to also check header files add this to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_d_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_d_no_include_search = 1
|
||||
"
|
||||
" To disable the include of the default include dirs (such as /usr/include)
|
||||
" add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_d_no_default_include_dirs = 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_d_includes. Then the header files are being re-checked
|
||||
" on the next file write.
|
||||
"
|
||||
" let g:syntastic_d_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_d_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_d_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" In order to add some custom include directories that should be added to the
|
||||
" dmd command line you can add those to the global variable
|
||||
" g:syntastic_d_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_d_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_d_compiler_options':
|
||||
"
|
||||
" let g:syntastic_d_compiler_options = ' -std=c++0x'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_d_config_file' allows you to define
|
||||
" a file that contains additional compiler arguments like include directories
|
||||
" or CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_d_config':
|
||||
"
|
||||
" let g:syntastic_d_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_d_remove_include_errors' you can
|
||||
" specify whether errors of files included via the
|
||||
" g:syntastic_d_include_dirs' setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_d_remove_include_errors = 1
|
||||
"
|
||||
" Use the variable 'g:syntastic_d_errorformat' to override the default error
|
||||
" format:
|
||||
"
|
||||
" let g:syntastic_d_errorformat = '%f:%l:%c: %trror: %m'
|
||||
"
|
||||
" Set your compiler executable with e.g. (defaults to dmd)
|
||||
"
|
||||
" let g:syntastic_d_compiler = 'clang++'
|
||||
|
||||
if exists('g:loaded_syntastic_d_dmd_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_d_dmd_checker = 1
|
||||
|
||||
if !exists('g:syntastic_d_compiler')
|
||||
let g:syntastic_d_compiler = 'dmd'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_d_dmd_IsAvailable()
|
||||
return executable(g:syntastic_d_compiler)
|
||||
endfunction
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_d_compiler_options')
|
||||
let g:syntastic_d_compiler_options = ''
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_d_config_file')
|
||||
let g:syntastic_d_config_file = '.syntastic_d_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_d_dmd_GetLocList()
|
||||
let makeprg = g:syntastic_d_compiler . ' -c -of' . syntastic#util#DevNull() . ' '
|
||||
let errorformat = '%-G%f:%s:,%f(%l): %m,%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_d_errorformat')
|
||||
let errorformat = g:syntastic_d_errorformat
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
let makeprg .= g:syntastic_d_compiler_options
|
||||
|
||||
let makeprg .= ' ' . syntastic#util#shexpand('%') .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('d')
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '\.di$'
|
||||
if exists('g:syntastic_d_check_header')
|
||||
let makeprg = g:syntastic_d_compiler .
|
||||
\ ' -c ' . syntastic#util#shexpand('%') .
|
||||
\ ' -of' . syntastic#util#DevNull() .
|
||||
\ ' ' . g:syntastic_d_compiler_options .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('d')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_d_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_d_no_include_search') ||
|
||||
\ g:syntastic_d_no_include_search != 1
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_d_auto_refresh_includes') &&
|
||||
\ g:syntastic_d_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_d_includes')
|
||||
let b:syntastic_d_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_d_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= b:syntastic_d_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_d_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_d_remove_include_errors') &&
|
||||
\ g:syntastic_d_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'd',
|
||||
\ 'name': 'dmd'})
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
|
@ -1,66 +0,0 @@
|
|||
"============================================================================
|
||||
"File: dart_analyzer.vim
|
||||
"Description: Dart syntax checker - using dart_analyzer
|
||||
"Maintainer: Maksim Ryzhikov <rv.maksim 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:loaded_syntastic_dart_dart_analyzer_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_dart_dart_analyzer_checker=1
|
||||
|
||||
if !exists("g:syntastic_dart_analyzer_conf")
|
||||
let g:syntastic_dart_analyzer_conf = ''
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_dart_dart_analyzer_IsAvailable()
|
||||
return executable("dart_analyzer")
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_dart_dart_analyzer_GetHighlightRegex(error)
|
||||
let lcol = a:error['col'] - 1
|
||||
let rcol = a:error['nr'] + lcol + 1
|
||||
|
||||
return '\%>'.lcol.'c\%<'.rcol.'c'
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_dart_dart_analyzer_GetLocList()
|
||||
let args = !empty(g:syntastic_dart_analyzer_conf) ? ' ' . g:syntastic_dart_analyzer_conf : ''
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'dart_analyzer',
|
||||
\ 'args': '--error_format machine',
|
||||
\ 'post_args': args,
|
||||
\ 'filetype': 'dart',
|
||||
\ 'subchecker': 'dart_analyzer' })
|
||||
|
||||
" Machine readable format looks like:
|
||||
" SEVERITY|TYPE|ERROR_CODE|file:FILENAME|LINE_NUMBER|COLUMN|LENGTH|MESSAGE
|
||||
" SEVERITY: (WARNING|ERROR)
|
||||
" TYPE: (RESOLVER|STATIC_TYPE|...)
|
||||
" ERROR_CODE: (NO_SUCH_TYPE|...)
|
||||
" FILENAME: String
|
||||
" LINE_NUMBER: int
|
||||
" COLUMN: int
|
||||
" LENGHT: int
|
||||
" MESSAGE: String
|
||||
|
||||
" We use %n to grab the error length to be able to access it in the matcher.
|
||||
let commonformat = '|%.%#|%.%#|file:%f|%l|%c|%n|%m'
|
||||
|
||||
" TODO(amouravski): simply take everything after ERROR|WARNING as a message
|
||||
" and then parse it by hand later.
|
||||
let errorformat = '%EERROR'.l:commonformat.','.
|
||||
\'%WWARNING'.l:commonformat
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'dart',
|
||||
\ 'name': 'dart_analyzer'})
|
|
@ -1,30 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_docbk_xmllint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_docbk_xmllint_checker=1
|
||||
|
||||
function! SyntaxCheckers_docbk_xmllint_IsAvailable()
|
||||
return SyntaxCheckers_xml_xmllint_IsAvailable()
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_docbk_xmllint_GetLocList()
|
||||
return SyntaxCheckers_xml_xmllint_GetLocList()
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'docbk',
|
||||
\ 'name': 'xmllint'})
|
||||
|
||||
runtime! syntax_checkers/xml/*.vim
|
|
@ -1,45 +0,0 @@
|
|||
"============================================================================
|
||||
"File: elixir.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Richard Ramsden <rramsden 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:loaded_syntastic_elixir_elixir_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_elixir_elixir_checker=1
|
||||
|
||||
" TODO: we should probably split this into separate checkers
|
||||
function! SyntaxCheckers_elixir_elixir_IsAvailable()
|
||||
return executable('elixir') && executable('mix')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_elixir_elixir_GetLocList()
|
||||
|
||||
let make_options = {}
|
||||
let compile_command = 'elixir'
|
||||
let mix_file = syntastic#util#findInParent('mix.exs', expand('%:p:h'))
|
||||
|
||||
if filereadable(mix_file)
|
||||
let compile_command = 'mix compile'
|
||||
let make_options['cwd'] = fnamemodify(mix_file, ':p:h')
|
||||
endif
|
||||
|
||||
let make_options['makeprg'] = syntastic#makeprg#build({
|
||||
\ 'exe': compile_command,
|
||||
\ 'filetype': 'elixir',
|
||||
\ 'subchecker': 'elixir' })
|
||||
|
||||
let make_options['errorformat'] = '** %*[^\ ] %f:%l: %m'
|
||||
|
||||
return SyntasticMake(make_options)
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'elixir',
|
||||
\ 'name': 'elixir'})
|
|
@ -1,51 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_erlang_erlang_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_erlang_erlang_checker=1
|
||||
|
||||
let s:check_file = expand('<sfile>:p:h') . '/erlang_check_file.erl'
|
||||
if !exists("g:syntastic_erlc_include_path")
|
||||
let g:syntastic_erlc_include_path=""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_erlang_escript_IsAvailable()
|
||||
return executable('escript')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_erlang_escript_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 ' . syntastic#util#shexpand('%:p')
|
||||
else
|
||||
let makeprg = 'escript ' . s:check_file . ' ' . syntastic#util#shexpand('%:p') . ' ' . g:syntastic_erlc_include_path
|
||||
endif
|
||||
else
|
||||
let makeprg = 'escript ' . s:check_file . ' ' . syntastic#util#shexpand('%:p') . ' '. g:syntastic_erlc_include_path
|
||||
endif
|
||||
let errorformat =
|
||||
\ '%f:%l:\ %tarning:\ %m,'.
|
||||
\ '%E%f:%l:\ %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'erlang',
|
||||
\ 'name': 'escript'})
|
|
@ -1,34 +0,0 @@
|
|||
#!/usr/bin/env escript
|
||||
-export([main/1]).
|
||||
|
||||
main([FileName]) ->
|
||||
LibDirs = filelib:wildcard("{lib,deps}/*/ebin"),
|
||||
compile(FileName, LibDirs);
|
||||
main([FileName | LibDirs]) ->
|
||||
compile(FileName, LibDirs).
|
||||
|
||||
compile(FileName, LibDirs) ->
|
||||
Root = get_root(filename:dirname(FileName)),
|
||||
ok = code:add_pathsa(LibDirs),
|
||||
compile:file(FileName, [warn_obsolete_guard,
|
||||
warn_unused_import,
|
||||
warn_shadow_vars,
|
||||
warn_export_vars,
|
||||
strong_validation,
|
||||
report,
|
||||
{i, filename:join(Root, "include")},
|
||||
{i, filename:join(Root, "deps")},
|
||||
{i, filename:join(Root, "apps")},
|
||||
{i, filename:join(Root, "lib")}
|
||||
]).
|
||||
|
||||
get_root(Dir) ->
|
||||
Path = filename:split(filename:absname(Dir)),
|
||||
filename:join(get_root(lists:reverse(Path), Path)).
|
||||
|
||||
get_root([], Path) ->
|
||||
Path;
|
||||
get_root(["src" | Tail], _Path) ->
|
||||
lists:reverse(Tail);
|
||||
get_root([_ | Tail], Path) ->
|
||||
get_root(Tail, Path).
|
|
@ -1,65 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_eruby_ruby_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_eruby_ruby_checker=1
|
||||
|
||||
if !exists("g:syntastic_ruby_exec")
|
||||
let g:syntastic_ruby_exec = "ruby"
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_eruby_ruby_IsAvailable()
|
||||
return executable(expand(g:syntastic_ruby_exec))
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_eruby_ruby_GetLocList()
|
||||
let exe = expand(g:syntastic_ruby_exec)
|
||||
if !has('win32')
|
||||
let exe = 'RUBYOPT= ' . exe
|
||||
endif
|
||||
|
||||
let fname = "'" . escape(expand('%'), "\\'") . "'"
|
||||
|
||||
" TODO: encodings became useful in ruby 1.9 :)
|
||||
if syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('ruby --version'), [1, 9])
|
||||
let enc = &fileencoding != '' ? &fileencoding : &encoding
|
||||
let encoding_spec = ', :encoding => "' . (enc ==? 'utf-8' ? 'UTF-8' : 'BINARY') . '"'
|
||||
else
|
||||
let encoding_spec = ''
|
||||
endif
|
||||
|
||||
"gsub fixes issue #7, rails has it's own eruby syntax
|
||||
let makeprg =
|
||||
\ exe . ' -rerb -e ' .
|
||||
\ syntastic#util#shescape('puts ERB.new(File.read(' .
|
||||
\ fname . encoding_spec .
|
||||
\ ').gsub(''<\%='',''<\%''), nil, ''-'').src') .
|
||||
\ ' \| ' . exe . ' -c'
|
||||
|
||||
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(""), 'vcol': 1 } })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'eruby',
|
||||
\ 'name': 'ruby'})
|
|
@ -1,63 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_fortran_gfortran_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_fortran_gfortran_checker=1
|
||||
|
||||
if !exists('g:syntastic_fortran_flags')
|
||||
let g:syntastic_fortran_flags = ''
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_fortran_gfortran_IsAvailable()
|
||||
return executable('gfortran')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_fortran_gfortran_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'gfortran',
|
||||
\ 'args': s:args(),
|
||||
\ 'filetype': 'fortran',
|
||||
\ 'subchecker': 'gfortran' })
|
||||
|
||||
let errorformat =
|
||||
\ '%-C %#,'.
|
||||
\ '%-C %#%.%#,'.
|
||||
\ '%A%f:%l.%c:,'.
|
||||
\ '%Z%m,'.
|
||||
\ '%G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
function s:args()
|
||||
let rv = '-fsyntax-only ' . g:syntastic_fortran_flags
|
||||
if exists('b:syntastic_fortran_flags')
|
||||
let rv .= " " . b:syntastic_fortran_flags
|
||||
endif
|
||||
return rv
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'fortran',
|
||||
\ 'name': 'gfortran'})
|
|
@ -1,75 +0,0 @@
|
|||
"============================================================================
|
||||
"File: go.vim
|
||||
"Description: Check go syntax using 'gofmt -l' followed by 'go [build|test]'
|
||||
"Maintainer: Kamil Kisiel <kamil@kamilkisiel.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.
|
||||
"
|
||||
" This syntax checker does not reformat your source code.
|
||||
" Use a BufWritePre autocommand to that end:
|
||||
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_go_go_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_go_go_checker=1
|
||||
|
||||
function! SyntaxCheckers_go_go_IsAvailable()
|
||||
return executable('go')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_go_go_GetLocList()
|
||||
" Check with gofmt first, since `go build` and `go test` might not report
|
||||
" syntax errors in the current file if another file with syntax error is
|
||||
" compiled first.
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'gofmt',
|
||||
\ 'args': '-l',
|
||||
\ 'tail': '1>' . syntastic#util#DevNull(),
|
||||
\ 'filetype': 'go',
|
||||
\ 'subchecker': 'go' })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c: %m,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
let errors = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'type': 'e'} })
|
||||
if !empty(errors)
|
||||
return errors
|
||||
endif
|
||||
|
||||
" Test files, i.e. files with a name ending in `_test.go`, are not
|
||||
" compiled by `go build`, therefore `go test` must be called for those.
|
||||
if match(expand('%'), '_test.go$') == -1
|
||||
let makeprg = 'go build ' . syntastic#c#GetNullDevice()
|
||||
else
|
||||
let makeprg = 'go test -c ' . syntastic#c#GetNullDevice()
|
||||
endif
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c:%m,' .
|
||||
\ '%f:%l%m,' .
|
||||
\ '%-G#%.%#'
|
||||
|
||||
" The go compiler needs to either be run with an import path as an
|
||||
" argument or directly from the package directory. Since figuring out
|
||||
" the proper import path is fickle, just cwd to the package.
|
||||
|
||||
let errors = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'cwd': expand('%:p:h'),
|
||||
\ 'defaults': {'type': 'e'} })
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'go',
|
||||
\ 'name': 'go'})
|
|
@ -1,42 +0,0 @@
|
|||
"============================================================================
|
||||
"File: gofmt.vim
|
||||
"Description: Check go syntax using 'gofmt -l'
|
||||
"Maintainer: Brandon Thomson <bt@brandonthomson.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 syntax checker does not reformat your source code.
|
||||
" Use a BufWritePre autocommand to that end:
|
||||
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_go_gofmt_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_go_gofmt_checker=1
|
||||
|
||||
function! SyntaxCheckers_go_gofmt_IsAvailable()
|
||||
return executable('gofmt')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_go_gofmt_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'gofmt',
|
||||
\ 'args': '-l',
|
||||
\ 'tail': '1>' . syntastic#util#DevNull(),
|
||||
\ 'filetype': 'go',
|
||||
\ 'subchecker': 'gofmt' })
|
||||
|
||||
let errorformat = '%f:%l:%c: %m,%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'type': 'e'} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'go',
|
||||
\ 'name': 'gofmt'})
|
|
@ -1,37 +0,0 @@
|
|||
"============================================================================
|
||||
"File: golint.vim
|
||||
"Description: Check go syntax using 'golint'
|
||||
"Maintainer: Hiroshi Ioka <hirochachacha@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("g:loaded_syntastic_go_golint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_go_golint_checker=1
|
||||
|
||||
function! SyntaxCheckers_go_golint_IsAvailable()
|
||||
return executable('golint')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_go_golint_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'golint',
|
||||
\ 'filetype': 'go',
|
||||
\ 'subchecker': 'golint' })
|
||||
|
||||
let errorformat = '%f:%l:%c: %m,%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style' })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'go',
|
||||
\ 'name': 'golint'})
|
|
@ -1,40 +0,0 @@
|
|||
"============================================================================
|
||||
"File: govet.vim
|
||||
"Description: Perform static analysis of Go code with the vet tool
|
||||
"Maintainer: Kamil Kisiel <kamil@kamilkisiel.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("g:loaded_syntastic_go_govet_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_go_govet_checker=1
|
||||
|
||||
function! SyntaxCheckers_go_govet_IsAvailable()
|
||||
return executable('go')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_go_govet_GetLocList()
|
||||
let makeprg = 'go vet'
|
||||
let errorformat = '%Evet: %.%\+: %f:%l:%c: %m,%W%f:%l: %m,%-G%.%#'
|
||||
|
||||
" The go compiler needs to either be run with an import path as an
|
||||
" argument or directly from the package directory. Since figuring out
|
||||
" the proper import path is fickle, just cwd to the package.
|
||||
|
||||
let errors = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'cwd': expand('%:p:h'),
|
||||
\ 'defaults': {'type': 'w'} })
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'go',
|
||||
\ 'name': 'govet'})
|
|
@ -1,45 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_haml_haml_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_haml_haml_checker=1
|
||||
|
||||
if !exists("g:syntastic_haml_interpreter")
|
||||
let g:syntastic_haml_interpreter = "haml"
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_haml_haml_IsAvailable()
|
||||
return executable(g:syntastic_haml_interpreter)
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haml_haml_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': g:syntastic_haml_interpreter,
|
||||
\ 'args': '-c',
|
||||
\ 'filetype': 'haml',
|
||||
\ 'subchecker': 'haml' })
|
||||
|
||||
let errorformat =
|
||||
\ 'Haml error on line %l: %m,' .
|
||||
\ 'Syntax error on line %l: %m,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'haml',
|
||||
\ 'name': 'haml'})
|
|
@ -1,47 +0,0 @@
|
|||
"============================================================================
|
||||
"File: ghc-mod.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("g:loaded_syntastic_haskell_ghc_mod_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_haskell_ghc_mod_checker=1
|
||||
|
||||
function! SyntaxCheckers_haskell_ghc_mod_IsAvailable()
|
||||
return executable('ghc-mod')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haskell_ghc_mod_GetLocList()
|
||||
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'
|
||||
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'ghc-mod check',
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'subchecker': 'ghc_mod' })
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'name': 'ghc_mod'})
|
|
@ -1,46 +0,0 @@
|
|||
"============================================================================
|
||||
"File: hdevtools.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("g:loaded_syntastic_haskell_hdevtools_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_haskell_hdevtools_checker=1
|
||||
|
||||
function! SyntaxCheckers_haskell_hdevtools_IsAvailable()
|
||||
return executable('hdevtools')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haskell_hdevtools_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'hdevtools check',
|
||||
\ 'args': get(g:, 'hdevtools_options', ''),
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'subchecker': 'hdevtools' })
|
||||
|
||||
let errorformat= '\%-Z\ %#,'.
|
||||
\ '%W%f:%l:%c:\ Warning:\ %m,'.
|
||||
\ '%E%f:%l:%c:\ %m,'.
|
||||
\ '%E%>%f:%l:%c:,'.
|
||||
\ '%+C\ \ %#%m,'.
|
||||
\ '%W%>%f:%l:%c:,'.
|
||||
\ '%+C\ \ %#%tarning:\ %m,'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'postprocess': ['compressWhitespace'] })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'name': 'hdevtools'})
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
"============================================================================
|
||||
"File: hlint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Nicolas Wu <nicolas.wu at gmail dot com>
|
||||
"License: BSD
|
||||
"============================================================================
|
||||
|
||||
if exists("g:loaded_syntastic_haskell_hlint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_haskell_hlint_checker=1
|
||||
|
||||
function! SyntaxCheckers_haskell_hlint_IsAvailable()
|
||||
return executable('hlint')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haskell_hlint_GetLocList()
|
||||
let errorformat =
|
||||
\ '%E%f:%l:%c: Error: %m,' .
|
||||
\ '%W%f:%l:%c: Warning: %m,' .
|
||||
\ '%C%m'
|
||||
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'hlint',
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'subchecker': 'hlint' })
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'postprocess': ['compressWhitespace'] })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'name': 'hlint'})
|
|
@ -1,52 +0,0 @@
|
|||
"============================================================================
|
||||
"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("g:loaded_syntastic_haxe_haxe_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_haxe_haxe_checker=1
|
||||
|
||||
function! SyntaxCheckers_haxe_haxe_IsAvailable()
|
||||
return executable('haxe')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haxe_haxe_GetLocList()
|
||||
if exists('b:vaxe_hxml')
|
||||
let hxml = b:vaxe_hxml
|
||||
elseif exists('g:vaxe_hxml')
|
||||
let hxml = g:vaxe_hxml
|
||||
else
|
||||
let hxml = syntastic#util#findInParent('*.hxml', expand('%:p:h'))
|
||||
endif
|
||||
let hxml = fnamemodify(hxml, ':p')
|
||||
|
||||
if !empty(hxml)
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'haxe',
|
||||
\ 'fname': syntastic#util#shescape(fnameescape(fnamemodify(hxml, ':t'))),
|
||||
\ 'filetype': 'haxe',
|
||||
\ 'subchecker': 'haxe' })
|
||||
|
||||
let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'cwd': fnamemodify(hxml, ':h') })
|
||||
endif
|
||||
|
||||
return []
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'haxe',
|
||||
\ 'name': 'haxe'})
|
|
@ -1,38 +0,0 @@
|
|||
"============================================================================
|
||||
"File: hss.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Justin Donaldson (jdonaldson@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("g:loaded_syntastic_hss_hss_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_hss_hss_checker=1
|
||||
|
||||
function! SyntaxCheckers_hss_hss_IsAvailable()
|
||||
return executable('hss')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_hss_hss_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'hss',
|
||||
\ 'args' : '-output ' . syntastic#util#DevNull(),
|
||||
\ 'filetype': 'hss',
|
||||
\ 'subchecker': 'hss' })
|
||||
|
||||
let errorformat = '%E%f:%l: %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'hss',
|
||||
\ 'name': 'hss'})
|
|
@ -1,174 +0,0 @@
|
|||
"============================================================================
|
||||
"File: tidy.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.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" Checker option:
|
||||
"
|
||||
" - g:syntastic_html_tidy_ignore_errors (list; default: [])
|
||||
" list of errors to ignore
|
||||
" - g:syntastic_html_tidy_blocklevel_tags (list; default: [])
|
||||
" list of additional blocklevel tags, to be added to "--new-blocklevel-tags"
|
||||
" - g:syntastic_html_tidy_inline_tags (list; default: [])
|
||||
" list of additional inline tags, to be added to "--new-inline-tags"
|
||||
" - g:syntastic_html_tidy_empty_tags (list; default: [])
|
||||
" list of additional empty tags, to be added to "--new-empty-tags"
|
||||
|
||||
if exists("g:loaded_syntastic_html_tidy_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_html_tidy_checker = 1
|
||||
|
||||
if !exists('g:syntastic_html_tidy_ignore_errors')
|
||||
let g:syntastic_html_tidy_ignore_errors = []
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_tidy_blocklevel_tags')
|
||||
let g:syntastic_html_tidy_blocklevel_tags = []
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_tidy_inline_tags')
|
||||
let g:syntastic_html_tidy_inline_tags = []
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_html_tidy_empty_tags')
|
||||
let g:syntastic_html_tidy_empty_tags = []
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_html_tidy_IsAvailable()
|
||||
return executable('tidy')
|
||||
endfunction
|
||||
|
||||
" 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',
|
||||
\'cp932' : '-shiftjis',
|
||||
\'sjis' : '-shiftjis',
|
||||
\'cp850' : '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
let s:ignore_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-",
|
||||
\ "missing <!DOCTYPE> declaration",
|
||||
\ "inserting implicit <body>",
|
||||
\ "inserting missing 'title' element",
|
||||
\ "attribute \"[+",
|
||||
\ "unescaped & or unknown entity",
|
||||
\ "<input> attribute \"type\" has invalid value \"search\""
|
||||
\ ]
|
||||
|
||||
let s:blocklevel_tags = [
|
||||
\ "main",
|
||||
\ "section",
|
||||
\ "article",
|
||||
\ "aside",
|
||||
\ "hgroup",
|
||||
\ "header",
|
||||
\ "footer",
|
||||
\ "nav",
|
||||
\ "figure",
|
||||
\ "figcaption"
|
||||
\ ]
|
||||
|
||||
let s:inline_tags = [
|
||||
\ "video",
|
||||
\ "audio",
|
||||
\ "source",
|
||||
\ "embed",
|
||||
\ "mark",
|
||||
\ "progress",
|
||||
\ "meter",
|
||||
\ "time",
|
||||
\ "ruby",
|
||||
\ "rt",
|
||||
\ "rp",
|
||||
\ "canvas",
|
||||
\ "command",
|
||||
\ "details",
|
||||
\ "datalist"
|
||||
\ ]
|
||||
|
||||
let s:empty_tags = [
|
||||
\ "wbr",
|
||||
\ "keygen"
|
||||
\ ]
|
||||
|
||||
function! s:IgnoreError(text)
|
||||
for i in s:ignore_errors + g:syntastic_html_tidy_ignore_errors
|
||||
if stridx(a:text, i) != -1
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:NewTags(name)
|
||||
return syntastic#util#shescape(join( s:{a:name} + g:syntastic_html_tidy_{a:name}, ',' ))
|
||||
endfunction
|
||||
|
||||
function s:Args()
|
||||
let args = s:TidyEncOptByFenc() .
|
||||
\ ' --new-blocklevel-tags ' . s:NewTags('blocklevel_tags') .
|
||||
\ ' --new-inline-tags ' . s:NewTags('inline_tags') .
|
||||
\ ' --new-empty-tags ' . s:NewTags('empty_tags') .
|
||||
\ ' -e'
|
||||
return args
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_tidy_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'tidy',
|
||||
\ 'args': s:Args(),
|
||||
\ 'tail': '2>&1',
|
||||
\ 'filetype': 'html',
|
||||
\ 'subchecker': 'tidy' })
|
||||
|
||||
let errorformat =
|
||||
\ '%Wline %l column %v - Warning: %m,' .
|
||||
\ '%Eline %l column %v - Error: %m,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")},
|
||||
\ 'returns': [0, 1, 2] })
|
||||
|
||||
" filter out valid HTML5 from the errors
|
||||
for n in range(len(loclist))
|
||||
if loclist[n]['valid'] && s:IgnoreError(loclist[n]['text']) == 1
|
||||
let loclist[n]['valid'] = 0
|
||||
endif
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'html',
|
||||
\ 'name': 'tidy'})
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue