1
0
Fork 0
mirror of synced 2024-11-22 16:55:34 -05:00

Updated plugins

This commit is contained in:
amix 2016-03-14 11:04:57 +01:00
parent 71fc570357
commit 20729bff94
56 changed files with 726 additions and 404 deletions

View file

@ -38,10 +38,10 @@ too:
## 2. Submitting a patch ## 2. Submitting a patch
Before you consider adding features to syntastic, _please_ spend a few Before you consider adding features to syntastic, _please_ spend a few minutes
minutes (re-)reading the latest version of the [manual][1]. Syntastic (re-)reading the latest version of the [manual][1]. Syntastic is changing
is changing rapidly at times, and it's quite possible that some features rapidly at times, and it's possible that some features you want to add exist
you want to add exist already. already.
To submit a patch: To submit a patch:

View file

@ -105,6 +105,12 @@ Syntastic should work with any modern plugin managers for Vim, such as
[Vundle][17]. Instructions for installing syntastic with [Pathogen][1] are [Vundle][17]. Instructions for installing syntastic with [Pathogen][1] are
included below for completeness. included below for completeness.
Starting with Vim version 7.4.1486 you can also load syntastic using the
standard mechanism of packages, without the help of third-party plugin managers
(see `:help packages` in Vim for details). Beware however that, while support
for packages has been added in Vim 7.4.1384, the functionality needed by
syntastic is present only in versions 7.4.1486 and later.
Last but not least: syntastic doesn't know how to do any syntax checks by Last but not least: syntastic doesn't know how to do any syntax checks by
itself. In order to get meaningful results you need to install external itself. In order to get meaningful results you need to install external
checkers corresponding to the types of files you use. Please consult the checkers corresponding to the types of files you use. Please consult the
@ -254,11 +260,11 @@ __4.4. Q. The `perl` checker has stopped working...__
A. The `perl` checker runs `perl -c` against your file, which in turn A. The `perl` checker runs `perl -c` against your file, which in turn
__executes__ any `BEGIN`, `UNITCHECK`, and `CHECK` blocks, and any `use` __executes__ any `BEGIN`, `UNITCHECK`, and `CHECK` blocks, and any `use`
statements in your file (cf. [perlrun][10]). This is probably fine if you statements in your file (cf. [perlrun][10]). This is probably fine if you
wrote the file yourself, but it's a security problem if you're checking third wrote the file yourself, but it's a security problem if you're checking
party files. Since there is currently no way to disable this behaviour while third-party files. Since there is currently no way to disable this behaviour
still producing useful results, the checker is now disabled by default. To while still producing useful results, the checker is now disabled by default.
(re-)enable it, make sure the `g:syntastic_perl_checkers` list includes `perl`, To (re-)enable it, make sure the `g:syntastic_perl_checkers` list includes
and set `g:syntastic_enable_perl_checker` to 1 in your `vimrc`: `perl`, and set `g:syntastic_enable_perl_checker` to 1 in your `vimrc`:
```vim ```vim
let g:syntastic_enable_perl_checker = 1 let g:syntastic_enable_perl_checker = 1
``` ```

View file

@ -240,7 +240,12 @@ function! syntastic#util#findGlobInParent(what, where) abort " {{{2
let old = '' let old = ''
while here !=# '' while here !=# ''
let p = split(globpath(here, a:what, 1), '\n') try
" Vim 7.4.279 and later
let p = globpath(here, a:what, 1, 1)
catch /\m^Vim\%((\a\+)\)\=:E118/
let p = split(globpath(here, a:what, 1), "\n")
endtry
if !empty(p) if !empty(p)
return fnamemodify(p[0], ':p') return fnamemodify(p[0], ':p')
@ -499,7 +504,13 @@ function! s:_rmrf(what) abort " {{{2
return return
endif endif
for f in split(globpath(a:what, '*', 1), "\n") try
" Vim 7.4.279 and later
let entries = globpath(a:what, '*', 1, 1)
catch /\m^Vim\%((\a\+)\)\=:E118/
let entries = split(globpath(a:what, '*', 1), "\n")
endtry
for f in entries
call s:_rmrf(f) call s:_rmrf(f)
endfor endfor
silent! call syntastic#util#system(s:rmdir . ' ' . syntastic#util#shescape(a:what)) silent! call syntastic#util#system(s:rmdir . ' ' . syntastic#util#shescape(a:what))

View file

@ -64,8 +64,8 @@ CONTENTS *syntastic-contents*
1. Intro *syntastic-intro* 1. Intro *syntastic-intro*
Syntastic is a syntax checking plugin that runs files through external syntax Syntastic is a syntax checking plugin that runs files through external syntax
checkers. This can be done on demand, or automatically as files are saved and checkers. This can be done on demand, or automatically as files are saved
opened. If syntax errors are detected, the user is notified and is happy and opened. If syntax errors are detected, the user is notified and is happy
because they didn't have to compile their code or execute their script to find because they didn't have to compile their code or execute their script to find
them. them.

View file

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.7.0-88' let g:_SYNTASTIC_VERSION = '3.7.0-99'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1

View file

