1
0
Fork 0
mirror of synced 2024-11-22 08:45:34 -05:00

Updated vim plugins

This commit is contained in:
amix 2015-02-24 10:45:22 +00:00
parent 8fa0bd4574
commit d195ccb777
104 changed files with 1743 additions and 1464 deletions

View file

@ -1,131 +1,148 @@
# ack.vim # ack.vim
This plugin is a front for the Perl module Run your favorite search tool from Vim, with an enhanced results list.
[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 This plugin was designed as a Vim frontend for the Perl module [App::Ack]. Ack
ack from vim, and shows the results in a split window. can be used as a replacement for 99% of the uses of _grep_. The plugin allows
you to run ack from vim, and shows the results in a split window.
But here's a little secret for the Vim-seasoned: it's just a light wrapper for
Vim's [grepprg] and the [quickfix] window for match results. This makes it easy
to integrate with your own Vim configuration and use existing knowledge of core
features. It also means the plugin is flexible to use with other search tools.
[App::Ack]: http://search.cpan.org/~petdance/ack/ack
[grepprg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'grepprg'
[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
## Installation ## Installation
### Ack ### Ack
You will need the ack(>= 2.0), of course, to install it follow the You will need ack (>= 2.0), of course. To install it follow the
[manual](http://beyondgrep.com/install/) [manual](http://beyondgrep.com/install/).
### The Plugin ### The Plugin
To install it is recommended to use one of the popular package managers for Vim, It is recommended to use one of the popular plugin managers for Vim. There are
rather than installing by drag and drop all required files into your `.vim` folder. many and you probably already have a preferred one, but a few examples for your
copy-and-paste convenience:
#### Manual (not recommended)
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)
#### Vundle #### Vundle
Bundle 'mileszs/ack.vim' Plugin 'mileszs/ack.vim'
#### NeoBundle #### NeoBundle
NeoBundle 'mileszs/ack.vim' NeoBundle 'mileszs/ack.vim'
#### Manual (not recommended)
[Download][releases] the plugin and extract it in `~/.vim/` (or
`%PROGRAMFILES%/Vim/vimfiles` on Windows).
[zipball]: https://github.com/mileszs/ack.vim/archive/master.zip
## Usage ## Usage
:Ack [options] {pattern} [{directories}] :Ack [options] {pattern} [{directories}]
Search recursively in {directory} (which defaults to the current directory) for Search recursively in `{directories}` (which defaults to the current directory)
the {pattern}. for the `{pattern}`.
Files containing the search term will be listed in the split window, along with Files containing the search term will be listed in the quickfix window, along
the line number of the occurrence, once for each occurrence. [Enter] on a line with the line number of the occurrence, once for each occurrence. `<Enter>` on
in this window will open the file, and place the cursor on the matching line. 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 Just like where you use `:grep`, `:grepadd`, `:lgrep`, and :`lgrepadd`, you can
`:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `:help Ack`
(See `doc/ack.txt`, or install and `:h Ack` for more information.) after installing, or [`doc/ack.txt`][doc] in the repo, for more information.)
For more ack options see For more ack help see [ack documentation](http://beyondgrep.com/documentation/).
[ack documentation](http://beyondgrep.com/documentation/)
[doc]: https://github.com/mileszs/ack.vim/blob/master/doc/ack.txt
### Keyboard Shortcuts ### Keyboard Shortcuts
In the quickfix window, you can use: The quickfix results window is augmented with these convenience mappings:
o to open (same as enter) ? a quick summary of these keys, repeat to close
O to open and close quickfix window o to open (same as Enter)
go to preview file (open but maintain focus on ack.vim results) O to open and close the 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
T to open in new tab silently T to open in new tab without moving to it
h to open in horizontal split h to open in horizontal split
H to open in horizontal split silently H to open in horizontal split, keeping focus on the results
v to open in vertical split v to open in vertical split
gv to open in vertical split silently gv to open in vertical split, keeping focus on the results
q to close the quickfix window 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
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://beyondgrep.com/).
### Gotchas ### Gotchas
Some characters have special meaning, and need to be escaped your search Some characters have special meaning, and need to be escaped in your search
pattern. For instance, '#'. You have to escape it like this `:Ack '\\\#define pattern. For instance, `#`. You need to escape it with `:Ack '\\\#define
foo'` to search for '#define foo'. (From blueyed in issue #5.) foo'` to search for '#define foo'. See [issue #5].
[issue #5]: https://github.com/mileszs/ack.vim/issues/5
## Possibly FAQ
#### Can I use `ag` ([The Silver Searcher]) with this?
Absolutely, and probably other tools if their output is similar or you can
write a pattern match for it--just set `g:ackprg`. If you like, you can fall
back to Ack in case you use your vimrc on a system without Ag available:
```vim
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
```
Since Ack is quite portable you might check a copy of it into your dotfiles
repository in `~/bin` so you'll nearly always have it available.
#### What's the difference from ag.vim?
Well... not a lot really.
Present maintainer, yours truly, [kind of wishes they never forked][sadface],
contributes to both, and wouldn't mind seeing them merged again. ag.vim got a
nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked
up a few features that haven't made their way to ag.vim, like `:AckWindow`,
optional background search execution with [vim-dispatch], and auto-previewing.
[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher
[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145
## Changelog ## Changelog
### 1.0 Please see [the Github releases page][releases].
* Remove support to ack 1.x ### 1.0.9 (unreleased)
* 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 * Fix location list and layout of quickfix when using Dispatch (#154)
* Fix the quick help overlay clobbering the list mappings
* Fix `:AckFile` when using Dispatch
* Restore original `'makeprg'` and `'errorformat'` when using Dispatch
* Internal refactoring and clean-up
* Fixes #124. Bug with `g:ack_autofold_results` ## Credits
### 1.0.2 This plugin is derived from Antoine Imbert's blog post [Ack and Vim
Integration][] (in particular, the function in the update to the post). [Miles
Sterrett][mileszs] packaged it up as a plugin and documented it in Vim's help
format, and since then [many contributors][contributors] have submitted
enhancements and fixes.
* Add compatibility with [vim-dispatch](https://github.com/tpope/vim-dispatch) And of course, where would we be without [Ack]. And, you know, Vim.
### 1.0.3 [Ack and Vim Integration]: http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html
[mileszs]: https://github.com/mileszs
[contributors]: https://github.com/mileszs/ack.vim/graphs/contributors
[Ack]: http://beyondgrep.com/
* Fixes #127. Use `&l:hlsearch` instead of `v:hlsearch` to keep compatibility [vim-dispatch]: https://github.com/tpope/vim-dispatch
with versions that does not have this variable. [releases]: https://github.com/mileszs/ack.vim/releases
### 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

View file

@ -1,6 +1,30 @@
function! ack#Ack(cmd, args) if exists('g:ack_use_dispatch')
if g:ack_use_dispatch && !exists(':Dispatch')
call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.')
let g:ack_use_dispatch = 0
endif
else
let g:ack_use_dispatch = 0
end
"-----------------------------------------------------------------------------
" Public API
"-----------------------------------------------------------------------------
function! ack#Ack(cmd, args) "{{{
call s:Init(a:cmd)
redraw redraw
echo "Searching ..."
" Local values that we'll temporarily set as options when searching
let l:grepprg = g:ackprg
let l:grepformat = '%f:%l:%c:%m,%f:%l:%m' " Include column number
" Strip some options that are meaningless for path search and set match
" format accordingly.
if s:SearchingFilepaths()
let l:grepprg = substitute(l:grepprg, '-H\|--column', '', 'g')
let l:grepformat = '%f'
endif
" If no pattern is provided, search for the word under the cursor " If no pattern is provided, search for the word under the cursor
if empty(a:args) if empty(a:args)
@ -8,74 +32,83 @@ function! ack#Ack(cmd, args)
else else
let l:grepargs = a:args . join(a:000, ' ') let l:grepargs = a:args . join(a:000, ' ')
end 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 " NOTE: we escape special chars, but not everything using shellescape to
" allow for passing arguments etc " allow for passing arguments etc
let l:escaped_args = escape(l:grepargs, '|#%')
echo "Searching ..."
if g:ack_use_dispatch if g:ack_use_dispatch
let &l:errorformat = g:ackformat call s:SearchWithDispatch(l:grepprg, l:escaped_args, l:grepformat)
let &l:makeprg=g:ackprg." " . escape(l:grepargs, '|#%')
Make
else else
silent execute a:cmd . " " . escape(l:grepargs, '|#%') call s:SearchWithGrep(a:cmd, l:grepprg, l:escaped_args, l:grepformat)
endif endif
finally " Dispatch has no callback mechanism currently, we just have to display the
let &grepprg=grepprg_bak " list window early and wait for it to populate :-/
let &grepformat=grepformat_bak call ack#ShowResults()
endtry call s:Highlight(l:grepargs)
endfunction "}}}
if a:cmd =~# '^l' function! ack#AckFromSearch(cmd, args) "{{{
let s:handler = g:ack_lhandler let search = getreg('/')
let s:apply_mappings = g:ack_apply_lmappings " translate vim regular expression to perl regular expression.
let s:close_cmd = ':lclose<CR>' let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g')
else call ack#Ack(a:cmd, '"' . search . '" ' . a:args)
let s:handler = g:ack_qhandler endfunction "}}}
let s:apply_mappings = g:ack_apply_qmappings
let s:close_cmd = ':cclose<CR>'
endif
if !g:ack_use_dispatch function! ack#AckHelp(cmd, args) "{{{
call ack#show_results() let args = a:args . ' ' . s:GetDocLocations()
else call ack#Ack(a:cmd, args)
copen endfunction "}}}
endif
call <SID>apply_maps()
call <SID>highlight(l:grepargs)
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 "}}}
function! ack#ShowResults() "{{{
let l:handler = s:UsingLocList() ? g:ack_lhandler : g:ack_qhandler
execute l:handler
call s:ApplyMappings()
redraw! redraw!
endfunction endfunction "}}}
function! ack#show_results() "-----------------------------------------------------------------------------
execute s:handler " Private API
endfunction "-----------------------------------------------------------------------------
function! s:apply_maps() function! s:ApplyMappings() "{{{
let g:ack_mappings.q = s:close_cmd if !s:UsingListMappings() || &filetype != 'qf'
return
endif
execute "nnoremap <buffer> <silent> ? :call ack#quick_help()<CR>" let l:wintype = s:UsingLocList() ? 'l' : 'c'
let l:closemap = ':' . l:wintype . 'close<CR>'
let g:ack_mappings.q = l:closemap
nnoremap <buffer> <silent> ? :call <SID>QuickHelp()<CR>
if s:apply_mappings && &ft == "qf"
if g:ack_autoclose if g:ack_autoclose
" We just map the 'go' and 'gv' mappings to close on autoclose, wtf?
for key_map in items(g:ack_mappings) 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) execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1) . l:closemap)
endfor endfor
execute "nnoremap <buffer> <silent> <CR> <CR>" . s:close_cmd
execute "nnoremap <buffer> <silent> <CR> <CR>" . l:closemap
else else
for key_map in items(g:ack_mappings) for key_map in items(g:ack_mappings)
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1)) execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1))
@ -83,14 +116,45 @@ function! s:apply_maps()
endif endif
if exists("g:ackpreview") " if auto preview in on, remap j and k keys 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>" nnoremap <buffer> <silent> j j<CR><C-W><C-W>
execute "nnoremap <buffer> <silent> k k<CR><C-W><C-W>" nnoremap <buffer> <silent> k k<CR><C-W><C-W>
endif endif
endif endfunction "}}}
endfunction
function! ack#quick_help() function! s:GetDocLocations() "{{{
execute "edit " . globpath(&rtp, "doc/ack_quick_help.txt") 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! s:Highlight(args) "{{{
if !g:ackhighlight
return
endif
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
call feedkeys(":let &hlsearch=1 \| echo \<CR>", "n")
endfunction "}}}
" Initialize state for an :Ack* or :LAck* search
function! s:Init(cmd) "{{{
let s:searching_filepaths = (a:cmd =~# '-g$') ? 1 : 0
let s:using_loclist = (a:cmd =~# '^l') ? 1 : 0
if g:ack_use_dispatch && s:using_loclist
call s:Warn('Dispatch does not support location lists! Proceeding with quickfix...')
let s:using_loclist = 0
endif
endfunction "}}}
function! s:QuickHelp() "{{{
execute 'edit' globpath(&rtp, 'doc/ack_quick_help.txt')
silent normal gg silent normal gg
setlocal buftype=nofile setlocal buftype=nofile
@ -104,51 +168,68 @@ function! ack#quick_help()
setlocal nowrap setlocal nowrap
setlocal foldlevel=20 setlocal foldlevel=20
setlocal foldmethod=diff setlocal foldmethod=diff
nnoremap <buffer> <silent> ? :q!<CR>:call ack#show_results()<CR>
endfunction
function! s:highlight(args) nnoremap <buffer> <silent> ? :q!<CR>:call ack#ShowResults()<CR>
if !g:ackhighlight endfunction "}}}
return
function! s:SearchWithDispatch(grepprg, grepargs, grepformat) "{{{
let l:makeprg_bak = &l:makeprg
let l:errorformat_bak = &l:errorformat
" We don't execute a :grep command for Dispatch, so add -g here instead
if s:SearchingFilepaths()
let l:grepprg = a:grepprg . ' -g'
else
let l:grepprg = a:grepprg
endif endif
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]") try
call feedkeys(":let &l:hlsearch=1 \| echo \<CR>", "n") let &l:makeprg = l:grepprg . ' ' . a:grepargs
endfunction let &l:errorformat = a:grepformat
function! ack#AckFromSearch(cmd, args) Make
let search = getreg('/') finally
" translate vim regular expression to perl regular expression. let &l:makeprg = l:makeprg_bak
let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g') let &l:errorformat = l:errorformat_bak
call ack#Ack(a:cmd, '"' . search . '" ' . a:args) endtry
endfunction endfunction "}}}
function! s:GetDocLocations() function! s:SearchWithGrep(grepcmd, grepprg, grepargs, grepformat) "{{{
let dp = '' let l:grepprg_bak = &l:grepprg
for p in split(&rtp, ',') let l:grepformat_bak = &grepformat
let p = p . '/doc/'
if isdirectory(p) try
let dp = p . '*.txt ' . dp let &l:grepprg = a:grepprg
let &grepformat = a:grepformat
silent execute a:grepcmd a:grepargs
finally
let &l:grepprg = l:grepprg_bak
let &grepformat = l:grepformat_bak
endtry
endfunction "}}}
" Are we finding matching files, not lines? (the -g option -- :AckFile)
function! s:SearchingFilepaths() "{{{
return get(s:, 'searching_filepaths', 0)
endfunction "}}}
" Predicate for whether mappings are enabled for list type of current search.
function! s:UsingListMappings() "{{{
if s:UsingLocList()
return g:ack_apply_lmappings
else
return g:ack_apply_qmappings
endif endif
endfor endfunction "}}}
return dp " Were we invoked with a :LAck command?
endfunction function! s:UsingLocList() "{{{
return get(s:, 'using_loclist', 0)
endfunction "}}}
function! ack#AckHelp(cmd, args) function! s:Warn(msg) "{{{
let args = a:args . ' ' . s:GetDocLocations() echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None
call ack#Ack(a:cmd, args) endf "}}}
endfunction
function! ack#AckWindow(cmd, args) " vim:set et sw=2 ts=2 tw=78 fdm=marker
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

View file

@ -68,7 +68,12 @@ 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 a line in this window will open the file, and place the cursor on the matching
line. line.
See http://betterthangrep.com/ for more information. Note that if you are using Dispatch.vim with |g:ack_use_dispatch|, location
lists are not supported, because Dispatch does not support them at this time.
`:LAck` versions of commands above will give a warning and proceed to use the
quickfix list instead.
See http://beyondgrep.com/ for more information on searching with ack.
============================================================================== ==============================================================================
@ -208,7 +213,12 @@ Example:
g:ack_use_dispatch g:ack_use_dispatch
Default: 0 Default: 0
Use this option to use vim-dispatch to search the results in background Use this option to use vim-dispatch to run searches in the background, with a
variety of execution backends for different systems.
Due to limitations in Dispatch at this time, location lists are unsupported
and result windows will appear before results are ready. Still, these may be
acceptable tradeoffs for very large projects where searches are slow.
Example: Example:
> >

View file

@ -1,6 +1,6 @@
==== ack.vim quick help =============== ==== ack.vim quick help ===============
*?:* Show this help *?:* Show/quit this help
*t:* Open in a new tab *t:* Open in a new tab
*T:* Open in a new tab silently *T:* Open in a new tab silently
*o:* Open *o:* Open

View file

@ -1,3 +1,7 @@
if exists('g:loaded_ack')
finish
endif
if !exists("g:ack_default_options") if !exists("g:ack_default_options")
let g:ack_default_options = " -s -H --nocolor --nogroup --column" let g:ack_default_options = " -s -H --nocolor --nogroup --column"
endif endif
@ -22,10 +26,6 @@ if !exists("g:ack_apply_lmappings")
let g:ack_apply_lmappings = !exists("g:ack_lhandler") let g:ack_apply_lmappings = !exists("g:ack_lhandler")
endif endif
if !exists("g:ack_use_dispatch")
let g:ack_use_dispatch = 0
end
let s:ack_mappings = { let s:ack_mappings = {
\ "t": "<C-W><CR><C-W>T", \ "t": "<C-W><CR><C-W>T",
\ "T": "<C-W><CR><C-W>TgT<C-W>j", \ "T": "<C-W><CR><C-W>TgT<C-W>j",
@ -73,3 +73,7 @@ command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep<bang
command! -bang -nargs=* -complete=help LAckHelp call ack#AckHelp('lgrep<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 AckWindow call ack#AckWindow('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=help LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>) command! -bang -nargs=* -complete=help LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
let g:loaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View file

@ -160,17 +160,7 @@ endfunction
function! s:goyo_on(width) function! s:goyo_on(width)
let s:orig_tab = tabpagenr() let s:orig_tab = tabpagenr()
let settings =
" New tab
tab split
let t:goyo_master = winbufnr(0)
let t:goyo_width = a:width
let t:goyo_margin_top = get(g:, 'goyo_margin_top', 4)
let t:goyo_margin_bottom = get(g:, 'goyo_margin_bottom', 4)
let t:goyo_initial_dim = [t:goyo_width, t:goyo_margin_top, t:goyo_margin_bottom]
let t:goyo_pads = {}
let t:goyo_revert =
\ { 'laststatus': &laststatus, \ { 'laststatus': &laststatus,
\ 'showtabline': &showtabline, \ 'showtabline': &showtabline,
\ 'fillchars': &fillchars, \ 'fillchars': &fillchars,
@ -182,6 +172,17 @@ function! s:goyo_on(width)
\ 'sidescroll': &sidescroll, \ 'sidescroll': &sidescroll,
\ 'sidescrolloff': &sidescrolloff \ 'sidescrolloff': &sidescrolloff
\ } \ }
" New tab
tab split
let t:goyo_master = winbufnr(0)
let t:goyo_width = a:width
let t:goyo_margin_top = get(g:, 'goyo_margin_top', 4)
let t:goyo_margin_bottom = get(g:, 'goyo_margin_bottom', 4)
let t:goyo_initial_dim = [t:goyo_width, t:goyo_margin_top, t:goyo_margin_bottom]
let t:goyo_pads = {}
let t:goyo_revert = settings
let t:goyo_maps = extend(s:maps_nop(), s:maps_resize()) let t:goyo_maps = extend(s:maps_nop(), s:maps_resize())
if has('gui_running') if has('gui_running')
let t:goyo_revert.guioptions = &guioptions let t:goyo_revert.guioptions = &guioptions

View file

@ -29,14 +29,15 @@
4.3. [Are there any local checkers for HTML5 that I can use with syntastic?](#faqhtml5) 4.3. [Are there any local checkers for HTML5 that I can use with syntastic?](#faqhtml5)
4.4. [The `perl` checker has stopped working...](#faqperl) 4.4. [The `perl` checker has stopped working...](#faqperl)
4.5. [What happened to the `rustc` checker?](#faqrust) 4.5. [What happened to the `rustc` checker?](#faqrust)
4.6. [I run a checker and the location list is not updated...](#faqloclist) 4.6. [What happened to the `xcrun` checker?](#faqxcrun)
4.6. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist) 4.7. [I run a checker and the location list is not updated...](#faqloclist)
4.7. [How can I pass additional arguments to a checker?](#faqargs) 4.7. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist)
4.8. [Syntastic supports several checkers for my filetype - how do I tell which one(s) to use?](#faqcheckers) 4.8. [How can I pass additional arguments to a checker?](#faqargs)
4.9. [What is the difference between syntax checkers and style checkers?](#faqstyle) 4.9. [Syntastic supports several checkers for my filetype - how do I tell which one(s) to use?](#faqcheckers)
4.10. [I have enabled multiple checkers for the current filetype. How can I display all of the errors from all of the checkers together?](#faqaggregate) 4.10. [What is the difference between syntax checkers and style checkers?](#faqstyle)
4.11. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext) 4.11. [I have enabled multiple checkers for the current filetype. How can I display all of the errors from all of the checkers together?](#faqaggregate)
4.12. [The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?](#faqbdelete) 4.12. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext)
4.13. [The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?](#faqbdelete)
5. [Resources](#otherresources) 5. [Resources](#otherresources)
- - - - - -
@ -51,7 +52,7 @@ 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 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. compile their code or execute their script to find them.
At the time of this writing, syntax checking plugins exist for ActionScript, At the time of this writing, syntastic has checking plugins for ActionScript,
Ada, AppleScript, AsciiDoc, ASM, BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Ada, AppleScript, AsciiDoc, ASM, BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal,
Chef, CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dust, Chef, CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dust,
Elixir, Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Elixir, Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell,
@ -59,11 +60,15 @@ Haxe, Handlebars, HSS, HTML, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo,
LISP, LLVM intermediate language, Lua, Markdown, MATLAB, NASM, Objective-C, LISP, LLVM intermediate language, Lua, Markdown, MATLAB, NASM, Objective-C,
Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable Object, OS X and Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable Object, OS X and
iOS property lists, Puppet, Python, R, Racket, Relax NG, reStructuredText, RPM iOS property lists, Puppet, Python, R, Racket, Relax NG, reStructuredText, RPM
spec, Ruby, SASS/SCSS, Scala, Slim, Swift, Tcl, TeX, Texinfo, Twig, TypeScript, spec, Ruby, SASS/SCSS, Scala, Slim, SML, Tcl, TeX, Texinfo, Twig, TypeScript,
Vala, Verilog, VHDL, VimL, xHtml, XML, XSLT, YACC, YAML, z80, Zope page Vala, Verilog, VHDL, VimL, xHtml, XML, XSLT, YACC, YAML, z80, Zope page
templates, and zsh. See the [wiki][3] for details about the corresponding templates, and zsh. See the [wiki][3] for details about the corresponding
supported checkers. supported checkers.
A number of third-party Vim plugins also provide checkers for syntastic,
for example: [omnisharp-vim][25], [rust.vim][12], [syntastic-extras][26],
[syntastic-more][27], and [vim-swift][24].
Below is a screenshot showing the methods that Syntastic uses to display syntax 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 errors. Note that, in practise, you will only have a subset of these methods
enabled. enabled.
@ -183,10 +188,18 @@ supported, look at the [wiki][3]. Note that aliases do not work; the actual
executables must be available in your `$PATH`. Symbolic links are okay though. executables must be available in your `$PATH`. Symbolic links are okay though.
You can see syntastic's idea of available checkers by running `:SyntasticInfo`. You can see syntastic's idea of available checkers by running `:SyntasticInfo`.
A second probable reason is that none of the available checkers are
enabled. Syntastic comes preconfigured with a default list of enabled checkers
per filetype, but this list is kept short in order to prevent slowing down Vim
or trying to run conflicting checks. The command `:SyntasticInfo` will show you
which checkers are enabled. You can tell syntastic which checkers (among the
available ones) you want to run by setting `g:syntastic_<filetype>_checkers` in
your `vimrc` (see [below](#faqcheckers)).
Another reason it could fail is that either the command line options or the 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 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 have the latest version of the syntax checker installed. If it still fails then
create an issue - or better yet, create a pull request. post an [issue][4] - or better yet, create a pull request.
<a name="faqpython3"></a> <a name="faqpython3"></a>
@ -236,14 +249,21 @@ let g:syntastic_enable_perl_checker = 1
__4.5. Q. What happened to the `rustc` checker?__ __4.5. Q. What happened to the `rustc` checker?__
A. It has been included in the [Rust compiler package][12]. If you have A. It is now part of the [rust.vim][12] plugin. If you install this plugin the
a recent version of the Rust compiler, the checker should be picked up checker should be picked up automatically by syntastic.
automatically by syntastic.
<a name="faqxcrun"></a>
__4.6. Q. What happened to the `xcrun` checker?__
A. The `xcrun` checker used to have a security problem and it has been removed.
A better checker for __Swift__ is part of the [vim-swift][24] plugin. If you
install this plugin the checker should be picked up automatically by syntastic.
<a name="faqloclist"></a> <a name="faqloclist"></a>
__4.6. Q. I run a checker and the location list is not updated...__ __4.7. Q. I run a checker and the location list is not updated...__
__4.6. Q. I run`:lopen` or `:lwindow` and the error window is empty...__ __4.7. Q. I run`:lopen` or `:lwindow` and the error window is empty...__
A. By default the location list is changed only when you run the `:Errors` 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 command, in order to minimise conflicts with other plugins. If you want the
@ -255,7 +275,7 @@ let g:syntastic_always_populate_loc_list = 1
<a name="faqargs"></a> <a name="faqargs"></a>
__4.7. Q. How can I pass additional arguments to a checker?__ __4.8. Q. How can I pass additional arguments to a checker?__
A. Almost all syntax checkers use the `makeprgBuild()` function. Those checkers A. Almost all syntax checkers use the `makeprgBuild()` function. Those checkers
that do can be configured using global variables. The general form of the that do can be configured using global variables. The general form of the
@ -271,7 +291,7 @@ See `:help syntastic-checker-options` for more information.
<a name="faqcheckers"></a> <a name="faqcheckers"></a>
__4.8. Q. Syntastic supports several checkers for my filetype - how do I tell it __4.9. Q. Syntastic supports several checkers for my filetype - how do I tell it
which one(s) to use?__ which one(s) to use?__
A. Stick a line like this in your `vimrc`: A. Stick a line like this in your `vimrc`:
@ -312,7 +332,7 @@ filetype of the current file is `php`).
<a name="faqstyle"></a> <a name="faqstyle"></a>
__4.9. Q. What is the difference between syntax checkers and style checkers?__ __4.10. Q. What is the difference between syntax checkers and style checkers?__
A. The errors and warnings they produce are highlighted differently and can A. The errors and warnings they produce are highlighted differently and can
be filtered by different rules, but otherwise the distinction is pretty much be filtered by different rules, but otherwise the distinction is pretty much
@ -342,7 +362,7 @@ See `:help syntastic_quiet_messages` for details.
<a name="faqaggregate"></a> <a name="faqaggregate"></a>
__4.10. Q. I have enabled multiple checkers for the current filetype. How can I __4.11. Q. I have enabled multiple checkers for the current filetype. How can I
display all of the errors from all of the checkers together?__ display all of the errors from all of the checkers together?__
A. Set `g:syntastic_aggregate_errors` to 1 in your `vimrc`: A. Set `g:syntastic_aggregate_errors` to 1 in your `vimrc`:
@ -354,7 +374,7 @@ See `:help syntastic-aggregating-errors` for more details.
<a name="faqlnext"></a> <a name="faqlnext"></a>
__4.11. Q. How can I jump between the different errors without using the location __4.12. Q. How can I jump between the different errors without using the location
list at the bottom of the window?__ list at the bottom of the window?__
A. Vim provides several built-in commands for this. See `:help :lnext` and A. Vim provides several built-in commands for this. See `:help :lnext` and
@ -366,7 +386,7 @@ mappings (among other things).
<a name="faqbdelete"></a> <a name="faqbdelete"></a>
__4.12. Q. The error window is closed automatically when I :quit the current buffer __4.13. Q. The error window is closed automatically when I :quit the current buffer
but not when I :bdelete it?__ but not when I :bdelete it?__
A. There is no safe way to handle that situation automatically, but you can A. There is no safe way to handle that situation automatically, but you can
@ -404,7 +424,7 @@ a look at [jedi-vim][7], [python-mode][8], or [YouCompleteMe][9].
[9]: http://valloric.github.io/YouCompleteMe/ [9]: http://valloric.github.io/YouCompleteMe/
[10]: http://perldoc.perl.org/perlrun.html#*-c* [10]: http://perldoc.perl.org/perlrun.html#*-c*
[11]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide [11]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide
[12]: https://github.com/rust-lang/rust/ [12]: https://github.com/rust-lang/rust.vim
[13]: http://www.vim.org/ [13]: http://www.vim.org/
[14]: https://github.com/Shougo/neobundle.vim [14]: https://github.com/Shougo/neobundle.vim
[15]: https://github.com/MarcWeber/vim-addon-manager [15]: https://github.com/MarcWeber/vim-addon-manager
@ -416,6 +436,10 @@ a look at [jedi-vim][7], [python-mode][8], or [YouCompleteMe][9].
[21]: https://github.com/validator/validator/releases/latest [21]: https://github.com/validator/validator/releases/latest
[22]: https://github.com/scrooloose/syntastic/wiki/HTML%3A---validator [22]: https://github.com/scrooloose/syntastic/wiki/HTML%3A---validator
[23]: http://validator.github.io/validator/#standalone [23]: http://validator.github.io/validator/#standalone
[24]: https://github.com/kballard/vim-swift
[25]: https://github.com/OmniSharp/omnisharp-vim
[26]: https://github.com/myint/syntastic-extras
[27]: https://github.com/roktas/syntastic-more
<!-- <!--
vim:tw=79:sw=4: vim:tw=79:sw=4:

View file

@ -10,14 +10,14 @@ set cpo&vim
" convenience function to determine the 'null device' parameter " convenience function to determine the 'null device' parameter
" based on the current operating system " based on the current operating system
function! syntastic#c#NullOutput() " {{{2 function! syntastic#c#NullOutput() abort " {{{2
let known_os = has('unix') || has('mac') || syntastic#util#isRunningWindows() let known_os = has('unix') || has('mac') || syntastic#util#isRunningWindows()
return known_os ? '-o ' . syntastic#util#DevNull() : '' return known_os ? '-o ' . syntastic#util#DevNull() : ''
endfunction " }}}2 endfunction " }}}2
" read additional compiler flags from the given configuration file " read additional compiler flags from the given configuration file
" the file format and its parsing mechanism is inspired by clang_complete " the file format and its parsing mechanism is inspired by clang_complete
function! syntastic#c#ReadConfig(file) " {{{2 function! syntastic#c#ReadConfig(file) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: looking for', a:file) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, 'ReadConfig: looking for', a:file)
" search upwards from the current file's directory " search upwards from the current file's directory
@ -69,7 +69,7 @@ function! syntastic#c#ReadConfig(file) " {{{2
endfunction " }}}2 endfunction " }}}2
" GetLocList() for C-like compilers " GetLocList() for C-like compilers
function! syntastic#c#GetLocList(filetype, subchecker, options) " {{{2 function! syntastic#c#GetLocList(filetype, subchecker, options) abort " {{{2
try try
let flags = s:_get_cflags(a:filetype, a:subchecker, a:options) let flags = s:_get_cflags(a:filetype, a:subchecker, a:options)
catch /\m\C^Syntastic: skip checks$/ catch /\m\C^Syntastic: skip checks$/
@ -96,7 +96,7 @@ endfunction " }}}2
" Private functions {{{1 " Private functions {{{1
" initialize c/cpp syntax checker handlers " initialize c/cpp syntax checker handlers
function! s:_init() " {{{2 function! s:_init() abort " {{{2
let s:handlers = [] let s:handlers = []
let s:cflags = {} let s:cflags = {}
@ -118,7 +118,7 @@ function! s:_init() " {{{2
endfunction " }}}2 endfunction " }}}2
" register a handler dictionary object " register a handler dictionary object
function! s:_registerHandler(regex, function, args) " {{{2 function! s:_registerHandler(regex, function, args) abort " {{{2
let handler = {} let handler = {}
let handler["regex"] = a:regex let handler["regex"] = a:regex
let handler["func"] = function(a:function) let handler["func"] = function(a:function)
@ -129,7 +129,7 @@ endfunction " }}}2
" try to find library with 'pkg-config' " try to find library with 'pkg-config'
" search possible libraries from first to last given " search possible libraries from first to last given
" argument until one is found " argument until one is found
function! s:_checkPackage(name, ...) " {{{2 function! s:_checkPackage(name, ...) abort " {{{2
if executable('pkg-config') if executable('pkg-config')
if !has_key(s:cflags, a:name) if !has_key(s:cflags, a:name)
for pkg in a:000 for pkg in a:000
@ -150,7 +150,7 @@ function! s:_checkPackage(name, ...) " {{{2
endfunction " }}}2 endfunction " }}}2
" try to find PHP includes with 'php-config' " try to find PHP includes with 'php-config'
function! s:_checkPhp() " {{{2 function! s:_checkPhp() abort " {{{2
if executable('php-config') if executable('php-config')
if !has_key(s:cflags, 'php') if !has_key(s:cflags, 'php')
let s:cflags['php'] = system('php-config --includes') let s:cflags['php'] = system('php-config --includes')
@ -162,7 +162,7 @@ function! s:_checkPhp() " {{{2
endfunction " }}}2 endfunction " }}}2
" try to find the python headers with distutils " try to find the python headers with distutils
function! s:_checkPython() " {{{2 function! s:_checkPython() abort " {{{2
if executable('python') if executable('python')
if !has_key(s:cflags, 'python') if !has_key(s:cflags, 'python')
let s:cflags['python'] = system('python -c ''from distutils import ' . let s:cflags['python'] = system('python -c ''from distutils import ' .
@ -176,7 +176,7 @@ function! s:_checkPython() " {{{2
endfunction " }}}2 endfunction " }}}2
" try to find the ruby headers with 'rbconfig' " try to find the ruby headers with 'rbconfig'
function! s:_checkRuby() " {{{2 function! s:_checkRuby() abort " {{{2
if executable('ruby') if executable('ruby')
if !has_key(s:cflags, 'ruby') if !has_key(s:cflags, 'ruby')
let s:cflags['ruby'] = system('ruby -r rbconfig -e ' . let s:cflags['ruby'] = system('ruby -r rbconfig -e ' .
@ -194,7 +194,7 @@ endfunction " }}}2
" Utilities {{{1 " Utilities {{{1
" resolve checker-related user variables " resolve checker-related user variables
function! s:_get_checker_var(scope, filetype, subchecker, name, default) " {{{2 function! s:_get_checker_var(scope, filetype, subchecker, name, default) abort " {{{2
let prefix = a:scope . ':' . 'syntastic_' let prefix = a:scope . ':' . 'syntastic_'
if exists(prefix . a:filetype . '_' . a:subchecker . '_' . a:name) if exists(prefix . a:filetype . '_' . a:subchecker . '_' . a:name)
return {a:scope}:syntastic_{a:filetype}_{a:subchecker}_{a:name} return {a:scope}:syntastic_{a:filetype}_{a:subchecker}_{a:name}
@ -206,7 +206,7 @@ function! s:_get_checker_var(scope, filetype, subchecker, name, default) " {{{2
endfunction " }}}2 endfunction " }}}2
" resolve user CFLAGS " resolve user CFLAGS
function! s:_get_cflags(ft, ck, opts) " {{{2 function! s:_get_cflags(ft, ck, opts) abort " {{{2
" determine whether to parse header files as well " determine whether to parse header files as well
if has_key(a:opts, 'header_names') && expand('%', 1) =~? a:opts['header_names'] if has_key(a:opts, 'header_names') && expand('%', 1) =~? a:opts['header_names']
if s:_get_checker_var('g', a:ft, a:ck, 'check_header', 0) if s:_get_checker_var('g', a:ft, a:ck, 'check_header', 0)
@ -253,7 +253,7 @@ endfunction " }}}2
" get the gcc include directory argument depending on the default " get the gcc include directory argument depending on the default
" includes and the optional user-defined 'g:syntastic_c_include_dirs' " includes and the optional user-defined 'g:syntastic_c_include_dirs'
function! s:_get_include_dirs(filetype) " {{{2 function! s:_get_include_dirs(filetype) abort " {{{2
let include_dirs = [] let include_dirs = []
if a:filetype =~# '\v^%(c|cpp|objc|objcpp)$' && if a:filetype =~# '\v^%(c|cpp|objc|objcpp)$' &&
@ -271,7 +271,7 @@ endfunction " }}}2
" search the first 100 lines for include statements that are " search the first 100 lines for include statements that are
" given in the handlers dictionary " given in the handlers dictionary
function! s:_search_headers() " {{{2 function! s:_search_headers() abort " {{{2
let includes = '' let includes = ''
let files = [] let files = []
let found = [] let found = []

View file

@ -10,24 +10,24 @@ let s:one_time_notices_issued = []
" Public functions {{{1 " Public functions {{{1
function! syntastic#log#info(msg) " {{{2 function! syntastic#log#info(msg) abort " {{{2
echomsg "syntastic: info: " . a:msg echomsg "syntastic: info: " . a:msg
endfunction " }}}2 endfunction " }}}2
function! syntastic#log#warn(msg) " {{{2 function! syntastic#log#warn(msg) abort " {{{2
echohl WarningMsg echohl WarningMsg
echomsg "syntastic: warning: " . a:msg echomsg "syntastic: warning: " . a:msg
echohl None echohl None
endfunction " }}}2 endfunction " }}}2
function! syntastic#log#error(msg) " {{{2 function! syntastic#log#error(msg) abort " {{{2
execute "normal \<Esc>" execute "normal \<Esc>"
echohl ErrorMsg echohl ErrorMsg
echomsg "syntastic: error: " . a:msg echomsg "syntastic: error: " . a:msg
echohl None echohl None
endfunction " }}}2 endfunction " }}}2
function! syntastic#log#oneTimeWarn(msg) " {{{2 function! syntastic#log#oneTimeWarn(msg) abort " {{{2
if index(s:one_time_notices_issued, a:msg) >= 0 if index(s:one_time_notices_issued, a:msg) >= 0
return return
endif endif
@ -37,7 +37,7 @@ function! syntastic#log#oneTimeWarn(msg) " {{{2
endfunction " }}}2 endfunction " }}}2
" @vimlint(EVL102, 1, l:OLD_VAR) " @vimlint(EVL102, 1, l:OLD_VAR)
function! syntastic#log#deprecationWarn(old, new, ...) " {{{2 function! syntastic#log#deprecationWarn(old, new, ...) abort " {{{2
if exists('g:syntastic_' . a:old) && !exists('g:syntastic_' . a:new) if exists('g:syntastic_' . a:old) && !exists('g:syntastic_' . a:new)
let msg = 'variable g:syntastic_' . a:old . ' is deprecated, please use ' let msg = 'variable g:syntastic_' . a:old . ' is deprecated, please use '
@ -60,7 +60,7 @@ function! syntastic#log#deprecationWarn(old, new, ...) " {{{2
endfunction " }}}2 endfunction " }}}2
" @vimlint(EVL102, 0, l:OLD_VAR) " @vimlint(EVL102, 0, l:OLD_VAR)
function! syntastic#log#debug(level, msg, ...) " {{{2 function! syntastic#log#debug(level, msg, ...) abort " {{{2
if !s:_isDebugEnabled(a:level) if !s:_isDebugEnabled(a:level)
return return
endif endif
@ -80,7 +80,7 @@ function! syntastic#log#debug(level, msg, ...) " {{{2
call s:_logRedirect(0) call s:_logRedirect(0)
endfunction " }}}2 endfunction " }}}2
function! syntastic#log#debugShowOptions(level, names) " {{{2 function! syntastic#log#debugShowOptions(level, names) abort " {{{2
if !s:_isDebugEnabled(a:level) if !s:_isDebugEnabled(a:level)
return return
endif endif
@ -96,7 +96,7 @@ function! syntastic#log#debugShowOptions(level, names) " {{{2
call s:_logRedirect(0) call s:_logRedirect(0)
endfunction " }}}2 endfunction " }}}2
function! syntastic#log#debugShowVariables(level, names) " {{{2 function! syntastic#log#debugShowVariables(level, names) abort " {{{2
if !s:_isDebugEnabled(a:level) if !s:_isDebugEnabled(a:level)
return return
endif endif
@ -115,7 +115,7 @@ function! syntastic#log#debugShowVariables(level, names) " {{{2
call s:_logRedirect(0) call s:_logRedirect(0)
endfunction " }}}2 endfunction " }}}2
function! syntastic#log#debugDump(level) " {{{2 function! syntastic#log#debugDump(level) abort " {{{2
if !s:_isDebugEnabled(a:level) if !s:_isDebugEnabled(a:level)
return return
endif endif
@ -127,11 +127,11 @@ endfunction " }}}2
" Private functions {{{1 " Private functions {{{1
function! s:_isDebugEnabled_smart(level) " {{{2 function! s:_isDebugEnabled_smart(level) abort " {{{2
return and(g:syntastic_debug, a:level) return and(g:syntastic_debug, a:level)
endfunction " }}}2 endfunction " }}}2
function! s:_isDebugEnabled_dumb(level) " {{{2 function! s:_isDebugEnabled_dumb(level) abort " {{{2
" poor man's bit test for bit N, assuming a:level == 2**N " poor man's bit test for bit N, assuming a:level == 2**N
return (g:syntastic_debug / a:level) % 2 return (g:syntastic_debug / a:level) % 2
endfunction " }}}2 endfunction " }}}2
@ -139,7 +139,7 @@ endfunction " }}}2
let s:_isDebugEnabled = function(exists('*and') ? 's:_isDebugEnabled_smart' : 's:_isDebugEnabled_dumb') let s:_isDebugEnabled = function(exists('*and') ? 's:_isDebugEnabled_smart' : 's:_isDebugEnabled_dumb')
lockvar s:_isDebugEnabled lockvar s:_isDebugEnabled
function! s:_logRedirect(on) " {{{2 function! s:_logRedirect(on) abort " {{{2
if exists("g:syntastic_debug_file") if exists("g:syntastic_debug_file")
if a:on if a:on
try try
@ -158,11 +158,11 @@ endfunction " }}}2
" Utilities {{{1 " Utilities {{{1
function! s:_log_timestamp() " {{{2 function! s:_log_timestamp() abort " {{{2
return 'syntastic: ' . split(reltimestr(reltime(g:_SYNTASTIC_START)))[0] . ': ' return 'syntastic: ' . split(reltimestr(reltime(g:_SYNTASTIC_START)))[0] . ': '
endfunction " }}}2 endfunction " }}}2
function! s:_format_variable(name) " {{{2 function! s:_format_variable(name) abort " {{{2
let vals = [] let vals = []
if exists('g:syntastic_' . a:name) if exists('g:syntastic_' . a:name)
call add(vals, 'g:syntastic_' . a:name . ' = ' . strtrans(string(g:syntastic_{a:name}))) call add(vals, 'g:syntastic_' . a:name . ' = ' . strtrans(string(g:syntastic_{a:name})))

View file

@ -9,7 +9,7 @@ set cpo&vim
" Public functions {{{1 " Public functions {{{1
" merge consecutive blanks " merge consecutive blanks
function! syntastic#postprocess#compressWhitespace(errors) " {{{2 function! syntastic#postprocess#compressWhitespace(errors) abort " {{{2
for e in a:errors for e in a:errors
let e['text'] = substitute(e['text'], "\001", '', 'g') let e['text'] = substitute(e['text'], "\001", '', 'g')
let e['text'] = substitute(e['text'], '\n', ' ', 'g') let e['text'] = substitute(e['text'], '\n', ' ', 'g')
@ -22,7 +22,7 @@ function! syntastic#postprocess#compressWhitespace(errors) " {{{2
endfunction " }}}2 endfunction " }}}2
" remove spurious CR under Cygwin " remove spurious CR under Cygwin
function! syntastic#postprocess#cygwinRemoveCR(errors) " {{{2 function! syntastic#postprocess#cygwinRemoveCR(errors) abort " {{{2
if has('win32unix') if has('win32unix')
for e in a:errors for e in a:errors
let e['text'] = substitute(e['text'], '\r', '', 'g') let e['text'] = substitute(e['text'], '\r', '', 'g')
@ -33,7 +33,7 @@ function! syntastic#postprocess#cygwinRemoveCR(errors) " {{{2
endfunction " }}}2 endfunction " }}}2
" decode XML entities " decode XML entities
function! syntastic#postprocess#decodeXMLEntities(errors) " {{{2 function! syntastic#postprocess#decodeXMLEntities(errors) abort " {{{2
for e in a:errors for e in a:errors
let e['text'] = syntastic#util#decodeXMLEntities(e['text']) let e['text'] = syntastic#util#decodeXMLEntities(e['text'])
endfor endfor
@ -42,13 +42,13 @@ function! syntastic#postprocess#decodeXMLEntities(errors) " {{{2
endfunction " }}}2 endfunction " }}}2
" filter out errors referencing other files " filter out errors referencing other files
function! syntastic#postprocess#filterForeignErrors(errors) " {{{2 function! syntastic#postprocess#filterForeignErrors(errors) abort " {{{2
return filter(copy(a:errors), 'get(v:val, "bufnr") == ' . bufnr('')) return filter(copy(a:errors), 'get(v:val, "bufnr") == ' . bufnr(''))
endfunction " }}}2 endfunction " }}}2
" make sure line numbers are not past end of buffers " make sure line numbers are not past end of buffers
" XXX: this loads all referenced buffers in memory " XXX: this loads all referenced buffers in memory
function! syntastic#postprocess#guards(errors) " {{{2 function! syntastic#postprocess#guards(errors) abort " {{{2
let buffers = syntastic#util#unique(map(filter(copy(a:errors), 'v:val["valid"]'), 'str2nr(v:val["bufnr"])')) let buffers = syntastic#util#unique(map(filter(copy(a:errors), 'v:val["valid"]'), 'str2nr(v:val["bufnr"])'))
let guards = {} let guards = {}

View file

@ -8,7 +8,7 @@ set cpo&vim
" Public functions {{{1 " Public functions {{{1
function! syntastic#preprocess#cabal(errors) " {{{2 function! syntastic#preprocess#cabal(errors) abort " {{{2
let out = [] let out = []
let star = 0 let star = 0
for err in a:errors for err in a:errors
@ -28,7 +28,7 @@ function! syntastic#preprocess#cabal(errors) " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#checkstyle(errors) " {{{2 function! syntastic#preprocess#checkstyle(errors) abort " {{{2
let out = [] let out = []
let fname = expand('%', 1) let fname = expand('%', 1)
for err in a:errors for err in a:errors
@ -55,14 +55,14 @@ function! syntastic#preprocess#checkstyle(errors) " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#cppcheck(errors) " {{{2 function! syntastic#preprocess#cppcheck(errors) abort " {{{2
return map(copy(a:errors), 'substitute(v:val, ''\v^\[[^]]+\]\zs( -\> \[[^]]+\])+\ze:'', "", "")') return map(copy(a:errors), 'substitute(v:val, ''\v^\[[^]]+\]\zs( -\> \[[^]]+\])+\ze:'', "", "")')
endfunction " }}}2 endfunction " }}}2
" @vimlint(EVL102, 1, l:true) " @vimlint(EVL102, 1, l:true)
" @vimlint(EVL102, 1, l:false) " @vimlint(EVL102, 1, l:false)
" @vimlint(EVL102, 1, l:null) " @vimlint(EVL102, 1, l:null)
function! syntastic#preprocess#flow(errors) " {{{2 function! syntastic#preprocess#flow(errors) abort " {{{2
" JSON artifacts " JSON artifacts
let true = 1 let true = 1
let false = 0 let false = 0
@ -123,11 +123,11 @@ endfunction " }}}2
" @vimlint(EVL102, 0, l:false) " @vimlint(EVL102, 0, l:false)
" @vimlint(EVL102, 0, l:null) " @vimlint(EVL102, 0, l:null)
function! syntastic#preprocess#killEmpty(errors) " {{{2 function! syntastic#preprocess#killEmpty(errors) abort " {{{2
return filter(copy(a:errors), 'v:val != ""') return filter(copy(a:errors), 'v:val != ""')
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#perl(errors) " {{{2 function! syntastic#preprocess#perl(errors) abort " {{{2
let out = [] let out = []
for e in a:errors for e in a:errors
@ -143,7 +143,7 @@ endfunction " }}}2
" @vimlint(EVL102, 1, l:true) " @vimlint(EVL102, 1, l:true)
" @vimlint(EVL102, 1, l:false) " @vimlint(EVL102, 1, l:false)
" @vimlint(EVL102, 1, l:null) " @vimlint(EVL102, 1, l:null)
function! syntastic#preprocess#prospector(errors) " {{{2 function! syntastic#preprocess#prospector(errors) abort " {{{2
" JSON artifacts " JSON artifacts
let true = 1 let true = 1
let false = 0 let false = 0
@ -158,7 +158,8 @@ function! syntastic#preprocess#prospector(errors) " {{{2
endtry endtry
let out = [] let out = []
if type(errs) == type({}) && has_key(errs, 'messages') && type(errs['messages']) == type([]) if type(errs) == type({}) && has_key(errs, 'messages')
if type(errs['messages']) == type([])
for e in errs['messages'] for e in errs['messages']
if type(e) == type({}) if type(e) == type({})
try try
@ -189,6 +190,7 @@ function! syntastic#preprocess#prospector(errors) " {{{2
else else
call syntastic#log#warn('checker python/prospector: unknown error format') call syntastic#log#warn('checker python/prospector: unknown error format')
endif endif
endif
return out return out
endfunction " }}}2 endfunction " }}}2
@ -196,7 +198,7 @@ endfunction " }}}2
" @vimlint(EVL102, 0, l:false) " @vimlint(EVL102, 0, l:false)
" @vimlint(EVL102, 0, l:null) " @vimlint(EVL102, 0, l:null)
function! syntastic#preprocess#rparse(errors) " {{{2 function! syntastic#preprocess#rparse(errors) abort " {{{2
let errlist = copy(a:errors) let errlist = copy(a:errors)
" remove uninteresting lines and handle continuations " remove uninteresting lines and handle continuations
@ -205,7 +207,7 @@ function! syntastic#preprocess#rparse(errors) " {{{2
if i > 0 && errlist[i][:1] == ' ' && errlist[i] !~ '\m\s\+\^$' if i > 0 && errlist[i][:1] == ' ' && errlist[i] !~ '\m\s\+\^$'
let errlist[i-1] .= errlist[i][1:] let errlist[i-1] .= errlist[i][1:]
call remove(errlist, i) call remove(errlist, i)
elseif errlist[i] !~ '\m^\(Lint:\|Lint checking:\|Error in\) ' elseif errlist[i] !~# '\m^\(Lint:\|Lint checking:\|Error in\) '
call remove(errlist, i) call remove(errlist, i)
else else
let i += 1 let i += 1
@ -235,11 +237,11 @@ function! syntastic#preprocess#rparse(errors) " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#tslint(errors) " {{{2 function! syntastic#preprocess#tslint(errors) abort " {{{2
return map(copy(a:errors), 'substitute(v:val, ''\m^\(([^)]\+)\)\s\(.\+\)$'', ''\2 \1'', "")') return map(copy(a:errors), 'substitute(v:val, ''\m^\(([^)]\+)\)\s\(.\+\)$'', ''\2 \1'', "")')
endfunction " }}}2 endfunction " }}}2
function! syntastic#preprocess#validator(errors) " {{{2 function! syntastic#preprocess#validator(errors) abort " {{{2
let out = [] let out = []
for e in a:errors for e in a:errors
let parts = matchlist(e, '\v^"([^"]+)"(.+)') let parts = matchlist(e, '\v^"([^"]+)"(.+)')
@ -254,6 +256,58 @@ function! syntastic#preprocess#validator(errors) " {{{2
return out return out
endfunction " }}}2 endfunction " }}}2
" @vimlint(EVL102, 1, l:true)
" @vimlint(EVL102, 1, l:false)
" @vimlint(EVL102, 1, l:null)
function! syntastic#preprocess#vint(errors) abort " {{{2
" JSON artifacts
let true = 1
let false = 0
let null = ''
" A hat tip to Marc Weber for this trick
" http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
try
let errs = eval(join(a:errors, ''))
catch
let errs = []
endtry
let out = []
if type(errs) == type([])
for e in errs
if type(e) == type({})
try
let msg =
\ e['file_path'] . ':' .
\ e['line_number'] . ':' .
\ e['column_number'] . ':' .
\ e['severity'][0] . ': ' .
\ e['description'] . ' (' .
\ e['policy_name'] . ')'
call add(out, msg)
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker vim/vint: unknown error format')
let out = []
break
endtry
else
call syntastic#log#warn('checker vim/vint: unknown error format')
let out = []
break
endif
endfor
else
call syntastic#log#warn('checker vim/vint: unknown error format')
endif
return out
endfunction " }}}2
" @vimlint(EVL102, 0, l:true)
" @vimlint(EVL102, 0, l:false)
" @vimlint(EVL102, 0, l:null)
" }}}1 " }}}1
let &cpo = s:save_cpo let &cpo = s:save_cpo

View file

@ -8,11 +8,11 @@ set cpo&vim
" Public functions {{{1 " Public functions {{{1
function! syntastic#util#isRunningWindows() " {{{2 function! syntastic#util#isRunningWindows() abort " {{{2
return has('win16') || has('win32') || has('win64') return has('win16') || has('win32') || has('win64')
endfunction " }}}2 endfunction " }}}2
function! syntastic#util#DevNull() " {{{2 function! syntastic#util#DevNull() abort " {{{2
if syntastic#util#isRunningWindows() if syntastic#util#isRunningWindows()
return 'NUL' return 'NUL'
endif endif
@ -24,8 +24,12 @@ function! syntastic#util#Slash() abort " {{{2
return (!exists("+shellslash") || &shellslash) ? '/' : '\' return (!exists("+shellslash") || &shellslash) ? '/' : '\'
endfunction " }}}2 endfunction " }}}2
function! syntastic#util#CygwinPath(path) abort " {{{2
return substitute(system('cygpath -m ' . syntastic#util#shescape(a:path)), "\n", '', 'g')
endfunction " }}}2
" Create a temporary directory " Create a temporary directory
function! syntastic#util#tmpdir() " {{{2 function! syntastic#util#tmpdir() abort " {{{2
let tempdir = '' let tempdir = ''
if (has('unix') || has('mac')) && executable('mktemp') if (has('unix') || has('mac')) && executable('mktemp')
@ -41,7 +45,7 @@ function! syntastic#util#tmpdir() " {{{2
if has('win32') || has('win64') if has('win32') || has('win64')
let tempdir = $TEMP . syntastic#util#Slash() . 'vim-syntastic-' . getpid() let tempdir = $TEMP . syntastic#util#Slash() . 'vim-syntastic-' . getpid()
elseif has('win32unix') elseif has('win32unix')
let tempdir = s:CygwinPath('/tmp/vim-syntastic-' . getpid()) let tempdir = syntastic#util#CygwinPath('/tmp/vim-syntastic-' . getpid())
elseif $TMPDIR != '' elseif $TMPDIR != ''
let tempdir = $TMPDIR . '/vim-syntastic-' . getpid() let tempdir = $TMPDIR . '/vim-syntastic-' . getpid()
else else
@ -60,7 +64,7 @@ function! syntastic#util#tmpdir() " {{{2
endfunction " }}}2 endfunction " }}}2
" Recursively remove a directory " Recursively remove a directory
function! syntastic#util#rmrf(what) " {{{2 function! syntastic#util#rmrf(what) abort " {{{2
" try to make sure we don't delete directories we didn't create " try to make sure we don't delete directories we didn't create
if a:what !~? 'vim-syntastic-' if a:what !~? 'vim-syntastic-'
return return
@ -94,7 +98,7 @@ endfunction " }}}2
"returns "returns
" "
"{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']} "{'exe': '/usr/bin/perl', 'args': ['-f', '-bar']}
function! syntastic#util#parseShebang() " {{{2 function! syntastic#util#parseShebang() abort " {{{2
for lnum in range(1, 5) for lnum in range(1, 5)
let line = getline(lnum) let line = getline(lnum)
if line =~ '^#!' if line =~ '^#!'
@ -109,7 +113,7 @@ function! syntastic#util#parseShebang() " {{{2
endfunction " }}}2 endfunction " }}}2
" Get the value of a variable. Allow local variables to override global ones. " Get the value of a variable. Allow local variables to override global ones.
function! syntastic#util#var(name, ...) " {{{2 function! syntastic#util#var(name, ...) abort " {{{2
return return
\ exists('b:syntastic_' . a:name) ? b:syntastic_{a:name} : \ exists('b:syntastic_' . a:name) ? b:syntastic_{a:name} :
\ exists('g:syntastic_' . a:name) ? g:syntastic_{a:name} : \ exists('g:syntastic_' . a:name) ? g:syntastic_{a:name} :
@ -117,7 +121,7 @@ function! syntastic#util#var(name, ...) " {{{2
endfunction " }}}2 endfunction " }}}2
" Parse a version string. Return an array of version components. " Parse a version string. Return an array of version components.
function! syntastic#util#parseVersion(version) " {{{2 function! syntastic#util#parseVersion(version) abort " {{{2
return map(split(matchstr( a:version, '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.'), 'str2nr(v:val)') return map(split(matchstr( a:version, '\v^\D*\zs\d+(\.\d+)+\ze' ), '\m\.'), 'str2nr(v:val)')
endfunction " }}}2 endfunction " }}}2
@ -127,13 +131,13 @@ endfunction " }}}2
" the "missing" elements will be assumed to be 0 for the purposes of checking. " the "missing" elements will be assumed to be 0 for the purposes of checking.
" "
" See http://semver.org for info about version numbers. " See http://semver.org for info about version numbers.
function! syntastic#util#versionIsAtLeast(installed, required) " {{{2 function! syntastic#util#versionIsAtLeast(installed, required) abort " {{{2
return syntastic#util#compareLexi(a:installed, a:required) >= 0 return syntastic#util#compareLexi(a:installed, a:required) >= 0
endfunction " }}}2 endfunction " }}}2
" Almost lexicographic comparison of two lists of integers. :) If lists " Almost lexicographic comparison of two lists of integers. :) If lists
" have different lengths, the "missing" elements are assumed to be 0. " have different lengths, the "missing" elements are assumed to be 0.
function! syntastic#util#compareLexi(a, b) " {{{2 function! syntastic#util#compareLexi(a, b) abort " {{{2
for idx in range(max([len(a:a), len(a:b)])) for idx in range(max([len(a:a), len(a:b)]))
let a_element = str2nr(get(a:a, idx, 0)) let a_element = str2nr(get(a:a, idx, 0))
let b_element = str2nr(get(a:b, idx, 0)) let b_element = str2nr(get(a:b, idx, 0))
@ -150,7 +154,7 @@ endfunction " }}}2
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen') let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
lockvar s:_width lockvar s:_width
function! syntastic#util#screenWidth(str, tabstop) " {{{2 function! syntastic#util#screenWidth(str, tabstop) abort " {{{2
let chunks = split(a:str, "\t", 1) let chunks = split(a:str, "\t", 1)
let width = s:_width(chunks[-1]) let width = s:_width(chunks[-1])
for c in chunks[:-2] for c in chunks[:-2]
@ -161,7 +165,7 @@ function! syntastic#util#screenWidth(str, tabstop) " {{{2
endfunction " }}}2 endfunction " }}}2
"print as much of a:msg as possible without "Press Enter" prompt appearing "print as much of a:msg as possible without "Press Enter" prompt appearing
function! syntastic#util#wideMsg(msg) " {{{2 function! syntastic#util#wideMsg(msg) abort " {{{2
let old_ruler = &ruler let old_ruler = &ruler
let old_showcmd = &showcmd let old_showcmd = &showcmd
@ -185,7 +189,7 @@ function! syntastic#util#wideMsg(msg) " {{{2
endfunction " }}}2 endfunction " }}}2
" Check whether a buffer is loaded, listed, and not hidden " Check whether a buffer is loaded, listed, and not hidden
function! syntastic#util#bufIsActive(buffer) " {{{2 function! syntastic#util#bufIsActive(buffer) abort " {{{2
" convert to number, or hell breaks loose " convert to number, or hell breaks loose
let buf = str2nr(a:buffer) let buf = str2nr(a:buffer)
@ -205,7 +209,7 @@ endfunction " }}}2
" start in directory a:where and walk up the parent folders until it " start in directory a:where and walk up the parent folders until it
" finds a file matching a:what; return path to that file " finds a file matching a:what; return path to that file
function! syntastic#util#findInParent(what, where) " {{{2 function! syntastic#util#findInParent(what, where) abort " {{{2
let here = fnamemodify(a:where, ':p') let here = fnamemodify(a:where, ':p')
let root = syntastic#util#Slash() let root = syntastic#util#Slash()
@ -237,7 +241,7 @@ function! syntastic#util#findInParent(what, where) " {{{2
endfunction " }}}2 endfunction " }}}2
" Returns unique elements in a list " Returns unique elements in a list
function! syntastic#util#unique(list) " {{{2 function! syntastic#util#unique(list) abort " {{{2
let seen = {} let seen = {}
let uniques = [] let uniques = []
for e in a:list for e in a:list
@ -250,17 +254,17 @@ function! syntastic#util#unique(list) " {{{2
endfunction " }}}2 endfunction " }}}2
" A less noisy shellescape() " A less noisy shellescape()
function! syntastic#util#shescape(string) " {{{2 function! syntastic#util#shescape(string) abort " {{{2
return a:string =~ '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string) return a:string =~# '\m^[A-Za-z0-9_/.-]\+$' ? a:string : shellescape(a:string)
endfunction " }}}2 endfunction " }}}2
" A less noisy shellescape(expand()) " A less noisy shellescape(expand())
function! syntastic#util#shexpand(string, ...) " {{{2 function! syntastic#util#shexpand(string, ...) abort " {{{2
return syntastic#util#shescape(a:0 ? expand(a:string, a:1) : expand(a:string, 1)) return syntastic#util#shescape(a:0 ? expand(a:string, a:1) : expand(a:string, 1))
endfunction " }}}2 endfunction " }}}2
" Escape arguments " Escape arguments
function! syntastic#util#argsescape(opt) " {{{2 function! syntastic#util#argsescape(opt) abort " {{{2
if type(a:opt) == type('') && a:opt != '' if type(a:opt) == type('') && a:opt != ''
return [a:opt] return [a:opt]
elseif type(a:opt) == type([]) elseif type(a:opt) == type([])
@ -271,7 +275,7 @@ function! syntastic#util#argsescape(opt) " {{{2
endfunction " }}}2 endfunction " }}}2
" decode XML entities " decode XML entities
function! syntastic#util#decodeXMLEntities(string) " {{{2 function! syntastic#util#decodeXMLEntities(string) abort " {{{2
let str = a:string let str = a:string
let str = substitute(str, '\m&lt;', '<', 'g') let str = substitute(str, '\m&lt;', '<', 'g')
let str = substitute(str, '\m&gt;', '>', 'g') let str = substitute(str, '\m&gt;', '>', 'g')
@ -281,7 +285,7 @@ function! syntastic#util#decodeXMLEntities(string) " {{{2
return str return str
endfunction " }}}2 endfunction " }}}2
function! syntastic#util#redraw(full) " {{{2 function! syntastic#util#redraw(full) abort " {{{2
if a:full if a:full
redraw! redraw!
else else
@ -289,7 +293,7 @@ function! syntastic#util#redraw(full) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! syntastic#util#dictFilter(errors, filter) " {{{2 function! syntastic#util#dictFilter(errors, filter) abort " {{{2
let rules = s:_translateFilter(a:filter) let rules = s:_translateFilter(a:filter)
" call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, "applying filter:", rules) " call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, "applying filter:", rules)
try try
@ -303,7 +307,7 @@ endfunction " }}}2
" Return a [high, low] list of integers, representing the time " Return a [high, low] list of integers, representing the time
" (hopefully high resolution) since program start " (hopefully high resolution) since program start
" TODO: This assumes reltime() returns a list of integers. " TODO: This assumes reltime() returns a list of integers.
function! syntastic#util#stamp() " {{{2 function! syntastic#util#stamp() abort " {{{2
return reltime(g:_SYNTASTIC_START) return reltime(g:_SYNTASTIC_START)
endfunction " }}}2 endfunction " }}}2
@ -311,7 +315,7 @@ endfunction " }}}2
" Private functions {{{1 " Private functions {{{1
function! s:_translateFilter(filters) " {{{2 function! s:_translateFilter(filters) abort " {{{2
let conditions = [] let conditions = []
for k in keys(a:filters) for k in keys(a:filters)
if type(a:filters[k]) == type([]) if type(a:filters[k]) == type([])
@ -327,7 +331,7 @@ function! s:_translateFilter(filters) " {{{2
return len(conditions) == 1 ? conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ') return len(conditions) == 1 ? conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
endfunction " }}}2 endfunction " }}}2
function! s:_translateElement(key, term) " {{{2 function! s:_translateElement(key, term) abort " {{{2
let fkey = a:key let fkey = a:key
if fkey[0] == '!' if fkey[0] == '!'
let fkey = fkey[1:] let fkey = fkey[1:]
@ -365,7 +369,7 @@ function! s:_translateElement(key, term) " {{{2
return ret return ret
endfunction " }}}2 endfunction " }}}2
function! s:_rmrf(what) " {{{2 function! s:_rmrf(what) abort " {{{2
if !exists('s:rmdir') if !exists('s:rmdir')
let s:rmdir = syntastic#util#shescape(get(g:, 'netrw_localrmdir', 'rmdir')) let s:rmdir = syntastic#util#shescape(get(g:, 'netrw_localrmdir', 'rmdir'))
endif endif

View file

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.6.0-16' let g:_SYNTASTIC_VERSION = '3.6.0-44'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1
@ -42,15 +42,21 @@ endfor
let s:_running_windows = syntastic#util#isRunningWindows() let s:_running_windows = syntastic#util#isRunningWindows()
lockvar s:_running_windows lockvar s:_running_windows
if !s:_running_windows && executable('uname') if s:_running_windows
let g:_SYNTASTIC_UNAME = 'Windows'
elseif executable('uname')
try try
let s:_uname = system('uname') let g:_SYNTASTIC_UNAME = split(system('uname'), "\n")[0]
catch /\m^Vim\%((\a\+)\)\=:E484/ catch /\m^Vim\%((\a\+)\)\=:E484/
call syntastic#log#error("your shell " . &shell . " can't handle traditional UNIX syntax for redirections") call syntastic#log#error("your shell " . &shell . " can't handle traditional UNIX syntax for redirections")
finish finish
catch /\m^Vim\%((\a\+)\)\=:E684/
let g:_SYNTASTIC_UNAME = 'Unknown'
endtry endtry
lockvar s:_uname else
let g:_SYNTASTIC_UNAME = 'Unknown'
endif endif
lockvar g:_SYNTASTIC_UNAME
" }}}1 " }}}1
@ -152,7 +158,7 @@ let s:modemap = g:SyntasticModeMap.Instance()
" @vimlint(EVL103, 1, a:cursorPos) " @vimlint(EVL103, 1, a:cursorPos)
" @vimlint(EVL103, 1, a:cmdLine) " @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead) " @vimlint(EVL103, 1, a:argLead)
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) " {{{2 function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) abort " {{{2
let checker_names = [] let checker_names = []
for ft in s:_resolve_filetypes([]) for ft in s:_resolve_filetypes([])
call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft)) call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft))
@ -167,7 +173,7 @@ endfunction " }}}2
" @vimlint(EVL103, 1, a:cursorPos) " @vimlint(EVL103, 1, a:cursorPos)
" @vimlint(EVL103, 1, a:cmdLine) " @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead) " @vimlint(EVL103, 1, a:argLead)
function! s:CompleteFiletypes(argLead, cmdLine, cursorPos) " {{{2 function! s:CompleteFiletypes(argLead, cmdLine, cursorPos) abort " {{{2
return join(s:registry.getKnownFiletypes(), "\n") return join(s:registry.getKnownFiletypes(), "\n")
endfunction " }}}2 endfunction " }}}2
" @vimlint(EVL103, 0, a:cursorPos) " @vimlint(EVL103, 0, a:cursorPos)
@ -185,34 +191,34 @@ command! SyntasticSetLoclist call SyntasticSetLoclist()
" Public API {{{1 " Public API {{{1
function! SyntasticCheck(...) " {{{2 function! SyntasticCheck(...) abort " {{{2
call s:UpdateErrors(0, a:000) call s:UpdateErrors(0, a:000)
call syntastic#util#redraw(g:syntastic_full_redraws) call syntastic#util#redraw(g:syntastic_full_redraws)
endfunction " }}}2 endfunction " }}}2
function! SyntasticInfo(...) " {{{2 function! SyntasticInfo(...) abort " {{{2
call s:modemap.modeInfo(a:000) call s:modemap.modeInfo(a:000)
call s:registry.echoInfoFor(s:_resolve_filetypes(a:000)) call s:registry.echoInfoFor(s:_resolve_filetypes(a:000))
call s:_explain_skip(a:000) call s:_explain_skip(a:000)
endfunction " }}}2 endfunction " }}}2
function! SyntasticErrors() " {{{2 function! SyntasticErrors() abort " {{{2
call g:SyntasticLoclist.current().show() call g:SyntasticLoclist.current().show()
endfunction " }}}2 endfunction " }}}2
function! SyntasticReset() " {{{2 function! SyntasticReset() abort " {{{2
call s:ClearCache() call s:ClearCache()
call s:notifiers.refresh(g:SyntasticLoclist.New([])) call s:notifiers.refresh(g:SyntasticLoclist.New([]))
endfunction " }}}2 endfunction " }}}2
function! SyntasticToggleMode() " {{{2 function! SyntasticToggleMode() abort " {{{2
call s:modemap.toggleMode() call s:modemap.toggleMode()
call s:ClearCache() call s:ClearCache()
call s:notifiers.refresh(g:SyntasticLoclist.New([])) call s:notifiers.refresh(g:SyntasticLoclist.New([]))
call s:modemap.echoMode() call s:modemap.echoMode()
endfunction " }}}2 endfunction " }}}2
function! SyntasticSetLoclist() " {{{2 function! SyntasticSetLoclist() abort " {{{2
call g:SyntasticLoclist.current().setloclist() call g:SyntasticLoclist.current().setloclist()
endfunction " }}}2 endfunction " }}}2
@ -233,7 +239,7 @@ if v:version > 703 || (v:version == 703 && has('patch544'))
augroup END augroup END
endif endif
function! s:BufReadPostHook() " {{{2 function! s:BufReadPostHook() abort " {{{2
if g:syntastic_check_on_open if g:syntastic_check_on_open
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufReadPost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr(""))))) \ 'autocmd: BufReadPost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
@ -241,19 +247,19 @@ function! s:BufReadPostHook() " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! s:BufWritePostHook() " {{{2 function! s:BufWritePostHook() abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufWritePost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr(""))))) \ 'autocmd: BufWritePost, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
call s:UpdateErrors(1, []) call s:UpdateErrors(1, [])
endfunction " }}}2 endfunction " }}}2
function! s:BufEnterHook() " {{{2 function! s:BufEnterHook() abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufEnter, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))) . \ 'autocmd: BufEnter, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))) .
\ ', &buftype = ' . string(&buftype)) \ ', &buftype = ' . string(&buftype))
if &buftype == '' if &buftype == ''
call s:notifiers.refresh(g:SyntasticLoclist.current()) call s:notifiers.refresh(g:SyntasticLoclist.current())
elseif &buftype == 'quickfix' elseif &buftype ==# 'quickfix'
" TODO: this is needed because in recent versions of Vim lclose " TODO: this is needed because in recent versions of Vim lclose
" can no longer be called from BufWinLeave " can no longer be called from BufWinLeave
" TODO: at this point there is no b:syntastic_loclist " TODO: at this point there is no b:syntastic_loclist
@ -266,7 +272,7 @@ function! s:BufEnterHook() " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! s:QuitPreHook() " {{{2 function! s:QuitPreHook() abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: QuitPre, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr(""))))) \ 'autocmd: QuitPre, buffer ' . bufnr("") . ' = ' . string(bufname(str2nr(bufnr("")))))
let b:syntastic_skip_checks = get(b:, 'syntastic_skip_checks', 0) || !syntastic#util#var('check_on_wq') let b:syntastic_skip_checks = get(b:, 'syntastic_skip_checks', 0) || !syntastic#util#var('check_on_wq')
@ -280,7 +286,7 @@ endfunction " }}}2
" Main {{{1 " Main {{{1
"refresh and redraw all the error info for this buf when saving or reading "refresh and redraw all the error info for this buf when saving or reading
function! s:UpdateErrors(auto_invoked, checker_names) " {{{2 function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'version') call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'version')
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS) call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES) call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
@ -336,13 +342,13 @@ function! s:UpdateErrors(auto_invoked, checker_names) " {{{2
endfunction " }}}2 endfunction " }}}2
"clear the loc list for the buffer "clear the loc list for the buffer
function! s:ClearCache() " {{{2 function! s:ClearCache() abort " {{{2
call s:notifiers.reset(g:SyntasticLoclist.current()) call s:notifiers.reset(g:SyntasticLoclist.current())
call b:syntastic_loclist.destroy() call b:syntastic_loclist.destroy()
endfunction " }}}2 endfunction " }}}2
"detect and cache all syntax errors in this buffer "detect and cache all syntax errors in this buffer
function! s:CacheErrors(checker_names) " {{{2 function! s:CacheErrors(checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: ' . call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: ' .
\ (len(a:checker_names) ? join(a:checker_names) : 'default checkers')) \ (len(a:checker_names) ? join(a:checker_names) : 'default checkers'))
call s:ClearCache() call s:ClearCache()
@ -351,7 +357,8 @@ function! s:CacheErrors(checker_names) " {{{2
if !s:_skip_file() if !s:_skip_file()
" debug logging {{{3 " debug logging {{{3
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors') call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . getcwd()) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$PATH = ' . string($PATH))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
" }}}3 " }}}3
let filetypes = s:_resolve_filetypes([]) let filetypes = s:_resolve_filetypes([])
@ -452,7 +459,7 @@ endfunction " }}}2
" 'env' - environment variables to set before running the checker " 'env' - environment variables to set before running the checker
" 'returns' - a list of valid exit codes for the checker " 'returns' - a list of valid exit codes for the checker
" @vimlint(EVL102, 1, l:env_save) " @vimlint(EVL102, 1, l:env_save)
function! SyntasticMake(options) " {{{2 function! SyntasticMake(options) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'SyntasticMake: called with options:', a:options) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'SyntasticMake: called with options:', a:options)
" save options and locale env variables {{{3 " save options and locale env variables {{{3
@ -479,8 +486,8 @@ function! SyntasticMake(options) " {{{2
if has_key(a:options, 'env') && len(a:options['env']) if has_key(a:options, 'env') && len(a:options['env'])
for key in keys(a:options['env']) for key in keys(a:options['env'])
if key =~? '\m^[a-z_]\+$' if key =~? '\m^[a-z_]\+$'
exec 'let env_save[' . string(key) . '] = $' . key execute 'let env_save[' . string(key) . '] = $' . key
exec 'let $' . key . ' = ' . string(a:options['env'][key]) execute 'let $' . key . ' = ' . string(a:options['env'][key])
endif endif
endfor endfor
endif endif
@ -495,7 +502,7 @@ function! SyntasticMake(options) " {{{2
let $LC_MESSAGES = old_lc_messages let $LC_MESSAGES = old_lc_messages
if len(env_save) if len(env_save)
for key in keys(env_save) for key in keys(env_save)
exec 'let $' . key . ' = ' . string(env_save[key]) execute 'let $' . key . ' = ' . string(env_save[key])
endfor endfor
endif endif
" }}}3 " }}}3
@ -543,7 +550,7 @@ function! SyntasticMake(options) " {{{2
let &shellredir = old_shellredir let &shellredir = old_shellredir
" }}}3 " }}}3
if !s:_running_windows && (s:_os_name() =~ "FreeBSD" || s:_os_name() =~ "OpenBSD") if !s:_running_windows && (s:_os_name() =~? "FreeBSD" || s:_os_name() =~? "OpenBSD")
call syntastic#util#redraw(g:syntastic_full_redraws) call syntastic#util#redraw(g:syntastic_full_redraws)
endif endif
@ -582,7 +589,7 @@ endfunction " }}}2
"g:syntastic_stl_format "g:syntastic_stl_format
" "
"return '' if no errors are cached for the buffer "return '' if no errors are cached for the buffer
function! SyntasticStatuslineFlag() " {{{2 function! SyntasticStatuslineFlag() abort " {{{2
return g:SyntasticLoclist.current().getStatuslineFlag() return g:SyntasticLoclist.current().getStatuslineFlag()
endfunction " }}}2 endfunction " }}}2
@ -590,12 +597,12 @@ endfunction " }}}2
" Utilities {{{1 " Utilities {{{1
function! s:_resolve_filetypes(filetypes) " {{{2 function! s:_resolve_filetypes(filetypes) abort " {{{2
let type = len(a:filetypes) ? a:filetypes[0] : &filetype let type = len(a:filetypes) ? a:filetypes[0] : &filetype
return split( get(g:syntastic_filetype_map, type, type), '\m\.' ) return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
endfunction " }}}2 endfunction " }}}2
function! s:_ignore_file(filename) " {{{2 function! s:_ignore_file(filename) abort " {{{2
let fname = fnamemodify(a:filename, ':p') let fname = fnamemodify(a:filename, ':p')
for pattern in g:syntastic_ignore_files for pattern in g:syntastic_ignore_files
if fname =~# pattern if fname =~# pattern
@ -606,7 +613,7 @@ function! s:_ignore_file(filename) " {{{2
endfunction " }}}2 endfunction " }}}2
" Skip running in special buffers " Skip running in special buffers
function! s:_skip_file() " {{{2 function! s:_skip_file() abort " {{{2
let fname = expand('%', 1) let fname = expand('%', 1)
let skip = get(b:, 'syntastic_skip_checks', 0) || (&buftype != '') || let skip = get(b:, 'syntastic_skip_checks', 0) || (&buftype != '') ||
\ !filereadable(fname) || getwinvar(0, '&diff') || s:_ignore_file(fname) || \ !filereadable(fname) || getwinvar(0, '&diff') || s:_ignore_file(fname) ||
@ -618,7 +625,7 @@ function! s:_skip_file() " {{{2
endfunction " }}}2 endfunction " }}}2
" Explain why checks will be skipped for the current file " Explain why checks will be skipped for the current file
function! s:_explain_skip(filetypes) " {{{2 function! s:_explain_skip(filetypes) abort " {{{2
if empty(a:filetypes) && s:_skip_file() if empty(a:filetypes) && s:_skip_file()
let why = [] let why = []
let fname = expand('%', 1) let fname = expand('%', 1)
@ -647,7 +654,7 @@ function! s:_explain_skip(filetypes) " {{{2
endfunction " }}}2 endfunction " }}}2
" Take a list of errors and add default values to them from a:options " Take a list of errors and add default values to them from a:options
function! s:_add_to_errors(errors, options) " {{{2 function! s:_add_to_errors(errors, options) abort " {{{2
for err in a:errors for err in a:errors
for key in keys(a:options) for key in keys(a:options)
if !has_key(err, key) || empty(err[key]) if !has_key(err, key) || empty(err[key])
@ -662,7 +669,7 @@ endfunction " }}}2
" XXX: Is this still needed? " XXX: Is this still needed?
" The script changes &shellredir to stop the screen " The script changes &shellredir to stop the screen
" flicking when shelling out to syntax checkers. " flicking when shelling out to syntax checkers.
function! s:_bash_hack() " {{{2 function! s:_bash_hack() abort " {{{2
if g:syntastic_bash_hack if g:syntastic_bash_hack
if !exists('s:shell_is_bash') if !exists('s:shell_is_bash')
let s:shell_is_bash = let s:shell_is_bash =
@ -677,12 +684,8 @@ function! s:_bash_hack() " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! s:_os_name() " {{{2 function! s:_os_name() abort " {{{2
if !exists('s:_uname') return g:_SYNTASTIC_UNAME
let s:_uname = system('uname')
lockvar s:_uname
endif
return s:_uname
endfunction " }}}2 endfunction " }}}2
" }}}1 " }}}1

View file

@ -7,17 +7,17 @@ let g:SyntasticAutoloclistNotifier = {}
" Public methods {{{1 " Public methods {{{1
" "
function! g:SyntasticAutoloclistNotifier.New() " {{{2 function! g:SyntasticAutoloclistNotifier.New() abort " {{{2
let newObj = copy(self) let newObj = copy(self)
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticAutoloclistNotifier.refresh(loclist) " {{{2 function! g:SyntasticAutoloclistNotifier.refresh(loclist) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'autoloclist: refresh') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'autoloclist: refresh')
call g:SyntasticAutoloclistNotifier.AutoToggle(a:loclist) call g:SyntasticAutoloclistNotifier.AutoToggle(a:loclist)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist) " {{{2 function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'autoloclist: toggle') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'autoloclist: toggle')
if !a:loclist.isEmpty() if !a:loclist.isEmpty()
if syntastic#util#var('auto_loc_list') == 1 if syntastic#util#var('auto_loc_list') == 1

View file

@ -11,17 +11,17 @@ let g:SyntasticBalloonsNotifier = {}
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticBalloonsNotifier.New() " {{{2 function! g:SyntasticBalloonsNotifier.New() abort " {{{2
let newObj = copy(self) let newObj = copy(self)
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticBalloonsNotifier.enabled() " {{{2 function! g:SyntasticBalloonsNotifier.enabled() abort " {{{2
return has('balloon_eval') && syntastic#util#var('enable_balloons') return has('balloon_eval') && syntastic#util#var('enable_balloons')
endfunction " }}}2 endfunction " }}}2
" Update the error balloons " Update the error balloons
function! g:SyntasticBalloonsNotifier.refresh(loclist) " {{{2 function! g:SyntasticBalloonsNotifier.refresh(loclist) abort " {{{2
unlet! b:syntastic_private_balloons unlet! b:syntastic_private_balloons
if self.enabled() && !a:loclist.isEmpty() if self.enabled() && !a:loclist.isEmpty()
let b:syntastic_private_balloons = a:loclist.balloons() let b:syntastic_private_balloons = a:loclist.balloons()
@ -33,7 +33,7 @@ endfunction " }}}2
" Reset the error balloons " Reset the error balloons
" @vimlint(EVL103, 1, a:loclist) " @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticBalloonsNotifier.reset(loclist) " {{{2 function! g:SyntasticBalloonsNotifier.reset(loclist) abort " {{{2
let b:syntastic_private_balloons = {} let b:syntastic_private_balloons = {}
if has('balloon_eval') if has('balloon_eval')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'balloons: reset') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'balloons: reset')
@ -47,7 +47,7 @@ endfunction " }}}2
" Private functions {{{1 " Private functions {{{1
function! SyntasticBalloonsExprNotifier() " {{{2 function! SyntasticBalloonsExprNotifier() abort " {{{2
if !exists('b:syntastic_private_balloons') if !exists('b:syntastic_private_balloons')
return '' return ''
endif endif

View file

@ -7,7 +7,7 @@ let g:SyntasticChecker = {}
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticChecker.New(args) " {{{2 function! g:SyntasticChecker.New(args) abort " {{{2
let newObj = copy(self) let newObj = copy(self)
let newObj._filetype = a:args['filetype'] let newObj._filetype = a:args['filetype']
@ -40,25 +40,43 @@ function! g:SyntasticChecker.New(args) " {{{2
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getFiletype() " {{{2 function! g:SyntasticChecker.getFiletype() abort " {{{2
return self._filetype return self._filetype
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getName() " {{{2 function! g:SyntasticChecker.getName() abort " {{{2
return self._name return self._name
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getExec() " {{{2 " Synchronise _exec with user's setting. Force re-validation if needed.
return "
" XXX: This function must be called at least once before calling either
" getExec() or getExecEscaped(). Normally isAvailable() does that for you
" automatically, but you should keep still this in mind if you change the
" current checker workflow.
function! g:SyntasticChecker.syncExec() dict " {{{2
let user_exec =
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec : \ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec', self._exec), 1 ) \ syntastic#util#var(self._filetype . '_' . self._name . '_exec'), 1 )
if user_exec != '' && user_exec !=# self._exec
let self._exec = user_exec
if has_key(self, '_available')
" we have a new _exec on the block, it has to be validated
call remove(self, '_available')
endif
endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getExecEscaped() " {{{2 function! g:SyntasticChecker.getExec() abort " {{{2
return syntastic#util#shescape(self.getExec()) return self._exec
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw() " {{{2 function! g:SyntasticChecker.getExecEscaped() abort " {{{2
return syntastic#util#shescape(self._exec)
endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw() abort " {{{2
let name = self._filetype . '/' . self._name let name = self._filetype . '/' . self._name
try try
let list = self._locListFunc() let list = self._locListFunc()
@ -73,11 +91,11 @@ function! g:SyntasticChecker.getLocListRaw() " {{{2
return list return list
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getLocList() " {{{2 function! g:SyntasticChecker.getLocList() abort " {{{2
return g:SyntasticLoclist.New(self.getLocListRaw()) return g:SyntasticLoclist.New(self.getLocListRaw())
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.getVersion(...) " {{{2 function! g:SyntasticChecker.getVersion(...) abort " {{{2
if !exists('self._version') if !exists('self._version')
let command = a:0 ? a:1 : self.getExecEscaped() . ' --version' let command = a:0 ? a:1 : self.getExecEscaped() . ' --version'
let version_output = system(command) let version_output = system(command)
@ -89,7 +107,7 @@ function! g:SyntasticChecker.getVersion(...) " {{{2
return get(self, '_version', []) return get(self, '_version', [])
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.setVersion(version) " {{{2 function! g:SyntasticChecker.setVersion(version) abort " {{{2
if len(a:version) if len(a:version)
let self._version = copy(a:version) let self._version = copy(a:version)
call self.log(self.getExec() . ' version =', a:version) call self.log(self.getExec() . ' version =', a:version)
@ -98,7 +116,7 @@ function! g:SyntasticChecker.setVersion(version) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.log(msg, ...) " {{{2 function! g:SyntasticChecker.log(msg, ...) abort " {{{2
let leader = self._filetype . '/' . self._name . ': ' let leader = self._filetype . '/' . self._name . ': '
if a:0 > 0 if a:0 > 0
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg, a:1) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg, a:1)
@ -107,7 +125,7 @@ function! g:SyntasticChecker.log(msg, ...) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.makeprgBuild(opts) " {{{2 function! g:SyntasticChecker.makeprgBuild(opts) abort " {{{2
let basename = self._filetype . '_' . self._name . '_' let basename = self._filetype . '_' . self._name . '_'
let parts = [] let parts = []
@ -120,20 +138,21 @@ function! g:SyntasticChecker.makeprgBuild(opts) " {{{2
return join(parts) return join(parts)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.isAvailable() " {{{2 function! g:SyntasticChecker.isAvailable() abort " {{{2
call self.syncExec()
if !has_key(self, '_available') if !has_key(self, '_available')
let self._available = self._isAvailableFunc() let self._available = self._isAvailableFunc()
endif endif
return self._available return self._available
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker.wantSort() " {{{2 function! g:SyntasticChecker.wantSort() abort " {{{2
return syntastic#util#var(self._filetype . '_' . self._name . '_sort', 0) return syntastic#util#var(self._filetype . '_' . self._name . '_sort', 0)
endfunction " }}}2 endfunction " }}}2
" This method is no longer used by syntastic. It's here only to maintain " This method is no longer used by syntastic. It's here only to maintain
" backwards compatibility with external checkers which might depend on it. " backwards compatibility with external checkers which might depend on it.
function! g:SyntasticChecker.setWantSort(val) " {{{2 function! g:SyntasticChecker.setWantSort(val) abort " {{{2
if !exists('g:syntastic_' . self._filetype . '_' . self._name . '_sort') if !exists('g:syntastic_' . self._filetype . '_' . self._name . '_sort')
let g:syntastic_{self._filetype}_{self._name}_sort = a:val let g:syntastic_{self._filetype}_{self._name}_sort = a:val
endif endif
@ -143,7 +162,7 @@ endfunction " }}}2
" Private methods {{{1 " Private methods {{{1
function! g:SyntasticChecker._quietMessages(errors) " {{{2 function! g:SyntasticChecker._quietMessages(errors) abort " {{{2
" wildcard quiet_messages " wildcard quiet_messages
let quiet_filters = copy(syntastic#util#var('quiet_messages', {})) let quiet_filters = copy(syntastic#util#var('quiet_messages', {}))
if type(quiet_filters) != type({}) if type(quiet_filters) != type({})
@ -168,7 +187,7 @@ function! g:SyntasticChecker._quietMessages(errors) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker._populateHighlightRegexes(errors) " {{{2 function! g:SyntasticChecker._populateHighlightRegexes(errors) abort " {{{2
if has_key(self, '_highlightRegexFunc') if has_key(self, '_highlightRegexFunc')
for e in a:errors for e in a:errors
if e['valid'] if e['valid']
@ -181,7 +200,7 @@ function! g:SyntasticChecker._populateHighlightRegexes(errors) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticChecker._getOpt(opts, basename, name, default) " {{{2 function! g:SyntasticChecker._getOpt(opts, basename, name, default) abort " {{{2
let ret = [] let ret = []
call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_before', '')) ) call extend( ret, syntastic#util#argsescape(get(a:opts, a:name . '_before', '')) )
call extend( ret, syntastic#util#argsescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) ) call extend( ret, syntastic#util#argsescape(syntastic#util#var( a:basename . a:name, get(a:opts, a:name, a:default) )) )

View file

@ -7,16 +7,16 @@ let g:SyntasticCursorNotifier = {}
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticCursorNotifier.New() " {{{2 function! g:SyntasticCursorNotifier.New() abort " {{{2
let newObj = copy(self) let newObj = copy(self)
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticCursorNotifier.enabled() " {{{2 function! g:SyntasticCursorNotifier.enabled() abort " {{{2
return syntastic#util#var('echo_current_error') return syntastic#util#var('echo_current_error')
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticCursorNotifier.refresh(loclist) " {{{2 function! g:SyntasticCursorNotifier.refresh(loclist) abort " {{{2
if self.enabled() && !a:loclist.isEmpty() if self.enabled() && !a:loclist.isEmpty()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'cursor: refresh') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'cursor: refresh')
let b:syntastic_private_messages = copy(a:loclist.messages(bufnr(''))) let b:syntastic_private_messages = copy(a:loclist.messages(bufnr('')))
@ -28,7 +28,7 @@ function! g:SyntasticCursorNotifier.refresh(loclist) " {{{2
endfunction " }}}2 endfunction " }}}2
" @vimlint(EVL103, 1, a:loclist) " @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticCursorNotifier.reset(loclist) " {{{2 function! g:SyntasticCursorNotifier.reset(loclist) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'cursor: reset') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'cursor: reset')
autocmd! syntastic CursorMoved autocmd! syntastic CursorMoved
unlet! b:syntastic_private_messages unlet! b:syntastic_private_messages
@ -40,7 +40,7 @@ endfunction " }}}2
" Private functions {{{1 " Private functions {{{1
function! SyntasticRefreshCursor() " {{{2 function! SyntasticRefreshCursor() abort " {{{2
if !exists('b:syntastic_private_messages') || empty(b:syntastic_private_messages) if !exists('b:syntastic_private_messages') || empty(b:syntastic_private_messages)
" file not checked " file not checked
return return
@ -93,7 +93,7 @@ endfunction " }}}2
" Utilities {{{1 " Utilities {{{1
function! s:_is_same_index(line, old_line, column, idx, messages) " {{{2 function! s:_is_same_index(line, old_line, column, idx, messages) abort " {{{2
if a:old_line >= 0 && a:line == a:old_line && a:idx >= 0 if a:old_line >= 0 && a:line == a:old_line && a:idx >= 0
if len(a:messages) <= 1 if len(a:messages) <= 1
return 1 return 1
@ -113,7 +113,7 @@ function! s:_is_same_index(line, old_line, column, idx, messages) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! s:_find_index(column, messages) " {{{2 function! s:_find_index(column, messages) abort " {{{2
let max = len(a:messages) - 1 let max = len(a:messages) - 1
if max == 0 if max == 0
return 0 return 0

View file

@ -13,7 +13,7 @@ let s:setup_done = 0
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticHighlightingNotifier.New() " {{{2 function! g:SyntasticHighlightingNotifier.New() abort " {{{2
let newObj = copy(self) let newObj = copy(self)
if !s:setup_done if !s:setup_done
@ -25,12 +25,12 @@ function! g:SyntasticHighlightingNotifier.New() " {{{2
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticHighlightingNotifier.enabled() " {{{2 function! g:SyntasticHighlightingNotifier.enabled() abort " {{{2
return s:has_highlighting && syntastic#util#var('enable_highlighting') return s:has_highlighting && syntastic#util#var('enable_highlighting')
endfunction " }}}2 endfunction " }}}2
" Sets error highlights in the cuirrent window " Sets error highlights in the cuirrent window
function! g:SyntasticHighlightingNotifier.refresh(loclist) " {{{2 function! g:SyntasticHighlightingNotifier.refresh(loclist) abort " {{{2
if self.enabled() if self.enabled()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'highlighting: refresh') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'highlighting: refresh')
call self._reset() call self._reset()
@ -61,7 +61,7 @@ endfunction " }}}2
" Remove all error highlights from the window " Remove all error highlights from the window
" @vimlint(EVL103, 1, a:loclist) " @vimlint(EVL103, 1, a:loclist)
function! g:SyntasticHighlightingNotifier.reset(loclist) " {{{2 function! g:SyntasticHighlightingNotifier.reset(loclist) abort " {{{2
if s:has_highlighting if s:has_highlighting
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'highlighting: reset') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'highlighting: reset')
call self._reset() call self._reset()
@ -74,7 +74,7 @@ endfunction " }}}2
" Private methods {{{1 " Private methods {{{1
" One time setup: define our own highlighting " One time setup: define our own highlighting
function! g:SyntasticHighlightingNotifier._setup() " {{{2 function! g:SyntasticHighlightingNotifier._setup() abort " {{{2
if s:has_highlighting if s:has_highlighting
if !hlexists('SyntasticError') if !hlexists('SyntasticError')
highlight link SyntasticError SpellBad highlight link SyntasticError SpellBad
@ -91,7 +91,7 @@ function! g:SyntasticHighlightingNotifier._setup() " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticHighlightingNotifier._reset() " {{{2 function! g:SyntasticHighlightingNotifier._reset() abort " {{{2
for match in getmatches() for match in getmatches()
if stridx(match['group'], 'Syntastic') == 0 if stridx(match['group'], 'Syntastic') == 0
call matchdelete(match['id']) call matchdelete(match['id'])

View file

@ -7,7 +7,7 @@ let g:SyntasticLoclist = {}
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticLoclist.New(rawLoclist) " {{{2 function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
let newObj = copy(self) let newObj = copy(self)
let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1') let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1')
@ -27,20 +27,20 @@ function! g:SyntasticLoclist.New(rawLoclist) " {{{2
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.current() " {{{2 function! g:SyntasticLoclist.current() abort " {{{2
if !exists("b:syntastic_loclist") || empty(b:syntastic_loclist) if !exists("b:syntastic_loclist") || empty(b:syntastic_loclist)
let b:syntastic_loclist = g:SyntasticLoclist.New([]) let b:syntastic_loclist = g:SyntasticLoclist.New([])
endif endif
return b:syntastic_loclist return b:syntastic_loclist
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.extend(other) " {{{2 function! g:SyntasticLoclist.extend(other) abort " {{{2
let list = self.copyRaw() let list = self.copyRaw()
call extend(list, a:other.copyRaw()) call extend(list, a:other.copyRaw())
return g:SyntasticLoclist.New(list) return g:SyntasticLoclist.New(list)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.sort() " {{{2 function! g:SyntasticLoclist.sort() abort " {{{2
if !self._sorted if !self._sorted
for e in self._rawLoclist for e in self._rawLoclist
call s:_set_screen_column(e) call s:_set_screen_column(e)
@ -52,11 +52,11 @@ function! g:SyntasticLoclist.sort() " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.isEmpty() " {{{2 function! g:SyntasticLoclist.isEmpty() abort " {{{2
return empty(self._rawLoclist) return empty(self._rawLoclist)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.isNewerThan(stamp) " {{{2 function! g:SyntasticLoclist.isNewerThan(stamp) abort " {{{2
if !exists("self._stamp") if !exists("self._stamp")
let self._stamp = [] let self._stamp = []
return 0 return 0
@ -64,23 +64,23 @@ function! g:SyntasticLoclist.isNewerThan(stamp) " {{{2
return syntastic#util#compareLexi(self._stamp, a:stamp) > 0 return syntastic#util#compareLexi(self._stamp, a:stamp) > 0
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.copyRaw() " {{{2 function! g:SyntasticLoclist.copyRaw() abort " {{{2
return copy(self._rawLoclist) return copy(self._rawLoclist)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getRaw() " {{{2 function! g:SyntasticLoclist.getRaw() abort " {{{2
return self._rawLoclist return self._rawLoclist
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getBuffers() " {{{2 function! g:SyntasticLoclist.getBuffers() abort " {{{2
return syntastic#util#unique(map(copy(self._rawLoclist), 'str2nr(v:val["bufnr"])') + [self._owner]) return syntastic#util#unique(map(copy(self._rawLoclist), 'str2nr(v:val["bufnr"])') + [self._owner])
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getCursorColumns() " {{{2 function! g:SyntasticLoclist.getCursorColumns() abort " {{{2
return self._columns return self._columns
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getStatuslineFlag() " {{{2 function! g:SyntasticLoclist.getStatuslineFlag() abort " {{{2
if !exists("self._stl_format") if !exists("self._stl_format")
let self._stl_format = '' let self._stl_format = ''
endif endif
@ -133,7 +133,7 @@ function! g:SyntasticLoclist.getStatuslineFlag() " {{{2
return self._stl_flag return self._stl_flag
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getFirstError(...) " {{{2 function! g:SyntasticLoclist.getFirstError(...) abort " {{{2
let max_issues = len(self._rawLoclist) let max_issues = len(self._rawLoclist)
if a:0 && a:1 < max_issues if a:0 && a:1 < max_issues
let max_issues = a:1 let max_issues = a:1
@ -148,23 +148,23 @@ function! g:SyntasticLoclist.getFirstError(...) " {{{2
return 0 return 0
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getName() " {{{2 function! g:SyntasticLoclist.getName() abort " {{{2
return len(self._name) return len(self._name)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.setName(name) " {{{2 function! g:SyntasticLoclist.setName(name) abort " {{{2
let self._name = a:name let self._name = a:name
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.getOwner() " {{{2 function! g:SyntasticLoclist.getOwner() abort " {{{2
return self._owner return self._owner
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.setOwner(buffer) " {{{2 function! g:SyntasticLoclist.setOwner(buffer) abort " {{{2
let self._owner = type(a:buffer) == type(0) ? a:buffer : str2nr(a:buffer) let self._owner = type(a:buffer) == type(0) ? a:buffer : str2nr(a:buffer)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.deploy() " {{{2 function! g:SyntasticLoclist.deploy() abort " {{{2
call self.setOwner(bufnr('')) call self.setOwner(bufnr(''))
let self._stamp = syntastic#util#stamp() let self._stamp = syntastic#util#stamp()
for buf in self.getBuffers() for buf in self.getBuffers()
@ -172,19 +172,19 @@ function! g:SyntasticLoclist.deploy() " {{{2
endfor endfor
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.destroy() " {{{2 function! g:SyntasticLoclist.destroy() abort " {{{2
for buf in self.getBuffers() for buf in self.getBuffers()
call setbufvar(buf, 'syntastic_loclist', {}) call setbufvar(buf, 'syntastic_loclist', {})
endfor endfor
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.decorate(tag) " {{{2 function! g:SyntasticLoclist.decorate(tag) abort " {{{2
for e in self._rawLoclist for e in self._rawLoclist
let e['text'] .= ' [' . a:tag . ']' let e['text'] .= ' [' . a:tag . ']'
endfor endfor
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.balloons() " {{{2 function! g:SyntasticLoclist.balloons() abort " {{{2
if !exists("self._cachedBalloons") if !exists("self._cachedBalloons")
let sep = has("balloon_multiline") ? "\n" : ' | ' let sep = has("balloon_multiline") ? "\n" : ' | '
@ -207,14 +207,14 @@ function! g:SyntasticLoclist.balloons() " {{{2
return get(self._cachedBalloons, bufnr(''), {}) return get(self._cachedBalloons, bufnr(''), {})
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.errors() " {{{2 function! g:SyntasticLoclist.errors() abort " {{{2
if !exists("self._cachedErrors") if !exists("self._cachedErrors")
let self._cachedErrors = self.filter({'type': "E"}) let self._cachedErrors = self.filter({'type': "E"})
endif endif
return self._cachedErrors return self._cachedErrors
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.warnings() " {{{2 function! g:SyntasticLoclist.warnings() abort " {{{2
if !exists("self._cachedWarnings") if !exists("self._cachedWarnings")
let self._cachedWarnings = self.filter({'type': "W"}) let self._cachedWarnings = self.filter({'type': "W"})
endif endif
@ -223,12 +223,12 @@ endfunction " }}}2
" Legacy function. Syntastic no longer calls it, but we keep it " Legacy function. Syntastic no longer calls it, but we keep it
" around because other plugins (f.i. powerline) depend on it. " around because other plugins (f.i. powerline) depend on it.
function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay() " {{{2 function! g:SyntasticLoclist.hasErrorsOrWarningsToDisplay() abort " {{{2
return !self.isEmpty() return !self.isEmpty()
endfunction " }}}2 endfunction " }}}2
" cache used by EchoCurrentError() " cache used by EchoCurrentError()
function! g:SyntasticLoclist.messages(buf) " {{{2 function! g:SyntasticLoclist.messages(buf) abort " {{{2
if !exists("self._cachedMessages") if !exists("self._cachedMessages")
let self._cachedMessages = {} let self._cachedMessages = {}
@ -280,14 +280,14 @@ endfunction " }}}2
"would return all errors for buffer 10. "would return all errors for buffer 10.
" "
"Note that all comparisons are done with ==? "Note that all comparisons are done with ==?
function! g:SyntasticLoclist.filter(filters) " {{{2 function! g:SyntasticLoclist.filter(filters) abort " {{{2
let conditions = values(map(copy(a:filters), 's:_translate(v:key, v:val)')) let conditions = values(map(copy(a:filters), 's:_translate(v:key, v:val)'))
let filter = len(conditions) == 1 ? let filter = len(conditions) == 1 ?
\ conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ') \ conditions[0] : join(map(conditions, '"(" . v:val . ")"'), ' && ')
return filter(copy(self._rawLoclist), filter) return filter(copy(self._rawLoclist), filter)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticLoclist.setloclist() " {{{2 function! g:SyntasticLoclist.setloclist() abort " {{{2
if !exists('w:syntastic_loclist_set') if !exists('w:syntastic_loclist_set')
let w:syntastic_loclist_set = 0 let w:syntastic_loclist_set = 0
endif endif
@ -298,7 +298,7 @@ function! g:SyntasticLoclist.setloclist() " {{{2
endfunction " }}}2 endfunction " }}}2
"display the cached errors for this buf in the location list "display the cached errors for this buf in the location list
function! g:SyntasticLoclist.show() " {{{2 function! g:SyntasticLoclist.show() abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: show') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: show')
call self.setloclist() call self.setloclist()
@ -333,7 +333,7 @@ endfunction " }}}2
" Public functions {{{1 " Public functions {{{1
function! SyntasticLoclistHide() " {{{2 function! SyntasticLoclistHide() abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: hide') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: hide')
silent! lclose silent! lclose
endfunction " }}}2 endfunction " }}}2
@ -342,11 +342,11 @@ endfunction " }}}2
" Utilities {{{1 " Utilities {{{1
function! s:_translate(key, val) " {{{2 function! s:_translate(key, val) abort " {{{2
return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val) return 'get(v:val, ' . string(a:key) . ', "") ==? ' . string(a:val)
endfunction " }}}2 endfunction " }}}2
function! s:_set_screen_column(item) " {{{2 function! s:_set_screen_column(item) abort " {{{2
if !has_key(a:item, 'scol') if !has_key(a:item, 'scol')
let col = get(a:item, 'col', 0) let col = get(a:item, 'col', 0)
if col != 0 && get(a:item, 'vcol', 0) == 0 if col != 0 && get(a:item, 'vcol', 0) == 0
@ -363,7 +363,7 @@ function! s:_set_screen_column(item) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! s:_remove_shadowed_items(errors) " {{{2 function! s:_remove_shadowed_items(errors) abort " {{{2
" keep only the first message at a given column " keep only the first message at a given column
let i = 0 let i = 0
while i < len(a:errors) - 1 while i < len(a:errors) - 1
@ -395,7 +395,7 @@ function! s:_remove_shadowed_items(errors) " {{{2
endwhile endwhile
endfunction " }}}2 endfunction " }}}2
function! s:_compare_error_items_by_columns(a, b) " {{{2 function! s:_compare_error_items_by_columns(a, b) abort " {{{2
if a:a['bufnr'] != a:b['bufnr'] if a:a['bufnr'] != a:b['bufnr']
" group by file " group by file
return a:a['bufnr'] - a:b['bufnr'] return a:a['bufnr'] - a:b['bufnr']
@ -413,7 +413,7 @@ function! s:_compare_error_items_by_columns(a, b) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! s:_compare_error_items_by_lines(a, b) " {{{2 function! s:_compare_error_items_by_lines(a, b) abort " {{{2
if a:a['bufnr'] != a:b['bufnr'] if a:a['bufnr'] != a:b['bufnr']
" group by file " group by file
return a:a['bufnr'] - a:b['bufnr'] return a:a['bufnr'] - a:b['bufnr']

View file

@ -7,7 +7,7 @@ let g:SyntasticModeMap = {}
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticModeMap.Instance() " {{{2 function! g:SyntasticModeMap.Instance() abort " {{{2
if !exists('s:SyntasticModeMapInstance') if !exists('s:SyntasticModeMapInstance')
let s:SyntasticModeMapInstance = copy(self) let s:SyntasticModeMapInstance = copy(self)
call s:SyntasticModeMapInstance.synch() call s:SyntasticModeMapInstance.synch()
@ -16,7 +16,7 @@ function! g:SyntasticModeMap.Instance() " {{{2
return s:SyntasticModeMapInstance return s:SyntasticModeMapInstance
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.synch() " {{{2 function! g:SyntasticModeMap.synch() abort " {{{2
if exists('g:syntastic_mode_map') if exists('g:syntastic_mode_map')
let self._mode = get(g:syntastic_mode_map, 'mode', 'active') let self._mode = get(g:syntastic_mode_map, 'mode', 'active')
let self._activeFiletypes = copy(get(g:syntastic_mode_map, 'active_filetypes', [])) let self._activeFiletypes = copy(get(g:syntastic_mode_map, 'active_filetypes', []))
@ -28,7 +28,7 @@ function! g:SyntasticModeMap.synch() " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.allowsAutoChecking(filetype) " {{{2 function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
let fts = split(a:filetype, '\m\.') let fts = split(a:filetype, '\m\.')
if self.isPassive() if self.isPassive()
@ -38,7 +38,7 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype) " {{{2
endif endif
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.doAutoChecking() " {{{2 function! g:SyntasticModeMap.doAutoChecking() abort " {{{2
let local_mode = get(b:, 'syntastic_mode', '') let local_mode = get(b:, 'syntastic_mode', '')
if local_mode ==# 'active' || local_mode ==# 'passive' if local_mode ==# 'active' || local_mode ==# 'passive'
return local_mode ==# 'active' return local_mode ==# 'active'
@ -47,11 +47,11 @@ function! g:SyntasticModeMap.doAutoChecking() " {{{2
return self.allowsAutoChecking(&filetype) return self.allowsAutoChecking(&filetype)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.isPassive() " {{{2 function! g:SyntasticModeMap.isPassive() abort " {{{2
return self._mode ==# 'passive' return self._mode ==# 'passive'
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.toggleMode() " {{{2 function! g:SyntasticModeMap.toggleMode() abort " {{{2
call self.synch() call self.synch()
if self._mode ==# 'active' if self._mode ==# 'active'
@ -67,12 +67,12 @@ function! g:SyntasticModeMap.toggleMode() " {{{2
let g:syntastic_mode_map['mode'] = self._mode let g:syntastic_mode_map['mode'] = self._mode
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.echoMode() " {{{2 function! g:SyntasticModeMap.echoMode() abort " {{{2
echo "Syntastic: " . self._mode . " mode enabled" echo "Syntastic: " . self._mode . " mode enabled"
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap.modeInfo(filetypes) " {{{2 function! g:SyntasticModeMap.modeInfo(filetypes) abort " {{{2
echomsg 'Syntastic version: ' . g:_SYNTASTIC_VERSION echomsg 'Syntastic version: ' . g:_SYNTASTIC_VERSION . ' (Vim ' . v:version . ', ' . g:_SYNTASTIC_UNAME . ')'
let type = len(a:filetypes) ? a:filetypes[0] : &filetype let type = len(a:filetypes) ? a:filetypes[0] : &filetype
echomsg 'Info for filetype: ' . type echomsg 'Info for filetype: ' . type
@ -104,11 +104,11 @@ endfunction " }}}2
" Private methods {{{1 " Private methods {{{1
function! g:SyntasticModeMap._isOneFiletypeActive(filetypes) " {{{2 function! g:SyntasticModeMap._isOneFiletypeActive(filetypes) abort " {{{2
return !empty(filter(copy(a:filetypes), 'index(self._activeFiletypes, v:val) != -1')) return !empty(filter(copy(a:filetypes), 'index(self._activeFiletypes, v:val) != -1'))
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticModeMap._noFiletypesArePassive(filetypes) " {{{2 function! g:SyntasticModeMap._noFiletypesArePassive(filetypes) abort " {{{2
return empty(filter(copy(a:filetypes), 'index(self._passiveFiletypes, v:val) != -1')) return empty(filter(copy(a:filetypes), 'index(self._passiveFiletypes, v:val) != -1'))
endfunction " }}}2 endfunction " }}}2

View file

@ -13,7 +13,7 @@ lockvar! s:_PERSISTENT_NOTIFIERS
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticNotifiers.Instance() " {{{2 function! g:SyntasticNotifiers.Instance() abort " {{{2
if !exists('s:SyntasticNotifiersInstance') if !exists('s:SyntasticNotifiersInstance')
let s:SyntasticNotifiersInstance = copy(self) let s:SyntasticNotifiersInstance = copy(self)
call s:SyntasticNotifiersInstance._initNotifiers() call s:SyntasticNotifiersInstance._initNotifiers()
@ -22,7 +22,7 @@ function! g:SyntasticNotifiers.Instance() " {{{2
return s:SyntasticNotifiersInstance return s:SyntasticNotifiersInstance
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticNotifiers.refresh(loclist) " {{{2 function! g:SyntasticNotifiers.refresh(loclist) abort " {{{2
if !a:loclist.isEmpty() && !a:loclist.isNewerThan([]) if !a:loclist.isEmpty() && !a:loclist.isNewerThan([])
" loclist not fully constructed yet " loclist not fully constructed yet
return return
@ -48,7 +48,7 @@ function! g:SyntasticNotifiers.refresh(loclist) " {{{2
endfor endfor
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticNotifiers.reset(loclist) " {{{2 function! g:SyntasticNotifiers.reset(loclist) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'notifiers: reset') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'notifiers: reset')
for type in self._enabled_types for type in self._enabled_types
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '') let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
@ -71,7 +71,7 @@ endfunction " }}}2
" Private methods {{{1 " Private methods {{{1
function! g:SyntasticNotifiers._initNotifiers() " {{{2 function! g:SyntasticNotifiers._initNotifiers() abort " {{{2
let self._notifier = {} let self._notifier = {}
for type in s:_NOTIFIER_TYPES for type in s:_NOTIFIER_TYPES
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '') let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')

View file

@ -73,8 +73,8 @@ let s:_DEFAULT_CHECKERS = {
\ 'scss': ['sass', 'scss_lint'], \ 'scss': ['sass', 'scss_lint'],
\ 'sh': ['sh', 'shellcheck'], \ 'sh': ['sh', 'shellcheck'],
\ 'slim': ['slimrb'], \ 'slim': ['slimrb'],
\ 'sml': ['smlnj'],
\ 'spec': ['rpmlint'], \ 'spec': ['rpmlint'],
\ 'swift': ['xcrun'],
\ 'tcl': ['nagelfar'], \ 'tcl': ['nagelfar'],
\ 'tex': ['lacheck', 'chktex'], \ 'tex': ['lacheck', 'chktex'],
\ 'texinfo': ['makeinfo'], \ 'texinfo': ['makeinfo'],
@ -137,7 +137,7 @@ let g:SyntasticRegistry = {}
" parameters, all private methods take normalized filetypes. Public methods " parameters, all private methods take normalized filetypes. Public methods
" are thus supposed to normalize filetypes before calling private methods. " are thus supposed to normalize filetypes before calling private methods.
function! g:SyntasticRegistry.Instance() " {{{2 function! g:SyntasticRegistry.Instance() abort " {{{2
if !exists('s:SyntasticRegistryInstance') if !exists('s:SyntasticRegistryInstance')
let s:SyntasticRegistryInstance = copy(self) let s:SyntasticRegistryInstance = copy(self)
let s:SyntasticRegistryInstance._checkerMap = {} let s:SyntasticRegistryInstance._checkerMap = {}
@ -146,7 +146,7 @@ function! g:SyntasticRegistry.Instance() " {{{2
return s:SyntasticRegistryInstance return s:SyntasticRegistryInstance
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticRegistry.CreateAndRegisterChecker(args) " {{{2 function! g:SyntasticRegistry.CreateAndRegisterChecker(args) abort " {{{2
let checker = g:SyntasticChecker.New(a:args) let checker = g:SyntasticChecker.New(a:args)
let registry = g:SyntasticRegistry.Instance() let registry = g:SyntasticRegistry.Instance()
call registry._registerChecker(checker) call registry._registerChecker(checker)
@ -156,7 +156,7 @@ endfunction " }}}2
" If hints_list is empty, user settings are are used instead. Checkers are " If hints_list is empty, user settings are are used instead. Checkers are
" not checked for availability (that is, the corresponding IsAvailable() are " not checked for availability (that is, the corresponding IsAvailable() are
" not run). " not run).
function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) " {{{2 function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) abort " {{{2
let ft = s:_normalise_filetype(a:ftalias) let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft) call self._loadCheckersFor(ft)
@ -179,11 +179,11 @@ endfunction " }}}2
" Same as getCheckers(), but keep only the checkers available. This runs the " Same as getCheckers(), but keep only the checkers available. This runs the
" corresponding IsAvailable() functions for all checkers. " corresponding IsAvailable() functions for all checkers.
function! g:SyntasticRegistry.getCheckersAvailable(ftalias, hints_list) " {{{2 function! g:SyntasticRegistry.getCheckersAvailable(ftalias, hints_list) abort " {{{2
return filter(self.getCheckers(a:ftalias, a:hints_list), 'v:val.isAvailable()') return filter(self.getCheckers(a:ftalias, a:hints_list), 'v:val.isAvailable()')
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticRegistry.getKnownFiletypes() " {{{2 function! g:SyntasticRegistry.getKnownFiletypes() abort " {{{2
let types = keys(s:_DEFAULT_CHECKERS) let types = keys(s:_DEFAULT_CHECKERS)
call extend(types, keys(s:_DEFAULT_FILETYPE_MAP)) call extend(types, keys(s:_DEFAULT_FILETYPE_MAP))
@ -199,13 +199,13 @@ function! g:SyntasticRegistry.getKnownFiletypes() " {{{2
return syntastic#util#unique(types) return syntastic#util#unique(types)
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) " {{{2 function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) abort " {{{2
let ft = s:_normalise_filetype(a:ftalias) let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft) call self._loadCheckersFor(ft)
return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' )) return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' ))
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) " {{{2 function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normalise_filetype(v:val)' )) let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normalise_filetype(v:val)' ))
if len(ft_list) != 1 if len(ft_list) != 1
let available = [] let available = []
@ -274,11 +274,11 @@ function! g:SyntasticRegistry._registerChecker(checker) abort " {{{2
let self._checkerMap[ft][name] = a:checker let self._checkerMap[ft][name] = a:checker
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) " {{{2 function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) abort " {{{2
return filter( map(copy(a:list), 'get(a:checkers_map, v:val, {})'), '!empty(v:val)' ) return filter( map(copy(a:list), 'get(a:checkers_map, v:val, {})'), '!empty(v:val)' )
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticRegistry._loadCheckersFor(filetype) " {{{2 function! g:SyntasticRegistry._loadCheckersFor(filetype) abort " {{{2
if has_key(self._checkerMap, a:filetype) if has_key(self._checkerMap, a:filetype)
return return
endif endif
@ -291,7 +291,7 @@ function! g:SyntasticRegistry._loadCheckersFor(filetype) " {{{2
endfunction " }}}2 endfunction " }}}2
" Check for obsolete variable g:syntastic_<filetype>_checker " Check for obsolete variable g:syntastic_<filetype>_checker
function! g:SyntasticRegistry._checkDeprecation(filetype) " {{{2 function! g:SyntasticRegistry._checkDeprecation(filetype) abort " {{{2
if exists('g:syntastic_' . a:filetype . '_checker') && !exists('g:syntastic_' . a:filetype . '_checkers') if exists('g:syntastic_' . a:filetype . '_checker') && !exists('g:syntastic_' . a:filetype . '_checkers')
let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker] let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker]
call syntastic#log#oneTimeWarn('variable g:syntastic_' . a:filetype . '_checker is deprecated') call syntastic#log#oneTimeWarn('variable g:syntastic_' . a:filetype . '_checker is deprecated')
@ -304,14 +304,14 @@ endfunction " }}}2
"resolve filetype aliases, and replace - with _ otherwise we cant name "resolve filetype aliases, and replace - with _ otherwise we cant name
"syntax checker functions legally for filetypes like "gentoo-metadata" "syntax checker functions legally for filetypes like "gentoo-metadata"
function! s:_normalise_filetype(ftalias) " {{{2 function! s:_normalise_filetype(ftalias) abort " {{{2
let ft = get(s:_DEFAULT_FILETYPE_MAP, a:ftalias, a:ftalias) let ft = get(s:_DEFAULT_FILETYPE_MAP, a:ftalias, a:ftalias)
let ft = get(g:syntastic_filetype_map, ft, ft) let ft = get(g:syntastic_filetype_map, ft, ft)
let ft = substitute(ft, '\m-', '_', 'g') let ft = substitute(ft, '\m-', '_', 'g')
return ft return ft
endfunction " }}}2 endfunction " }}}2
function! s:_disabled_by_eclim(filetype) " {{{2 function! s:_disabled_by_eclim(filetype) abort " {{{2
if index(s:_ECLIM_TYPES, a:filetype) >= 0 if index(s:_ECLIM_TYPES, a:filetype) >= 0
let lang = toupper(a:filetype[0]) . a:filetype[1:] let lang = toupper(a:filetype[0]) . a:filetype[1:]
let ft = a:filetype !=# 'cpp' ? lang : 'C' let ft = a:filetype !=# 'cpp' ? lang : 'C'
@ -321,7 +321,7 @@ function! s:_disabled_by_eclim(filetype) " {{{2
return 0 return 0
endfunction " }}}2 endfunction " }}}2
function! s:_disabled_by_ycm(filetype) " {{{2 function! s:_disabled_by_ycm(filetype) abort " {{{2
return index(s:_YCM_TYPES, a:filetype) >= 0 return index(s:_YCM_TYPES, a:filetype) >= 0
endfunction " }}}2 endfunction " }}}2

View file

@ -19,7 +19,7 @@ let s:setup_done = 0
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticSignsNotifier.New() " {{{2 function! g:SyntasticSignsNotifier.New() abort " {{{2
let newObj = copy(self) let newObj = copy(self)
if !s:setup_done if !s:setup_done
@ -31,11 +31,11 @@ function! g:SyntasticSignsNotifier.New() " {{{2
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticSignsNotifier.enabled() " {{{2 function! g:SyntasticSignsNotifier.enabled() abort " {{{2
return has('signs') && syntastic#util#var('enable_signs') return has('signs') && syntastic#util#var('enable_signs')
endfunction " }}}2 endfunction " }}}2
function! g:SyntasticSignsNotifier.refresh(loclist) " {{{2 function! g:SyntasticSignsNotifier.refresh(loclist) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'signs: refresh') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'signs: refresh')
let old_signs = copy(self._bufSignIds()) let old_signs = copy(self._bufSignIds())
if self.enabled() if self.enabled()
@ -49,7 +49,7 @@ endfunction " }}}2
" Private methods {{{1 " Private methods {{{1
" One time setup: define our own sign types and highlighting " One time setup: define our own sign types and highlighting
function! g:SyntasticSignsNotifier._setup() " {{{2 function! g:SyntasticSignsNotifier._setup() abort " {{{2
if has('signs') if has('signs')
if !hlexists('SyntasticErrorSign') if !hlexists('SyntasticErrorSign')
highlight link SyntasticErrorSign error highlight link SyntasticErrorSign error
@ -83,7 +83,7 @@ function! g:SyntasticSignsNotifier._setup() " {{{2
endfunction " }}}2 endfunction " }}}2
" Place signs by all syntax errors in the buffer " Place signs by all syntax errors in the buffer
function! g:SyntasticSignsNotifier._signErrors(loclist) " {{{2 function! g:SyntasticSignsNotifier._signErrors(loclist) abort " {{{2
let loclist = a:loclist let loclist = a:loclist
if !loclist.isEmpty() if !loclist.isEmpty()
@ -116,7 +116,7 @@ function! g:SyntasticSignsNotifier._signErrors(loclist) " {{{2
endfunction " }}}2 endfunction " }}}2
" Remove the signs with the given ids from this buffer " Remove the signs with the given ids from this buffer
function! g:SyntasticSignsNotifier._removeSigns(ids) " {{{2 function! g:SyntasticSignsNotifier._removeSigns(ids) abort " {{{2
if has('signs') if has('signs')
for s in reverse(copy(a:ids)) for s in reverse(copy(a:ids))
execute "sign unplace " . s execute "sign unplace " . s
@ -126,7 +126,7 @@ function! g:SyntasticSignsNotifier._removeSigns(ids) " {{{2
endfunction " }}}2 endfunction " }}}2
" Get all the ids of the SyntaxError signs in the buffer " Get all the ids of the SyntaxError signs in the buffer
function! g:SyntasticSignsNotifier._bufSignIds() " {{{2 function! g:SyntasticSignsNotifier._bufSignIds() abort " {{{2
if !exists("b:syntastic_private_sign_ids") if !exists("b:syntastic_private_sign_ids")
let b:syntastic_private_sign_ids = [] let b:syntastic_private_sign_ids = []
endif endif

View file

@ -146,7 +146,7 @@ function! SyntaxCheckers_java_javac_GetLocList() dict " {{{1
let fname = expand('%:p:h', 1) . syntastic#util#Slash() . expand ('%:t', 1) let fname = expand('%:p:h', 1) . syntastic#util#Slash() . expand ('%:t', 1)
if has('win32unix') if has('win32unix')
let fname = s:CygwinPath(fname) let fname = syntastic#util#CygwinPath(fname)
endif endif
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
@ -155,9 +155,9 @@ function! SyntaxCheckers_java_javac_GetLocList() dict " {{{1
" unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types " unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types
let errorformat = let errorformat =
\ '%E%f:%l:\ error:\ %m,'. \ '%E%f:%l: error: %m,'.
\ '%W%f:%l:\ warning:\ %m,'. \ '%W%f:%l: warning: %m,'.
\ '%A%f:%l:\ %m,'. \ '%A%f:%l: %m,'.
\ '%+Z%p^,'. \ '%+Z%p^,'.
\ '%+C%.%#,'. \ '%+C%.%#,'.
\ '%-G%.%#' \ '%-G%.%#'
@ -179,10 +179,6 @@ endfunction " }}}1
" Utilities {{{1 " Utilities {{{1
function! s:CygwinPath(path) " {{{2
return substitute(system('cygpath -m ' . syntastic#util#shescape(a:path)), "\n", '', 'g')
endfunction " }}}2
function! s:RemoveCarriageReturn(line) " {{{2 function! s:RemoveCarriageReturn(line) " {{{2
return substitute(a:line, "\r", '', 'g') return substitute(a:line, "\r", '', 'g')
endfunction " }}}2 endfunction " }}}2
@ -360,13 +356,14 @@ function! s:GetMavenClasspath() " {{{2
let mvn_properties = s:GetMavenProperties() let mvn_properties = s:GetMavenProperties()
let output_dir = 'target/classes' let sep = syntastic#util#Slash()
let output_dir = join(['target', 'classes'], sep)
if has_key(mvn_properties, 'project.build.outputDirectory') if has_key(mvn_properties, 'project.build.outputDirectory')
let output_dir = mvn_properties['project.build.outputDirectory'] let output_dir = mvn_properties['project.build.outputDirectory']
endif endif
let mvn_classpath = s:AddToClasspath(mvn_classpath, output_dir) let mvn_classpath = s:AddToClasspath(mvn_classpath, output_dir)
let test_output_dir = 'target/test-classes' let test_output_dir = join(['target', 'test-classes'], sep)
if has_key(mvn_properties, 'project.build.testOutputDirectory') if has_key(mvn_properties, 'project.build.testOutputDirectory')
let test_output_dir = mvn_properties['project.build.testOutputDirectory'] let test_output_dir = mvn_properties['project.build.testOutputDirectory']
endif endif
@ -388,21 +385,23 @@ function! s:MavenOutputDirectory() " {{{2
if has_key(mvn_properties, 'project.properties.build.dir') if has_key(mvn_properties, 'project.properties.build.dir')
let output_dir = mvn_properties['project.properties.build.dir'] let output_dir = mvn_properties['project.properties.build.dir']
endif endif
if stridx(expand('%:p:h', 1), 'src.main.java') >= 0
let output_dir .= '/target/classes' let sep = syntastic#util#Slash()
if stridx(expand('%:p:h', 1), join(['src', 'main', 'java'], sep)) >= 0
let output_dir = join ([output_dir, 'target', 'classes'], sep)
if has_key(mvn_properties, 'project.build.outputDirectory') if has_key(mvn_properties, 'project.build.outputDirectory')
let output_dir = mvn_properties['project.build.outputDirectory'] let output_dir = mvn_properties['project.build.outputDirectory']
endif endif
endif endif
if stridx(expand('%:p:h', 1), 'src.test.java') >= 0 if stridx(expand('%:p:h', 1), join(['src', 'test', 'java'], sep)) >= 0
let output_dir .= '/target/test-classes' let output_dir = join([output_dir, 'target', 'test-classes'], sep)
if has_key(mvn_properties, 'project.build.testOutputDirectory') if has_key(mvn_properties, 'project.build.testOutputDirectory')
let output_dir = mvn_properties['project.build.testOutputDirectory'] let output_dir = mvn_properties['project.build.testOutputDirectory']
endif endif
endif endif
if has('win32unix') if has('win32unix')
let output_dir = s:CygwinPath(output_dir) let output_dir = syntastic#util#CygwinPath(output_dir)
endif endif
return output_dir return output_dir
endif endif

View file

@ -0,0 +1,47 @@
"============================================================================
"File: standard.vim
"Description: JavaScript syntax checker - using standard
"Maintainer: LCD 47 <lcd047@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_javascript_standard_checker")
finish
endif
let g:loaded_syntastic_javascript_standard_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_javascript_standard_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return syntastic#util#versionIsAtLeast(self.getVersion(), [2, 6, 1])
endfunction
function! SyntaxCheckers_javascript_standard_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args': '-v' })
let errorformat = ' %f:%l:%c: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'subtype': 'Style',
\ 'defaults': {'type': 'W'},
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'javascript',
\ 'name': 'standard'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -22,7 +22,7 @@ function! SyntaxCheckers_json_jsonval_GetLocList() dict
let makeprg = self.makeprgBuild({}) let makeprg = self.makeprgBuild({})
let errorformat = let errorformat =
\ '%E%f:\ %m\ at\ line\ %l,' . \ '%E%f: %m at line %l,' .
\ '%-G%.%#' \ '%-G%.%#'
return SyntasticMake({ return SyntasticMake({

View file

@ -21,7 +21,7 @@ set cpo&vim
function! SyntaxCheckers_nasm_nasm_GetLocList() dict function! SyntaxCheckers_nasm_nasm_GetLocList() dict
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'args_after': '-X gnu -f elf' . \ 'args_after': '-X gnu -f elf' .
\ ' -I ' . syntastic#util#shescape(expand('%:p:h', 1) . '/') . \ ' -I ' . syntastic#util#shescape(expand('%:p:h', 1) . syntastic#util#Slash()) .
\ ' ' . syntastic#c#NullOutput() }) \ ' ' . syntastic#c#NullOutput() })
let errorformat = '%f:%l: %t%*[^:]: %m' let errorformat = '%f:%l: %t%*[^:]: %m'

View file

@ -46,7 +46,7 @@ endfunction " }}}1
function! SyntaxCheckers_ocaml_camlp4o_GetLocList() dict " {{{1 function! SyntaxCheckers_ocaml_camlp4o_GetLocList() dict " {{{1
let makeprg = s:GetMakeprg() let makeprg = s:GetMakeprg()
if makeprg == "" if makeprg == ''
return [] return []
endif endif

View file

@ -44,7 +44,7 @@ function! SyntaxCheckers_python_flake8_GetLocList() dict
let e['text'] .= printf(' [%s%03d]', e['type'], e['nr']) let e['text'] .= printf(' [%s%03d]', e['type'], e['nr'])
" E901 are syntax errors " E901 are syntax errors
" E902 are I/O errors " E902 are I/O errors
if e['type'] ==? 'E' && e['nr'] !~ '\m^9' if e['type'] ==? 'E' && e['nr'] !~# '\m^9'
let e['subtype'] = 'Style' let e['subtype'] = 'Style'
endif endif
call remove(e, 'nr') call remove(e, 'nr')

View file

@ -62,7 +62,7 @@ function! SyntaxCheckers_r_lint_GetLocList() dict
\ 'returns': [0] }) \ 'returns': [0] })
for e in loclist for e in loclist
if e['type'] == 'F' if e['type'] ==? 'F'
" parse error " parse error
let e['type'] = 'E' let e['type'] = 'E'
call remove(e, 'subtype') call remove(e, 'subtype')

View file

@ -26,7 +26,7 @@ function! SyntaxCheckers_ruby_reek_IsAvailable() dict
endfunction endfunction
function! SyntaxCheckers_ruby_reek_GetLocList() dict function! SyntaxCheckers_ruby_reek_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_before': '--no-color --quiet --line-number --single-line' }) let makeprg = self.makeprgBuild({ 'args_before': '--no-color --line-number --single-line' })
let errorformat = let errorformat =
\ '%E%.%#: Racc::ParseError: %f:%l :: %m,' . \ '%E%.%#: Racc::ParseError: %f:%l :: %m,' .
@ -34,7 +34,8 @@ function! SyntaxCheckers_ruby_reek_GetLocList() dict
let loclist = SyntasticMake({ let loclist = SyntasticMake({
\ 'makeprg': makeprg, \ 'makeprg': makeprg,
\ 'errorformat': errorformat }) \ 'errorformat': errorformat,
\ 'returns': [0, 2] })
for e in loclist for e in loclist
if e['type'] ==? 'W' if e['type'] ==? 'W'

View file

@ -23,7 +23,9 @@ function! SyntaxCheckers_ruby_rubylint_GetLocList() dict
if !exists('s:rubylint_new') if !exists('s:rubylint_new')
let s:rubylint_new = syntastic#util#versionIsAtLeast(self.getVersion(), [2]) let s:rubylint_new = syntastic#util#versionIsAtLeast(self.getVersion(), [2])
endif endif
let makeprg = self.makeprgBuild({ 'args': (s:rubylint_new ? '' : 'analyze ') . '--presenter=syntastic' }) let makeprg = self.makeprgBuild({
\ 'args': (s:rubylint_new ? '' : 'analyze '),
\ 'args_after': '--presenter=syntastic' })
let errorformat = '%f:%t:%l:%c: %m' let errorformat = '%f:%t:%l:%c: %m'

View file

@ -28,14 +28,14 @@ function! SyntaxCheckers_slim_slimrb_GetLocList() dict
if s:slimrb_new if s:slimrb_new
let errorformat = let errorformat =
\ '%C\ %#%f\, Line %l\, Column %c,'. \ '%C %#%f\, Line %l\, Column %c,'.
\ '%-G\ %.%#,'. \ '%-G %.%#,'.
\ '%ESlim::Parser::SyntaxError: %m,'. \ '%ESlim::Parser::SyntaxError: %m,'.
\ '%+C%.%#' \ '%+C%.%#'
else else
let errorformat = let errorformat =
\ '%C\ %#%f\, Line %l,'. \ '%C %#%f\, Line %l,'.
\ '%-G\ %.%#,'. \ '%-G %.%#,'.
\ '%ESlim::Parser::SyntaxError: %m,'. \ '%ESlim::Parser::SyntaxError: %m,'.
\ '%+C%.%#' \ '%+C%.%#'
endif endif

View file

@ -1,46 +1,45 @@
"============================================================================ "============================================================================
"File: xcrun.vim "File: smlnj.vim
"Description: swift syntax checker - using xcrun "Description: Syntax checking plugin for syntastic.vim
"Maintainer: Tom Fogg <tom@canobe.com> "Maintainer: LCD 47 <lcd047 at gmail dot com>
"License: This program is free software. It comes without any warranty, "License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute " 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 " 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. " Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details. " See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================ "============================================================================
if exists("g:loaded_syntastic_swift_xcrun_checker") if exists("g:loaded_syntastic_sml_smlnj_checker")
finish finish
endif endif
let g:loaded_syntastic_xcrun_checker = 1 let g:loaded_syntastic_sml_smlnj_checker = 1
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! SyntaxCheckers_swift_xcrun_GetLocList() dict function! SyntaxCheckers_sml_smlnj_GetLocList() dict
let makeprg = self.makeprgBuild({})
let makeprg = self.makeprgBuild({ 'args_after': 'swift' })
let errorformat = let errorformat =
\ '%f:%l:%c:{%*[^}]}: %trror: %m,'. \ '%E%f:%l%\%.%c %trror: %m,' .
\ '%f:%l:%c:{%*[^}]}: fatal %trror: %m,'. \ '%E%f:%l%\%.%c-%\d%\+%\%.%\d%\+ %trror: %m,' .
\ '%f:%l:%c:{%*[^}]}: %tarning: %m,'. \ '%W%f:%l%\%.%c %tarning: %m,' .
\ '%f:%l:%c: %trror: %m,'. \ '%W%f:%l%\%.%c-%\d%\+%\%.%\d%\+ %tarning: %m,' .
\ '%f:%l:%c: fatal %trror: %m,'. \ '%C%\s%\+%m,' .
\ '%f:%l:%c: %tarning: %m,'.
\ '%f:%l: %trror: %m,'.
\ '%f:%l: fatal %trror: %m,'.
\ '%f:%l: %tarning: %m,' .
\ '%-G%.%#' \ '%-G%.%#'
return SyntasticMake({ return SyntasticMake({
\ 'makeprg': makeprg, \ 'makeprg': makeprg,
\ 'errorformat': errorformat }) \ 'errorformat': errorformat,
\ 'postprocess': ['compressWhitespace'],
\ 'returns': [0, 1] })
endfunction endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({ call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'swift', \ 'filetype': 'sml',
\ 'name': 'xcrun'}) \ 'name': 'smlnj',
\ 'exec': 'sml'})
let &cpo = s:save_cpo let &cpo = s:save_cpo
unlet s:save_cpo unlet s:save_cpo

View file

@ -0,0 +1,55 @@
"============================================================================
"File: vint.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.
"
"============================================================================
if exists("g:loaded_syntastic_vim_vint_checker")
finish
endif
let g:loaded_syntastic_vim_vint_checker = 1
if !exists('g:syntastic_vim_vint_sort')
let g:syntastic_vim_vint_sort = 1
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_vim_vint_GetLocList() dict
let makeprg = self.makeprgBuild({ 'post_args': '--json' })
let errorformat = '%f:%l:%c:%t: %m'
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'vint',
\ 'returns': [0, 1] })
for e in loclist
if e['type'] ==? 's'
let e['type'] = 'w'
let e['subtype'] = 'Style'
elseif e['type'] !=? 'e' && e['type'] !=? 'w'
let e['type'] = 'e'
endif
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'vim',
\ 'name': 'vint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (C) 2013-2014 Bailey Ling Copyright (C) 2013-2015 Bailey Ling
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"), a copy of this software and associated documentation files (the "Software"),

View file

@ -178,7 +178,7 @@ Contributions and pull requests are welcome. Please take note of the following
# License # License
MIT License. Copyright (c) 2013-2014 Bailey Ling. MIT License. Copyright (c) 2013-2015 Bailey Ling.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bling/vim-airline/trend.png)](https://bitdeli.com/free "Bitdeli Badge") [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bling/vim-airline/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', []) let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', [])

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:prototype = {} let s:prototype = {}
@ -77,7 +77,7 @@ function! s:should_change_group(group1, group2)
endif endif
let color1 = airline#highlighter#get_highlight(a:group1) let color1 = airline#highlighter#get_highlight(a:group1)
let color2 = airline#highlighter#get_highlight(a:group2) let color2 = airline#highlighter#get_highlight(a:group2)
if has('gui_running') if has('gui_running') || (has("termtruecolor") && &guicolors == 1)
return color1[1] != color2[1] || color1[0] != color2[0] return color1[1] != color2[1] || color1[0] != color2[0]
else else
return color1[3] != color2[3] || color1[2] != color2[2] return color1[3] != color2[3] || color1[2] != color2[2]

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
function! airline#debug#profile1() function! airline#debug#profile1()

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
function! airline#deprecation#check() function! airline#deprecation#check()

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:ext = {} let s:ext = {}

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:has_fugitive = exists('*fugitive#head') let s:has_fugitive = exists('*fugitive#head')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists('*bufferline#get_status_string') if !exists('*bufferline#get_status_string')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'command_t_loaded', 0) if !get(g:, 'command_t_loaded', 0)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_csv', 0) && !exists(':Table') if !get(g:, 'loaded_csv', 0) && !exists(':Table')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_ctrlp', 0) if !get(g:, 'loaded_ctrlp', 0)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', { let s:section_truncate_width = get(g:, 'airline#extensions#default#section_truncate_width', {

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':ProjectCreate') if !exists(':ProjectCreate')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
" we don't actually want this loaded :P " we don't actually want this loaded :P

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) && !get(g:, 'loaded_changes', 0) if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) && !get(g:, 'loaded_changes', 0)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':NetrwSettings') if !exists(':NetrwSettings')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_nrrw_rgn', 0) if !get(g:, 'loaded_nrrw_rgn', 0)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':PromptlineSnapshot') if !exists(':PromptlineSnapshot')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let g:airline#extensions#quickfix#quickfix_text = 'Quickfix' let g:airline#extensions#quickfix#quickfix_text = 'Quickfix'

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':SyntasticCheck') if !exists(':SyntasticCheck')

View file

@ -1,36 +1,9 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
scriptencoding utf-8
let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default') let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default')
let s:excludes = get(g:, 'airline#extensions#tabline#excludes', [])
let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1) let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1) let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1)
let s:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
let s:show_close_button = get(g:, 'airline#extensions#tabline#show_close_button', 1)
let s:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X')
let s:buffer_idx_mode = get(g:, 'airline#extensions#tabline#buffer_idx_mode', 0)
let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0)
let s:tab_min_count = get(g:, 'airline#extensions#tabline#tab_min_count', 0)
let s:spc = g:airline_symbols.space
let s:number_map = &encoding == 'utf-8'
\ ? {
\ '0': '⁰',
\ '1': '¹',
\ '2': '²',
\ '3': '³',
\ '4': '⁴',
\ '5': '⁵',
\ '6': '⁶',
\ '7': '⁷',
\ '8': '⁸',
\ '9': '⁹'
\ }
\ : {}
function! airline#extensions#tabline#init(ext) function! airline#extensions#tabline#init(ext)
if has('gui_running') if has('gui_running')
@ -39,42 +12,23 @@ function! airline#extensions#tabline#init(ext)
autocmd User AirlineToggledOn call s:toggle_on() autocmd User AirlineToggledOn call s:toggle_on()
autocmd User AirlineToggledOff call s:toggle_off() autocmd User AirlineToggledOff call s:toggle_off()
autocmd BufDelete * let s:current_bufnr = -1
call s:toggle_on() call s:toggle_on()
call a:ext.add_theme_func('airline#extensions#tabline#load_theme') call a:ext.add_theme_func('airline#extensions#tabline#load_theme')
if s:buffer_idx_mode
call s:define_buffer_idx_mode_mappings()
endif
endfunction endfunction
function! s:toggle_off() function! s:toggle_off()
if exists('s:original_tabline') call airline#extensions#tabline#autoshow#off()
let &tabline = s:original_tabline call airline#extensions#tabline#tabs#off()
let &showtabline = s:original_showtabline call airline#extensions#tabline#buffers#off()
endif
endfunction endfunction
function! s:toggle_on() function! s:toggle_on()
let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ] call airline#extensions#tabline#autoshow#on()
call airline#extensions#tabline#tabs#on()
call airline#extensions#tabline#buffers#on()
set tabline=%!airline#extensions#tabline#get() set tabline=%!airline#extensions#tabline#get()
augroup airline_tabline
autocmd!
" Invalidate cache.
autocmd BufAdd,BufUnload * unlet! s:current_buffer_list
if s:buf_min_count <= 0 && s:tab_min_count <= 1
set showtabline=2
else
if s:show_buffers == 1
autocmd BufEnter * call <sid>show_tabline(s:buf_min_count, len(s:get_buffer_list()))
autocmd BufUnload * call <sid>show_tabline(s:buf_min_count, len(s:get_buffer_list()) - 1)
else
autocmd TabEnter * call <sid>show_tabline(s:tab_min_count, tabpagenr('$'))
endif
endif
augroup END
endfunction endfunction
function! airline#extensions#tabline#load_theme(palette) function! airline#extensions#tabline#load_theme(palette)
@ -101,28 +55,19 @@ function! airline#extensions#tabline#load_theme(palette)
call airline#highlighter#exec('airline_tabhid', l:tabhid) call airline#highlighter#exec('airline_tabhid', l:tabhid)
endfunction endfunction
function! s:show_tabline(min_count, total_count) let s:current_tabcnt = -1
if a:total_count >= a:min_count
if &showtabline != 2
set showtabline=2
endif
else
if &showtabline != 0
set showtabline=0
endif
endif
endfunction
function! airline#extensions#tabline#get() function! airline#extensions#tabline#get()
let curtabcnt = tabpagenr('$') let curtabcnt = tabpagenr('$')
if curtabcnt != s:current_tabcnt if curtabcnt != s:current_tabcnt
let s:current_tabcnt = curtabcnt let s:current_tabcnt = curtabcnt
let s:current_bufnr = -1 " force a refresh... call airline#extensions#tabline#tabs#invalidate()
call airline#extensions#tabline#buffers#invalidate()
endif endif
if s:show_buffers && curtabcnt == 1 || !s:show_tabs if s:show_buffers && curtabcnt == 1 || !s:show_tabs
return s:get_buffers() return airline#extensions#tabline#buffers#get()
else else
return s:get_tabs() return airline#extensions#tabline#tabs#get()
endif endif
endfunction endfunction
@ -133,182 +78,10 @@ function! airline#extensions#tabline#title(n)
endfunction endfunction
function! airline#extensions#tabline#get_buffer_name(nr) function! airline#extensions#tabline#get_buffer_name(nr)
return airline#extensions#tabline#{s:formatter}#format(a:nr, s:get_buffer_list()) return airline#extensions#tabline#formatters#{s:formatter}#format(a:nr, airline#extensions#tabline#buflist#list())
endfunction endfunction
function! s:get_buffer_list() function! airline#extensions#tabline#new_builder()
if exists('s:current_buffer_list')
return s:current_buffer_list
endif
let buffers = []
let cur = bufnr('%')
for nr in range(1, bufnr('$'))
if buflisted(nr) && bufexists(nr)
let toadd = 1
for ex in s:excludes
if match(bufname(nr), ex) >= 0
let toadd = 0
break
endif
endfor
if getbufvar(nr, 'current_syntax') == 'qf'
let toadd = 0
endif
if toadd
call add(buffers, nr)
endif
endif
endfor
let s:current_buffer_list = buffers
return buffers
endfunction
function! s:get_visible_buffers()
let buffers = s:get_buffer_list()
let cur = bufnr('%')
let total_width = 0
let max_width = 0
for nr in buffers
let width = len(airline#extensions#tabline#get_buffer_name(nr)) + 4
let total_width += width
let max_width = max([max_width, width])
endfor
" only show current and surrounding buffers if there are too many buffers
let position = index(buffers, cur)
let vimwidth = &columns
if total_width > vimwidth && position > -1
let buf_count = len(buffers)
" determine how many buffers to show based on the longest buffer width,
" use one on the right side and put the rest on the left
let buf_max = vimwidth / max_width
let buf_right = 1
let buf_left = max([0, buf_max - buf_right])
let start = max([0, position - buf_left])
let end = min([buf_count, position + buf_right])
" fill up available space on the right
if position < buf_left
let end += (buf_left - position)
endif
" fill up available space on the left
if end > buf_count - 1 - buf_right
let start -= max([0, buf_right - (buf_count - 1 - position)])
endif
let buffers = eval('buffers[' . start . ':' . end . ']')
if start > 0
call insert(buffers, -1, 0)
endif
if end < buf_count - 1
call add(buffers, -1)
endif
endif
let g:current_visible_buffers = buffers
return buffers
endfunction
let s:current_bufnr = -1
let s:current_tabnr = -1
let s:current_tabcnt = -1
let s:current_tabline = ''
let s:current_modified = 0
function! s:get_buffers()
let cur = bufnr('%')
if cur == s:current_bufnr
if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified
return s:current_tabline
endif
endif
let l:index = 1
let b = s:new_builder()
let tab_bufs = tabpagebuflist(tabpagenr())
for nr in s:get_visible_buffers()
if nr < 0
call b.add_raw('%#airline_tabhid#...')
continue
endif
if cur == nr
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
else
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod_unsel'
elseif index(tab_bufs, nr) > -1
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
if s:buffer_idx_mode
if len(s:number_map) > 0
call b.add_section(group, s:spc . get(s:number_map, l:index, '') . '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)' . s:spc)
else
call b.add_section(group, '['.l:index.s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.']')
endif
let l:index = l:index + 1
else
call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc)
endif
endfor
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tabfill', '')
call b.add_section('airline_tabtype', ' buffers ')
let s:current_bufnr = cur
let s:current_tabline = b.build()
return s:current_tabline
endfunction
function! s:select_tab(buf_index)
" no-op when called in the NERDTree buffer
if exists('t:NERDTreeBufName') && bufname('%') == t:NERDTreeBufName
return
endif
let idx = a:buf_index
if g:current_visible_buffers[0] == -1
let idx = idx + 1
endif
let buf = get(g:current_visible_buffers, idx, 0)
if buf != 0
exec 'b!' . buf
endif
endfunction
function! s:define_buffer_idx_mode_mappings()
noremap <unique> <Plug>AirlineSelectTab1 :call <SID>select_tab(0)<CR>
noremap <unique> <Plug>AirlineSelectTab2 :call <SID>select_tab(1)<CR>
noremap <unique> <Plug>AirlineSelectTab3 :call <SID>select_tab(2)<CR>
noremap <unique> <Plug>AirlineSelectTab4 :call <SID>select_tab(3)<CR>
noremap <unique> <Plug>AirlineSelectTab5 :call <SID>select_tab(4)<CR>
noremap <unique> <Plug>AirlineSelectTab6 :call <SID>select_tab(5)<CR>
noremap <unique> <Plug>AirlineSelectTab7 :call <SID>select_tab(6)<CR>
noremap <unique> <Plug>AirlineSelectTab8 :call <SID>select_tab(7)<CR>
noremap <unique> <Plug>AirlineSelectTab9 :call <SID>select_tab(8)<CR>
endfunction
function! s:new_builder()
let builder_context = { let builder_context = {
\ 'active' : 1, \ 'active' : 1,
\ 'right_sep' : get(g:, 'airline#extensions#tabline#right_sep' , g:airline_right_sep), \ 'right_sep' : get(g:, 'airline#extensions#tabline#right_sep' , g:airline_right_sep),
@ -324,54 +97,3 @@ function! s:new_builder()
return airline#builder#new(builder_context) return airline#builder#new(builder_context)
endfunction endfunction
function! s:get_tabs()
let curbuf = bufnr('%')
let curtab = tabpagenr()
if curbuf == s:current_bufnr && curtab == s:current_tabnr
if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified
return s:current_tabline
endif
endif
let b = s:new_builder()
for i in range(1, tabpagenr('$'))
if i == curtab
let group = 'airline_tabsel'
if g:airline_detect_modified
for bi in tabpagebuflist(i)
if getbufvar(bi, '&modified')
let group = 'airline_tabmod'
endif
endfor
endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
else
let group = 'airline_tab'
endif
let val = '%('
if s:show_tab_nr
if s:tab_nr_type == 0
let val .= ' %{len(tabpagebuflist('.i.'))}'
else
let val .= (g:airline_symbols.space).i
endif
endif
call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)')
endfor
call b.add_raw('%T')
call b.add_section('airline_tabfill', '')
call b.split()
if s:show_close_button
call b.add_section('airline_tab', ' %999X'.s:close_symbol.' ')
endif
if s:show_tab_type
call b.add_section('airline_tabtype', ' tabs ')
endif
let s:current_bufnr = curbuf
let s:current_tabnr = curtab
let s:current_tabline = b.build()
return s:current_tabline
endfunction

View file

@ -0,0 +1,51 @@
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:buf_min_count = get(g:, 'airline#extensions#tabline#buffer_min_count', 0)
let s:tab_min_count = get(g:, 'airline#extensions#tabline#tab_min_count', 0)
function! airline#extensions#tabline#autoshow#off()
if exists('s:original_tabline')
let &tabline = s:original_tabline
let &showtabline = s:original_showtabline
endif
augroup airline_tabline_autoshow
autocmd!
augroup END
endfunction
function! airline#extensions#tabline#autoshow#on()
let [ s:original_tabline, s:original_showtabline ] = [ &tabline, &showtabline ]
augroup airline_tabline_autoshow
autocmd!
if s:buf_min_count <= 0 && s:tab_min_count <= 1
set showtabline=2
else
if s:show_buffers == 1
autocmd BufEnter * call <sid>show_tabline(s:buf_min_count, len(airline#extensions#tabline#buflist#list()))
autocmd BufUnload * call <sid>show_tabline(s:buf_min_count, len(airline#extensions#tabline#buflist#list()) - 1)
else
autocmd TabEnter * call <sid>show_tabline(s:tab_min_count, tabpagenr('$'))
endif
endif
" Invalidate cache. This has to come after the BufUnload for
" s:show_buffers, to invalidate the cache for BufEnter.
autocmd BufAdd,BufUnload * call airline#extensions#tabline#buflist#invalidate()
augroup END
endfunction
function! s:show_tabline(min_count, total_count)
if a:total_count >= a:min_count
if &showtabline != 2
set showtabline=2
endif
else
if &showtabline != 0
set showtabline=0
endif
endif
endfunction

View file

@ -0,0 +1,185 @@
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
scriptencoding utf-8
let s:buffer_idx_mode = get(g:, 'airline#extensions#tabline#buffer_idx_mode', 0)
let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
let s:spc = g:airline_symbols.space
let s:current_bufnr = -1
let s:current_modified = 0
let s:current_tabline = ''
let s:current_visible_buffers = []
let s:number_map = &encoding == 'utf-8'
\ ? {
\ '0': '⁰',
\ '1': '¹',
\ '2': '²',
\ '3': '³',
\ '4': '⁴',
\ '5': '⁵',
\ '6': '⁶',
\ '7': '⁷',
\ '8': '⁸',
\ '9': '⁹'
\ }
\ : {}
function! airline#extensions#tabline#buffers#off()
augroup airline_tabline_buffers
autocmd!
augroup END
endfunction
function! airline#extensions#tabline#buffers#on()
augroup airline_tabline_buffers
autocmd!
autocmd BufDelete * call airline#extensions#tabline#buffers#invalidate()
augroup END
endfunction
function! airline#extensions#tabline#buffers#invalidate()
let s:current_bufnr = -1
endfunction
function! airline#extensions#tabline#buffers#get()
let cur = bufnr('%')
if cur == s:current_bufnr
if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified
return s:current_tabline
endif
endif
let l:index = 1
let b = airline#extensions#tabline#new_builder()
let tab_bufs = tabpagebuflist(tabpagenr())
for nr in s:get_visible_buffers()
if nr < 0
call b.add_raw('%#airline_tabhid#...')
continue
endif
if cur == nr
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
else
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod_unsel'
elseif index(tab_bufs, nr) > -1
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
if s:buffer_idx_mode
if len(s:number_map) > 0
call b.add_section(group, s:spc . get(s:number_map, l:index, '') . '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)' . s:spc)
else
call b.add_section(group, '['.l:index.s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.']')
endif
let l:index = l:index + 1
else
call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc)
endif
endfor
call b.add_section('airline_tabfill', '')
call b.split()
call b.add_section('airline_tabfill', '')
if s:show_tab_type
call b.add_section('airline_tabtype', ' buffers ')
endif
let s:current_bufnr = cur
let s:current_tabline = b.build()
return s:current_tabline
endfunction
function! s:get_visible_buffers()
let buffers = airline#extensions#tabline#buflist#list()
let cur = bufnr('%')
let total_width = 0
let max_width = 0
for nr in buffers
let width = len(airline#extensions#tabline#get_buffer_name(nr)) + 4
let total_width += width
let max_width = max([max_width, width])
endfor
" only show current and surrounding buffers if there are too many buffers
let position = index(buffers, cur)
let vimwidth = &columns
if total_width > vimwidth && position > -1
let buf_count = len(buffers)
" determine how many buffers to show based on the longest buffer width,
" use one on the right side and put the rest on the left
let buf_max = vimwidth / max_width
let buf_right = 1
let buf_left = max([0, buf_max - buf_right])
let start = max([0, position - buf_left])
let end = min([buf_count, position + buf_right])
" fill up available space on the right
if position < buf_left
let end += (buf_left - position)
endif
" fill up available space on the left
if end > buf_count - 1 - buf_right
let start -= max([0, buf_right - (buf_count - 1 - position)])
endif
let buffers = eval('buffers[' . start . ':' . end . ']')
if start > 0
call insert(buffers, -1, 0)
endif
if end < buf_count - 1
call add(buffers, -1)
endif
endif
let s:current_visible_buffers = buffers
return buffers
endfunction
function! s:select_tab(buf_index)
" no-op when called in the NERDTree buffer
if exists('t:NERDTreeBufName') && bufname('%') == t:NERDTreeBufName
return
endif
let idx = a:buf_index
if s:current_visible_buffers[0] == -1
let idx = idx + 1
endif
let buf = get(s:current_visible_buffers, idx, 0)
if buf != 0
exec 'b!' . buf
endif
endfunction
if s:buffer_idx_mode
noremap <unique> <Plug>AirlineSelectTab1 :call <SID>select_tab(0)<CR>
noremap <unique> <Plug>AirlineSelectTab2 :call <SID>select_tab(1)<CR>
noremap <unique> <Plug>AirlineSelectTab3 :call <SID>select_tab(2)<CR>
noremap <unique> <Plug>AirlineSelectTab4 :call <SID>select_tab(3)<CR>
noremap <unique> <Plug>AirlineSelectTab5 :call <SID>select_tab(4)<CR>
noremap <unique> <Plug>AirlineSelectTab6 :call <SID>select_tab(5)<CR>
noremap <unique> <Plug>AirlineSelectTab7 :call <SID>select_tab(6)<CR>
noremap <unique> <Plug>AirlineSelectTab8 :call <SID>select_tab(7)<CR>
noremap <unique> <Plug>AirlineSelectTab9 :call <SID>select_tab(8)<CR>
endif

View file

@ -0,0 +1,38 @@
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:excludes = get(g:, 'airline#extensions#tabline#excludes', [])
function! airline#extensions#tabline#buflist#invalidate()
unlet! s:current_buffer_list
endfunction
function! airline#extensions#tabline#buflist#list()
if exists('s:current_buffer_list')
return s:current_buffer_list
endif
let buffers = []
let cur = bufnr('%')
for nr in range(1, bufnr('$'))
if buflisted(nr) && bufexists(nr)
let toadd = 1
for ex in s:excludes
if match(bufname(nr), ex) >= 0
let toadd = 0
break
endif
endfor
if getbufvar(nr, 'current_syntax') == 'qf'
let toadd = 0
endif
if toadd
call add(buffers, nr)
endif
endif
endfor
let s:current_buffer_list = buffers
return buffers
endfunction

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.') let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
@ -7,7 +7,7 @@ let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s
let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0) let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0)
let s:buf_modified_symbol = g:airline_symbols.modified let s:buf_modified_symbol = g:airline_symbols.modified
function! airline#extensions#tabline#default#format(bufnr, buffers) function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
let _ = '' let _ = ''
let name = bufname(a:bufnr) let name = bufname(a:bufnr)
@ -21,10 +21,10 @@ function! airline#extensions#tabline#default#format(bufnr, buffers)
endif endif
endif endif
return airline#extensions#tabline#default#wrap_name(a:bufnr, _) return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, _)
endfunction endfunction
function! airline#extensions#tabline#default#wrap_name(bufnr, buffer_name) function! airline#extensions#tabline#formatters#default#wrap_name(bufnr, buffer_name)
let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : '' let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : ''
let _ .= substitute(a:buffer_name, '\\', '/', 'g') let _ .= substitute(a:buffer_name, '\\', '/', 'g')

View file

@ -1,7 +1,7 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
function! airline#extensions#tabline#unique_tail#format(bufnr, buffers) function! airline#extensions#tabline#formatters#unique_tail#format(bufnr, buffers)
let duplicates = {} let duplicates = {}
let tails = {} let tails = {}
let map = {} let map = {}
@ -15,12 +15,12 @@ function! airline#extensions#tabline#unique_tail#format(bufnr, buffers)
let duplicates[nr] = nr let duplicates[nr] = nr
endif endif
let tails[tail] = 1 let tails[tail] = 1
let map[nr] = airline#extensions#tabline#default#wrap_name(nr, tail) let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, tail)
endif endif
endfor endfor
for nr in values(duplicates) for nr in values(duplicates)
let map[nr] = airline#extensions#tabline#default#wrap_name(nr, fnamemodify(bufname(nr), ':p:.')) let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, fnamemodify(bufname(nr), ':p:.'))
endfor endfor
return map[a:bufnr] return map[a:bufnr]

View file

@ -1,13 +1,13 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
scriptencoding utf-8 scriptencoding utf-8
let s:skip_symbol = '…' let s:skip_symbol = '…'
function! airline#extensions#tabline#unique_tail_improved#format(bufnr, buffers) function! airline#extensions#tabline#formatters#unique_tail_improved#format(bufnr, buffers)
if len(a:buffers) <= 1 " don't need to compare bufnames if has less than one buffer opened if len(a:buffers) <= 1 " don't need to compare bufnames if has less than one buffer opened
return airline#extensions#tabline#default#format(a:bufnr, a:buffers) return airline#extensions#tabline#formatters#default#format(a:bufnr, a:buffers)
endif endif
let curbuf_tail = fnamemodify(bufname(a:bufnr), ':t') let curbuf_tail = fnamemodify(bufname(a:bufnr), ':t')
@ -84,8 +84,8 @@ function! airline#extensions#tabline#unique_tail_improved#format(bufnr, buffers)
call insert(buf_name, s:skip_symbol) call insert(buf_name, s:skip_symbol)
endif endif
return airline#extensions#tabline#default#wrap_name(a:bufnr, join(buf_name, '/')) return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, join(buf_name, '/'))
else else
return airline#extensions#tabline#default#format(a:bufnr, a:buffers) return airline#extensions#tabline#formatters#default#format(a:bufnr, a:buffers)
endif endif
endfunction endfunction

View file

@ -0,0 +1,80 @@
" MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:show_tab_nr = get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
let s:tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
let s:show_close_button = get(g:, 'airline#extensions#tabline#show_close_button', 1)
let s:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
let s:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X')
let s:current_bufnr = -1
let s:current_tabnr = -1
let s:current_modified = 0
function! airline#extensions#tabline#tabs#off()
augroup airline_tabline_tabs
autocmd!
augroup END
endfunction
function! airline#extensions#tabline#tabs#on()
augroup airline_tabline_tabs
autocmd!
autocmd BufDelete * call airline#extensions#tabline#tabs#invalidate()
augroup END
endfunction
function! airline#extensions#tabline#tabs#invalidate()
let s:current_bufnr = -1
endfunction
function! airline#extensions#tabline#tabs#get()
let curbuf = bufnr('%')
let curtab = tabpagenr()
if curbuf == s:current_bufnr && curtab == s:current_tabnr
if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified
return s:current_tabline
endif
endif
let b = airline#extensions#tabline#new_builder()
for i in range(1, tabpagenr('$'))
if i == curtab
let group = 'airline_tabsel'
if g:airline_detect_modified
for bi in tabpagebuflist(i)
if getbufvar(bi, '&modified')
let group = 'airline_tabmod'
endif
endfor
endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
else
let group = 'airline_tab'
endif
let val = '%('
if s:show_tab_nr
if s:tab_nr_type == 0
let val .= ' %{len(tabpagebuflist('.i.'))}'
else
let val .= (g:airline_symbols.space).i
endif
endif
call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)')
endfor
call b.add_raw('%T')
call b.add_section('airline_tabfill', '')
call b.split()
if s:show_close_button
call b.add_section('airline_tab', ' %999X'.s:close_symbol.' ')
endif
if s:show_tab_type
call b.add_section('airline_tabtype', ' tabs ')
endif
let s:current_bufnr = curbuf
let s:current_tabnr = curtab
let s:current_tabline = b.build()
return s:current_tabline
endfunction

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':TagbarToggle') if !exists(':TagbarToggle')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':Tmuxline') if !exists(':Tmuxline')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !exists(':UndotreeToggle') if !exists(':UndotreeToggle')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_unite', 0) if !get(g:, 'loaded_unite', 0)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !isdirectory($VIRTUAL_ENV) if !isdirectory($VIRTUAL_ENV)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
" http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html " http://got-ravings.blogspot.com/2008/10/vim-pr0n-statusline-whitespace-flags.html

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
@ -16,13 +16,13 @@ endfunction
function! s:get_syn(group, what) function! s:get_syn(group, what)
" need to pass in mode, known to break on 7.3.547 " need to pass in mode, known to break on 7.3.547
let mode = has('gui_running') ? 'gui' : 'cterm' let mode = has('gui_running') || (has("termtruecolor") && &guicolors == 1) ? 'gui' : 'cterm'
let color = synIDattr(synIDtrans(hlID(a:group)), a:what, mode) let color = synIDattr(synIDtrans(hlID(a:group)), a:what, mode)
if empty(color) || color == -1 if empty(color) || color == -1
let color = synIDattr(synIDtrans(hlID('Normal')), a:what, mode) let color = synIDattr(synIDtrans(hlID('Normal')), a:what, mode)
endif endif
if empty(color) || color == -1 if empty(color) || color == -1
if has('gui_running') if has('gui_running') || (has("termtruecolor") && &guicolors == 1)
let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF' let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF'
else else
let color = a:what ==# 'fg' ? 0 : 1 let color = a:what ==# 'fg' ? 0 : 1
@ -34,7 +34,7 @@ endfunction
function! s:get_array(fg, bg, opts) function! s:get_array(fg, bg, opts)
let fg = a:fg let fg = a:fg
let bg = a:bg let bg = a:bg
return has('gui_running') return has('gui_running') || (has("termtruecolor") && &guicolors == 1)
\ ? [ fg, bg, '', '', join(a:opts, ',') ] \ ? [ fg, bg, '', '', join(a:opts, ',') ]
\ : [ '', '', fg, bg, join(a:opts, ',') ] \ : [ '', '', fg, bg, join(a:opts, ',') ]
endfunction endfunction
@ -42,7 +42,7 @@ endfunction
function! airline#highlighter#get_highlight(group, ...) function! airline#highlighter#get_highlight(group, ...)
let fg = s:get_syn(a:group, 'fg') let fg = s:get_syn(a:group, 'fg')
let bg = s:get_syn(a:group, 'bg') let bg = s:get_syn(a:group, 'bg')
let reverse = has('gui_running') let reverse = has('gui_running') || (has("termtruecolor") && &guicolors == 1)
\ ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui') \ ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui')
\ : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm') \ : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm')
\|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term') \|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term')

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
function! s:check_defined(variable, default) function! s:check_defined(variable, default)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
let s:parts = {} let s:parts = {}

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
call airline#init#bootstrap() call airline#init#bootstrap()

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
" generates a dictionary which defines the colors for each highlight group " generates a dictionary which defines the colors for each highlight group

View file

@ -15,7 +15,7 @@ let s:V4 = [ '#c7915b' , 173 ] " coffee
let s:PA = [ '#f4cf86' , 222 ] " dirtyblonde let s:PA = [ '#f4cf86' , 222 ] " dirtyblonde
let s:RE = [ '#ff9eb8' , 211 ] " dress let s:RE = [ '#ff9eb8' , 211 ] " dress
let s:IA = [ s:N2[1] , s:N3[1] , s:N2[3] , s:N3[3] , '' ] let s:IA = [ s:N3[1] , s:N2[1] , s:N3[3] , s:N2[3] , '' ]
let g:airline#themes#badwolf#palette = {} let g:airline#themes#badwolf#palette = {}

View file

@ -69,7 +69,7 @@ else
\ } \ }
let s:N1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffText', 'fg'], 'bold') let s:N1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffText', 'fg'], 'bold')
let s:N2 = airline#themes#get_highlight('Visual') let s:N2 = airline#themes#get_highlight2(['Visual', 'fg'], ['Visual', 'bg'])
let s:N3 = airline#themes#get_highlight('CursorLine') let s:N3 = airline#themes#get_highlight('CursorLine')
let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
@ -78,19 +78,19 @@ else
\ 'statusline': [ group[0], '', group[2], '', '' ] \ 'statusline': [ group[0], '', group[2], '', '' ]
\ } \ }
let s:I1 = airline#themes#get_highlight2(['DiffAdded', 'bg'], ['DiffAdded', 'fg'], 'bold') let s:I1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffAdded', 'fg'], 'bold')
let s:I2 = airline#themes#get_highlight2(['DiffAdded', 'fg'], ['Normal', 'bg']) let s:I2 = airline#themes#get_highlight2(['DiffAdded', 'fg'], ['Normal', 'bg'])
let s:I3 = s:N3 let s:I3 = s:N3
let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#base16#palette.insert_modified = g:airline#themes#base16#palette.normal_modified let g:airline#themes#base16#palette.insert_modified = g:airline#themes#base16#palette.normal_modified
let s:R1 = airline#themes#get_highlight2(['WarningMsg', 'bg'], ['WarningMsg', 'fg'], 'bold') let s:R1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['WarningMsg', 'fg'], 'bold')
let s:R2 = s:N2 let s:R2 = s:N2
let s:R3 = s:N3 let s:R3 = s:N3
let g:airline#themes#base16#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) let g:airline#themes#base16#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3)
let g:airline#themes#base16#palette.replace_modified = g:airline#themes#base16#palette.normal_modified let g:airline#themes#base16#palette.replace_modified = g:airline#themes#base16#palette.normal_modified
let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Constant', 'fg'], 'bold') let s:V1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['Constant', 'fg'], 'bold')
let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg']) let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg'])
let s:V3 = s:N3 let s:V3 = s:N3
let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
call airline#init#bootstrap() call airline#init#bootstrap()

View file

@ -14,16 +14,17 @@ CONTENTS *airline-contents*
03. Name ................................................. |airline-name| 03. Name ................................................. |airline-name|
04. Configuration ............................... |airline-configuration| 04. Configuration ............................... |airline-configuration|
05. Commands ......................................... |airline-commands| 05. Commands ......................................... |airline-commands|
06. Customization ............................... |airline-customization| 06. Autocommands ................................. |airline-autocommands|
07. Extensions ..................................... |airline-extensions| 07. Customization ............................... |airline-customization|
08. Advanced Customization ............. |airline-advanced-customization| 08. Extensions ..................................... |airline-extensions|
09. Funcrefs ......................................... |airline-funcrefs| 09. Advanced Customization ............. |airline-advanced-customization|
10. Pipeline ......................................... |airline-pipeline| 10. Funcrefs ......................................... |airline-funcrefs|
11. Writing Extensions ..................... |airline-writing-extensions| 11. Pipeline ......................................... |airline-pipeline|
12. Writing Themes ..................................... |airline-themes| 12. Writing Extensions ..................... |airline-writing-extensions|
13. Troubleshooting ........................... |airline-troubleshooting| 13. Writing Themes ..................................... |airline-themes|
14. Contributions ............................... |airline-contributions| 14. Troubleshooting ........................... |airline-troubleshooting|
15. License ........................................... |airline-license| 15. Contributions ............................... |airline-contributions|
16. License ........................................... |airline-license|
============================================================================== ==============================================================================
INTRODUCTION *airline-intro* INTRODUCTION *airline-intro*
@ -146,6 +147,17 @@ COMMANDS *airline-commands*
:AirlineRefresh *:AirlineRefresh* :AirlineRefresh *:AirlineRefresh*
Refreshes all highlight groups and redraws the statusline. Refreshes all highlight groups and redraws the statusline.
==============================================================================
AUTOCOMMANDS *airline-autocommands*
Airline comes with some user-defined autocommands.
|AirlineAfterInit| after plugin is initialized, but before the statusline
is replaced
|AirlineToggledOn| after airline is activated and replaced the statusline
|AirlineToggledOff| after airline is deactivated and the statusline is
restored to the original
============================================================================== ==============================================================================
CUSTOMIZATION *airline-customization* CUSTOMIZATION *airline-customization*
@ -616,7 +628,7 @@ define a section like this: >
let g:airline_section_b = airline#section#create_left(['ffenc','file']) let g:airline_section_b = airline#section#create_left(['ffenc','file'])
let g:airline_section_c = airline#section#create(['%{getcwd()}']) let g:airline_section_c = airline#section#create(['%{getcwd()}'])
endfunction endfunction
autocmd VimEnter * call AirlineInit() autocmd User AirlineAfterInit call AirlineInit()
< <
This will create a section with the `mode`, followed by a space, and our `foo` This will create a section with the `mode`, followed by a space, and our `foo`
part in section `a`. Section `b` will have two parts with a left-side part in section `a`. Section `b` will have two parts with a left-side
@ -795,7 +807,7 @@ Contributions and pull requests are welcome.
============================================================================== ==============================================================================
LICENSE *airline-license* LICENSE *airline-license*
MIT License. Copyright © 2013-2014 Bailey Ling. MIT License. Copyright © 2013-2015 Bailey Ling.
vim:tw=78:ts=8:ft=help:norl: vim:tw=78:ts=8:ft=help:norl:

View file

@ -1,4 +1,4 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2015 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline) if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline)
@ -6,14 +6,8 @@ if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline)
endif endif
let g:loaded_airline = 1 let g:loaded_airline = 1
" autocmd VimEnter * call airline#deprecation#check()
let s:airline_initialized = 0
let s:airline_theme_defined = 0 let s:airline_theme_defined = 0
function! s:init() function! s:init()
if !s:airline_initialized
let s:airline_initialized = 1
call airline#init#bootstrap() call airline#init#bootstrap()
call airline#extensions#load() call airline#extensions#load()
call airline#init#sections() call airline#init#sections()
@ -23,19 +17,19 @@ function! s:init()
let g:airline_theme = get(g:, 'airline_theme', 'dark') let g:airline_theme = get(g:, 'airline_theme', 'dark')
call airline#switch_theme(g:airline_theme) call airline#switch_theme(g:airline_theme)
endif endif
endif
silent doautocmd User AirlineAfterInit
call s:airline_toggle()
endfunction endfunction
function! s:on_window_changed() function! s:on_window_changed()
if pumvisible() if pumvisible()
return return
endif endif
call <sid>init()
call airline#update_statusline() call airline#update_statusline()
endfunction endfunction
function! s:on_colorscheme_changed() function! s:on_colorscheme_changed()
call <sid>init()
if !s:airline_theme_defined if !s:airline_theme_defined
if airline#switch_matching_theme() if airline#switch_matching_theme()
return return
@ -81,11 +75,8 @@ function! s:airline_toggle()
\ | call airline#load_theme() \ | call airline#load_theme()
augroup END augroup END
silent doautocmd User AirlineToggledOn
if s:airline_initialized
call <sid>on_window_changed() call <sid>on_window_changed()
endif silent doautocmd User AirlineToggledOn
endif endif
endfunction endfunction
@ -93,6 +84,7 @@ function! s:get_airline_themes(a, l, p)
let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n") let files = split(globpath(&rtp, 'autoload/airline/themes/'.a:a.'*'), "\n")
return map(files, 'fnamemodify(v:val, ":t:r")') return map(files, 'fnamemodify(v:val, ":t:r")')
endfunction endfunction
function! s:airline_theme(...) function! s:airline_theme(...)
if a:0 if a:0
call airline#switch_theme(a:1) call airline#switch_theme(a:1)
@ -100,10 +92,12 @@ function! s:airline_theme(...)
echo g:airline_theme echo g:airline_theme
endif endif
endfunction endfunction
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>) command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle() command! AirlineToggleWhitespace call airline#extensions#whitespace#toggle()
command! AirlineToggle call <sid>airline_toggle() command! AirlineToggle call <sid>airline_toggle()
command! AirlineRefresh call airline#load_theme() | call airline#update_statusline() command! AirlineRefresh call airline#load_theme() | call airline#update_statusline()
call <sid>airline_toggle() autocmd VimEnter * call airline#deprecation#check()
autocmd VimEnter * call s:init()

View file

@ -193,8 +193,10 @@ function! fugitive#detect(path) abort
let &mls = save_mls let &mls = save_mls
endtry endtry
endif endif
if !exists('g:fugitive_no_maps')
cnoremap <buffer> <expr> <C-R><C-G> fnameescape(<SID>recall()) cnoremap <buffer> <expr> <C-R><C-G> fnameescape(<SID>recall())
nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR> nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR>
endif
let buffer = fugitive#buffer() let buffer = fugitive#buffer()
if expand('%:p') =~# '//' if expand('%:p') =~# '//'
call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', '')) call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', ''))
@ -2225,7 +2227,10 @@ function! s:Browse(bang,line1,count,...) abort
elseif exists(':Browse') == 2 elseif exists(':Browse') == 2
return 'echomsg '.string(url).'|Browse '.url return 'echomsg '.string(url).'|Browse '.url
else else
if has("patch-7.4.567") if !exists('g:loaded_netrw')
runtime! autoload/netrw.vim
endif
if exists('*netrw#BrowseX')
return 'echomsg '.string(url).'|call netrw#BrowseX('.string(url).', 0)' return 'echomsg '.string(url).'|call netrw#BrowseX('.string(url).', 0)'
else else
return 'echomsg '.string(url).'|call netrw#NetrwBrowseX('.string(url).', 0)' return 'echomsg '.string(url).'|call netrw#NetrwBrowseX('.string(url).', 0)'

View file

@ -37,26 +37,28 @@ disabled/enabled easily.
## Install ## Install
First of all, do not use it with other Go plugins. If you use pathogen, just Vim-go follows the standard runtime path structure, so I highly recommend to use
clone it into your bundle directory: a common and well known plugin manager to install vim-go. Do not use vim-go with
other Go plugins. For Pathogen just clone the repo, for other plugin managers
add the appropriate lines and execute the plugin's install command.
```bash * [Pathogen](https://github.com/tpope/vim-pathogen)
$ cd ~/.vim/bundle * `git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go`
$ git clone https://github.com/fatih/vim-go.git * [vim-plug](https://github.com/junegunn/vim-plug)
``` * `Plug 'fatih/vim-go'`
* [NeoBundle](https://github.com/Shougo/neobundle.vim)
* `NeoBundle 'fatih/vim-go'`
* [Vundle](https://github.com/gmarik/vundle)
* `Plugin 'fatih/vim-go'`
* Manual
* Copy all of the files into your `~/.vim` directory
For Vundle add this line to your vimrc:
```vimrc
Plugin 'fatih/vim-go'
```
and execute `:PluginInstall` (or `:BundleInstall` for older versions of Vundle)
Please be sure all necessary binaries are installed (such as `gocode`, `godef`, Please be sure all necessary binaries are installed (such as `gocode`, `godef`,
`goimports`, etc..). You can easily install them with the included `goimports`, etc..). You can easily install them with the included
`:GoInstallBinaries` command. Those binaries will be automatically downloaded `:GoInstallBinaries` command. If you invoke it, all necessary binaries will be
and installed to your `$GOBIN` environment (if not set it will use automatically downloaded and installed to your `$GOBIN` environment (if not set
`$GOPATH/bin`). It requires `git` and `hg` for fetching the individual Go it will use `$GOPATH/bin`). It requires `git` for fetching the individual Go
packages. packages.
### Optional ### Optional

View file

@ -68,7 +68,7 @@ function! go#fmt#Format(withGoimport)
" restore 'redo' history because it's getting being destroyed every " restore 'redo' history because it's getting being destroyed every
" BufWritePre " BufWritePre
let tmpundofile=tempname() let tmpundofile=tempname()
exe 'wundo! ' . Tmpundofile exe 'wundo! ' . tmpundofile
endif endif
" get the command first so we can test it " get the command first so we can test it

View file

@ -10,16 +10,20 @@ if !exists("g:go_oracle_bin")
let g:go_oracle_bin = "oracle" let g:go_oracle_bin = "oracle"
endif endif
" Parses (via regex) Oracle's 'plain' format output and puts them into a
" quickfix list.
func! s:qflist(output) func! s:qflist(output)
let qflist = [] let qflist = []
" Parse GNU-style 'file:line.col-line.col: message' format. " Parse GNU-style 'file:line.col-line.col: message' format.
let mx = '^\(\a:[\\/][^:]\+\|[^:]\+\):\(\d\+\):\(\d\+\):\(.*\)$' let mx = '^\(\a:[\\/][^:]\+\|[^:]\+\):\(\d\+\):\(\d\+\):\(.*\)$'
for line in split(a:output, "\n") for line in split(a:output, "\n")
let ml = matchlist(line, mx) let ml = matchlist(line, mx)
" Ignore non-match lines or warnings " Ignore non-match lines or warnings
if ml == [] || ml[4] =~ '^ warning:' if ml == [] || ml[4] =~ '^ warning:'
continue continue
endif endif
let item = { let item = {
\ 'filename': ml[1], \ 'filename': ml[1],
\ 'text': ml[4], \ 'text': ml[4],
@ -36,6 +40,31 @@ func! s:qflist(output)
cwindow cwindow
endfun endfun
" This uses Vim's errorformat to parse the output from Oracle's 'plain output
" and put it into quickfix list. I believe using errorformat is much more
" easier to use. If we need more power we can always switch back to parse it
" via regex.
func! s:qflistSecond(output)
" backup users errorformat, will be restored once we are finished
let old_errorformat = &errorformat
" match two possible styles of errorformats:
"
" 'file:line.col-line2.col2: message'
" 'file:line:col: message'
"
" We discard line2 and col2 for the first errorformat, because it's not
" useful and quickfix only has the ability to show one line and column
" number
let &errorformat = "%f:%l.%c-%.%#:\ %m,%f:%l:%c:\ %m"
" create the quickfix list and open it
cgetexpr split(a:output, "\n")
cwindow
let &errorformat = old_errorformat
endfun
func! s:getpos(l, c) func! s:getpos(l, c)
if &encoding != 'utf-8' if &encoding != 'utf-8'
let buf = a:l == 1 ? '' : (join(getline(1, a:l-1), "\n") . "\n") let buf = a:l == 1 ? '' : (join(getline(1, a:l-1), "\n") . "\n")
@ -50,16 +79,21 @@ func! s:RunOracle(mode, selected) range abort
let dname = expand('%:p:h') let dname = expand('%:p:h')
let pkg = go#package#ImportPath(dname) let pkg = go#package#ImportPath(dname)
if exists('g:go_oracle_scope_file') if exists('g:go_oracle_scope')
" let the user defines the scope " let the user defines the scope, must be a space separated string,
let sname = shellescape(get(g:, 'go_oracle_scope_file')) " example: 'fmt math net/http'
let unescaped_scopes = split(get(g:, 'go_oracle_scope'))
let scopes = []
for unescaped_scope in unescaped_scopes
call add(scopes, shellescape(unescaped_scope))
endfor
elseif exists('g:go_oracle_include_tests') && pkg != -1 elseif exists('g:go_oracle_include_tests') && pkg != -1
" give import path so it includes all _test.go files too " give import path so it includes all _test.go files too
let sname = shellescape(pkg) let scopes = [shellescape(pkg)]
else else
" best usable way, only pass the package itself, without the test " best usable way, only pass the package itself, without the test
" files " files
let sname = join(go#tool#Files(), ' ') let scopes = go#tool#Files()
endif endif
"return with a warning if the bin doesn't exist "return with a warning if the bin doesn't exist
@ -71,16 +105,24 @@ func! s:RunOracle(mode, selected) range abort
if a:selected != -1 if a:selected != -1
let pos1 = s:getpos(line("'<"), col("'<")) let pos1 = s:getpos(line("'<"), col("'<"))
let pos2 = s:getpos(line("'>"), col("'>")) let pos2 = s:getpos(line("'>"), col("'>"))
let cmd = printf('%s -format json -pos=%s:#%d,#%d %s %s', let cmd = printf('%s -format plain -pos=%s:#%d,#%d %s',
\ bin_path, \ bin_path,
\ shellescape(fname), pos1, pos2, a:mode, sname) \ shellescape(fname), pos1, pos2, a:mode)
else else
let pos = s:getpos(line('.'), col('.')) let pos = s:getpos(line('.'), col('.'))
let cmd = printf('%s -format json -pos=%s:#%d %s %s', let cmd = printf('%s -format plain -pos=%s:#%d %s',
\ bin_path, \ bin_path,
\ shellescape(fname), pos, a:mode, sname) \ shellescape(fname), pos, a:mode)
endif endif
" now append each scope to the end as Oracle's scope parameter. It can be
" a packages or go files, dependent on the User's own choice. For more
" info check Oracle's User Manual section about scopes:
" https://docs.google.com/document/d/1SLk36YRjjMgKqe490mSRzOPYEDe0Y_WQNRv-EiFYUyw/view#heading=h.nwso96pj07q8
for scope in scopes
let cmd .= ' ' . scope
endfor
echon "vim-go: " | echohl Identifier | echon "analysing ..." | echohl None echon "vim-go: " | echohl Identifier | echon "analysing ..." | echohl None
let out = system(cmd) let out = system(cmd)
@ -89,169 +131,65 @@ func! s:RunOracle(mode, selected) range abort
" parsable to show the real error. But the main issue is usually the " parsable to show the real error. But the main issue is usually the
" package which doesn't build. " package which doesn't build.
redraw | echon "vim-go: " | echohl Statement | echon out | echohl None redraw | echon "vim-go: " | echohl Statement | echon out | echohl None
return {} return ""
else else
let json_decoded = webapi#json#decode(out)
return json_decoded return out
endif
endfun endfun
" Show 'implements' relation for selected package " Show 'implements' relation for selected package
function! go#oracle#Implements(selected) function! go#oracle#Implements(selected)
let out = s:RunOracle('implements', a:selected) let out = s:RunOracle('implements', a:selected)
if empty(out) call s:qflistSecond(out)
return
endif
" be sure they exists before we retrieve them from the map
if !has_key(out, "implements")
return
endif
if has_key(out.implements, "from")
let interfaces = out.implements.from
elseif has_key(out.implements, "fromptr")
let interfaces = out.implements.fromptr
else
redraw | echon "vim-go: " | echon "does not satisfy any interface"| echohl None
return
endif
" get the type name from the type under the cursor
let typeName = out.implements.type.name
" prepare the title
let title = typeName . " implements:"
" start to populate our buffer content
let result = [title, ""]
for interface in interfaces
" don't add runtime interfaces
if interface.name !~ '^runtime'
let line = interface.name . "\t" . interface.pos
call add(result, line)
endif
endfor
" open a window and put the result
call go#ui#OpenWindow("Implements", result)
" define some buffer related mappings:
"
" go to definition when hit enter
nnoremap <buffer> <CR> :<C-u>call go#ui#OpenDefinition("implements")<CR>
" close the window when hit ctrl-c
nnoremap <buffer> <c-c> :<C-u>call go#ui#CloseWindow()<CR>
endfunction endfunction
" Describe selected syntax: definition, methods, etc " Describe selected syntax: definition, methods, etc
function! go#oracle#Describe(selected) function! go#oracle#Describe(selected)
let out = s:RunOracle('describe', a:selected) let out = s:RunOracle('describe', a:selected)
if empty(out) call s:qflistSecond(out)
return
endif
echo out
return
let detail = out["describe"]["detail"]
let desc = out["describe"]["desc"]
echo '# detail: '. detail
" package, constant, variable, type, function or statement labe
if detail == "package"
echo desc
return
endif
if detail == "value"
echo desc
echo out["describe"]["value"]
return
endif
" the rest needs to be implemented
echo desc
endfunction endfunction
" Show possible targets of selected function call " Show possible targets of selected function call
function! go#oracle#Callees(selected) function! go#oracle#Callees(selected)
let out = s:RunOracle('callees', a:selected) let out = s:RunOracle('callees', a:selected)
if empty(out) call s:qflistSecond(out)
return
endif
" be sure the callees object exists which contains the position and names
" of the callees, before we continue
if !has_key(out, "callees")
return
endif
" get the callees list
if has_key(out.callees, "callees")
let callees = out.callees.callees
else
redraw | echon "vim-go: " | echon "no callees available"| echohl None
return
endif
let title = "Call targets:"
" start to populate our buffer content
let result = [title, ""]
for calls in callees
let line = calls.name . "\t" . calls.pos
call add(result, line)
endfor
" open a window and put the result
call go#ui#OpenWindow("Callees", result)
" define some buffer related mappings:
"
" go to definition when hit enter
nnoremap <buffer> <CR> :<C-u>call go#ui#OpenDefinition("call targets")<CR>
" close the window when hit ctrl-c
nnoremap <buffer> <c-c> :<C-u>call go#ui#CloseWindow()<CR>
endfunction endfunction
" Show possible callers of selected function " Show possible callers of selected function
function! go#oracle#Callers(selected) function! go#oracle#Callers(selected)
let out = s:RunOracle('callers', a:selected) let out = s:RunOracle('callers', a:selected)
echo out call s:qflistSecond(out)
endfunction endfunction
" Show the callgraph of the current program. " Show the callgraph of the current program.
function! go#oracle#Callgraph(selected) function! go#oracle#Callgraph(selected)
let out = s:RunOracle('callgraph', a:selected) let out = s:RunOracle('callgraph', a:selected)
echo out call s:qflistSecond(out)
endfunction endfunction
" Show path from callgraph root to selected function " Show path from callgraph root to selected function
function! go#oracle#Callstack(selected) function! go#oracle#Callstack(selected)
let out = s:RunOracle('callstack', a:selected) let out = s:RunOracle('callstack', a:selected)
echo out call s:qflistSecond(out)
endfunction endfunction
" Show free variables of selection " Show free variables of selection
function! go#oracle#Freevars(selected) function! go#oracle#Freevars(selected)
let out = s:RunOracle('freevars', a:selected) let out = s:RunOracle('freevars', a:selected)
echo out call s:qflistSecond(out)
endfunction endfunction
" Show send/receive corresponding to selected channel op " Show send/receive corresponding to selected channel op
function! go#oracle#Peers(selected) function! go#oracle#ChannelPeers(selected)
let out = s:RunOracle('peers', a:selected) let out = s:RunOracle('peers', a:selected)
echo out call s:qflistSecond(out)
endfunction endfunction
" Show all refs to entity denoted by selected identifier " Show all refs to entity denoted by selected identifier
function! go#oracle#Referrers(selected) function! go#oracle#Referrers(selected)
let out = s:RunOracle('referrers', a:selected) let out = s:RunOracle('referrers', a:selected)
echo out call s:qflistSecond(out)
endfunction endfunction
" vim:ts=4:sw=4:et " vim:ts=4:sw=4:et

View file

@ -1,135 +0,0 @@
" json
" Last Change: 2012-03-08
" Maintainer: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" License: This file is placed in the public domain.
" Reference:
"
let s:save_cpo = &cpo
set cpo&vim
function! webapi#json#null()
return 0
endfunction
function! webapi#json#true()
return 1
endfunction
function! webapi#json#false()
return 0
endfunction
function! s:nr2byte(nr)
if a:nr < 0x80
return nr2char(a:nr)
elseif a:nr < 0x800
return nr2char(a:nr/64+192).nr2char(a:nr%64+128)
else
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
endif
endfunction
function! s:nr2enc_char(charcode)
if &encoding == 'utf-8'
return nr2char(a:charcode)
endif
let char = s:nr2byte(a:charcode)
if strlen(char) > 1
let char = strtrans(iconv(char, 'utf-8', &encoding))
endif
return char
endfunction
function! s:fixup(val, tmp)
if type(a:val) == 0
return a:val
elseif type(a:val) == 1
if a:val == a:tmp.'null'
return function('webapi#json#null')
elseif a:val == a:tmp.'true'
return function('webapi#json#true')
elseif a:val == a:tmp.'false'
return function('webapi#json#false')
endif
return a:val
elseif type(a:val) == 2
return a:val
elseif type(a:val) == 3
return map(a:val, 's:fixup(v:val, a:tmp)')
elseif type(a:val) == 4
return map(a:val, 's:fixup(v:val, a:tmp)')
else
return string(a:val)
endif
endfunction
function! webapi#json#decode(json)
let json = iconv(a:json, "utf-8", &encoding)
if get(g:, 'webapi#json#parse_strict', 1) == 1 && substitute(substitute(substitute(
\ json,
\ '\\\%(["\\/bfnrt]\|u[0-9a-fA-F]\{4}\)', '\@', 'g'),
\ '"[^\"\\\n\r]*\"\|true\|false\|null\|-\?\d\+'
\ . '\%(\.\d*\)\?\%([eE][+\-]\{-}\d\+\)\?', ']', 'g'),
\ '\%(^\|:\|,\)\%(\s*\[\)\+', '', 'g') !~ '^[\],:{} \t\n]*$'
throw json
endif
let json = substitute(json, '\n', '', 'g')
let json = substitute(json, '\\u34;', '\\"', 'g')
if v:version >= 703 && has('patch780')
let json = substitute(json, '\\u\(\x\x\x\x\)', '\=iconv(nr2char(str2nr(submatch(1), 16), 1), "utf-8", &encoding)', 'g')
else
let json = substitute(json, '\\u\(\x\x\x\x\)', '\=s:nr2enc_char("0x".submatch(1))', 'g')
endif
if get(g:, 'webapi#json#allow_nil', 0) != 0
let tmp = '__WEBAPI_JSON__'
while 1
if stridx(json, tmp) == -1
break
endif
let tmp .= '_'
endwhile
let [null,true,false] = [
\ tmp.'null',
\ tmp.'true',
\ tmp.'false']
sandbox let ret = eval(json)
call s:fixup(ret, tmp)
else
let [null,true,false] = [0,1,0]
sandbox let ret = eval(json)
endif
return ret
endfunction
function! webapi#json#encode(val)
if type(a:val) == 0
return a:val
elseif type(a:val) == 1
let json = '"' . escape(a:val, '\"') . '"'
let json = substitute(json, "\r", '\\r', 'g')
let json = substitute(json, "\n", '\\n', 'g')
let json = substitute(json, "\t", '\\t', 'g')
let json = substitute(json, '\([[:cntrl:]]\)', '\=printf("\x%02d", char2nr(submatch(1)))', 'g')
return iconv(json, &encoding, "utf-8")
elseif type(a:val) == 2
let s = string(a:val)
if s == "function('webapi#json#null')"
return 'null'
elseif s == "function('webapi#json#true')"
return 'true'
elseif s == "function('webapi#json#false')"
return 'false'
endif
elseif type(a:val) == 3
return '[' . join(map(copy(a:val), 'webapi#json#encode(v:val)'), ',') . ']'
elseif type(a:val) == 4
return '{' . join(map(keys(a:val), 'webapi#json#encode(v:val).":".webapi#json#encode(a:val[v:val])'), ',') . '}'
else
return string(a:val)
endif
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et:

View file

@ -243,9 +243,7 @@ COMMANDS *go-commands*
Show 'implements' relation for a selected package. A list of interfaces Show 'implements' relation for a selected package. A list of interfaces
for the type that implements an interface under the cursor (or selected for the type that implements an interface under the cursor (or selected
package) is shown in a custom window. Hit `<enter>` to jump in a new tab package) is shown quickfix list.
or close it via `<c-c>`.
*:GoRename* *:GoRename*
:GoRename [to] :GoRename [to]
@ -255,11 +253,73 @@ COMMANDS *go-commands*
*:GoCallees* *:GoCallees*
:GoCallees :GoCallees
Show 'callees' relation for a selected package. A list of call targets Show 'callees' relation for a selected package. A list of possible call
for the type under the cursor (or selected package) is shown in a custom targets for the type under the cursor (or selected package) is shown in a
window. Hit `<enter>` to jump in a new tab or close it via `<c-c>`. For quickfix list.
example if called for a interface method call, it will show all call targets
that has implemented the method. *:GoCallers*
:GoCallers
Show 'callers' relation for a selected function. A list of possible
callers for the selected function under the cursor is shown in a quickfix
list.
*:GoDescribe*
:GoDescribe
Shows various properties of the selected syntax: its syntactic kind, its
type (for an expression), its value (for a constant expression), its size,
alignment, method set and interfaces (for a type), its declaration (for an
identifier), etc. Almost any piece of syntax may be described, and the
oracle will try to print all the useful information it can.
*:GoCallgraph*
:GoCallgraph
Shows the 'callgraph' for the entire program. For more info about the
indentation checkout the Oracle User Manual:
golang.org/s/oracle-user-manual
*:GoCallstack*
:GoCallstack
Shows 'callstack' relation for the selected function. An arbitrary path
from the root of the callgrap to the selected function is showed in a
quickfix list. This may be useful to understand how the function is
reached in a given program.
*:GoFreevars*
:GoFreevars
Enumerates the free variables of the selection. “Free variables” is a
technical term meaning the set of variables that are referenced but not
defined within the selection, or loosely speaking, its inputs.
This information is useful if youre considering whether to refactor the
selection into a function of its own, as the free variables would be the
necessary parameters of that function. Its also useful when you want to
understand what the inputs are to a complex block of code even if you
dont plan to change it.
*:GoChannelPeers*
:GoChannelPeers
Shows the set of possible sends/receives on the channel operand of the
selected send or receive operation; the selection must be a <- token.
For example, visually select a channel operand in the form of:
"done <- true"
and call |GoChannelPeers| on it. It will show where it was allocated, and
the sending and receiving endings.
*:GoReferrers*
:GoReferrers
The referrers query shows the set of identifiers that refer to the same
object as does the selected identifier, within any package in the analysis
scope.
=============================================================================== ===============================================================================
@ -271,8 +331,9 @@ mapping for the `(go-run)`: >
au FileType go nmap <leader>r <Plug>(go-run) au FileType go nmap <leader>r <Plug>(go-run)
As always one is free to create more advanced mappings or functions based As always one is free to create more advanced mappings or functions based with
with |go-commands|. Available <Plug> keys are: |go-commands|. For more information please check out the mappings command
documentation in the |go-commands| section. Available <Plug> keys are:
*(go-run)* *(go-run)*
@ -372,6 +433,36 @@ Rename the identifier under the cursor to the desired new name
Show the call targets for the type under the cursor Show the call targets for the type under the cursor
*(go-callers)*
Show possible callers of selected function
*(go-describe)*
Describe selected syntax: definition, methods, etc
*(go-callgraph)*
Show the callgraph of the current program.
*(go-callstack)*
Show path from callgraph root to selected function
*(go-freevars)*
Show free variables of selection
*(go-channelpeers)*
Show send/receive corresponding to selected channel op
*(go-referrers)*
Show all refs to entity denoted by selected identifier
=============================================================================== ===============================================================================
TEXT OBJECTS *go-text-objects* TEXT OBJECTS *go-text-objects*
@ -387,6 +478,7 @@ if "inside a function", select contents of a function,
excluding the function definition and the closing bracket. excluding the function definition and the closing bracket.
=============================================================================== ===============================================================================
SETTINGS *go-settings* SETTINGS *go-settings*
@ -499,6 +591,18 @@ is used. Use "neosnippet" for neosnippet.vim: >
let g:go_snippet_engine = "ultisnips" let g:go_snippet_engine = "ultisnips"
< <
*'g:go_oracle_scope'*
Use this option to define the scope of the analysis to be passed for Oracle
related commands, such as |GoImplements|, |GoCallers|, etc.. By default it's
not set, so only the current packages go files are passed as scope. For more
info please have look at Oracle's User Manual:
https://docs.google.com/document/d/1SLk36YRjjMgKqe490mSRzOPYEDe0Y_WQNRv-EiFYUyw/view#heading=h.nwso96pj07q8
>
let g:go_oracle_scope = ''
<
*'g:go_highlight_array_whitespace_error'* *'g:go_highlight_array_whitespace_error'*
Highlights white space after "[]". > Highlights white space after "[]". >

View file

@ -18,6 +18,13 @@ nnoremap <silent> <Plug>(go-import) :<C-u>call go#import#SwitchImport(1, '', exp
nnoremap <silent> <Plug>(go-implements) :<C-u>call go#oracle#Implements(-1)<CR> nnoremap <silent> <Plug>(go-implements) :<C-u>call go#oracle#Implements(-1)<CR>
nnoremap <silent> <Plug>(go-callees) :<C-u>call go#oracle#Callees(-1)<CR> nnoremap <silent> <Plug>(go-callees) :<C-u>call go#oracle#Callees(-1)<CR>
nnoremap <silent> <Plug>(go-callers) :<C-u>call go#oracle#Callers(-1)<CR>
nnoremap <silent> <Plug>(go-describe) :<C-u>call go#oracle#Describe(-1)<CR>
nnoremap <silent> <Plug>(go-callgraph) :<C-u>call go#oracle#Callgraph(-1)<CR>
nnoremap <silent> <Plug>(go-callstack) :<C-u>call go#oracle#Callstack(-1)<CR>
nnoremap <silent> <Plug>(go-freevars) :<C-u>call go#oracle#Freevars(-1)<CR>
nnoremap <silent> <Plug>(go-channelpeers) :<C-u>call go#oracle#ChannelPeers(-1)<CR>
nnoremap <silent> <Plug>(go-referrers) :<C-u>call go#oracle#Referrers(-1)<CR>
nnoremap <silent> <Plug>(go-rename) :<C-u>call go#rename#Rename()<CR> nnoremap <silent> <Plug>(go-rename) :<C-u>call go#rename#Rename()<CR>
@ -39,6 +46,13 @@ command! -nargs=? GoRename call go#rename#Rename(<f-args>)
" oracle " oracle
command! -range=% GoImplements call go#oracle#Implements(<count>) command! -range=% GoImplements call go#oracle#Implements(<count>)
command! -range=% GoCallees call go#oracle#Callees(<count>) command! -range=% GoCallees call go#oracle#Callees(<count>)
command! -range=% GoDescribe call go#oracle#Describe(<count>)
command! -range=% GoCallers call go#oracle#Callers(<count>)
command! -range=% GoCallgraph call go#oracle#Callgraph(<count>)
command! -range=% GoCallstack call go#oracle#Callstack(<count>)
command! -range=% GoFreevars call go#oracle#Freevars(<count>)
command! -range=% GoChannelPeers call go#oracle#ChannelPeers(<count>)
command! -range=% GoReferrers call go#oracle#Referrers(<count>)
" tool " tool
command! -nargs=0 GoFiles echo go#tool#Files() command! -nargs=0 GoFiles echo go#tool#Files()
@ -78,16 +92,4 @@ command! GoLint call go#lint#Run()
" -- errcheck " -- errcheck
command! -nargs=? -complete=customlist,go#package#Complete GoErrCheck call go#errcheck#Run(<f-args>) command! -nargs=? -complete=customlist,go#package#Complete GoErrCheck call go#errcheck#Run(<f-args>)
" Disable all commands until they are fully integrated.
"
" command! -range=% GoOracleDescribe call go#oracle#Describe(<count>)
" command! -range=% GoOracleCallers call go#oracle#Callers(<count>)
" command! -range=% GoOracleCallgraph call go#oracle#Callgraph(<count>)
" command! -range=% GoOracleCallstack call go#oracle#Callstack(<count>)
" command! -range=% GoOracleFreevars call go#oracle#Freevars(<count>)
" command! -range=% GoOraclePeers call go#oracle#Peers(<count>)
" command! -range=% GoOracleReferrers call go#oracle#Referrers(<count>)
" vim:ts=4:sw=4:et " vim:ts=4:sw=4:et
"

View file

@ -20,6 +20,11 @@ snippet ap "append(slice, value)"
append(${1:slice}, ${0:value}) append(${1:slice}, ${0:value})
endsnippet endsnippet
# append assignment
snippet ap= "a = append(a, value)"
${1:slice} = append($1, ${0:value})
endsnippet
# break # break
snippet br "break" snippet br "break"
break break
@ -147,6 +152,14 @@ if err != nil {
${0} ${0}
endsnippet endsnippet
# error snippet
snippet errt "Error test fatal " !b
if err != nil {
t.Fatal(err)
}
${0}
endsnippet
snippet errn, "Error return with two return values" !b snippet errn, "Error return with two return values" !b
if err != nil { if err != nil {
return ${1:nil}, err return ${1:nil}, err
@ -307,6 +320,30 @@ func Test${1:Function}(t *testing.T) {
} }
endsnippet endsnippet
# quick test server
snippet tsrv "httptest.NewServer"
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, ${1:`response`})
}))
defer ts.Close()
${0:someUrl} = ts.URL
endsnippet
# test error handling
snippet ter "if err != nil { t.Errorf(...) }"
if err != nil {
t.Errorf("${0:message}")
}
endsnippet
# test fatal error
snippet terf "if err != nil { t.Fatalf(...) }"
if err != nil {
t.Fatalf("${0:message}")
}
endsnippet
# variable declaration # variable declaration
snippet var "var x Type [= ...]" snippet var "var x Type [= ...]"
var ${1:x} ${2:Type}${3: = ${0:value\}} var ${1:x} ${2:Type}${3: = ${0:value\}}
@ -344,6 +381,4 @@ def closing_par(snip, pos):
endglobal endglobal
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -12,6 +12,10 @@ abbr fn := func() { ... }
snippet ap snippet ap
abbr append(slice, value) abbr append(slice, value)
append(${1:slice}, ${0:value}) append(${1:slice}, ${0:value})
# append assign
snippet ap=
abbr slice = append(slice, value)
${1:slice} = append($1, ${0:value})
# break # break
snippet br snippet br
abbr break abbr break
@ -120,6 +124,12 @@ abbr if err != nil { ... }
if err != nil { if err != nil {
return err return err
} }
# error snippet in TestFunc
snippet errt
abbr if err != nil { ... }
if err != nil {
t.Fatal(err)
}
# error snippet with two return values # error snippet with two return values
snippet errn, snippet errn,
@ -262,6 +272,28 @@ abbr func TestXYZ(t *testing.T) { ... }
func Test${1:Function}(t *testing.T) { func Test${1:Function}(t *testing.T) {
${0} ${0}
} }
# test server
snippet tsrv
abbr ts := httptest.NewServer(...)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, ${1:`response`})
}))
defer ts.Close()
//Use testing server url (type string) somewhere
${0:someUrl} = ts.URL
# test error
snippet ter
abbr if err != nil { t.Errorf(...) }
if err != nil {
t.Errorf("${1}")
}
# test fatal error
snippet terf
abbr if err != nil { t.Fatalf(...) }
if err != nil {
t.Fatalf("${1}")
}
# variable declaration # variable declaration
snippet var snippet var
abbr var x Type [= ...] abbr var x Type [= ...]

View file

@ -24,6 +24,17 @@ if exists("*GoIndent")
finish finish
endif endif
" use shiftwidth function only if it's available
if exists('*shiftwidth')
func s:sw()
return shiftwidth()
endfunc
else
func s:sw()
return &sw
endfunc
endif
function! GoIndent(lnum) function! GoIndent(lnum)
let prevlnum = prevnonblank(a:lnum-1) let prevlnum = prevnonblank(a:lnum-1)
if prevlnum == 0 if prevlnum == 0
@ -37,21 +48,20 @@ function! GoIndent(lnum)
let previ = indent(prevlnum) let previ = indent(prevlnum)
let ind = previ let ind = previ
let s:shiftwidth = shiftwidth()
if prevl =~ '[({]\s*$' if prevl =~ '[({]\s*$'
" previous line opened a block " previous line opened a block
let ind += s:shiftwidth let ind += s:sw()
endif endif
if prevl =~# '^\s*\(case .*\|default\):$' if prevl =~# '^\s*\(case .*\|default\):$'
" previous line is part of a switch statement " previous line is part of a switch statement
let ind += s:shiftwidth let ind += s:sw()
endif endif
" TODO: handle if the previous line is a label. " TODO: handle if the previous line is a label.
if thisl =~ '^\s*[)}]' if thisl =~ '^\s*[)}]'
" this line closed a block " this line closed a block
let ind -= s:shiftwidth let ind -= s:sw()
endif endif
" Colons are tricky. " Colons are tricky.
@ -59,8 +69,10 @@ function! GoIndent(lnum)
" We ignore trying to deal with jump labels because (a) they're rare, and " We ignore trying to deal with jump labels because (a) they're rare, and
" (b) they're hard to disambiguate from a composite literal key. " (b) they're hard to disambiguate from a composite literal key.
if thisl =~# '^\s*\(case .*\|default\):$' if thisl =~# '^\s*\(case .*\|default\):$'
let ind -= s:shiftwidth let ind -= s:sw()
endif endif
return ind return ind
endfunction endfunction
" vim:ts=4:sw=4:et

View file

@ -84,9 +84,9 @@ In this configuration `<C-n>` will start multicursor mode using word boundaries
**NOTE:** Prior to version 1.3, the recommended way to map the keys is using the expression quote syntax in Vim, using something like `"\<C-n>"` or `"\<Esc>"` (see h: expr-quote). After 1.3, the recommended way is to use a raw string like above. If your key mappings don't appear to work, give the new syntax a try. **NOTE:** Prior to version 1.3, the recommended way to map the keys is using the expression quote syntax in Vim, using something like `"\<C-n>"` or `"\<Esc>"` (see h: expr-quote). After 1.3, the recommended way is to use a raw string like above. If your key mappings don't appear to work, give the new syntax a try.
## Setting ## Setting
Currently there're three additional global settings one can tweak: Currently there are four additional global settings one can tweak:
### ```g:multi_cursor_exit_from_visual_mode``` (Default: 1)
### ```g:multi_cursor_exit_from_visual_mode``` (Default: 1)
If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors. If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
### ```g:multi_cursor_exit_from_insert_mode``` (Default: 1) ### ```g:multi_cursor_exit_from_insert_mode``` (Default: 1)
@ -158,8 +158,11 @@ See [CHANGELOG.md](CHANGELOG.md)
## Contributing ## Contributing
As one can see, there're still many issues to be resolved, patches and suggestions are always welcome! A list of open feature requests can be found [here](../../issues?labels=enhancement&state=open). As one can see, there're still many issues to be resolved, patches and suggestions are always welcome! A list of open feature requests can be found [here](../../issues?labels=enhancement&state=open).
Running the test suite requires ruby and rake as well as vim of course. On Mac
OS, [MacVim](https://code.google.com/p/macvim/) is known to work.
## Credit ## Credit
Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selection] feature, also encouraged by Emac's [multiple cursors][emacs-multiple-cursors] implemetation by Magnar Sveen Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selection] feature, also encouraged by Emac's [multiple cursors][emacs-multiple-cursors] implementation by Magnar Sveen
[vim-multiple-cursors]:http://github.com/terryma/vim-multiple-cursors [vim-multiple-cursors]:http://github.com/terryma/vim-multiple-cursors
[sublime-multiple-selection]:http://www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html [sublime-multiple-selection]:http://www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html

View file

@ -141,9 +141,9 @@ try.
============================================================================== ==============================================================================
4. Global Options *multiple-cursors-global-options* 4. Global Options *multiple-cursors-global-options*
Currently there're two additional global settings one can tweak: Currently there are four additional global settings one can tweak:
*g:multi_cursor_exit_from_visual_mode* (Defaut: 1) *g:multi_cursor_exit_from_visual_mode* (Default: 1)
If set to 0, then pressing |g:multi_cursor_quit_key| in Visual mode will not If set to 0, then pressing |g:multi_cursor_quit_key| in Visual mode will not
quit and delete all existing cursors. This is useful if you want to press quit and delete all existing cursors. This is useful if you want to press
@ -157,6 +157,27 @@ quit and delete all existing cursors. This is useful if you want to press
Escape and go back to Normal mode, and still be able to operate on all the Escape and go back to Normal mode, and still be able to operate on all the
cursors. cursors.
*g:multi_cursor_insert_maps* (Default: `{}`)
Any key in this map (values are ignored) will cause multi-cursor _Insert_ mode
to pause for `timeoutlen` waiting for map completion just like normal vim.
Otherwise keys mapped in insert mode are ignored when multiple cursors are
active. For example, setting it to `{'\':1}` will make insert-mode mappings
beginning with the default leader key work in multi-cursor mode. You have to
manually set this because vim doesn't provide a way to see which keys _start_
mappings.
*g:multi_cursor_normal_maps* (Default: `{}`)
Any key in this map (values are ignored) will cause multi-cursor _Normal_ mode
to pause for map completion just like normal vim. Otherwise keys mapped in
normal mode will "fail to replay" when multiple cursors are active. For example,
setting it to `{'d':1}` will make normal-mode mappings beginning with `d` (such
as `dw` to delete a word) work in multi-cursor mode. You have to
manually set this because vim doesn't provide a way to see which keys _start_
mappings; setting it to include motion commands like `j` can break things.
The plugin uses the highlight group `multiple_cursors_cursor` and The plugin uses the highlight group `multiple_cursors_cursor` and
`multiple_cursors_visual` to highlight the virtual cursors and their visual `multiple_cursors_visual` to highlight the virtual cursors and their visual
selections respectively. You can customize them by putting something similar selections respectively. You can customize them by putting something similar
@ -165,6 +186,7 @@ like the following in your vimrc: >
" Default highlighting (see help :highlight and help :highlight-link) " Default highlighting (see help :highlight and help :highlight-link)
highlight multiple_cursors_cursor term=reverse cterm=reverse gui=reverse highlight multiple_cursors_cursor term=reverse cterm=reverse gui=reverse
highlight link multiple_cursors_visual Visual highlight link multiple_cursors_visual Visual
< <
============================================================================== ==============================================================================

View file

@ -112,12 +112,17 @@ function! repeat#wrap(command,count)
endif endif
endfunction endfunction
nnoremap <silent> . :<C-U>call repeat#run(v:count)<CR> nnoremap <silent> <Plug>(RepeatDot) :<C-U>call repeat#run(v:count)<CR>
nnoremap <silent> u :<C-U>call repeat#wrap('u',v:count)<CR> nnoremap <silent> <Plug>(RepeatUndo) :<C-U>call repeat#wrap('u',v:count)<CR>
if maparg('U','n') ==# '' nnoremap <silent> <Plug>(RepeatUndoLine) :<C-U>call repeat#wrap('U',v:count)<CR>
nnoremap <silent> U :<C-U>call repeat#wrap('U',v:count)<CR> nnoremap <silent> <Plug>(RepeatRedo) :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
if !hasmapto('<Plug>(RepeatDot)', 'n') | nmap . <Plug>(RepeatDot)| endif
if !hasmapto('<Plug>(RepeatUndo)', 'n') | nmap u <Plug>(RepeatUndo)| endif
if maparg('U','n') ==# '' && !hasmapto('<Plug>(RepeatUndoLine)', 'n')
nmap U <Plug>(RepeatUndoLine)
endif endif
nnoremap <silent> <C-R> :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR> if !hasmapto('<Plug>(RepeatRedo)', 'n') | nmap <C-R> <Plug>(RepeatRedo)| endif
augroup repeatPlugin augroup repeatPlugin
autocmd! autocmd!

View file

@ -42,4 +42,5 @@ additional contributions from:
* [steveno](https://github.com/steveno) * [steveno](https://github.com/steveno)
* [taq](https://github.com/taq) * [taq](https://github.com/taq)
* [thisgeek](https://github.com/thisgeek) * [thisgeek](https://github.com/thisgeek)
* [trusktr](https://github.com/trusktr)
* [Xandaros](https://github.com/Xandaros) * [Xandaros](https://github.com/Xandaros)

View file

@ -19,7 +19,9 @@ Garbas][garbas], [Marc Weber][marcweber], and [Adnan Zafar][ajzafar].
We recommend one of the following methods for installing SnipMate and its We recommend one of the following methods for installing SnipMate and its
dependencies. SnipMate depends on [vim-addon-mw-utils][mw-utils] and dependencies. SnipMate depends on [vim-addon-mw-utils][mw-utils] and
[tlib][tlib]. Since SnipMate does not ship with any snippets, we suggest [tlib][tlib].
> **NOTE:** SnipMate does not ship with any snippets out of the box. We suggest
looking at the [vim-snippets][vim-snippets] repository. looking at the [vim-snippets][vim-snippets] repository.
* Using [VAM][vam], add `vim-snippets` to the list of packages to be installed. * Using [VAM][vam], add `vim-snippets` to the list of packages to be installed.

View file

@ -329,9 +329,9 @@ endfunction
function! s:snippet_filenames(scope, trigger) abort function! s:snippet_filenames(scope, trigger) abort
let mid = ['', '_*', '/*'] let mid = ['', '_*', '/*']
let mid += map(copy(mid[1:]), "'/' . a:trigger . '*' . v:val") let mid += map(copy(mid), "'/' . a:trigger . '*' . v:val")
return join(map(mid, "'snippets/' . a:scope . v:val . '.snippet'" call map(mid, "'snippets/' . a:scope . v:val . '.snippet'")
\ . ". (v:key < 3 ? 's' : '')")) return join(map(mid[:2], 'v:val . "s"') + mid[3:])
endfunction endfunction
function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort
@ -455,7 +455,7 @@ fun! snipMate#GetSnippetsForWordBelowCursor(word, exact) abort
let parts = split(a:word, '\W\zs') let parts = split(a:word, '\W\zs')
" Since '\W\zs' results in splitting *after* a non-keyword character, the " Since '\W\zs' results in splitting *after* a non-keyword character, the
" first \W stays connected to whatever's before it, so split it off " first \W stays connected to whatever's before it, so split it off
if len(parts) > 1 && len(parts[0]) > 1 if !empty(parts) && parts[0] =~ '\W$'
let parts = [ parts[0][:-2], strpart(parts[0], len(parts[0]) - 1) ] let parts = [ parts[0][:-2], strpart(parts[0], len(parts[0]) - 1) ]
\ + parts[1:] \ + parts[1:]
endif endif

View file

@ -205,7 +205,6 @@ to maintain snippets for a language, please get in touch.
Notes: People are interested in snippets - and their interest may wane again. Notes: People are interested in snippets - and their interest may wane again.
This list is kept up-to-date on a best effort basis. This list is kept up-to-date on a best effort basis.
* Clojure - [lpil](https://github.com/lpil)
* Elixir - [iurifq](https://github.com/iurifq) * Elixir - [iurifq](https://github.com/iurifq)
* Falcon - [steveno](https://github.com/steveno) * Falcon - [steveno](https://github.com/steveno)
* HTML Django - [honza](http://github.com/honza) * HTML Django - [honza](http://github.com/honza)
@ -214,7 +213,6 @@ This list is kept up-to-date on a best effort basis.
* PHP - [chrisyue](http://github.com/chrisyue) * PHP - [chrisyue](http://github.com/chrisyue)
* Python - [honza](http://github.com/honza) * Python - [honza](http://github.com/honza)
* Ruby - [taq](http://github.com/taq) * Ruby - [taq](http://github.com/taq)
* Rust - [lpil](https://github.com/lpil)
* Scala - [gorodinskiy](https://github.com/gorodinskiy) * Scala - [gorodinskiy](https://github.com/gorodinskiy)
License License

View file

@ -1,168 +0,0 @@
priority -50
snippet do
do
${1}
end
endsnippet
snippet if "if .. do .. end"
if ${1:condition} do
${2:expression}
end
endsnippet
snippet if "if .. do: .."
if ${1:condition}, do: ${2:expression}
endsnippet
snippet ife "if .. do .. else .. end"
if ${1:condition} do
${2:expression}
else
${3:expression}
end
endsnippet
snippet ife "if .. do: .. else:"
if ${1:condition}, do: ${2}, else: ${3}
endsnippet
snippet unless "unless .. do .. end"
unless ${1} do
${2}
end
endsnippet
snippet unless "unless .. do: .."
unless ${1:condition}, do: ${2}
endsnippet
snippet unlesse "unless .. do .. else .. end"
unless ${1:condition} do
${2}
else
${3}
end
endsnippet
snippet unlesse "unless .. do: .. else:"
unless ${1:condition}, do: ${2}, else: ${3}
endsnippet
snippet cond
"cond do"
${1} ->
${2}
end
endsnippet
snippet case
case ${1} do
${2} ->
${3}
end
endsnippet
snippet def
def ${1:name} do
${2}
end
endsnippet
snippet defin "def function(n), do: n"
def ${1:name}, do: ${2}
endsnippet
snippet defg
def ${1:name} when ${2:guard-condition} do
${3}
end
endsnippet
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${3}
end
endsnippet
snippet defma
defmacro ${1:name} do
${2}
end
endsnippet
snippet defmo
defmodule ${1:module_name} do
${2}
end
endsnippet
snippet defp
defp ${1:name} do
${2}
end
endsnippet
snippet defpr
defprotocol ${1:name}, [${2:function}]
endsnippet
snippet defr
defrecord ${1:record_name}, ${2:fields}
endsnippet
snippet doc
@doc """
${1}
"""
endsnippet
snippet fn
fn(${1:args}) -> ${2} end
endsnippet
snippet fun
function do
${1}
end
endsnippet
snippet mdoc
@moduledoc """
${1}
"""
endsnippet
snippet rec
receive do
${1} ->
${2}
end
endsnippet
snippet req
require ${1:module_name}
endsnippet
snippet imp
import ${1:module_name}
endsnippet
snippet ali "alias old-module to shorthand"
alias ${1:module_name}
endsnippet
snippet test
test "${1:test_name}" do
${2}
end
endsnippet
snippet try "try .. rescue .. end"
try do
${1}
rescue
${2} -> ${3}
end
endsnippet

View file

@ -111,7 +111,6 @@ public function get${1/\w+\s*/\u$0/}()
{ {
return $this->$1;$3 return $this->$1;$3
} }
$0
endsnippet endsnippet
snippet setter "PHP Class Setter" b snippet setter "PHP Class Setter" b
@ -266,7 +265,7 @@ namespace ${1:`!p
abspath = os.path.abspath(path) abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', abspath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};
endsnippet endsnippet
@ -277,7 +276,7 @@ namespace ${1:`!p
abspath = os.path.abspath(path) abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', abspath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};
/** /**
@ -287,7 +286,6 @@ if m:
class $1 class $1
{ {
} }
$0
endsnippet endsnippet
snippet interface "Interface declaration template" b snippet interface "Interface declaration template" b
@ -297,7 +295,7 @@ namespace ${1:`!p
abspath = os.path.abspath(path) abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath) m = re.search(r'[A-Z].+(?=/)', abspath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};
/** /**
@ -306,7 +304,7 @@ if m:
*/ */
interface $1 interface $1
{ {
public function ${3:someFunction}();$4 public function ${3:someFunction}();$4
} }
endsnippet endsnippet

View file

@ -6,7 +6,7 @@ snippet if if .. do .. end
if ${1} do if ${1} do
${0} ${0}
end end
snippet if if .. do: .. snippet if: if .. do: ..
if ${1:condition}, do: ${0} if ${1:condition}, do: ${0}
snippet ife if .. do .. else .. end snippet ife if .. do .. else .. end
if ${1:condition} do if ${1:condition} do
@ -14,13 +14,13 @@ snippet ife if .. do .. else .. end
else else
${0} ${0}
end end
snippet ife if .. do: .. else: snippet ife: if .. do: .. else:
if ${1:condition}, do: ${2}, else: ${0} if ${1:condition}, do: ${2}, else: ${0}
snippet unless unless .. do .. end snippet unless unless .. do .. end
unless ${1} do unless ${1} do
${0} ${0}
end end
snippet unless unless .. do: .. snippet unless: unless .. do: ..
unless ${1:condition}, do: ${0} unless ${1:condition}, do: ${0}
snippet unlesse unless .. do .. else .. end snippet unlesse unless .. do .. else .. end
unless ${1:condition} do unless ${1:condition} do
@ -28,7 +28,7 @@ snippet unlesse unless .. do .. else .. end
else else
${0} ${0}
end end
snippet unlesse unless .. do: .. else: snippet unlesse: unless .. do: .. else:
unless ${1:condition}, do: ${2}, else: ${0} unless ${1:condition}, do: ${2}, else: ${0}
snippet cond snippet cond
cond do cond do
@ -46,6 +46,13 @@ snippet def
def ${1:name} do def ${1:name} do
${0} ${0}
end end
snippet defd
@doc """
${1:doc string}
"""
def ${2:name} do
${0}
end
snippet defim snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do defimpl ${1:protocol_name}, for: ${2:data_type} do
${0} ${0}
@ -71,7 +78,7 @@ snippet doc
${0} ${0}
""" """
snippet fn snippet fn
fn(${1:args}) -> ${0} end fn ${1:args} -> ${0} end
snippet fun snippet fun
function do function do
${0} ${0}
@ -95,9 +102,16 @@ snippet test
test "${1:test_name}" do test "${1:test_name}" do
${0} ${0}
end end
snippet testa
test "${1:test_name}", %{${2:arg: arg}} do
${0}
end
snippet try try .. rescue .. end snippet try try .. rescue .. end
try do try do
${1} ${1}
rescue rescue
${2} -> ${0} ${2} -> ${0}
end end
snippet pry
require IEx; IEx.pry
$0

Some files were not shown because too many files have changed in this diff Show more