@ -164,7 +164,7 @@ function! g:SyntasticRegistry.CreateAndRegisterChecker(args) abort " {{{2
if has_key(a:args, 'redirect') if has_key(a:args, 'redirect')
let [ft, name] = split(a:args['redirect'], '/') let [ft, name] = split(a:args['redirect'], '/')
call registry._loadCheckersFor(ft) call registry._loadCheckersFor(ft, 1)
let clone = get(registry._checkerMap[ft], name, {}) let clone = get(registry._checkerMap[ft], name, {})
if empty(clone) if empty(clone)
@ -320,8 +320,9 @@ function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) abort "
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) abort " {{{2 function! g:SyntasticRegistry._loadCheckersFor(filetype, ...) abort " {{{2
if has_key(self._checkerMap, a:filetype) " XXX: a:1 == 1 means re-scan checkers for filetype
if has_key(self._checkerMap, a:filetype) && (!a:0 || !a:1)
return return
endif endif

View file

@ -21,13 +21,6 @@ let s:setup_done = 0
function! g:SyntasticSignsNotifier.New() abort " {{{2 function! g:SyntasticSignsNotifier.New() abort " {{{2
let newObj = copy(self) let newObj = copy(self)
if !s:setup_done
call self._setup()
let s:setup_done = 1
lockvar s:setup_done
endif
return newObj return newObj
endfunction " }}}2 endfunction " }}}2
@ -37,8 +30,15 @@ endfunction " }}}2
function! g:SyntasticSignsNotifier.refresh(loclist) abort " {{{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()
if !s:setup_done
call self._setup()
let s:setup_done = 1
lockvar s:setup_done
endif
call self._signErrors(a:loclist) call self._signErrors(a:loclist)
endif endif
call self._removeSigns(old_signs) call self._removeSigns(old_signs)

View file

@ -21,6 +21,7 @@ function! SyntaxCheckers_haskell_hlint_GetLocList() dict
\ '%E%f:%l:%v: Error while reading hint file\, %m,' . \ '%E%f:%l:%v: Error while reading hint file\, %m,' .
\ '%E%f:%l:%v: Error: %m,' . \ '%E%f:%l:%v: Error: %m,' .
\ '%W%f:%l:%v: Warning: %m,' . \ '%W%f:%l:%v: Warning: %m,' .
\ '%W%f:%l:%v: Suggestion: %m,' .
\ '%C%m' \ '%C%m'
return SyntasticMake({ return SyntasticMake({

View file

@ -1,6 +1,13 @@
"============================================================================ "============================================================================
"File: pep257.vim "File: pep257.vim
"Description: Docstring style checking plugin for syntastic.vim "Description: Syntax checking plugin for syntastic
"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_python_pep257_checker') if exists('g:loaded_syntastic_python_pep257_checker')
@ -8,52 +15,9 @@ if exists('g:loaded_syntastic_python_pep257_checker')
endif endif
let g:loaded_syntastic_python_pep257_checker = 1 let g:loaded_syntastic_python_pep257_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pep257_GetLocList() dict
if !exists('s:pep257_new')
let s:pep257_new = syntastic#util#versionIsAtLeast(self.getVersion(), [0, 3])
endif
let makeprg = self.makeprgBuild({})
if s:pep257_new
let errorformat =
\ '%E%f:%l %.%#:,' .
\ '%+C %m'
else
let errorformat =
\ '%E%f:%l:%c%\%.%\%.%\d%\+:%\d%\+: %m,' .
\ '%E%f:%l:%c: %m,' .
\ '%+C %m'
endif
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style',
\ 'preprocess': 'killEmpty',
\ 'postprocess': ['compressWhitespace'] })
if s:pep257_new == 0
" byte offsets rather than column numbers
for e in loclist
let e['col'] = get(e, 'col', 0) + 1
endfor
endif
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({ call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python', \ 'filetype': 'python',
\ 'name': 'pep257'}) \ 'name': 'pep257',
\ 'redirect': 'python/pydocstyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker: " vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,66 @@
"============================================================================
"File: pydocstyle.vim
"Description: Syntax checking plugin for syntastic
"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_python_pydocstyle_checker')
finish
endif
let g:loaded_syntastic_python_pydocstyle_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pydocstyle_GetLocList() dict
if !exists('s:pydocstyle_new')
let s:pydocstyle_new = syntastic#util#versionIsAtLeast(self.getVersion(), [0, 3])
endif
let makeprg = self.makeprgBuild({})
if s:pydocstyle_new
let errorformat =
\ '%E%f:%l %.%#:,' .
\ '%+C %m'
else
let errorformat =
\ '%E%f:%l:%c%\%.%\%.%\d%\+:%\d%\+: %m,' .
\ '%E%f:%l:%c: %m,' .
\ '%+C %m'
endif
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style',
\ 'preprocess': 'killEmpty',
\ 'postprocess': ['compressWhitespace'] })
if s:pydocstyle_new == 0
" byte offsets rather than column numbers
for e in loclist
let e['col'] = get(e, 'col', 0) + 1
endfor
endif
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pydocstyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -50,6 +50,12 @@ function! airline#themes#lucius#refresh()
\ 'red': airline#themes#get_highlight('Constant'), \ 'red': airline#themes#get_highlight('Constant'),
\ } \ }
" Extra tabline colors
let s:TS = airline#themes#get_highlight('TabLineSel')
let g:airline#themes#lucius#palette.tabline = {}
let g:airline#themes#lucius#palette.tabline.airline_tabsel = s:TS
let g:airline#themes#lucius#palette.tabline.airline_tabsel_right = s:TS
endfunction endfunction
call airline#themes#lucius#refresh() call airline#themes#lucius#refresh()

View file

@ -3,16 +3,31 @@
This is the Changelog for the vim-airline project. This is the Changelog for the vim-airline project.
## [Unreleased] ## [Unreleased]
## [0.8] - 2016-03-09
- Changes - Changes
- Themes have been moved into an extra repository [vim-airline-themes](https://github.com/vim-airline/vim-airline-themes) - Airline converted to an organization and moved to new [repository](https://github.com/vim-airline/vim-airline)
- Many new themes - Themes have been split into an separate repository [vim-airline-themes](https://github.com/vim-airline/vim-airline-themes)
- Airline Moved to new [repository](https://github.com/vim-airline/vim-airline) - Improvements
- New features - Extensions
- Integration with [taboo](https://github.com/gcmt/taboo.vim), [vim-ctrlspace](https://github.com/szw/vim-ctrlspace), - branch: support Git and Mercurial simultaneously, untracked files
[quickfixsigns](https://github.com/tomtom/quickfixsigns_vim), [YouCompleteMe](https://github.com/Valloric/YouCompleteMe) - whitespace: new mixed-indent rule
- Windows support
- Many bug fixes
- Support for Neovim - Support for Neovim
- Added wordcount extension - New features
- Adding Crypt and Byte Order Mark Indicator - Many new themes
- Extensions/integration
- [taboo](https://github.com/gcmt/taboo.vim)
- [vim-ctrlspace](https://github.com/szw/vim-ctrlspace)
- [quickfixsigns](https://github.com/tomtom/quickfixsigns_vim)
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
- [po.vim](http://www.vim.org/scripts/script.php?script_id=695)
- [unicode.vim](https://github.com/chrisbra/unicode.vim)
- wordcount
- crypt indicator
- byte order mark indicator
- Tabline's tab mode can display splits simultaneously
## [0.7] - 2014-12-10 ## [0.7] - 2014-12-10
- New features - New features
@ -94,7 +109,8 @@ This is the Changelog for the vim-airline project.
- integration with other plugins: netrw, unite, nerdtree, undotree, gundo, tagbar, minibufexplr, ctrlp - integration with other plugins: netrw, unite, nerdtree, undotree, gundo, tagbar, minibufexplr, ctrlp
- support for themes: 8 included - support for themes: 8 included
[Unreleased]: https://github.com/vim-airline/vim-airline/compare/v0.7...HEAD [Unreleased]: https://github.com/vim-airline/vim-airline/compare/v0.8...HEAD
[0.8]: https://github.com/vim-airline/vim-airline/compare/v0.7...v0.8
[0.7]: https://github.com/vim-airline/vim-airline/compare/v0.6...v0.7 [0.7]: https://github.com/vim-airline/vim-airline/compare/v0.6...v0.7
[0.6]: https://github.com/vim-airline/vim-airline/compare/v0.5...v0.6 [0.6]: https://github.com/vim-airline/vim-airline/compare/v0.5...v0.6
[0.5]: https://github.com/vim-airline/vim-airline/compare/v0.4...v0.5 [0.5]: https://github.com/vim-airline/vim-airline/compare/v0.4...v0.5

View file

@ -0,0 +1,14 @@
#### environment
- vim: ????
- vim-airline: ????
- OS: ????
- terminal: ????
#### actual behavior
????
#### expected behavior
????

View file

@ -72,9 +72,10 @@ endfunction
function! airline#switch_matching_theme() function! airline#switch_matching_theme()
if exists('g:colors_name') if exists('g:colors_name')
let existing = g:airline_theme let existing = g:airline_theme
let theme = substitute(g:colors_name, '-', '_', 'g')
try try
let palette = g:airline#themes#{g:colors_name}#palette let palette = g:airline#themes#{theme}#palette
call airline#switch_theme(g:colors_name) call airline#switch_theme(theme)
return 1 return 1
catch catch
for map in items(g:airline_theme_map) for map in items(g:airline_theme_map)

View file

@ -210,6 +210,10 @@ function! airline#extensions#load()
call airline#extensions#whitespace#init(s:ext) call airline#extensions#whitespace#init(s:ext)
endif endif
if get(g:, 'airline#extensions#po#enabled', 1) && executable('msgfmt')
call airline#extensions#po#init(s:ext)
endif
if get(g:, 'airline#extensions#wordcount#enabled', 1) if get(g:, 'airline#extensions#wordcount#enabled', 1)
call airline#extensions#wordcount#init(s:ext) call airline#extensions#wordcount#init(s:ext)
endif endif

View file

@ -154,7 +154,7 @@ function! airline#extensions#branch#head()
if exists("g:airline#extensions#branch#displayed_head_limit") if exists("g:airline#extensions#branch#displayed_head_limit")
let w:displayed_head_limit = g:airline#extensions#branch#displayed_head_limit let w:displayed_head_limit = g:airline#extensions#branch#displayed_head_limit
if len(b:airline_head) > w:displayed_head_limit - 1 if len(b:airline_head) > w:displayed_head_limit - 1
let b:airline_head = b:airline_head[0:w:displayed_head_limit - 1].'…' let b:airline_head = b:airline_head[0:(w:displayed_head_limit - 1)].(&encoding ==? 'utf-8' ? '…' : '.')
endif endif
endif endif

View file

@ -0,0 +1,36 @@
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#extensions#po#apply(...)
if &ft ==# 'po'
call airline#extensions#prepend_to_section('z', '%{airline#extensions#po#stats()}')
autocmd airline BufWritePost * unlet! b:airline_po_stats
endif
endfunction
function! airline#extensions#po#stats()
if exists('b:airline_po_stats') && !empty(b:airline_po_stats)
return b:airline_po_stats
endif
let airline_po_stats = system('msgfmt --statistics -o /dev/null -- '. expand('%:p'))
if v:shell_error
return ''
endif
try
let b:airline_po_stats = '['. split(airline_po_stats, '\n')[0]. ']'
catch
let b:airline_po_stats = ''
endtry
if exists("g:airline#extensions#po#displayed_limit")
let w:displayed_po_limit = g:airline#extensions#po#displayed_limit
if len(b:airline_po_stats) > w:displayed_po_limit - 1
let b:airline_po_stats = b:airline_po_stats[0:(w:displayed_po_limit - 1)].(&encoding==?'utf-8' ? '…' : '.')
endif
endif
return b:airline_po_stats
endfunction
function! airline#extensions#po#init(ext)
call a:ext.add_statusline_func('airline#extensions#po#apply')
endfunction

View file

@ -5,6 +5,7 @@ let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default')
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:ignore_bufadd_pat = get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree') let s:ignore_bufadd_pat = get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree')
let s:taboo = get(g:, 'airline#extensions#taboo#enabled', 1) && get(g:, 'loaded_taboo', 0) let s:taboo = get(g:, 'airline#extensions#taboo#enabled', 1) && get(g:, 'loaded_taboo', 0)
if s:taboo if s:taboo
let g:taboo_tabline = 0 let g:taboo_tabline = 0
@ -41,6 +42,9 @@ function! s:toggle_on()
endfunction endfunction
function! s:update_tabline() function! s:update_tabline()
if get(g:, 'airline#extensions#tabline#disable_refresh', 0)
return
endif
let match = expand('<afile>') let match = expand('<afile>')
if pumvisible() if pumvisible()
return return
@ -52,16 +56,7 @@ function! s:update_tabline()
\ || isdirectory(expand("<afile>")) \ || isdirectory(expand("<afile>"))
return return
endif endif
if empty(mapcheck("<Plug>AirlineTablineRefresh", 'n')) doautocmd User BufMRUChange
noremap <silent> <Plug>AirlineTablineRefresh :set mod!<cr>
endif
call feedkeys("\<Plug>AirlineTablineRefresh")
call feedkeys("\<Plug>AirlineTablineRefresh")
"call feedkeys(',,', 't')
"call feedkeys(':unmap ,,')
" force re-evaluation of tabline setting
" disable explicit redraw, may cause E315
"redraw
endfunction endfunction
function! airline#extensions#tabline#load_theme(palette) function! airline#extensions#tabline#load_theme(palette)
@ -92,6 +87,7 @@ function! airline#extensions#tabline#load_theme(palette)
" Theme for tabs on the right " Theme for tabs on the right
let l:tabsel_right = get(colors, 'airline_tabsel_right', a:palette.normal.airline_a) let l:tabsel_right = get(colors, 'airline_tabsel_right', a:palette.normal.airline_a)
let l:tab_right = get(colors, 'airline_tab_right', a:palette.inactive.airline_c)
let l:tabmod_right = get(colors, 'airline_tabmod_right', a:palette.insert.airline_a) let l:tabmod_right = get(colors, 'airline_tabmod_right', a:palette.insert.airline_a)
let l:tabhid_right = get(colors, 'airline_tabhid_right', a:palette.normal.airline_c) let l:tabhid_right = get(colors, 'airline_tabhid_right', a:palette.normal.airline_c)
if has_key(a:palette, 'normal_modified') && has_key(a:palette.normal_modified, 'airline_c') if has_key(a:palette, 'normal_modified') && has_key(a:palette.normal_modified, 'airline_c')
@ -100,6 +96,7 @@ function! airline#extensions#tabline#load_theme(palette)
"Fall back to normal airline_c if modified airline_c isn't present "Fall back to normal airline_c if modified airline_c isn't present
let l:tabmodu_right = get(colors, 'airline_tabmod_unsel_right', a:palette.normal.airline_c) let l:tabmodu_right = get(colors, 'airline_tabmod_unsel_right', a:palette.normal.airline_c)
endif endif
call airline#highlighter#exec('airline_tab_right', l:tab_right)
call airline#highlighter#exec('airline_tabsel_right', l:tabsel_right) call airline#highlighter#exec('airline_tabsel_right', l:tabsel_right)
call airline#highlighter#exec('airline_tabmod_right', l:tabmod_right) call airline#highlighter#exec('airline_tabmod_right', l:tabmod_right)
call airline#highlighter#exec('airline_tabhid_right', l:tabhid_right) call airline#highlighter#exec('airline_tabhid_right', l:tabhid_right)
@ -163,3 +160,23 @@ function! airline#extensions#tabline#new_builder()
return airline#builder#new(builder_context) return airline#builder#new(builder_context)
endfunction endfunction
function! airline#extensions#tabline#group_of_bufnr(tab_bufs, bufnr)
let cur = bufnr('%')
if cur == a:bufnr
if g:airline_detect_modified && getbufvar(a:bufnr, '&modified')
let group = 'airline_tabmod'
else
let group = 'airline_tabsel'
endif
else
if g:airline_detect_modified && getbufvar(a:bufnr, '&modified')
let group = 'airline_tabmod_unsel'
elseif index(a:tab_bufs, a:bufnr) > -1
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif
endif
return group
endfunction

View file

@ -5,6 +5,7 @@ scriptencoding utf-8
let s:buffer_idx_mode = get(g:, 'airline#extensions#tabline#buffer_idx_mode', 0) 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:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
let s:buffers_label = get(g:, 'airline#extensions#tabline#buffers_label', 'buffers')
let s:spc = g:airline_symbols.space let s:spc = g:airline_symbols.space
let s:current_bufnr = -1 let s:current_bufnr = -1
@ -64,23 +65,16 @@ function! airline#extensions#tabline#buffers#get()
continue continue
endif endif
if cur == nr let group = airline#extensions#tabline#group_of_bufnr(tab_bufs, nr)
if g:airline_detect_modified && getbufvar(nr, '&modified')
let group = 'airline_tabmod' if nr == cur
else
let group = 'airline_tabsel'
endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0 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 endif
" Neovim feature: Have clickable buffers
if has("tablineat")
call b.add_raw('%'.nr.'@airline#extensions#tabline#buffers#switchbuf@')
endif
if s:buffer_idx_mode if s:buffer_idx_mode
if len(s:number_map) > 0 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) call b.add_section(group, s:spc . get(s:number_map, l:index, '') . '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)' . s:spc)
@ -91,13 +85,16 @@ function! airline#extensions#tabline#buffers#get()
else else
call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc) call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc)
endif endif
if has("tablineat")
call b.add_raw('%X')
endif
endfor endfor
call b.add_section('airline_tabfill', '') call b.add_section('airline_tabfill', '')
call b.split() call b.split()
call b.add_section('airline_tabfill', '') call b.add_section('airline_tabfill', '')
if s:show_tab_type if s:show_tab_type
call b.add_section('airline_tabtype', ' buffers ') call b.add_section_spaced('airline_tabtype', s:buffers_label)
endif endif
let s:current_bufnr = cur let s:current_bufnr = cur
@ -198,3 +195,11 @@ function s:map_keys()
noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR> noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
endif endif
endfunction endfunction
function airline#extensions#tabline#buffers#switchbuf(minwid, clicks, button, modifiers) abort
" Run the following code only on a single left mouse button click without modifiers pressed
" works only in recent NeoVim with has('tablineat')
if a:clicks == 1 && a:button is# 'l' && a:modifiers !~# '[^ ]'
sil execute 'buffer' a:minwid
endif
endfunction

View file

@ -7,6 +7,12 @@ let s:current_bufnr = -1
let s:current_tabnr = -1 let s:current_tabnr = -1
let s:current_tabline = '' let s:current_tabline = ''
let s:buffers_label = get(g:, 'airline#extensions#tabline#buffers_label', 'buffers')
let s:tabs_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs')
let s:switch_buffers_and_tabs = get(g:, 'airline#extensions#tabline#switch_buffers_and_tabs', 0)
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1)
function! airline#extensions#tabline#ctrlspace#off() function! airline#extensions#tabline#ctrlspace#off()
augroup airline_tabline_ctrlspace augroup airline_tabline_ctrlspace
autocmd! autocmd!
@ -25,6 +31,62 @@ function! airline#extensions#tabline#ctrlspace#invalidate()
let s:current_tabnr = -1 let s:current_tabnr = -1
endfunction endfunction
function! airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, pos)
if a:pos == 0
let pos_extension = ''
else
let pos_extension = '_right'
endif
let s:buffer_list = ctrlspace#api#BufferList(a:cur_tab)
for buffer in s:buffer_list
if a:cur_buf == buffer.index
if buffer.modified
let group = 'airline_tabmod'.pos_extension
else
let group = 'airline_tabsel'.pos_extension
endif
else
if buffer.modified
let group = 'airline_tabmod_unsel'.pos_extension
elseif buffer.visible
let group = 'airline_tab'.pos_extension
else
let group = 'airline_tabhid'.pos_extension
endif
endif
let buf_name = '%(%{airline#extensions#tabline#get_buffer_name('.buffer.index.')}%)'
call a:builder.add_section_spaced(group, buf_name)
endfor
endfunction
function! airline#extensions#tabline#ctrlspace#add_tab_section(builder, pos)
if a:pos == 0
let pos_extension = ''
else
let pos_extension = '_right'
endif
for tab in s:tab_list
if tab.current
if tab.modified
let group = 'airline_tabmod'.pos_extension
else
let group = 'airline_tabsel'.pos_extension
endif
else
if tab.modified
let group = 'airline_tabmod_unsel'.pos_extension
else
let group = 'airline_tabhid'.pos_extension
endif
endif
call a:builder.add_section_spaced(group, tab.title.ctrlspace#api#TabBuffersNumber(tab.index))
endfor
endfunction
function! airline#extensions#tabline#ctrlspace#get() function! airline#extensions#tabline#ctrlspace#get()
let cur_buf = bufnr('%') let cur_buf = bufnr('%')
@ -39,59 +101,44 @@ function! airline#extensions#tabline#ctrlspace#get()
return s:current_tabline return s:current_tabline
endif endif
let b = airline#extensions#tabline#new_builder() let builder = airline#extensions#tabline#new_builder()
call b.add_section_spaced('airline_tabtype', 'buffers') " Add left tabline content
if s:show_buffers == 0
let s:buffer_list = ctrlspace#api#BufferList(cur_tab) call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0)
for buffer in s:buffer_list elseif s:show_tabs == 0
if cur_buf == buffer.index call airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0)
if buffer.modified
let group = 'airline_tabmod'
else else
let group = 'airline_tabsel' if s:switch_buffers_and_tabs == 0
endif call builder.add_section_spaced('airline_tabtype', s:buffers_label)
call airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 0)
else else
if buffer.modified call builder.add_section_spaced('airline_tabtype', s:tabs_label)
let group = 'airline_tabmod_unsel' call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 0)
elseif buffer.visible
let group = 'airline_tab'
else
let group = 'airline_tabhid'
endif endif
endif endif
let buf_name = '%(%{airline#extensions#tabline#get_buffer_name('.buffer.index.')}%)' call builder.add_section('airline_tabfill', '')
call b.add_section_spaced(group, buf_name) call builder.split()
endfor call builder.add_section('airline_tabfill', '')
" Add right tabline content
call b.add_section('airline_tabfill', '') if s:show_buffers == 0
call b.split() call builder.add_section_spaced('airline_tabtype', s:tabs_label)
call b.add_section('airline_tabfill', '') elseif s:show_tabs == 0
call builder.add_section_spaced('airline_tabtype', s:buffers_label)
for tab in s:tab_list
if tab.current
if tab.modified
let group = 'airline_tabmod_right'
else else
let group = 'airline_tabsel_right' if s:switch_buffers_and_tabs == 0
endif call airline#extensions#tabline#ctrlspace#add_tab_section(builder, 1)
call builder.add_section_spaced('airline_tabtype', s:tabs_label)
else else
if tab.modified call airline#extensions#tabline#ctrlspace#add_buffer_section(builder, cur_tab, cur_buf, 1)
let group = 'airline_tabmod_unsel_right' call builder.add_section_spaced('airline_tabtype', s:buffers_label)
else
let group = 'airline_tabhid_right'
endif endif
endif endif
call b.add_section_spaced(group, tab.title.ctrlspace#api#TabBuffersNumber(tab.index))
endfor
call b.add_section_spaced('airline_tabtype', 'tabs')
let s:current_bufnr = cur_buf let s:current_bufnr = cur_buf
let s:current_tabnr = cur_tab let s:current_tabnr = cur_tab
let s:current_tabline = b.build() let s:current_tabline = builder.build()
return s:current_tabline return s:current_tabline
endfunction endfunction

View file

@ -1,11 +1,14 @@
" MIT License. Copyright (c) 2013-2016 Bailey Ling. " MIT License. Copyright (c) 2013-2016 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " 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_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:show_tab_type = get(g:, 'airline#extensions#tabline#show_tab_type', 1)
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:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X') let s:close_symbol = get(g:, 'airline#extensions#tabline#close_symbol', 'X')
let s:tabs_label = get(g:, 'airline#extensions#tabline#tabs_label', 'tabs')
let s:show_splits = get(g:, 'airline#extensions#tabline#show_splits', 1)
let s:spc = g:airline_symbols.space
let s:current_bufnr = -1 let s:current_bufnr = -1
let s:current_tabnr = -1 let s:current_tabnr = -1
@ -39,19 +42,20 @@ function! airline#extensions#tabline#tabs#get()
endif endif
let b = airline#extensions#tabline#new_builder() let b = airline#extensions#tabline#new_builder()
for i in range(1, tabpagenr('$')) for i in range(1, tabpagenr('$'))
if i == curtab if i == curtab
let group = 'airline_tabsel' let group = 'airline_tabsel_right'
if g:airline_detect_modified if g:airline_detect_modified
for bi in tabpagebuflist(i) for bi in tabpagebuflist(i)
if getbufvar(bi, '&modified') if getbufvar(bi, '&modified')
let group = 'airline_tabmod' let group = 'airline_tabmod_right'
endif endif
endfor endfor
endif endif
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0 let s:current_modified = (group == 'airline_tabmod_right') ? 1 : 0
else else
let group = 'airline_tab' let group = 'airline_tab_right'
endif endif
let val = '%(' let val = '%('
if s:show_tab_nr if s:show_tab_nr
@ -66,14 +70,22 @@ function! airline#extensions#tabline#tabs#get()
call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)') call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)')
endfor endfor
call b.add_raw('%T')
call b.add_section('airline_tabfill', '') call b.add_section('airline_tabfill', '')
call b.split() call b.split()
call b.add_section('airline_tabfill', '')
if s:show_close_button if s:show_close_button
call b.add_section('airline_tab', ' %999X'.s:close_symbol.' ') call b.add_section('airline_tab_right', ' %999X'.s:close_symbol.' ')
endif endif
if s:show_tab_type
call b.add_section('airline_tabtype', ' tabs ') if s:show_splits == 1
let buffers = tabpagebuflist(curtab)
for nr in buffers
let group = airline#extensions#tabline#group_of_bufnr(buffers, nr)
call b.add_section_spaced(group, '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)')
endfor
elseif s:show_tab_type == 1
call b.add_section_spaced('airline_tabtype', s:tabs_label)
endif endif
let s:current_bufnr = curbuf let s:current_bufnr = curbuf

View file

@ -35,8 +35,14 @@ function! s:check_mixed_indent()
endfunction endfunction
function! s:check_mixed_indent_file() function! s:check_mixed_indent_file()
if stridx(&ft, 'c') == 0 || stridx(&ft, 'cpp') == 0 || stridx(&ft, 'javascript') == 0
" for C/CPP only allow /** */ comment style with one space before the '*'
let head_spc = '\v(^ +\*@!)'
else
let head_spc = '\v(^ +)'
endif
let indent_tabs = search('\v(^\t+)', 'nw') let indent_tabs = search('\v(^\t+)', 'nw')
let indent_spc = search('\v(^ +)', 'nw') let indent_spc = search(head_spc, 'nw')
if indent_tabs > 0 && indent_spc > 0 if indent_tabs > 0 && indent_spc > 0
return printf("%d:%d", indent_tabs, indent_spc) return printf("%d:%d", indent_tabs, indent_spc)
else else

View file

@ -47,13 +47,12 @@ function! airline#init#bootstrap()
call s:check_defined('g:airline_theme_map', {}) call s:check_defined('g:airline_theme_map', {})
call extend(g:airline_theme_map, { call extend(g:airline_theme_map, {
\ 'Tomorrow.*': 'tomorrow', \ '\CTomorrow': 'tomorrow',
\ 'base16.*': 'base16', \ 'base16': 'base16',
\ 'bubblegum': 'bubblegum',
\ 'mo[l|n]okai': 'molokai', \ 'mo[l|n]okai': 'molokai',
\ 'wombat.*': 'wombat', \ 'wombat': 'wombat',
\ '.*zenburn.*': 'zenburn', \ 'zenburn': 'zenburn',
\ '.*solarized.*': 'solarized', \ 'solarized': 'solarized',
\ }, 'keep') \ }, 'keep')
call s:check_defined('g:airline_symbols', {}) call s:check_defined('g:airline_symbols', {})

View file

@ -70,7 +70,11 @@ function! airline#parts#iminsert()
endfunction endfunction
function! airline#parts#readonly() function! airline#parts#readonly()
if &readonly && &modifiable && !filereadable(bufname('%'))
return '[noperm]'
else
return &readonly ? g:airline_symbols.readonly : '' return &readonly ? g:airline_symbols.readonly : ''
endif
endfunction endfunction
function! airline#parts#filetype() function! airline#parts#filetype()

View file

@ -489,13 +489,22 @@ eclim <https://eclim.org>
let g:airline#extensions#whitespace#trailing_regexp = '\s$' let g:airline#extensions#whitespace#trailing_regexp = '\s$'
< <
------------------------------------- *airline-tabline* ------------------------------------- *airline-tabline*
* enable/disable enhanced tabline. > Note: If you're using the ctrlspace tabline only the option marked with (c)
are supported!
* enable/disable enhanced tabline. (c)
let g:airline#extensions#tabline#enabled = 0 let g:airline#extensions#tabline#enabled = 0
<
* enable/disable displaying buffers with a single tab. > * enable/disable displaying open splits per tab (only when tabs are opened). >
let g:airline#extensions#tabline#show_splits = 1
*
* switch position of buffers and tabs on splited tabline (c)
let g:airline#extensions#tabline#switch_buffers_and_tabs = 0
* enable/disable displaying buffers with a single tab. (c)
let g:airline#extensions#tabline#show_buffers = 1 let g:airline#extensions#tabline#show_buffers = 1
< <
* enable/disable displaying tabs, regardless of number. > * enable/disable displaying tabs, regardless of number. (c)
let g:airline#extensions#tabline#show_tabs = 1 let g:airline#extensions#tabline#show_tabs = 1
< <
* configure filename match rules to exclude from the tabline. > * configure filename match rules to exclude from the tabline. >
@ -515,11 +524,13 @@ eclim <https://eclim.org>
* enable/disable displaying tab type (far right) > * enable/disable displaying tab type (far right) >
let g:airline#extensions#tabline#show_tab_type = 1 let g:airline#extensions#tabline#show_tab_type = 1
* enable/disable displaying index of the buffer. * rename label for buffers (default: 'buffers') (c)
let g:airline#extensions#tabline#buffers_label = 'b'
Note: If you're using ctrlspace the tabline shows your tabs on the right and * rename label for tabs (default: 'tabs') (c)
buffer on the left. Also none of the tabline switches is currently let g:airline#extensions#tabline#tabs_label = 't'
supported!
* enable/disable displaying index of the buffer.
When enabled, numbers will be displayed in the tabline and mappings will be When enabled, numbers will be displayed in the tabline and mappings will be
exposed to allow you to select a buffer directly. Up to 9 mappings will be exposed to allow you to select a buffer directly. Up to 9 mappings will be
@ -545,7 +556,7 @@ eclim <https://eclim.org>
Use |gt| for switching tabs. Use |gt| for switching tabs.
In tabmode, those mappings will switch to the specified tab. In tabmode, those mappings will switch to the specified tab.
* defines the name of a formatter for how buffer names are displayed. > * defines the name of a formatter for how buffer names are displayed. (c)
let g:airline#extensions#tabline#formatter = 'default' let g:airline#extensions#tabline#formatter = 'default'
" here is how you can define a 'foo' formatter: " here is how you can define a 'foo' formatter:
@ -565,7 +576,7 @@ eclim <https://eclim.org>
* configure whether buffer numbers should be shown. > * configure whether buffer numbers should be shown. >
let g:airline#extensions#tabline#buffer_nr_show = 0 let g:airline#extensions#tabline#buffer_nr_show = 0
< <
* configure how buffer numbers should be formatted with |printf|. > * configure how buffer numbers should be formatted with |printf()|. >
let g:airline#extensions#tabline#buffer_nr_format = '%s: ' let g:airline#extensions#tabline#buffer_nr_format = '%s: '
< <
* configure the formatting of filenames (see |filename-modifiers|). > * configure the formatting of filenames (see |filename-modifiers|). >
@ -614,9 +625,13 @@ eclim <https://eclim.org>
let airline#extensions#tabline#ignore_bufadd_pat = let airline#extensions#tabline#ignore_bufadd_pat =
\ '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree' \ '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree'
<
Note: Enabling this extension will modify 'showtabline' and 'guioptions'. Note: Enabling this extension will modify 'showtabline' and 'guioptions'.
* enable Refresh of tabline buffers on |BufAdd| autocommands
(set this to one, if you note 'AirlineTablineRefresh', however, this
won't update airline on |:badd| commands) >
let airline#extensions#tabline#disable_refresh = 0
------------------------------------- *airline-tmuxline* ------------------------------------- *airline-tmuxline*
tmuxline <https://github.com/edkolev/tmuxline.vim> tmuxline <https://github.com/edkolev/tmuxline.vim>
@ -707,6 +722,15 @@ Shows number of errors and warnings in the current file detected by YCM.
* set warning count prefix > * set warning count prefix >
let g:airline#extensions#ycm#warning_symbol = 'W:' let g:airline#extensions#ycm#warning_symbol = 'W:'
< <
------------------------------------- *airline-po*
po.vim <http://www.vim.org/scripts/script.php?script_id=2530>
* enable/disable po integration >
let g:airline#extensions#po#enabled = 1
<
* truncate width names to a fixed length >
let g:airline#extensions#po#displayed_limit = 0
<
============================================================================== ==============================================================================
ADVANCED CUSTOMIZATION *airline-advanced-customization* ADVANCED CUSTOMIZATION *airline-advanced-customization*

View file

@ -28,11 +28,11 @@ function! s:go(type,...) abort
let [lnum1, lnum2] = [line("'["), line("']")] let [lnum1, lnum2] = [line("'["), line("']")]
endif endif
let [l, r] = s:surroundings() let [l_, r_] = s:surroundings()
let uncomment = 2 let uncomment = 2
for lnum in range(lnum1,lnum2) for lnum in range(lnum1,lnum2)
let line = matchstr(getline(lnum),'\S.*\s\@<!') let line = matchstr(getline(lnum),'\S.*\s\@<!')
let [l, r] = s:strip_white_space(l,r,line) let [l, r] = s:strip_white_space(l_,r_,line)
if line != '' && (stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r) if line != '' && (stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
let uncomment = 0 let uncomment = 0
endif endif

View file

@ -57,6 +57,10 @@ that are part of Git repositories).
q close status q close status
r reload status r reload status
S |:Gvsplit| S |:Gvsplit|
U |:Git| checkout
U |:Git| checkout HEAD (staged files)
U |:Git| clean (untracked files)
U |:Git| rm (unmerged files)
*fugitive-:Gcommit* *fugitive-:Gcommit*
:Gcommit [args] A wrapper around git-commit. If there is nothing :Gcommit [args] A wrapper around git-commit. If there is nothing

View file

@ -123,7 +123,9 @@ let s:abstract_prototype = {}
function! fugitive#is_git_dir(path) abort function! fugitive#is_git_dir(path) abort
let path = s:sub(a:path, '[\/]$', '') . '/' let path = s:sub(a:path, '[\/]$', '') . '/'
return isdirectory(path.'objects') && isdirectory(path.'refs') && getfsize(path.'HEAD') > 10 return getfsize(path.'HEAD') > 10 && (
\ isdirectory(path.'objects') && isdirectory(path.'refs') ||
\ getftype(path.'commondir') ==# 'file')
endfunction endfunction
function! fugitive#extract_git_dir(path) abort function! fugitive#extract_git_dir(path) abort
@ -265,9 +267,17 @@ function! s:configured_tree(git_dir) abort
let config = readfile(config_file,'',10) let config = readfile(config_file,'',10)
call filter(config,'v:val =~# "^\\s*worktree *="') call filter(config,'v:val =~# "^\\s*worktree *="')
if len(config) == 1 if len(config) == 1
let s:worktree_for_dir[a:git_dir] = matchstr(config[0], '= *\zs.*') let worktree = matchstr(config[0], '= *\zs.*')
let s:dir_for_worktree[s:worktree_for_dir[a:git_dir]] = a:git_dir
endif endif
elseif filereadable(a:git_dir . '/gitdir')
let worktree = fnamemodify(readfile(a:git_dir . '/gitdir')[0], ':h')
if worktree ==# '.'
unlet! worktree
endif
endif
if exists('worktree')
let s:worktree_for_dir[a:git_dir] = worktree
let s:dir_for_worktree[s:worktree_for_dir[a:git_dir]] = a:git_dir
endif endif
endif endif
if s:worktree_for_dir[a:git_dir] =~# '^\.' if s:worktree_for_dir[a:git_dir] =~# '^\.'
@ -299,6 +309,10 @@ function! s:repo_bare() dict abort
endfunction endfunction
function! s:repo_translate(spec) dict abort function! s:repo_translate(spec) dict abort
let refs = self.dir('refs/')
if filereadable(self.dir('commondir'))
let refs = simplify(self.dir(get(readfile(self.dir('commondir'), 1), 0, ''))) . '/refs/'
endif
if a:spec ==# '.' || a:spec ==# '/.' if a:spec ==# '.' || a:spec ==# '/.'
return self.bare() ? self.dir() : self.tree() return self.bare() ? self.dir() : self.tree()
elseif a:spec =~# '^/\=\.git$' && self.bare() elseif a:spec =~# '^/\=\.git$' && self.bare()
@ -322,18 +336,18 @@ function! s:repo_translate(spec) dict abort
return 'fugitive://'.self.dir().'//0/'.a:spec[1:-1] return 'fugitive://'.self.dir().'//0/'.a:spec[1:-1]
elseif a:spec ==# '@' elseif a:spec ==# '@'
return self.dir('HEAD') return self.dir('HEAD')
elseif a:spec =~# 'HEAD\|^refs/' && a:spec !~ ':' && filereadable(self.dir(a:spec)) elseif a:spec =~# 'HEAD\|^refs/' && a:spec !~ ':' && filereadable(refs . '../' . a:spec)
return self.dir(a:spec) return simplify(refs . '../' . a:spec)
elseif filereadable(self.dir('refs/'.a:spec)) elseif filereadable(refs.a:spec)
return self.dir('refs/'.a:spec) return refs.a:spec
elseif filereadable(self.dir('refs/tags/'.a:spec)) elseif filereadable(refs.'tags/'.a:spec)
return self.dir('refs/tags/'.a:spec) return refs.'tags/'.a:spec
elseif filereadable(self.dir('refs/heads/'.a:spec)) elseif filereadable(refs.'heads/'.a:spec)
return self.dir('refs/heads/'.a:spec) return refs.'heads/'.a:spec
elseif filereadable(self.dir('refs/remotes/'.a:spec)) elseif filereadable(refs.'remotes/'.a:spec)
return self.dir('refs/remotes/'.a:spec) return refs.'remotes/'.a:spec
elseif filereadable(self.dir('refs/remotes/'.a:spec.'/HEAD')) elseif filereadable(refs.'remotes/'.a:spec.'/HEAD')
return self.dir('refs/remotes/'.a:spec,'/HEAD') return refs.'remotes/'.a:spec,'/HEAD'
else else
try try
let ref = self.rev_parse(matchstr(a:spec,'[^:]*')) let ref = self.rev_parse(matchstr(a:spec,'[^:]*'))
@ -849,7 +863,9 @@ function! s:StageUndo() abort
let hash = repo.git_chomp('hash-object', '-w', filename) let hash = repo.git_chomp('hash-object', '-w', filename)
if !empty(hash) if !empty(hash)
if section ==# 'untracked' if section ==# 'untracked'
call delete(s:repo().tree(filename)) call repo.git_chomp_in_tree('clean', '--', filename)
elseif section ==# 'unmerged'
call repo.git_chomp_in_tree('rm', '--', filename)
elseif section ==# 'unstaged' elseif section ==# 'unstaged'
call repo.git_chomp_in_tree('checkout', '--', filename) call repo.git_chomp_in_tree('checkout', '--', filename)
else else
@ -2675,7 +2691,7 @@ function! s:BufReadObject() abort
if b:fugitive_display_format if b:fugitive_display_format
call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash)) call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash))
else else
call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree %T%nparent %P%nauthor %an <%ae> %ad%ncommitter %cn <%ce> %cd%nencoding %e%n%n%s%n%n%b',hash)) call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b',hash))
keepjumps call search('^parent ') keepjumps call search('^parent ')
if getline('.') ==# 'parent ' if getline('.') ==# 'parent '
silent keepjumps delete_ silent keepjumps delete_

View file

@ -0,0 +1,9 @@
Thanks for improving vim-go! Before you dive in please read the following:
1. Please read our
[FAQ](https://github.com/fatih/vim-go/wiki/FAQ-Troubleshooting), it might
have answers for your problem
2. If you add a new feature please don't forget to update the documentation:
[doc/vim-go.txt](doc/vim-go.txt)
3. If it's a breaking change or exceed +100 lines please open an issue first
and describe the changes you want to make.

View file

@ -0,0 +1,30 @@
### Expected behavior
Write here what you're expecting ...
### Actual behavior
Write here what happens instead ...
### Steps to reproduce:
Please create a reproducible case of your problem. Re produce it
with a minimal `vimrc` with all plugins disabled and only `vim-go`
enabled:
1.
2.
3.
### Configuration
#### `vimrc` you used to reproduce:
#### vim version:
#### vim-go version:
#### go version:

View file

@ -5,26 +5,26 @@ endif
" Test alternates between the implementation of code and the test code. " Test alternates between the implementation of code and the test code.
function! go#alternate#Switch(bang, cmd) function! go#alternate#Switch(bang, cmd)
let l:file = go#alternate#Filename(fnameescape(expand("%"))) let file = expand('%')
if !filereadable(l:file) && !bufexists(l:file) && !a:bang if empty(file)
redraws! | echon "vim-go: " | echohl ErrorMsg | echon "couldn't find ".file | echohl None call go#util#EchoError("no buffer name")
return
elseif file =~# '^\f\+_test\.go$'
let l:root = split(file, '_test.go$')[0]
let l:alt_file = l:root . ".go"
elseif file =~# '^\f\+\.go$'
let l:root = split(file, ".go$")[0]
let l:alt_file = l:root . '_test.go'
else
call go#util#EchoError("not a go file")
return
endif
if !filereadable(alt_file) && !bufexists(alt_file) && !a:bang
call go#util#EchoError("couldn't find ".alt_file)
return return
elseif empty(a:cmd) elseif empty(a:cmd)
execute ":" . g:go_alternate_mode . " " . file execute ":" . g:go_alternate_mode . " " . alt_file
else else
execute ":" . a:cmd . " " . file execute ":" . a:cmd . " " . alt_file
endif endif
endfunction endfunction
" Filename returns the name of the test file or implementation file
" depending on the arguments
function! go#alternate#Filename(path)
if empty(matchstr(a:path, "_test"))
let l:root = split(a:path, ".go$")[0]
let l:file = l:root . "_test.go"
else
let l:root = split(a:path, "_test.go$")[0]
let l:file = l:root . ".go"
endif
return l:file
endfunction

View file

@ -74,8 +74,12 @@ endfunction
" Run runs the current file (and their dependencies if any) in a new terminal. " Run runs the current file (and their dependencies if any) in a new terminal.
function! go#cmd#RunTerm(bang, mode) function! go#cmd#RunTerm(bang, mode, files)
if empty(a:files)
let cmd = "go run ". go#util#Shelljoin(go#tool#Files()) let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
else
let cmd = "go run ". go#util#Shelljoin(map(copy(a:files), "expand(v:val)"), 1)
endif
call go#term#newmode(a:bang, cmd, a:mode) call go#term#newmode(a:bang, cmd, a:mode)
endfunction endfunction
@ -85,7 +89,7 @@ endfunction
" calling long running apps will block the whole UI. " calling long running apps will block the whole UI.
function! go#cmd#Run(bang, ...) function! go#cmd#Run(bang, ...)
if has('nvim') if has('nvim')
call go#cmd#RunTerm(a:bang, '') call go#cmd#RunTerm(a:bang, '', a:000)
return return
endif endif
@ -117,9 +121,9 @@ function! go#cmd#Run(bang, ...)
if g:go_dispatch_enabled && exists(':Make') == 2 if g:go_dispatch_enabled && exists(':Make') == 2
silent! exe 'Make' silent! exe 'Make'
elseif l:listtype == "locationlist" elseif l:listtype == "locationlist"
silent! exe 'lmake!' exe 'lmake!'
else else
silent! exe 'make!' exe 'make!'
endif endif
let items = go#list#Get(l:listtype) let items = go#list#Get(l:listtype)

View file

@ -149,13 +149,16 @@ function! go#complete#GetInfoFromOffset(offset)
endfunction endfunction
function! go#complete#GetInfo() function! go#complete#GetInfo()
let offset = go#complete#gocodeCursor() let offset = go#complete#gocodeCursor()+1
return go#complete#GetInfoFromOffset(offset) return go#complete#GetInfoFromOffset(offset)
endfunction endfunction
function! go#complete#Info() function! go#complete#Info(auto)
" auto is true if we were called by g:go_auto_type_info's autocmd
let result = go#complete#GetInfo() let result = go#complete#GetInfo()
if !empty(result) if !empty(result)
" if auto, and the result is a PANIC by gocode, hide it
if a:auto && result ==# 'PANIC PANIC PANIC' | return | endif
echo "vim-go: " | echohl Function | echon result | echohl None echo "vim-go: " | echohl Function | echon result | echohl None
endif endif
endfunction endfunction

View file

@ -116,7 +116,7 @@ function! s:godefJump(out, mode)
" jump to file now " jump to file now
sil ll 1 sil ll 1
normal zz normal! zz
let &switchbuf = old_switchbuf let &switchbuf = old_switchbuf
end end

View file

@ -113,28 +113,28 @@ function! go#doc#Open(newmode, mode, ...)
call s:GodocView(a:newmode, a:mode, content) call s:GodocView(a:newmode, a:mode, content)
if exported_name == '' if exported_name == ''
silent! normal gg silent! normal! gg
return -1 return -1
endif endif
" jump to the specified name " jump to the specified name
if search('^func ' . exported_name . '(') if search('^func ' . exported_name . '(')
silent! normal zt silent! normal! zt
return -1 return -1
endif endif
if search('^type ' . exported_name) if search('^type ' . exported_name)
silent! normal zt silent! normal! zt
return -1 return -1
endif endif
if search('^\%(const\|var\|type\|\s\+\) ' . pkg . '\s\+=\s') if search('^\%(const\|var\|type\|\s\+\) ' . pkg . '\s\+=\s')
silent! normal zt silent! normal! zt
return -1 return -1
endif endif
" nothing found, jump to top " nothing found, jump to top
silent! normal gg silent! normal! gg
endfunction endfunction
function! s:GodocView(newposition, position, content) function! s:GodocView(newposition, position, content)

View file

@ -52,13 +52,25 @@ endif
" this and have VimL experience, please look at the function for " this and have VimL experience, please look at the function for
" improvements, patches are welcome :) " improvements, patches are welcome :)
function! go#fmt#Format(withGoimport) function! go#fmt#Format(withGoimport)
" save cursor position, folds and many other things if g:go_fmt_experimental == 1
" Using winsaveview to save/restore cursor state has the problem of
" closing folds on save:
" https://github.com/fatih/vim-go/issues/502
" One fix is to use mkview instead. Unfortunately, this sometimes causes
" other bad side effects:
" https://github.com/fatih/vim-go/issues/728
" and still closes all folds if foldlevel>0:
" https://github.com/fatih/vim-go/issues/732
let l:curw = {} let l:curw = {}
try try
mkview! mkview!
catch catch
let l:curw=winsaveview() let l:curw=winsaveview()
endtry endtry
else
" Save cursor position and many other things.
let l:curw=winsaveview()
endif
" Write current unsaved buffer to a temp file " Write current unsaved buffer to a temp file
let l:tmpname = tempname() let l:tmpname = tempname()
@ -101,6 +113,24 @@ function! go#fmt#Format(withGoimport)
let command = command . g:go_fmt_options let command = command . g:go_fmt_options
endif endif
if fmt_command == "goimports"
if !exists('b:goimports_vendor_compatible')
let out = system("goimports --help")
if out !~ "-srcdir"
echohl WarningMsg
echomsg "vim-go: goimports does not support srcdir."
echomsg " update with: :GoUpdateBinaries"
echohl None
else
let b:goimports_vendor_compatible = 1
endif
endif
if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible
let command = command . '-srcdir ' . fnameescape(expand("%:p:h"))
endif
endif
" execute our command... " execute our command...
let out = system(command . " " . l:tmpname) let out = system(command . " " . l:tmpname)
@ -163,12 +193,17 @@ function! go#fmt#Format(withGoimport)
call delete(tmpundofile) call delete(tmpundofile)
endif endif
" restore our cursor/windows positions, folds, etc.. if g:go_fmt_experimental == 1
" Restore our cursor/windows positions, folds, etc.
if empty(l:curw) if empty(l:curw)
silent! loadview silent! loadview
else else
call winrestview(l:curw) call winrestview(l:curw)
endif endif
else
" Restore our cursor/windows positions.
call winrestview(l:curw)
endif
endfunction endfunction

View file

@ -165,7 +165,7 @@ function! go#import#SwitchImport(enabled, localname, path, bang)
call append(appendline, appendstr) call append(appendline, appendstr)
execute appendline + 1 execute appendline + 1
if indentstr if indentstr
execute 'normal >>' execute 'normal! >>'
endif endif
let linesdelta += 1 let linesdelta += 1
endif endif

View file

@ -114,6 +114,10 @@ func! s:RunOracle(mode, selected, needs_package) range abort
\ shellescape(fname), pos, tags, a:mode) \ shellescape(fname), pos, tags, a:mode)
endif endif
" strip trailing slashes for each path in scoped. bug:
" https://github.com/golang/go/issues/14584
let scopes = go#util#StripTrailingSlash(scopes)
" now append each scope to the end as Oracle's scope parameter. It can be " 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 " a packages or go files, dependent on the User's own choice. For more
" info check Oracle's User Manual section about scopes: " info check Oracle's User Manual section about scopes:

View file

@ -48,6 +48,12 @@ function! go#util#StripPathSep(path)
return a:path return a:path
endfunction endfunction
" StripTrailingSlash strips the trailing slash from the given path list.
" example: ['/foo/bar/'] -> ['/foo/bar']
function! go#util#StripTrailingSlash(paths)
return map(copy(a:paths), 'go#util#StripPathSep(v:val)')
endfunction
" Shelljoin returns a shell-safe string representation of arglist. The " Shelljoin returns a shell-safe string representation of arglist. The
" {special} argument of shellescape() may optionally be passed. " {special} argument of shellescape() may optionally be passed.
function! go#util#Shelljoin(arglist, ...) function! go#util#Shelljoin(arglist, ...)

View file

@ -16,12 +16,12 @@ command! -nargs=? GoOracleTags call go#oracle#Tags(<f-args>)
" tool " tool
command! -nargs=0 GoFiles echo go#tool#Files() command! -nargs=0 GoFiles echo go#tool#Files()
command! -nargs=0 GoDeps echo go#tool#Deps() command! -nargs=0 GoDeps echo go#tool#Deps()
command! -nargs=* GoInfo call go#complete#Info() command! -nargs=* GoInfo call go#complete#Info(0)
" cmd " cmd
command! -nargs=* -bang GoBuild call go#cmd#Build(<bang>0,<f-args>) command! -nargs=* -bang GoBuild call go#cmd#Build(<bang>0,<f-args>)
command! -nargs=* -bang GoGenerate call go#cmd#Generate(<bang>0,<f-args>) command! -nargs=* -bang GoGenerate call go#cmd#Generate(<bang>0,<f-args>)
command! -nargs=* -bang GoRun call go#cmd#Run(<bang>0,<f-args>) command! -nargs=* -bang -complete=file GoRun call go#cmd#Run(<bang>0,<f-args>)
command! -nargs=* -bang GoInstall call go#cmd#Install(<bang>0, <f-args>) command! -nargs=* -bang GoInstall call go#cmd#Install(<bang>0, <f-args>)
command! -nargs=* -bang GoTest call go#cmd#Test(<bang>0, 0, <f-args>) command! -nargs=* -bang GoTest call go#cmd#Test(<bang>0, 0, <f-args>)
command! -nargs=* -bang GoTestFunc call go#cmd#TestFunc(<bang>0, <f-args>) command! -nargs=* -bang GoTestFunc call go#cmd#TestFunc(<bang>0, <f-args>)

View file

@ -12,9 +12,9 @@ endif
nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(!g:go_jump_to_error)<CR> nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(!g:go_jump_to_error)<CR>
if has("nvim") if has("nvim")
nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit')<CR> nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit', [])<CR>
nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split')<CR> nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split', [])<CR>
nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe')<CR> nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe', [])<CR>
endif endif
nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(!g:go_jump_to_error)<CR> nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(!g:go_jump_to_error)<CR>
@ -27,7 +27,7 @@ nnoremap <silent> <Plug>(go-coverage) :<C-u>call go#cmd#Coverage(!g:go_jump_to_e
nnoremap <silent> <Plug>(go-files) :<C-u>call go#tool#Files()<CR> nnoremap <silent> <Plug>(go-files) :<C-u>call go#tool#Files()<CR>
nnoremap <silent> <Plug>(go-deps) :<C-u>call go#tool#Deps()<CR> nnoremap <silent> <Plug>(go-deps) :<C-u>call go#tool#Deps()<CR>
nnoremap <silent> <Plug>(go-info) :<C-u>call go#complete#Info()<CR> nnoremap <silent> <Plug>(go-info) :<C-u>call go#complete#Info(0)<CR>
nnoremap <silent> <Plug>(go-import) :<C-u>call go#import#SwitchImport(1, '', expand('<cword>'), '')<CR> nnoremap <silent> <Plug>(go-import) :<C-u>call go#import#SwitchImport(1, '', expand('<cword>'), '')<CR>
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>

View file

@ -143,7 +143,7 @@ augroup vim-go
" GoInfo automatic update " GoInfo automatic update
if get(g:, "go_auto_type_info", 0) if get(g:, "go_auto_type_info", 0)
autocmd CursorHold *.go nested call go#complete#Info() autocmd CursorHold *.go nested call go#complete#Info(1)
endif endif
" Echo the identifier information when completion is done. Useful to see " Echo the identifier information when completion is done. Useful to see

View file

@ -179,30 +179,31 @@ syn region goBlock start="{" end="}" transparent fold
syn region goParen start='(' end=')' transparent syn region goParen start='(' end=')' transparent
" Integers " Integers
syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>" syn match goDecimalInt "\<-\=\d\+\%([Ee][-+]\=\d\+\)\=\>"
syn match goHexadecimalInt "\<0x\x\+\>" syn match goHexadecimalInt "\<-\=0[xX]\x\+\>"
syn match goOctalInt "\<0\o\+\>" syn match goOctalInt "\<-\=0\o\+\>"
syn match goOctalError "\<0\o*[89]\d*\>" syn match goOctalError "\<-\=0\o*[89]\d*\>"
hi def link goDecimalInt Integer hi def link goDecimalInt Integer
hi def link goHexadecimalInt Integer hi def link goHexadecimalInt Integer
hi def link goOctalInt Integer hi def link goOctalInt Integer
hi def link goOctalError Error
hi def link Integer Number hi def link Integer Number
" Floating point " Floating point
syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" syn match goFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>"
syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" syn match goFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>"
syn match goFloat "\<\d\+[Ee][-+]\d\+\>"
hi def link goFloat Float hi def link goFloat Float
" Imaginary literals " Imaginary literals
syn match goImaginary "\<\d\+i\>" syn match goImaginary "\<-\=\d\+i\>"
syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" syn match goImaginary "\<-\=\d\+[Ee][-+]\=\d\+i\>"
syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" syn match goImaginaryFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=i\>"
syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>" syn match goImaginaryFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=i\>"
hi def link goImaginary Number hi def link goImaginary Number
hi def link goImaginaryFloat Float
" Spaces after "[]" " Spaces after "[]"
if g:go_highlight_array_whitespace_error != 0 if g:go_highlight_array_whitespace_error != 0

View file

@ -9,7 +9,7 @@ endif
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=<!--%s-->
setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]: setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:

View file

@ -283,7 +283,9 @@ fun! s:AddScopeAliases(list) abort
return keys(did) return keys(did)
endf endf
augroup SnipMateSource
au SourceCmd *.snippet,*.snippets call s:source_snippet() au SourceCmd *.snippet,*.snippets call s:source_snippet()
augroup END
function! s:info_from_filename(file) abort function! s:info_from_filename(file) abort
let parts = split(fnamemodify(a:file, ':r'), '/') let parts = split(fnamemodify(a:file, ':r'), '/')

View file

@ -28,12 +28,14 @@ if (!exists('g:snipMateSources'))
let g:snipMateSources['default'] = funcref#Function('snipMate#DefaultPool') let g:snipMateSources['default'] = funcref#Function('snipMate#DefaultPool')
endif endif
augroup SnipMateDetect
au BufRead,BufNewFile *.snippet,*.snippets setlocal filetype=snippets au BufRead,BufNewFile *.snippet,*.snippets setlocal filetype=snippets
au FileType snippets if expand('<afile>:e') =~# 'snippet$' au FileType snippets if expand('<afile>:e') =~# 'snippet$'
\ | setlocal syntax=snippet \ | setlocal syntax=snippet
\ | else \ | else
\ | setlocal syntax=snippets \ | setlocal syntax=snippets
\ | endif \ | endif
augroup END
inoremap <silent> <Plug>snipMateNextOrTrigger <C-R>=snipMate#TriggerSnippet()<CR> inoremap <silent> <Plug>snipMateNextOrTrigger <C-R>=snipMate#TriggerSnippet()<CR>
snoremap <silent> <Plug>snipMateNextOrTrigger <Esc>a<C-R>=snipMate#TriggerSnippet()<CR> snoremap <silent> <Plug>snipMateNextOrTrigger <Esc>a<C-R>=snipMate#TriggerSnippet()<CR>

View file

@ -74,7 +74,9 @@ Additional snippets can be added to the current buffer with the
"snippets" ending. For example, to add the JavaScript Jasmine snippets, run: "snippets" ending. For example, to add the JavaScript Jasmine snippets, run:
`:UltiSnipsAddFiletypes javascript-jasmine`. To have this snippet loaded `:UltiSnipsAddFiletypes javascript-jasmine`. To have this snippet loaded
everytime a JavaScript file is opened or created you can add the command to your everytime a JavaScript file is opened or created you can add the command to your
`.vim/ftplugin/javascript.vim` file. -`.vim/ftplugin/javascript.vim` file. Another way is to add
`autocmd FileType js UltiSnipsAddFiletypes javascript-jasmine` in your `.vimrc`.
For more see the UltiSnips docs (`:help UltiSnips`). For more see the UltiSnips docs (`:help UltiSnips`).

View file

@ -185,7 +185,7 @@ ${1:FIELDNAME} = models.DateTimeField($2)
endsnippet endsnippet
snippet mdecimal "DecimalField" b snippet mdecimal "DecimalField" b
${1:FIELDNAME} = models.DateTimeField($2) ${1:FIELDNAME} = models.DecimalField(max_digits=${2:10}, decimal_places=${3:2})
endsnippet endsnippet
snippet memail "EmailField" b snippet memail "EmailField" b

View file

@ -45,25 +45,6 @@ type ${1:Interface} interface {
} }
endsnippet endsnippet
# statements
snippet for "For loop" b
for ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet fori "Integer for loop" b
for ${1:i} := 0; $1 < ${2:N}; $1++ {
${0:${VISUAL}}
}
endsnippet
snippet forr "For range loop" b
for ${2:name} := range ${1:collection} {
${0:${VISUAL}}
}
endsnippet
snippet if "If statement" b snippet if "If statement" b
if ${1:condition}${1/(.+)/ /}{ if ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}} ${0:${VISUAL}}
@ -76,22 +57,6 @@ case${0}
} }
endsnippet endsnippet
snippet select "Select statement" b
select {
case${0}
}
endsnippet
snippet case "Case clause" b
case ${1:condition}:
${0:${VISUAL}}
endsnippet
snippet default "Default clause" b
default:
${0:${VISUAL}}
endsnippet
# functions # functions
snippet /^main/ "Main function" r snippet /^main/ "Main function" r
func main() { func main() {

View file

@ -58,6 +58,12 @@ ${1:var }${2:function_name} = function $2(${3}) {
}; };
endsnippet endsnippet
snippet af "Anonymous Function" i
function($1) {
${VISUAL}$0
}
endsnippet
snippet iife "Immediately-Invoked Function Expression (iife)" snippet iife "Immediately-Invoked Function Expression (iife)"
(function(${1:window}) { (function(${1:window}) {
${VISUAL}$0 ${VISUAL}$0

View file

@ -51,11 +51,11 @@ format!("${1}"${2/..*/, /}${2});
endsnippet endsnippet
snippet macro "macro_rules!" b snippet macro "macro_rules!" b
macro_rules! ${1:name} ( macro_rules! ${1:name} {
(${2:matcher}) => ( (${2:matcher}) => (
${3} ${3}
) )
) }
endsnippet endsnippet
snippet mod "A module" b snippet mod "A module" b
@ -88,7 +88,7 @@ pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
impl $1 { impl $1 {
pub fn new(${2}) -> $1 { pub fn new(${2}) -> $1 {
$1 { ${3} }; $1 { ${3} }
} }
} }
endsnippet endsnippet

View file

@ -87,10 +87,6 @@ snippet doc
""" """
snippet fn snippet fn
fn ${1:args} -> ${0} end fn ${1:args} -> ${0} end
snippet fun
function do
${0}
end
snippet mdoc snippet mdoc
@moduledoc """ @moduledoc """
${0} ${0}
@ -114,6 +110,12 @@ snippet test
end end
snippet testa snippet testa
test "${1:test_name}", %{${2:arg: arg}} do test "${1:test_name}", %{${2:arg: arg}} do
${0}
end
snippet exunit
defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
use ExUnit.Case
${0} ${0}
end end
snippet try try .. rescue .. end snippet try try .. rescue .. end

View file

@ -53,26 +53,6 @@ snippet dfr
${0} ${0}
} }
}() }()
# gpl
snippet gpl
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) ${1:Author}, `strftime("%Y")`
*/
${0}
# int # int
snippet i snippet i
int int
@ -94,6 +74,12 @@ snippet if
if ${1:/* condition */} { if ${1:/* condition */} {
${2} ${2}
} }
snippet ife
if ${1:/* condition */} {
${2}
} else {
${0}
}
# else snippet # else snippet
snippet el snippet el
else { else {
@ -128,18 +114,21 @@ snippet ie
${3} ${3}
} }
${0} ${0}
# for loop # for int loop
snippet fo snippet for
for ${1}{
${0}
}
# for int loop
snippet fori
for ${2:i} := 0; $2 < ${1:count}; $2${3:++} { for ${2:i} := 0; $2 < ${1:count}; $2${3:++} {
${4}
}
${0} ${0}
}
# for range loop # for range loop
snippet fr snippet forr
for ${1:k}, ${2:v} := range ${3} { for ${1:e} := range ${2:collection} {
${4}
}
${0} ${0}
}
# function simple # function simple
snippet fun snippet fun
func ${1:funcName}(${2}) ${3:error} { func ${1:funcName}(${2}) ${3:error} {
@ -196,8 +185,6 @@ snippet sl
select { select {
case ${1:v1} := <-${2:chan1} case ${1:v1} := <-${2:chan1}
${3} ${3}
case ${4:v2} := <-${5:chan2}
${6}
default: default:
${0} ${0}
} }

View file

@ -5,7 +5,7 @@ snippet ex
module.exports = ${1}; module.exports = ${1};
# require # require
snippet re snippet re
var ${1} = require('${2:module_name}'); ${1:var} ${2} = require('${3:module_name}');
# EventEmitter # EventEmitter
snippet on snippet on
on('${1:event_name}', function(${2:stream}) { on('${1:event_name}', function(${2:stream}) {

View file

@ -723,3 +723,7 @@ snippet iiexp
it { is_expected.to ${0} } it { is_expected.to ${0} }
snippet iiexpn snippet iiexpn
it { is_expected.not_to ${0} } it { is_expected.not_to ${0} }
snippet agg
aggregate_failures '${1:message}' do
${0}
end

View file

@ -25,7 +25,7 @@ snippet bench "Bench function" b
} }
snippet new "Constructor function" snippet new "Constructor function"
pub fn new(${2}) -> ${1:Name} { pub fn new(${2}) -> ${1:Name} {
$1 { ${3} }; $1 { ${3} }
} }
snippet main "Main function" snippet main "Main function"
pub fn main() { pub fn main() {
@ -143,7 +143,7 @@ snippet stn "Struct with new constructor"
impl $1 { impl $1 {
pub fn new(${2}) -> $1 { pub fn new(${2}) -> $1 {
$1 { ${3} }; $1 { ${3} }
} }
} }
snippet type "Type alias" snippet type "Type alias"