1
0
Fork 0
mirror of synced 2024-11-22 00:35:35 -05:00

Updated vim plugins

This commit is contained in:
amix 2016-11-09 18:22:55 +01:00
parent aad95603ea
commit 1494e2edfa
81 changed files with 2756 additions and 470 deletions

View file

@ -98,6 +98,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'bufname_mod': ['s:bufname_mod', ':t'],
\ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'],
\ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'],
\ 'user_command_async': ['s:usrcmdasync', 0],
\ }, {
\ 'open_multiple_files': 's:opmul',
\ 'regexp': 's:regexp',
@ -212,11 +213,13 @@ el
en
let g:ctrlp_builtins = len(g:ctrlp_types)-1
let s:coretypes = filter([
\ ['files', 'fil'],
\ ['buffers', 'buf'],
\ ['mru files', 'mru'],
\ ], 'index(g:ctrlp_types, v:val[1])!=-1')
let s:coretype_names = {
\ 'fil' : 'files',
\ 'buf' : 'buffers',
\ 'mru' : 'mru files',
\ }
let s:coretypes = map(copy(g:ctrlp_types), '[s:coretype_names[v:val], v:val]')
" Get the options {{{2
fu! s:opts(...)
@ -326,11 +329,11 @@ fu! s:Open()
cal s:setupblank()
endf
fu! s:Close(exit)
fu! s:Close()
cal s:buffunc(0)
if winnr('$') == 1
bw!
elsei a:exit
el
try | bun!
cat | clo! | endt
cal s:unmarksigns()
@ -431,6 +434,11 @@ fu! s:GlobPath(dirs, depth)
en
endf
fu! ctrlp#addfile(ch, file)
call add(g:ctrlp_allfiles, a:file)
cal s:BuildPrompt(1)
endf
fu! s:UserCmd(lscmd)
let [path, lscmd] = [s:dyncwd, a:lscmd]
let do_ign =
@ -446,7 +454,13 @@ fu! s:UserCmd(lscmd)
if (has('win32') || has('win64')) && match(&shell, 'sh') != -1
let path = tr(path, '\', '/')
en
if has('patch-7.4-597') && !(has('win32') || has('win64'))
if s:usrcmdasync && v:version >= 800 && exists('*job_start')
if exists('s:job')
call job_stop(s:job)
en
let g:ctrlp_allfiles = []
let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'})
elsei has('patch-7.4-597') && !(has('win32') || has('win64'))
let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
el
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
@ -658,7 +672,7 @@ fu! s:Update(str)
let pat = s:matcher == {} ? s:SplitPattern(str) : str
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
if empty(str) | call clearmatches() | en
if empty(str) | cal clearmatches() | en
cal s:Render(lines, pat)
return lines
endf
@ -923,7 +937,7 @@ fu! s:PrtExit()
let bw = bufwinnr('%')
exe bufwinnr(s:bufnr).'winc w'
if bufnr('%') == s:bufnr && bufname('%') == 'ControlP'
noa cal s:Close(1)
noa cal s:Close()
noa winc p
els
exe bw.'winc w'
@ -2562,6 +2576,10 @@ fu! ctrlp#init(type, ...)
cal s:SetWD(a:0 ? a:1 : {})
cal s:MapNorms()
cal s:MapSpecs()
if empty(g:ctrlp_types) && empty(g:ctrlp_ext_vars)
call ctrlp#exit()
retu
en
if type(a:type) == 0
let type = a:type
el
@ -2588,7 +2606,7 @@ if has('autocmd')
aug CtrlPAug
au!
au BufEnter ControlP cal s:checkbuf()
au BufLeave ControlP noa cal s:Close(0)
au BufLeave ControlP noa cal s:Close()
au VimLeavePre * cal s:leavepre()
aug END
en

View file

@ -885,7 +885,8 @@ MRU mode options:~
在匹配窗口和提示符面板之间切换焦点。
<esc>,
<c-c>
<c-c>,
<c-g>
退出CtrlP。
移动:~

View file

@ -943,7 +943,8 @@ Once inside the prompt:~
Toggle the focus between the match window and the prompt.
<esc>,
<c-c>
<c-c>,
<c-g>
Exit CtrlP.
Moving:~

View file

@ -17,7 +17,7 @@ let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
com! -n=? -com=dir CtrlP cal ctrlp#init('fil', { 'dir': <q-args> })
com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init('mru', { 'dir': <q-args> })
com! -bar CtrlPBuffer cal ctrlp#init('buf')

View file

@ -415,15 +415,15 @@ let g:lightline = {
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified'
\ 'fugitive': 'LightlineFugitive',
\ 'readonly': 'LightlineReadonly',
\ 'modified': 'LightlineModified'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
if &filetype == "help"
return ""
elseif &modified
@ -435,7 +435,7 @@ function! LightLineModified()
endif
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
if &filetype == "help"
return ""
elseif &readonly
@ -445,7 +445,7 @@ function! LightLineReadonly()
endif
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
```
@ -464,16 +464,16 @@ let g:lightline = {
\ [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified',
\ 'filename': 'LightLineFilename'
\ 'fugitive': 'LightlineFugitive',
\ 'readonly': 'LightlineReadonly',
\ 'modified': 'LightlineModified',
\ 'filename': 'LightlineFilename'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
if &filetype == "help"
return ""
elseif &modified
@ -485,7 +485,7 @@ function! LightLineModified()
endif
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
if &filetype == "help"
return ""
elseif &readonly
@ -495,21 +495,21 @@ function! LightLineReadonly()
endif
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/14.png)
Oops! We forgot the cool mark for the branch component! (work with the patched font for vim-powerline)
```vim
function! LightLineFugitive()
function! LightlineFugitive()
if exists("*fugitive#head")
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
@ -528,7 +528,7 @@ let g:lightline = {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'my_component' ] ] },
\ 'component_function': {
\ 'my_component': 'LightLineComponent', ...
\ 'my_component': 'LightlineComponent', ...
```
This is the end of the tutorial. For more information, see `:help lightline`. Good luck with your nice statuslines.
@ -555,37 +555,37 @@ let g:lightline = {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'LightLineModified',
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'modified': 'LightlineModified',
\ 'readonly': 'LightlineReadonly',
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
@ -593,19 +593,19 @@ function! LightLineFugitive()
return ''
endfunction
function! LightLineFileformat()
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
function! LightlineMode()
return winwidth(0) > 60 ? lightline#mode() : ''
endfunction
```
@ -640,12 +640,12 @@ let g:lightline = {
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
@ -657,15 +657,15 @@ let g:lightline = {
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
function! LightlineFilename()
let fname = expand('%:t')
return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
@ -673,12 +673,12 @@ function! LightLineFilename()
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
@ -690,19 +690,19 @@ function! LightLineFugitive()
return ''
endfunction
function! LightLineFileformat()
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
function! LightlineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :

View file

@ -2,7 +2,7 @@
" Filename: autoload/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/09/04 13:01:40.
" Last Change: 2016/10/05 08:00:00.
" =============================================================================
let s:save_cpo = &cpo
@ -191,10 +191,6 @@ function! lightline#colorscheme() abort
let s:lightline.colorscheme = 'default'
let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette
finally
let s:highlight = {}
call lightline#highlight('normal')
call lightline#link()
let s:_ = 0
if has('win32') && !has('gui_running') && &t_Co < 256
for u in values(s:lightline.palette)
for v in values(u)
@ -204,6 +200,10 @@ function! lightline#colorscheme() abort
endfor
endfor
endif
let s:highlight = {}
call lightline#highlight('normal')
call lightline#link()
let s:_ = 0
endtry
endfunction

View file

@ -0,0 +1,36 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Dracula.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/11/06 01:08:03.
" =============================================================================
let s:black = [ '#282a36', 235 ]
let s:gray = [ '#44475a', 236 ]
let s:white = [ '#f8f8f2', 231 ]
let s:darkblue = [ '#6272a4', 61 ]
let s:cyan = [ '#8be9fd', 117 ]
let s:green = [ '#50fa7b', 84 ]
let s:orange = [ '#ffb86c', 215 ]
let s:purple = [ '#bd93f9', 141 ]
let s:red = [ '#ff79c6', 212 ]
let s:yellow = [ '#f1fa8c', 228 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:black, s:purple ], [ s:cyan, s:gray ] ]
let s:p.normal.right = [ [ s:black, s:purple ], [ s:white, s:darkblue ] ]
let s:p.inactive.right = [ [ s:black, s:gray ], [ s:white, s:black ] ]
let s:p.inactive.left = [ [ s:cyan, s:black ], [ s:white, s:black ] ]
let s:p.insert.left = [ [ s:black, s:green ], [ s:cyan, s:gray ] ]
let s:p.replace.left = [ [ s:black, s:red ], [ s:cyan, s:gray ] ]
let s:p.visual.left = [ [ s:black, s:orange ], [ s:cyan, s:gray ] ]
let s:p.normal.middle = [ [ s:white, s:gray ] ]
let s:p.inactive.middle = [ [ s:white, s:gray ] ]
let s:p.tabline.left = [ [ s:darkblue, s:gray ] ]
let s:p.tabline.tabsel = [ [ s:cyan, s:black ] ]
let s:p.tabline.middle = [ [ s:darkblue, s:gray ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:black ] ]
let s:p.normal.warning = [ [ s:yellow, s:black ] ]
let g:lightline#colorscheme#Dracula#palette = lightline#colorscheme#flatten(s:p)

View file

@ -0,0 +1,63 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/one.vim
" Author: Zoltan Dalmadi
" License: MIT License
" Last Change: 2016/11/2 17:34:27.
" =============================================================================
" Common colors
let s:fg = '#abb2bf'
let s:blue = '#61afef'
let s:green = '#98c379'
let s:purple = '#c678dd'
let s:red1 = '#e06c75'
let s:red2 = '#be5046'
let s:yellow = '#e5c07b'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
if &background ==# 'light'
" Light variant
let s:bg = '#fafafa'
let s:gray1 = '#494b53'
let s:gray2 = '#f0f0f0'
let s:gray3 = '#d0d0d0'
let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:gray1, s:gray3 ] ]
let s:p.normal.middle = [ [ s:gray1, s:gray2 ] ]
let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ]
let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ]
let s:p.inactive.right = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ]
let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:gray1, s:gray3 ] ]
let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:gray1, s:gray3 ] ]
let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:gray1, s:gray3 ] ]
else
" Dark variant
let s:bg = '#282c34'
let s:gray1 = '#5c6370'
let s:gray2 = '#2c323d'
let s:gray3 = '#3e4452'
let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ]
let s:p.normal.middle = [ [ s:fg, s:gray2 ] ]
let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ]
let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ]
let s:p.inactive.right = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ]
let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ]
let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ]
let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ]
endif
" Common
let s:p.normal.right = [ [ s:bg, s:green, 'bold' ], [ s:bg, s:green, 'bold' ] ]
let s:p.normal.error = [ [ s:red2, s:bg ] ]
let s:p.normal.warning = [ [ s:yellow, s:bg ] ]
let s:p.insert.right = [ [ s:bg, s:blue, 'bold' ], [ s:bg, s:blue, 'bold' ] ]
let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:bg, s:red1, 'bold' ] ]
let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:bg, s:purple, 'bold' ] ]
let s:p.tabline.left = [ [ s:bg, s:gray3 ] ]
let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ]
let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let g:lightline#colorscheme#one#palette = lightline#colorscheme#fill(s:p)

View file

@ -4,7 +4,7 @@ Version: 0.1
Author: itchyny (https://github.com/itchyny)
License: MIT License
Repository: https://github.com/itchyny/lightline.vim
Last Change: 2016/09/13 23:56:56.
Last Change: 2016/10/24 08:12:28.
CONTENTS *lightline-contents*
@ -151,10 +151,10 @@ OPTIONS *lightline-option*
\ [ 'myreadonly', 'filename', 'modified' ] ],
\ },
\ 'component_function': {
\ 'myreadonly': 'LightLineReadonly'
\ 'myreadonly': 'LightlineReadonly'
\ },
\ }
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
<
@ -223,7 +223,7 @@ OPTIONS *lightline-option*
The colorscheme for lightline.vim.
Currently, wombat, solarized, powerline, jellybeans, Tomorrow,
Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Eighties,
PaperColor, seoul256, landscape and 16color are available.
PaperColor, seoul256, landscape, one, Dracula, and 16color are available.
The default value is:
>
let g:lightline.colorscheme = 'default'
@ -299,16 +299,16 @@ nice.
\ 'lineinfo': ' %3l:%-2v',
\ },
\ 'component_function': {
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive'
\ 'readonly': 'LightlineReadonly',
\ 'fugitive': 'LightlineFugitive'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
function! LightLineReadonly()
function! LightlineReadonly()
return &readonly ? '' : ''
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if exists('*fugitive#head')
let branch = fugitive#head()
return branch !=# '' ? ''.branch : ''
@ -324,16 +324,16 @@ look nice.
\ 'lineinfo': '⭡ %3l:%-2v',
\ },
\ 'component_function': {
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive'
\ 'readonly': 'LightlineReadonly',
\ 'fugitive': 'LightlineFugitive'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineReadonly()
function! LightlineReadonly()
return &readonly ? '⭤' : ''
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if exists('*fugitive#head')
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
@ -655,22 +655,22 @@ In order to define your own component:
\ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ]
\ },
\ 'component_function': {
\ 'myfilename': 'LightLineFilename',
\ 'myreadonly': 'LightLineReadonly',
\ 'mymodified': 'LightLineModified',
\ 'myfilename': 'LightlineFilename',
\ 'myreadonly': 'LightlineReadonly',
\ 'mymodified': 'LightlineModified',
\ }
\ }
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineModified()
function! LightlineModified()
return &modifiable && &modified ? '+' : ''
endfunction
<
@ -710,25 +710,25 @@ A nice example for non-patched font users.
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename'
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename'
\ }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if &ft !~? 'vimfiler' && exists('*fugitive#head')
return fugitive#head()
endif
@ -743,27 +743,27 @@ A nice example for |vim-powerline| font users:
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename'
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help\|vimfiler' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if &ft !~? 'vimfiler' && exists('*fugitive#head')
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
@ -784,12 +784,12 @@ For users who uses lots of plugins:
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
@ -801,15 +801,15 @@ For users who uses lots of plugins:
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
function! LightlineFilename()
let fname = expand('%:t')
return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
@ -817,12 +817,12 @@ For users who uses lots of plugins:
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
@ -834,19 +834,19 @@ For users who uses lots of plugins:
return ''
endfunction
function! LightLineFileformat()
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
function! LightlineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :
@ -1189,10 +1189,10 @@ Problem 12: *lightline-problem-12*
>
let g:lightline = {
\ 'component': {
\ 'modified': '%#ModifiedColor#%{LightLineModified()}',
\ 'modified': '%#ModifiedColor#%{LightlineModified()}',
\ }
\ }
function! LightLineModified()
function! LightlineModified()
let map = { 'V': 'n', "\<C-v>": 'n', 's': 'n', 'v': 'n', "\<C-s>": 'n', 'c': 'n', 'R': 'n'}
let mode = get(map, mode()[0], mode()[0])
let bgcolor = {'n': [240, '#585858'], 'i': [31, '#0087af']}
@ -1211,7 +1211,7 @@ Problem 13: *lightline-problem-13*
Add the following settings to your .vimrc(_vimrc).
>
augroup LightLineColorscheme
augroup LightlineColorscheme
autocmd!
autocmd ColorScheme * call s:lightline_update()
augroup END

View file

@ -1,4 +1,8 @@
Next
- Reuse/reopen existing window trees where possible #244
- Remove NERDTree.previousBuf()
- Change color of arrow (Leeiio) #630
- Improved a tip in README.markdown (ggicci) #628
- Shorten delete confimration of empty directory to 'y' (mikeperri) #530
- Fix API call to open directory tree in window (devm33) #533
- Change default arrows on non-Windows platforms (gwilk) #546

View file

@ -101,15 +101,13 @@ Stick this in your vimrc:
Note: Now start vim with plain `vim`, not `vim .`
---
> How can I open NERDTree on startup, and have my cursor start in the other window?
> How can I open NERDTree automatically when vim starts up on opening a directory?
Stick this in your vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
autocmd vimenter * NERDTree
autocmd vimenter * wincmd p
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.
*via [stackoverflow/Yohann](http://stackoverflow.com/questions/4277808/nerdtree-auto-focus-to-file-when-opened-in-new-tab/19330023#19330023)*
---
> How can I map a specific key or shortcut to open NERDTree?
@ -134,5 +132,5 @@ See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-9259069
Use these variables in your vimrc. Note that below are default arrow symbols
let g:NERDTreeDirArrowExpandable = ''
let g:NERDTreeDirArrowCollapsible = ''
let g:NERDTreeDirArrowExpandable = ''
let g:NERDTreeDirArrowCollapsible = ''

View file

@ -13,9 +13,37 @@ endfunction
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
if a:dir != '' && isdirectory(a:dir)
call g:NERDTreeCreator.CreateWindowTree(a:dir)
if !isdirectory(a:dir)
return
endif
if s:reuseWin(a:dir)
return
endif
call g:NERDTreeCreator.CreateWindowTree(a:dir)
endfunction
"FUNCTION: s:reuseWin(dir) {{{2
"finds a NERDTree buffer with root of dir, and opens it.
function! s:reuseWin(dir) abort
let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p"))
for i in range(1, bufnr("$"))
unlet! nt
let nt = getbufvar(i, "NERDTree")
if empty(nt)
continue
endif
if nt.isWinTree() && nt.root.path.equals(path)
call nt.setPreviousBuf(bufnr("#"))
exec "buffer " . i
return 1
endif
endfor
return 0
endfunction
" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2

View file

@ -186,6 +186,10 @@ function! s:NERDTree.previousBuf()
return self._previousBuf
endfunction
function! s:NERDTree.setPreviousBuf(bnum)
let self._previousBuf = a:bnum
endfunction
"FUNCTION: s:NERDTree.render() {{{1
"A convenience function - since this is called often
function! s:NERDTree.render()

View file

@ -74,7 +74,7 @@ endfunction
function! s:promptToRenameBuffer(bufnum, msg, newFileName)
echo a:msg
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
let quotedFileName = fnameescape(a:newFilename)
let quotedFileName = fnameescape(a:newFileName)
" 1. ensure that a new buffer is loaded
exec "badd " . quotedFileName
" 2. ensure that all windows which display the just deleted filename

View file

@ -68,8 +68,8 @@ call s:initVariable("g:NERDTreeShowLineNumbers", 0)
call s:initVariable("g:NERDTreeSortDirs", 1)
if !nerdtree#runningWindows()
call s:initVariable("g:NERDTreeDirArrowExpandable", "")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "")
call s:initVariable("g:NERDTreeDirArrowExpandable", "")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "")
else
call s:initVariable("g:NERDTreeDirArrowExpandable", "+")
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")

View file

@ -72,8 +72,8 @@ hi def link NERDTreeDir Directory
hi def link NERDTreeUp Directory
hi def link NERDTreeFile Normal
hi def link NERDTreeCWD Statement
hi def link NERDTreeOpenable Title
hi def link NERDTreeClosable Title
hi def link NERDTreeOpenable Directory
hi def link NERDTreeClosable Directory
hi def link NERDTreeIgnore ignore
hi def link NERDTreeRO WarningMsg
hi def link NERDTreeBookmark Statement

View file

@ -26,20 +26,21 @@
4. [FAQ](#faq)
4.1. [I installed syntastic but it isn't reporting any errors...](#faqinfo)
4.2. [Syntastic supports several checkers for my filetype, how do I tell it which one(s) to use?](#faqcheckers)
4.3. [I have enabled multiple checkers for the current filetype. How can I display all errors from all checkers together?](#faqaggregate)
4.4. [How can I pass additional arguments to a checker?](#faqargs)
4.5. [I run a checker and the location list is not updated...](#faqloclist)
4.5. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist)
4.6. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext)
4.7. [The error window is closed automatically when I `:quit` the current buffer but not when I `:bdelete` it?](#faqbdelete)
4.8. [My favourite checker needs to load a configuration file from the project's root rather than the current directory...](#faqconfig)
4.9. [What is the difference between syntax checkers and style checkers?](#faqstyle)
4.10. [How can I check scripts written for different versions of Python?](#faqpython)
4.11. [How can I check scripts written for different versions of Ruby?](#faqruby)
4.12. [The `perl` checker has stopped working...](#faqperl)
4.13. [What happened to the `rustc` checker?](#faqrust)
4.14. [What happened to the `tsc` checker?](#faqtsc)
4.15. [What happened to the `xcrun` checker?](#faqxcrun)
4.3. [How can I run checkers for "foreign" filetypes against the current file?](#faqforeign)
4.4. [I have enabled multiple checkers for the current filetype. How can I display all errors from all checkers together?](#faqaggregate)
4.5. [How can I pass additional arguments to a checker?](#faqargs)
4.6. [I run a checker and the location list is not updated...](#faqloclist)
4.6. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist)
4.7. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext)
4.8. [The error window is closed automatically when I `:quit` the current buffer but not when I `:bdelete` it?](#faqbdelete)
4.9. [My favourite checker needs to load a configuration file from the project's root rather than the current directory...](#faqconfig)
4.10. [What is the difference between syntax checkers and style checkers?](#faqstyle)
4.11. [How can I check scripts written for different versions of Python?](#faqpython)
4.12. [How can I check scripts written for different versions of Ruby?](#faqruby)
4.13. [The `perl` checker has stopped working...](#faqperl)
4.14. [What happened to the `rustc` checker?](#faqrust)
4.15. [What happened to the `tsc` checker?](#faqtsc)
4.16. [What happened to the `xcrun` checker?](#faqxcrun)
5. [Resources](#otherresources)
- - -
@ -65,9 +66,9 @@ MATLAB, Mercury, NASM, Nix, Objective-C, Objective-C++, OCaml, Perl, Perl
POD, PHP, gettext Portable Object, OS X and iOS property lists, Pug (formerly
Jade), Puppet, Python, QML, R, Racket, RDF TriG, RDF Turtle, Relax NG,
reStructuredText, RPM spec, Ruby, SASS/SCSS, Scala, Slim, SML, Solidity,
Sphinx, SQL, Stylus, Tcl, TeX, Texinfo, Twig, TypeScript, Vala, Verilog,
VHDL, VimL, xHtml, XML, XSLT, XQuery, YACC, YAML, YANG data models, z80, Zope
page templates, and Zsh. See the [manual][checkers] for details about the
Sphinx, SQL, Stylus, Tcl, TeX, Texinfo, Twig, TypeScript, Vala, Verilog, VHDL,
Vim help, VimL, xHtml, XML, XSLT, XQuery, YACC, YAML, YANG data models, z80,
Zope page templates, and Zsh. See the [manual][checkers] for details about the
corresponding supported checkers (`:help syntastic-checkers` in Vim).
A number of third-party Vim plugins also provide checkers for syntastic, for
@ -264,13 +265,36 @@ For example to run `phpcs` and `phpmd`:
```
This works for any checkers available for the current filetype, even if they
aren't listed in `g:syntastic_<filetype>_checkers`. You can't run checkers for
"foreign" filetypes though (e.g. you can't run, say, a Python checker if the
filetype of the current file is `php`).
aren't listed in `g:syntastic_<filetype>_checkers`.
<a name="faqforeign"></a>
__4.3. Q. How can I run checkers for "foreign" filetypes against the current
file?__
A. You need to qualify the name of the "foreign" checker with the name
of its filetype. For example to check `tex` files with the checker
`language_check` (which normally acts only on files of type `text`), you can
add `text/language_check` to the list fo checkers for `tex`:
```vim
let g:syntastic_tex_checkers = ['lacheck', 'text/language_check']
```
This also works with `:SyntasticCheck`, e.g. the following command runs
`text/language_check` against the current file regardless of the current
filetype:
```vim
:SyntasticCheck text/language_check
```
Of course, the checkers specified this way need to be known to syntastic, and
they need to be shown as available when you run `:SyntasticInfo`. You can't
just make up a combination of a filetype and a program name and expect it to
work as a checker.
<a name="faqaggregate"></a>
__4.3. Q. I have enabled multiple checkers for the current filetype. How can I
__4.4. Q. I have enabled multiple checkers for the current filetype. How can I
display all errors from all checkers together?__
A. Set `g:syntastic_aggregate_errors` to 1 in your `vimrc`:
@ -282,7 +306,7 @@ See `:help syntastic-aggregating-errors` for more details.
<a name="faqargs"></a>
__4.4. Q. How can I pass additional arguments to a checker?__
__4.5. Q. How can I pass additional arguments to a checker?__
A. In most cases a command line is constructed using an internal function
named `makeprgBuild()`, which provides a number of options that allow you to
@ -306,8 +330,8 @@ list of options should be included in the [manual][checkers]
<a name="faqloclist"></a>
__4.5. Q. I run a checker and the location list is not updated...__
__4.5. Q. I run`:lopen` or `:lwindow` and the error window is empty...__
__4.6. 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...__
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
@ -319,7 +343,7 @@ let g:syntastic_always_populate_loc_list = 1
<a name="faqlnext"></a>
__4.6. Q. How can I jump between the different errors without using the location
__4.7. Q. How can I jump between the different errors without using the location
list at the bottom of the window?__
A. Vim provides several built-in commands for this. See `:help :lnext` and
@ -331,7 +355,7 @@ mappings (among other things).
<a name="faqbdelete"></a>
__4.7. Q. The error window is closed automatically when I `:quit` the current buffer
__4.8. Q. The error window is closed automatically when I `:quit` the current buffer
but not when I `:bdelete` it?__
A. There is no safe way to handle that situation automatically, but you can
@ -343,7 +367,7 @@ cabbrev <silent> bd <C-r>=(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdele
<a name="faqconfig"></a>
__4.8. My favourite checker needs to load a configuration file from the
__4.9. My favourite checker needs to load a configuration file from the
project's root rather than the current directory...__
A. You can set up an `autocmd` to search for the configuration file in the
@ -363,7 +387,7 @@ autocmd FileType javascript let b:syntastic_javascript_jscs_args =
<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
be filtered by different rules, but otherwise the distinction is pretty much
@ -393,7 +417,7 @@ See `:help syntastic_quiet_messages` for more information.
<a name="faqpython"></a>
__4.10. Q. How can I check scripts written for different versions of Python?__
__4.11. Q. How can I check scripts written for different versions of Python?__
A. Install a Python version manager such as [virtualenv][virtualenv]
or [pyenv][pyenv], activate the environment for the relevant version
@ -409,7 +433,7 @@ scripts.
<a name="faqruby"></a>
__4.11. Q. How can I check scripts written for different versions of Ruby?__
__4.12. Q. How can I check scripts written for different versions of Ruby?__
A. Install a Ruby version manager such as [rvm][rvm] or [rbenv][rbenv],
activate the environment for the relevant version of Ruby, and install in it
@ -424,7 +448,7 @@ scripts.
<a name="faqperl"></a>
__4.12. Q. The `perl` checker has stopped working...__
__4.13. Q. The `perl` checker has stopped working...__
A. The `perl` checker runs `perl -c` against your file, which in turn
__executes__ any `BEGIN`, `UNITCHECK`, and `CHECK` blocks, and any `use`
@ -440,14 +464,14 @@ let g:syntastic_enable_perl_checker = 1
<a name="faqrust"></a>
__4.13. Q. What happened to the `rustc` checker?__
__4.14. Q. What happened to the `rustc` checker?__
A. It is now part of the [rust.vim][rust] plugin. If you install this plugin the
checker should be picked up automatically by syntastic.
<a name="faqtsc"></a>
__4.14. Q. What happened to the `tsc` checker?__
__4.15. Q. What happened to the `tsc` checker?__
A. It didn't meet people's expectations and it has been removed. The plugin
[tsuquyomi][tsuquyomi] comes packaged with a checker for TypeScript. If you
@ -455,7 +479,7 @@ install this plugin the checker should be picked up automatically by syntastic.
<a name="faqxcrun"></a>
__4.15. Q. What happened to the `xcrun` checker?__
__4.16. 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][swift] plugin. If you

View file

@ -21,7 +21,7 @@ function! syntastic#log#warn(msg) abort " {{{2
endfunction " }}}2
function! syntastic#log#error(msg) abort " {{{2
execute "normal \<Esc>"
execute 'normal! \<Esc>'
echohl ErrorMsg
echomsg 'syntastic: error: ' . a:msg
echohl None
@ -68,7 +68,7 @@ function! syntastic#log#debug(level, msg, ...) abort " {{{2
let leader = s:_log_timestamp()
call s:_logRedirect(1)
if a:0 > 0
if a:0
" filter out dictionary functions
echomsg leader . a:msg . ' ' .
\ strtrans(string(type(a:1) == type({}) || type(a:1) == type([]) ?

View file

@ -102,6 +102,10 @@ function! syntastic#util#rmrf(what) abort " {{{2
endif
endfunction " }}}2
function! syntastic#util#getbufvar(buf, name, ...) abort " {{{2
return a:0 ? s:_getbufvar(a:buf, a:name, a:1) : getbufvar(a:buf, a:name)
endfunction " }}}2
" Search the first 5 lines of the file for a magic number and return a map
" containing the args and the executable
"
@ -126,9 +130,19 @@ function! syntastic#util#parseShebang() abort " {{{2
return { 'exe': '', 'args': [] }
endfunction " }}}2
" Get the value of a Vim variable. Allow buffer variables to override global ones.
function! syntastic#util#bufRawVar(buf, name, ...) abort " {{{2
return s:_getbufvar(a:buf, a:name, get(g:, a:name, a:0 ? a:1 : ''))
endfunction "}}}2
" Get the value of a syntastic variable. Allow buffer variables to override global ones.
function! syntastic#util#bufVar(buf, name, ...) abort " {{{2
return call('syntastic#util#bufRawVar', [a:buf, 'syntastic_' . a:name] + a:000)
endfunction "}}}2
" Get the value of a Vim variable. Allow local variables to override global ones.
function! syntastic#util#rawVar(name, ...) abort " {{{2
return get(b:, a:name, get(g:, a:name, a:0 > 0 ? a:1 : ''))
return get(b:, a:name, get(g:, a:name, a:0 ? a:1 : ''))
endfunction " }}}2
" Get the value of a syntastic variable. Allow local variables to override global ones.
@ -165,11 +179,6 @@ function! syntastic#util#compareLexi(a, b) abort " {{{2
return 0
endfunction " }}}2
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
" and hope for the best :)
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
lockvar s:_width
function! syntastic#util#screenWidth(str, tabstop) abort " {{{2
let chunks = split(a:str, "\t", 1)
let width = s:_width(chunks[-1])
@ -391,9 +400,6 @@ function! syntastic#util#setWids() abort " {{{2
endfor
endfunction " }}}2
let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr')
lockvar s:_str2float
function! syntastic#util#str2float(val) abort " {{{2
return s:_str2float(a:val)
endfunction " }}}2
@ -515,6 +521,11 @@ function! s:_translateElement(key, term) abort " {{{2
return ret
endfunction " }}}2
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
" and hope for the best :)
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
lockvar s:_width
" @vimlint(EVL103, 1, a:flags)
function! s:_delete_dumb(what, flags) abort " {{{2
if !exists('s:rmrf')
@ -561,6 +572,9 @@ function! s:_rmrf(what) abort " {{{2
endif
endfunction " }}}2
let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr')
lockvar s:_str2float
function! s:_float2str_smart(val) abort " {{{2
return printf('%.1f', a:val)
endfunction " }}}2
@ -572,6 +586,18 @@ endfunction " }}}2
let s:_float2str = function(has('float') ? 's:_float2str_smart' : 's:_float2str_dumb')
lockvar s:_float2str
function! s:_getbufvar_dumb(buf, name, ...) abort " {{{2
let ret = getbufvar(a:buf, a:name)
if a:0 && type(ret) == type('') && ret ==# ''
unlet! ret
let ret = a:1
endif
return ret
endfunction "}}}2
let s:_getbufvar = function(v:version > 703 || (v:version == 703 && has('patch831')) ? 'getbufvar' : 's:_getbufvar_dumb')
lockvar s:_getbufvar
" }}}1
let &cpo = s:save_cpo

View file

@ -117,6 +117,7 @@ SYNTAX CHECKERS BY LANGUAGE *syntastic-checkers-lang*
Vala.....................................|syntastic-checkers-vala|
Verilog..................................|syntastic-checkers-verilog|
VHDL.....................................|syntastic-checkers-vhdl|
Vim help.................................|syntastic-checkers-help|
VimL.....................................|syntastic-checkers-vim|
xHTML....................................|syntastic-checkers-xhtml|
@ -353,6 +354,7 @@ SYNTAX CHECKERS FOR ASCIIDOC *syntastic-checkers-asciidoc*
The following checkers are available for AsciiDoc (filetype "asciidoc"):
1. Asciidoc.................|syntastic-asciidoc-asciidoc|
2. proselint................|syntastic-asciidoc-proselint|
------------------------------------------------------------------------------
1. Asciidoc *syntastic-asciidoc-asciidoc*
@ -374,6 +376,27 @@ Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
2. proselint *syntastic-asciidoc-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-help-proselint|, |syntastic-html-proselint|,
|syntastic-markdown-proselint|, |syntastic-nroff-proselint|,
|syntastic-pod-proselint|, |syntastic-rst-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
==============================================================================
SYNTAX CHECKERS FOR ASSEMBLY LANGUAGES *syntastic-checkers-asm*
@ -2586,10 +2609,12 @@ The following checkers are available for HTML (filetype "html"):
1. ESLint...................|syntastic-html-eslint|
2. gjslint..................|syntastic-html-gjslint|
3. HTML tidy................|syntastic-html-tidy|
4. JSHint...................|syntastic-html-jshint|
5. textlint.................|syntastic-html-textlint|
6. Validator................|syntastic-html-validator|
7. W3.......................|syntastic-html-w3|
4. HTMLHint.................|syntastic-html-htmlhint|
5. JSHint...................|syntastic-html-jshint|
6. proselint................|syntastic-html-proselint|
7. textlint.................|syntastic-html-textlint|
8. Validator................|syntastic-html-validator|
9. W3.......................|syntastic-html-w3|
------------------------------------------------------------------------------
1. ESLint *syntastic-html-eslint*
@ -2679,7 +2704,25 @@ List of additional empty tags, to be added to "--new-empty-tags".
See also: |syntastic-xhtml-tidy|.
------------------------------------------------------------------------------
4. jshint *syntastic-html-jshint*
4. HTMLHint *syntastic-html-htmlhint*
Name: HTMLHint
Maintainer: LCD 47 <lcd047@gmail.com>
"JSHint" is a static code analysis tool for HTML. See the project's page for
details:
http://htmlhint.com/
Syntastic requires "HTMLHint" version 0.9.13 or later.
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
5. jshint *syntastic-html-jshint*
Name: JSHint
Maintainer: LCD 47 <lcd047@gmail.com>
@ -2725,7 +2768,28 @@ in "JSHint". If that is undesirable, your only other option is to leave
See also: |syntastic-javascript-jshint|, |syntastic-xhtml-jshint|.
------------------------------------------------------------------------------
5. textlint *syntastic-html-textlint*
6. proselint *syntastic-html-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-markdown-proselint|, |syntastic-nroff-proselint|,
|syntastic-pod-proselint|, |syntastic-rst-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
------------------------------------------------------------------------------
7. textlint *syntastic-html-textlint*
Name: textlint
Maintainer: LCD 47 <lcd047@gmail.com>
@ -2750,7 +2814,7 @@ work:
See also: |syntastic-markdown-textlint|, |syntastic-text-textlint|.
------------------------------------------------------------------------------
6. Validator *syntastic-html-validator*
8. Validator *syntastic-html-validator*
Name: validator
Maintainer: LCD 47 <lcd047@gmail.com>
@ -2823,7 +2887,7 @@ You can lookup the meaning of these codes in cURL's manual:
http://curl.haxx.se/docs/manpage.html#EXIT
------------------------------------------------------------------------------
7. W3 *syntastic-html-w3*
9. W3 *syntastic-html-w3*
Name: w3
Maintainer: Martin Grenfell <martin.grenfell@gmail.com>
@ -2949,6 +3013,14 @@ Name: javac
Maintainers: Jochen Keil <jochen.keil@gmail.com>
Dmitry Geurkov <d.geurkov@gmail.com>
Note~
This checker is not suitable for use with large Java projects. The design
of "javac" makes this checker prone to running into various limitations of
your shell, Vim, and your Java compiler. You are strongly advised to use
something like Eclim (http://eclim.org/) instead of syntastic for projects of
any substantial size or complexity.
Commands~
The following commands are available:
@ -3684,7 +3756,8 @@ SYNTAX CHECKERS FOR MARKDOWN *syntastic-checkers-markdown*
The following checkers are available for Markdown (filetype "markdown"):
1. Markdown lint tool.......|syntastic-markdown-mdl|
2. textlint.................|syntastic-markdown-textlint|
2. proselint................|syntastic-markdown-proselint|
3. textlint.................|syntastic-markdown-textlint|
------------------------------------------------------------------------------
1. Markdown lint tool *syntastic-markdown-mdl*
@ -3721,7 +3794,28 @@ to a set of valid "markdownlint-cli" options): >
let g:syntastic_markdown_mdl_args = ""
<
------------------------------------------------------------------------------
2. textlint *syntastic-markdown-textlint*
2. proselint *syntastic-markdown-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-nroff-proselint|,
|syntastic-pod-proselint|, |syntastic-rst-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
------------------------------------------------------------------------------
3. textlint *syntastic-markdown-textlint*
Name: textlint
Maintainer: LCD 47 <lcd047@gmail.com>
@ -3836,6 +3930,7 @@ The following checkers are available for nroff (filetype "nroff"):
1. Igor.....................|syntastic-nroff-igor|
2. mandoc...................|syntastic-nroff-mandoc|
3. proselint................|syntastic-nroff-proselint|
------------------------------------------------------------------------------
1. Igor *syntastic-nroff-igor*
@ -3875,6 +3970,27 @@ Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
3. proselint *syntastic-nroff-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-pod-proselint|, |syntastic-rst-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
==============================================================================
SYNTAX CHECKERS FOR OBJECTIVE-C *syntastic-checkers-objc*
@ -4362,6 +4478,7 @@ SYNTAX CHECKERS FOR POD *syntastic-checkers-pod*
The following checkers are available for POD (filetype "pod"):
1. Pod::Checker.............|syntastic-pod-podchecker|
2. proselint................|syntastic-pod-proselint|
------------------------------------------------------------------------------
1. Pod::Checker *syntastic-pod-podchecker*
@ -4381,6 +4498,27 @@ accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-perl-podchecker|.
------------------------------------------------------------------------------
2. proselint *syntastic-pod-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-nroff-proselint|, |syntastic-rst-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
==============================================================================
SYNTAX CHECKERS FOR PUG (FORMERLY JADE) *syntastic-checkers-pug*
@ -5034,12 +5172,34 @@ SYNTAX CHECKERS FOR RESTRUCTUREDTEXT *syntastic-checkers-rst*
The following checkers are available for reStructuredText (filetype "rst"):
1. rst2pseudoxml............|syntastic-rst-rst2pseudoxml|
2. rstcheck.................|syntastic-rst-rstcheck|
3. Sphinx...................|syntastic-rst-sphinx|
1. proselint................|syntastic-rst-proselint|
2. rst2pseudoxml............|syntastic-rst-rst2pseudoxml|
3. rstcheck.................|syntastic-rst-rstcheck|
4. Sphinx...................|syntastic-rst-sphinx|
------------------------------------------------------------------------------
1. rst2pseudoxml *syntastic-rst-rst2pseudoxml*
1. proselint *syntastic-rst-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-nroff-proselint|, |syntastic-pod-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
------------------------------------------------------------------------------
2. rst2pseudoxml *syntastic-rst-rst2pseudoxml*
Name: rst2pseudoxml
Maintainer: James Rowe <jnrowe@gmail.com>
@ -5057,7 +5217,7 @@ This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
2. rstcheck *syntastic-rst-rstcheck*
3. rstcheck *syntastic-rst-rstcheck*
Name: rstcheck
Maintainer: Steven Myint <git@stevenmyint.com>
@ -5073,7 +5233,7 @@ This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
3. Sphinx *syntastic-rst-sphinx*
4. Sphinx *syntastic-rst-sphinx*
Name: sphinx
Maintainer: Buck Evan <buck@yelp.com>
@ -5892,6 +6052,7 @@ The following checkers are available for TeX (filetype "tex"):
1. ChkTeX...................|syntastic-tex-chktex|
2. lacheck..................|syntastic-tex-lacheck|
3. proselint................|syntastic-tex-proselint|
------------------------------------------------------------------------------
1. ChkTeX *syntastic-tex-chktex*
@ -5937,12 +6098,34 @@ Limitations~
At the time of this writing "lacheck" can't expand "\def" commands. As a
result, most "\input" commands using macros are signaled as errors.
------------------------------------------------------------------------------
3. proselint *syntastic-tex-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-nroff-proselint|, |syntastic-pod-proselint|,
|syntastic-rst-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
==============================================================================
SYNTAX CHECKERS FOR TEXINFO *syntastic-checkers-texinfo*
The following checkers are available for Texinfo (filetype "texinfo"):
1. Makeinfo.................|syntastic-texinfo-makeinfo|
2. proselint................|syntastic-texinfo-proselint|
------------------------------------------------------------------------------
1. Makeinfo *syntastic-texinfo-makeinfo*
@ -5960,6 +6143,27 @@ Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
2. proselint *syntastic-texinfo-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-nroff-proselint|, |syntastic-pod-proselint|,
|syntastic-rst-proselint|, |syntastic-tex-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
==============================================================================
SYNTAX CHECKERS FOR TEXT *syntastic-checkers-text*
@ -5968,7 +6172,8 @@ The following checkers are available for plain text (filetype "text"):
1. atdtool..................|syntastic-text-atdtool|
2. Igor.....................|syntastic-text-igor|
3. language-check...........|syntastic-text-language_check|
4. textlint.................|syntastic-text-textlint|
4. proselint................|syntastic-text-proselint|
5. textlint.................|syntastic-text-textlint|
------------------------------------------------------------------------------
1. atdtool *syntastic-text-atdtool*
@ -6031,7 +6236,28 @@ This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
------------------------------------------------------------------------------
4. textlint *syntastic-text-textlint*
4. proselint *syntastic-text-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-nroff-proselint|, |syntastic-pod-proselint|,
|syntastic-rst-proselint|, |syntastic-tex-proselint|,
|syntastic-texinfo-proselint|, |syntastic-xhtml-proselint|.
------------------------------------------------------------------------------
5. textlint *syntastic-text-textlint*
Name: textlint
Maintainer: LCD 47 <lcd047@gmail.com>
@ -6394,6 +6620,34 @@ Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
==============================================================================
SYNTAX CHECKERS FOR VIM HELP *syntastic-checkers-help*
The following checkers are available for Vim help (filetype "help"):
1. proselint................|syntastic-help-proselint|
------------------------------------------------------------------------------
1. proselint *syntastic-help-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-html-proselint|,
|syntastic-markdown-proselint|, |syntastic-nroff-proselint|,
|syntastic-pod-proselint|, |syntastic-rst-proselint|,
|syntastic-tex-proselint|, |syntastic-texinfo-proselint|,
|syntastic-text-proselint|, |syntastic-xhtml-proselint|.
==============================================================================
SYNTAX CHECKERS FOR VIML *syntastic-checkers-vim*
@ -6479,6 +6733,7 @@ The following checkers are available for xHTML (filetype "xhtml"):
1. HTML Tidy................|syntastic-xhtml-tidy|
2. jshint...................|syntastic-xhtml-jshint|
3. proselint................|syntastic-xhtml-proselint|
------------------------------------------------------------------------------
1. HTML tidy *syntastic-xhtml-tidy*
@ -6553,6 +6808,27 @@ in "JSHint". If that is undesirable, your only other option is to leave
<
See also: |syntastic-html-jshint|, |syntastic-javascript-jshint|.
------------------------------------------------------------------------------
3. proselint *syntastic-xhtml-proselint*
Name: proselint
Maintainer: LCD 47 <lcd047@gmail.com>
"proselint" is a linter for prose. See the page for details:
http://proselint.com/
Checker options~
This checker is initialised using the "makeprgBuild()" function and thus it
accepts the standard options described at |syntastic-config-makeprg|.
See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
|syntastic-html-proselint|, |syntastic-markdown-proselint|,
|syntastic-nroff-proselint|, |syntastic-pod-proselint|,
|syntastic-rst-proselint|, |syntastic-tex-proselint|,
|syntastic-texinfo-proselint|, |syntastic-text-proselint|.
==============================================================================
SYNTAX CHECKERS FOR XML *syntastic-checkers-xml*

View file

@ -48,19 +48,20 @@ CONTENTS *syntastic-contents*
7.Compatibility with other software............|syntastic-compatibility|
7.1.airline................................|syntastic-airline|
7.2.The csh and tcsh shells................|syntastic-csh|
7.3.Eclim..................................|syntastic-eclim|
7.4.ferret.................................|syntastic-ferret|
7.5.The fish shell.........................|syntastic-fish|
7.6.The fizsh shell........................|syntastic-fizsh|
7.7.flagship...............................|syntastic-flagship|
7.8.powerline..............................|syntastic-powerline|
7.9.The PowerShell shell...................|syntastic-powershell|
7.10.python-mode...........................|syntastic-pymode|
7.11.vim-auto-save.........................|syntastic-vim-auto-save|
7.12.vim-go................................|syntastic-vim-go|
7.13.vim-virtualenv........................|syntastic-vim-virtualenv|
7.14.YouCompleteMe.........................|syntastic-ycm|
7.15.The zsh shell and MacVim..............|syntastic-zsh|
7.3.EasyGrep...............................|syntastic-easygrep|
7.4.Eclim..................................|syntastic-eclim|
7.5.ferret.................................|syntastic-ferret|
7.6.The fish shell.........................|syntastic-fish|
7.7.The fizsh shell........................|syntastic-fizsh|
7.8.flagship...............................|syntastic-flagship|
7.9.powerline..............................|syntastic-powerline|
7.10.The PowerShell shell..................|syntastic-powershell|
7.11.python-mode...........................|syntastic-pymode|
7.12.vim-auto-save.........................|syntastic-vim-auto-save|
7.13.vim-go................................|syntastic-vim-go|
7.14.vim-virtualenv........................|syntastic-vim-virtualenv|
7.15.YouCompleteMe.........................|syntastic-ycm|
7.16.The zsh shell and MacVim..............|syntastic-zsh|
8.About........................................|syntastic-about|
9.License......................................|syntastic-license|
@ -301,12 +302,22 @@ the order specified. The set by |'syntastic_aggregate_errors'| still apply.
Example: >
:SyntasticCheck flake8 pylint
<
You can also run checkers for filetypes different from the current filetype
by qualifying their names with their respective filetypes, like this:
"<filetype>/<checker>".
Example: >
:SyntasticCheck lacheck text/language_check
<
:SyntasticInfo *:SyntasticInfo*
The command takes an optional argument, and outputs information about the
checkers available for the filetype named by said argument, or for the current
filetype if no argument was provided.
Example: >
:SyntasticInfo python
<
:SyntasticReset *:SyntasticReset*
Resets the list of errors and turns off all error notifiers.
@ -761,6 +772,10 @@ If neither |'g:syntastic_<filetype>_checkers'| nor |'b:syntastic_checkers'|
is set, a default list of checker is used. Beware however that this list
deliberately kept minimal, for performance reasons.
You can specify checkers for other filetypes anywhere in these lists, by
qualifying their names with their respective filetypes: >
let g:syntastic_tex_checkers = ["lacheck", "text/language_check"]
<
Take a look elsewhere in this manual to find out what checkers and filetypes
are supported by syntastic: |syntastic-checkers|.
@ -854,9 +869,8 @@ omitting the filename from the command line: >
let g:syntastic_sml_smlnj_fname = ""
<
*syntastic-config-no-makeprgbuild*
For checkers that do not use the "makeprgBuild()" function you will have to
look at the source code of the checker in question. If there are specific
options that can be set they are normally documented in this manual (see
For checkers that do not use the "makeprgBuild()" function any specific
options that can be set should be documented in this manual (see
|syntastic-checkers|).
------------------------------------------------------------------------------
@ -1017,7 +1031,16 @@ such as "zsh", "bash", "ksh", or even the original Bourne "sh": >
let g:syntastic_shell = "/bin/sh"
<
------------------------------------------------------------------------------
7.3. Eclim *syntastic-eclim*
7.3. EasyGrep *syntastic-easygrep*
The "EasyGrep" Vim plugin (https://github.com/dkprice/vim-easygrep) can use
either |quickfix| lists, or location lists (see |location-list|). Syntastic can
be run along with "EasyGrep" provided that the latter is configured to use
|quickfix| lists (which is the default at the time of this writing): >
let g:EasyGrepWindow = 0
<
------------------------------------------------------------------------------
7.4. Eclim *syntastic-eclim*
Syntastic can be used together with "Eclim" (see http://eclim.org/). However,
by default Eclim disables syntastic's checks for the filetypes it supports, in
@ -1030,7 +1053,7 @@ run Eclim's validation for others. Please consult Eclim's documentation for
details.
------------------------------------------------------------------------------
7.4. ferret *syntastic-ferret*
7.5. ferret *syntastic-ferret*
At the time of this writing syntastic conflicts with the "ferret" Vim plugin
(https://github.com/wincent/ferret). The "ferret" plugin assumes control over
@ -1038,7 +1061,7 @@ loclist windows even when configured to use |quickfix| lists. This interferes
with syntastic's functioning.
------------------------------------------------------------------------------
7.5. The fish shell *syntastic-fish*
7.6. The fish shell *syntastic-fish*
At the time of this writing the "fish" shell (see http://fishshell.com/)
doesn't support the standard UNIX syntax for file redirections, and thus it
@ -1048,7 +1071,7 @@ original Bourne "sh": >
let g:syntastic_shell = "/bin/sh"
<
------------------------------------------------------------------------------
7.6. The fizsh shell *syntastic-fizsh*
7.7. The fizsh shell *syntastic-fizsh*
Using syntastic with the "fizsh" shell (see https://github.com/zsh-users/fizsh)
is possible, but potentially problematic. In order to do it you'll need to set
@ -1061,7 +1084,7 @@ interactive features of "fizsh". Using a more traditional shell such as "zsh",
let g:syntastic_shell = "/bin/sh"
<
------------------------------------------------------------------------------
7.7. flagship *syntastic-flagship*
7.8. flagship *syntastic-flagship*
The "flagship" Vim plugin (https://github.com/tpope/vim-flagship) has its
own mechanism of showing flags on the |'statusline'|. To allow "flagship"
@ -1071,7 +1094,7 @@ described in the |syntastic-statusline-flag| section above: >
autocmd User Flags call Hoist("window", "SyntasticStatuslineFlag")
<
------------------------------------------------------------------------------
7.8. powerline *syntastic-powerline*
7.9. powerline *syntastic-powerline*
The "powerline" Vim plugin (https://github.com/powerline/powerline) comes
packaged with a syntastic segment. To customize this segment create a file
@ -1088,7 +1111,7 @@ packaged with a syntastic segment. To customize this segment create a file
}
<
------------------------------------------------------------------------------
7.9. The PowerShell shell *syntastic-powershell*
7.10. The PowerShell shell *syntastic-powershell*
At the time of this writing syntastic is not compatible with using
"PowerShell" (https://msdn.microsoft.com/en-us/powershell) as Vim's 'shell'.
@ -1099,7 +1122,7 @@ You may still run Vim from "PowerShell", but you do have to point Vim's
set shell=/bin/sh
<
------------------------------------------------------------------------------
7.10. python-mode *syntastic-pymode*
7.11. python-mode *syntastic-pymode*
Syntastic can be used along with the "python-mode" Vim plugin (see
https://github.com/klen/python-mode). However, they both run syntax checks by
@ -1110,14 +1133,14 @@ for python in syntastic (see |'syntastic_mode_map'|), or disable lint checks in
let g:pymode_lint_on_write = 0
<
------------------------------------------------------------------------------
7.11. vim-auto-save *syntastic-vim-auto-save*
7.12. vim-auto-save *syntastic-vim-auto-save*
Syntastic can be used together with the "vim-auto-save" Vim plugin (see
https://github.com/907th/vim-auto-save). However, syntastic checks in active
mode only work with "vim-auto-save" version 0.1.7 or later.
------------------------------------------------------------------------------
7.12. vim-go *syntastic-vim-go*
7.13. vim-go *syntastic-vim-go*
Syntastic can be used along with the "vim-go" Vim plugin (see
https://github.com/fatih/vim-go). However, both "vim-go" and syntastic run
@ -1134,7 +1157,7 @@ stick with |quickfix| lists: >
let g:go_list_type = "quickfix"
<
------------------------------------------------------------------------------
7.13. vim-virtualenv *syntastic-vim-virtualenv*
7.14. vim-virtualenv *syntastic-vim-virtualenv*
At the time of this writing, syntastic can't run checkers installed
in Python virtual environments activated by "vim-virtualenv" (see
@ -1142,7 +1165,7 @@ https://github.com/jmcantrell/vim-virtualenv). This is a limitation of
"vim-virtualenv".
------------------------------------------------------------------------------
7.14. YouCompleteMe *syntastic-ycm*
7.15. YouCompleteMe *syntastic-ycm*
Syntastic can be used together with the "YouCompleteMe" Vim plugin (see
http://valloric.github.io/YouCompleteMe/). However, by default "YouCompleteMe"
@ -1153,7 +1176,7 @@ have to set |g:ycm_show_diagnostics_ui| to 0. E.g.: >
let g:ycm_show_diagnostics_ui = 0
<
------------------------------------------------------------------------------
7.15. The zsh shell and MacVim *syntastic-zsh*
7.16. The zsh shell and MacVim *syntastic-zsh*
If you're running MacVim together with the "zsh" shell (http://www.zsh.org/)
you need to be aware that MacVim does not source your .zshrc file, but will

View file

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-226'
let g:_SYNTASTIC_VERSION = '3.8.0-3'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -57,7 +57,7 @@ elseif executable('uname')
try
let g:_SYNTASTIC_UNAME = split(syntastic#util#system('uname'), "\n")[0]
catch /\m^Vim\%((\a\+)\)\=:E484/
call syntastic#log#error("your shell " . syntastic#util#var('shell') . " can't handle traditional UNIX syntax for redirections")
call syntastic#log#error("can't run external programs (misconfigured shell options?)")
finish
catch /\m^Vim\%((\a\+)\)\=:E684/
let g:_SYNTASTIC_UNAME = 'Unknown'
@ -136,9 +136,9 @@ let s:_DEBUG_DUMP_OPTIONS = [
\ 'shellxquote'
\ ]
for s:feature in [
\ 'shellxescape',
\ 'shellslash',
\ 'autochdir',
\ 'shellslash',
\ 'shellxescape',
\ ]
if exists('+' . s:feature)
@ -178,11 +178,20 @@ let s:_quit_pre = []
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead)
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) abort " {{{2
let checker_names = []
for ft in s:_resolve_filetypes([])
call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
return join(checker_names, "\n")
let names = []
let sep_idx = stridx(a:argLead, '/')
if sep_idx >= 1
let ft = a:argLead[: sep_idx-1]
call extend(names, map( s:registry.getNamesOfAvailableCheckers(ft), 'ft . "/" . v:val' ))
else
for ft in s:registry.resolveFiletypes(&filetype)
call extend(names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
call extend(names, map( copy(s:registry.getKnownFiletypes()), 'v:val . "/"' ))
endif
return join(names, "\n")
endfunction " }}}2
" @vimlint(EVL103, 0, a:cursorPos)
" @vimlint(EVL103, 0, a:cmdLine)
@ -220,7 +229,7 @@ endfunction " }}}2
function! SyntasticInfo(...) abort " {{{2
call s:modemap.modeInfo(a:000)
call s:registry.echoInfoFor(s:_resolve_filetypes(a:000))
call s:registry.echoInfoFor(a:000)
call s:_explain_skip(a:000)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
@ -312,7 +321,7 @@ function! s:BufEnterHook(fname) abort " {{{2
" TODO: this is needed because in recent versions of Vim lclose
" can no longer be called from BufWinLeave
" TODO: at this point there is no b:syntastic_loclist
let loclist = filter(copy(getloclist(0)), 'v:val["valid"] == 1')
let loclist = filter(copy(getloclist(0)), 'v:val["valid"]')
let owner = str2nr(getbufvar(buf, 'syntastic_owner_buffer'))
let buffers = syntastic#util#unique(map(loclist, 'v:val["bufnr"]') + (owner ? [owner] : []))
if !empty(get(w:, 'syntastic_loclist_set', [])) && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
@ -384,14 +393,12 @@ function! s:UpdateErrors(buf, auto_invoked, checker_names) abort " {{{2
return
endif
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking()
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking(a:buf)
if run_checks
call s:CacheErrors(a:buf, a:checker_names)
call syntastic#util#setLastTick(a:buf)
else
if a:auto_invoked
return
endif
elseif a:auto_invoked
return
endif
let loclist = g:SyntasticLoclist.current(a:buf)
@ -453,20 +460,17 @@ function! s:CacheErrors(buf, checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
" }}}3
let filetypes = s:_resolve_filetypes([])
let aggregate_errors = syntastic#util#var('aggregate_errors') || len(filetypes) > 1
let clist = s:registry.getCheckers(getbufvar(a:buf, '&filetype'), a:checker_names)
let aggregate_errors =
\ syntastic#util#var('aggregate_errors') || len(syntastic#util#unique(map(copy(clist), 'v:val.getFiletype()'))) > 1
let decorate_errors = aggregate_errors && syntastic#util#var('id_checkers')
let sort_aggregated_errors = aggregate_errors && syntastic#util#var('sort_aggregated_errors')
let clist = []
for type in filetypes
call extend(clist, s:registry.getCheckers(type, a:checker_names))
endfor
let names = []
let unavailable_checkers = 0
for checker in clist
let cname = checker.getFiletype() . '/' . checker.getName()
let cname = checker.getCName()
if !checker.isAvailable()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: Checker ' . cname . ' is not available')
let unavailable_checkers += 1
@ -687,11 +691,6 @@ endfunction " }}}2
" Utilities {{{1
function! s:_resolve_filetypes(filetypes) abort " {{{2
let type = len(a:filetypes) ? a:filetypes[0] : &filetype
return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
endfunction " }}}2
function! s:_ignore_file(filename) abort " {{{2
let fname = fnamemodify(a:filename, ':p')
for pattern in g:syntastic_ignore_files

View file

@ -15,7 +15,7 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
if a:0
" redirected checker
let newObj._exec = get(a:args, 'exec', a:1['_exec'])
let newObj._exec_default = get(a:args, 'exec', a:1['_exec_default'])
let filetype = a:1['_filetype']
let name = a:1['_name']
@ -31,7 +31,10 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
let newObj._enable = a:1['_enable']
endif
else
let newObj._exec = get(a:args, 'exec', newObj._name)
let newObj._exec_default = get(a:args, 'exec', newObj._name)
if newObj._exec_default ==# ''
let newObj._exec_default = '<dummy>'
endif
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
if has_key(a:args, 'enable')
@ -62,23 +65,24 @@ function! g:SyntasticChecker.getName() abort " {{{2
return self._name
endfunction " }}}2
function! g:SyntasticChecker.getCName() abort " {{{2
return self._filetype . '/' . self._name
endfunction " }}}2
" Synchronise _exec with user's setting. Force re-validation if needed.
"
" 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() abort " {{{2
let user_exec =
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ 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
function! g:SyntasticChecker.syncExec(...) abort " {{{2
if a:0
let self._exec = a:1
else
let suffix = self._name . '_exec'
let self._exec = expand(
\ syntastic#util#var(self._filetype . '_' . suffix,
\ syntastic#util#var(suffix, self._exec_default)), 1 )
endif
endfunction " }}}2
@ -92,7 +96,7 @@ endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw() abort " {{{2
let checker_start = reltime()
let name = self._filetype . '/' . self._name
let name = self.getCName()
if has_key(self, '_enable')
let status = syntastic#util#var(self._enable, -1)
@ -150,7 +154,7 @@ function! g:SyntasticChecker.getVersion(...) abort " {{{2
call self.setVersion(parsed_ver)
else
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
call syntastic#log#error("checker " . self._filetype . "/" . self._name . ": can't parse version string (abnormal termination?)")
call syntastic#log#error("checker " . self.getCName() . ": can't parse version string (abnormal termination?)")
endif
endif
return get(self, '_version', [])
@ -164,8 +168,8 @@ function! g:SyntasticChecker.setVersion(version) abort " {{{2
endfunction " }}}2
function! g:SyntasticChecker.log(msg, ...) abort " {{{2
let leader = self._filetype . '/' . self._name . ': '
if a:0 > 0
let leader = self.getCName() . ': '
if a:0
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg, a:1)
else
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg)
@ -187,10 +191,15 @@ endfunction " }}}2
function! g:SyntasticChecker.isAvailable() abort " {{{2
call self.syncExec()
if !has_key(self, '_available')
let self._available = self._isAvailableFunc()
let self._available = {}
endif
return self._available
if !has_key(self._available, self._exec)
let self._available[self._exec] = self._isAvailableFunc()
endif
return self._available[self._exec]
endfunction " }}}2
function! g:SyntasticChecker.isDisabled() abort " {{{2

View file

@ -10,7 +10,7 @@ let g:SyntasticLoclist = {}
function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
let newObj = copy(self)
let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1')
let llist = filter(copy(a:rawLoclist), 'v:val["valid"]')
for e in llist
if get(e, 'type', '') ==# ''
@ -28,8 +28,8 @@ function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
endfunction " }}}2
function! g:SyntasticLoclist.current(...) abort " {{{2
let buf = a:0 > 1 ? a:1 : bufnr('')
let loclist = getbufvar(buf, 'syntastic_loclist')
let buf = a:0 ? a:1 : bufnr('')
let loclist = syntastic#util#getbufvar(buf, 'syntastic_loclist', {})
if type(loclist) != type({}) || empty(loclist)
unlet! loclist
let loclist = g:SyntasticLoclist.New([])
@ -281,7 +281,7 @@ endfunction " }}}2
"
"would return all errors for buffer 10.
"
"Note that all comparisons are done with ==?
"Note that all string comparisons are done with ==?
function! g:SyntasticLoclist.filter(filters) abort " {{{2
let conditions = values(map(copy(a:filters), 's:_translate(v:key, v:val)'))
let filter = len(conditions) == 1 ?

View file

@ -29,7 +29,8 @@ function! g:SyntasticModeMap.synch() abort " {{{2
endfunction " }}}2
function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
let fts = split(a:filetype, '\m\.')
let registry = g:SyntasticRegistry.Instance()
let fts = registry.resolveFiletypes(a:filetype)
if self.isPassive()
return self._isOneFiletypeActive(fts)
@ -38,13 +39,13 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
endif
endfunction " }}}2
function! g:SyntasticModeMap.doAutoChecking() abort " {{{2
let local_mode = get(b:, 'syntastic_mode', '')
function! g:SyntasticModeMap.doAutoChecking(buf) abort " {{{2
let local_mode = getbufvar(a:buf, 'syntastic_mode')
if local_mode ==# 'active' || local_mode ==# 'passive'
return local_mode ==# 'active'
endif
return self.allowsAutoChecking(&filetype)
return self.allowsAutoChecking(getbufvar(a:buf, '&filetype'))
endfunction " }}}2
function! g:SyntasticModeMap.isPassive() abort " {{{2
@ -96,7 +97,7 @@ function! g:SyntasticModeMap.modeInfo(filetypes) abort " {{{2
echomsg 'Local mode: ' . b:syntastic_mode
endif
echomsg 'The current file will ' . (self.doAutoChecking() ? '' : 'not ') . 'be checked automatically'
echomsg 'The current file will ' . (self.doAutoChecking(bufnr('')) ? '' : 'not ') . 'be checked automatically'
endif
endfunction " }}}2

View file

@ -43,6 +43,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'handlebars': ['handlebars'],
\ 'haskell': ['hdevtools', 'hlint'],
\ 'haxe': ['haxe'],
\ 'help': [],
\ 'hss': ['hss'],
\ 'html': ['tidy'],
\ 'jade': ['jade_lint'],
@ -188,24 +189,39 @@ endfunction " }}}2
" not checked for availability (that is, the corresponding IsAvailable() are
" not run).
function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) abort " {{{2
let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft, 0)
let checkers_map = self._checkerMap[ft]
if empty(checkers_map)
return []
endif
call self._checkDeprecation(ft)
let ftlist = self.resolveFiletypes(a:ftalias)
let names =
\ !empty(a:hints_list) ? syntastic#util#unique(a:hints_list) :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers :
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:_DEFAULT_CHECKERS, ft, 0)
\ !empty(a:hints_list) ? a:hints_list :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers : []
return type(names) == type([]) ?
\ self._filterCheckersByName(checkers_map, names) : [checkers_map[keys(checkers_map)[0]]]
let cnames = []
if !empty(names)
for name in names
if name !~# '/'
for ft in ftlist
call add(cnames, ft . '/' . name)
endfor
else
call add(cnames, name)
endif
endfor
else
for ft in ftlist
call self._sanityCheck(ft)
let defs =
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:_DEFAULT_CHECKERS, ft, [])
call extend(cnames, map(copy(defs), 'stridx(v:val, "/") < 0 ? ft . "/" . v:val : v:val' ))
endfor
endif
let cnames = syntastic#util#unique(cnames)
for ft in syntastic#util#unique(map( copy(cnames), 'v:val[: stridx(v:val, "/")-1]' ))
call self._loadCheckersFor(ft, 0)
endfor
return self._filterCheckersByName(cnames)
endfunction " }}}2
" Same as getCheckers(), but keep only the available checkers. This runs the
@ -242,8 +258,12 @@ function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) abort " {{{2
return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' ))
endfunction " }}}2
function! g:SyntasticRegistry.resolveFiletypes(ftalias) abort " {{{2
return map(split( get(g:syntastic_filetype_map, a:ftalias, a:ftalias), '\m\.' ), 's:_normalise_filetype(v:val)')
endfunction " }}}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(self.resolveFiletypes(empty(a:ftalias_list) ? &filetype : a:ftalias_list[0]))
if len(ft_list) != 1
let available = []
let active = []
@ -257,8 +277,8 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
else
let ft = ft_list[0]
let available = self.getNamesOfAvailableCheckers(ft)
let active = map(self.getCheckersAvailable(ft, []), 'v:val.getName()')
let disabled = map(self.getCheckersDisabled(ft, []), 'v:val.getName()')
let active = map(self.getCheckersAvailable(ft, []), 'ft ==# v:val.getFiletype() ? v:val.getName() : v:val.getCName()')
let disabled = map(self.getCheckersDisabled(ft, []), 'ft ==# v:val.getFiletype() ? v:val.getName() : v:val.getCName()')
endif
let cnt = len(available)
@ -274,7 +294,7 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
let cnt = len(disabled)
let plural = cnt != 1 ? 's' : ''
if len(disabled)
let cklist = join(sort(disabled))
let cklist = join(sort(disabled, 's:_compare_checker_names'))
echomsg 'Checker' . plural . ' disabled for security reasons: ' . cklist
endif
@ -321,8 +341,20 @@ function! g:SyntasticRegistry._registerChecker(checker) abort " {{{2
let self._checkerMap[ft][name] = a:checker
endfunction " }}}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)' )
function! g:SyntasticRegistry._findChecker(cname) abort " {{{2
let sep_idx = stridx(a:cname, '/')
if sep_idx > 0
let ft = a:cname[: sep_idx-1]
let name = a:cname[sep_idx+1 :]
else
let ft = &filetype
let name = a:cname
endif
return get(self._checkerMap[ft], name, {})
endfunction "}}}2
function! g:SyntasticRegistry._filterCheckersByName(cnames) abort " {{{2
return filter( map(copy(a:cnames), 'self._findChecker(v:val)'), '!empty(v:val)' )
endfunction " }}}2
function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2
@ -338,7 +370,14 @@ function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2
endfunction " }}}2
" Check for obsolete variable g:syntastic_<filetype>_checker
function! g:SyntasticRegistry._checkDeprecation(filetype) abort " {{{2
function! g:SyntasticRegistry._sanityCheck(filetype) abort " {{{2
if exists('g:syntastic_' . a:filetype . '_checkers') &&
\ type(g:syntastic_{a:filetype}_checkers) != type([])
unlet! g:syntastic_{a:filetype}_checkers
call syntastic#log#error('variable g:syntastic_' . a:filetype . '_checkers has to be a list of strings')
endif
if exists('g:syntastic_' . a:filetype . '_checker') &&
\ !exists('g:syntastic_' . a:filetype . '_checkers') &&
\ type(g:syntastic_{a:filetype}_checker) == type('')
@ -375,6 +414,26 @@ function! s:_disabled_by_ycm(filetype) abort " {{{2
return index(s:_YCM_TYPES, a:filetype) >= 0
endfunction " }}}2
function! s:_compare_checker_names(a, b) abort " {{{2
if a:a ==# a:b
return 0
endif
if stridx(a:a, '/') < 0
if stridx(a:b, '/') < 0
return a:a < a:b ? -1 : 1
else
return -1
endif
else
if stridx(a:b, '/') < 0
return 1
else
return a:a < a:b ? -1 : 1
endif
endif
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_asciidoc_proselint_checker')
finish
endif
let g:loaded_syntastic_asciidoc_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'asciidoc',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -1,94 +0,0 @@
"============================================================================
"File: ghc-mod.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer: Anthony Carapetis <anthony.carapetis at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_haskell_ghc_mod_checker')
finish
endif
let g:loaded_syntastic_haskell_ghc_mod_checker = 1
let s:ghc_mod_new = -1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_haskell_ghc_mod_IsAvailable() dict " {{{1
if !executable(self.getExec())
return 0
endif
" ghc-mod 5.0.0 and later needs the "version" command to print the
" version. But the "version" command appeared in 4.1.0. Thus, we need to
" know the version in order to know how to find out the version. :)
" Try "ghc-mod version".
let version_output = split(syntastic#util#system(self.getExecEscaped() . ' version'), '\n', 1)
let ver = filter(copy(version_output), 'v:val =~# ''\m\sversion''')
if !len(ver)
" That didn't work. Try "ghc-mod" alone.
let version_output = split(syntastic#util#system(self.getExecEscaped()), '\n', 1)
let ver = filter(copy(version_output), 'v:val =~# ''\m\sversion''')
endif
let parsed_ver = len(ver) ? syntastic#util#parseVersion(ver[0]) : []
if len(parsed_ver)
" Encouraged by the great success in finding out the version, now we
" need either a Vim that can handle NULs in system() output, or a
" ghc-mod that has the "--boundary" option.
call self.setVersion(parsed_ver)
let s:ghc_mod_new = syntastic#util#versionIsAtLeast(parsed_ver, [2, 1, 2])
else
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', version_output)
call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)")
let s:ghc_mod_new = -1
endif
" ghc-mod 5.4.0 wants to run in the root directory of the project;
" syntastic can't cope with the resulting complications
"
" References:
" https://hackage.haskell.org/package/ghc-mod-5.4.0.0/changelog
let s:ghc_mod_bailout = syntastic#util#versionIsAtLeast(parsed_ver, [5, 4])
return (s:ghc_mod_new >= 0) && (v:version >= 704 || s:ghc_mod_new) && !s:ghc_mod_bailout
endfunction " }}}1
function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict " {{{1
let makeprg = self.makeprgBuild({
\ 'exe': self.getExecEscaped() . ' check' . (s:ghc_mod_new ? ' --boundary=""' : '') })
let errorformat =
\ '%-G%\s%#,' .
\ '%f:%l:%c:%trror: %m,' .
\ '%f:%l:%c:%tarning: %m,'.
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l:%c:%m,' .
\ '%E%f:%l:%c:,' .
\ '%Z%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'iconv',
\ 'postprocess': ['compressWhitespace'],
\ 'returns': [0] })
endfunction " }}}1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'haskell',
\ 'name': 'ghc_mod',
\ 'exec': 'ghc-mod' })
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_help_proselint_checker')
finish
endif
let g:loaded_syntastic_help_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'help',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,46 @@
"============================================================================
"File: html.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_html_htmlhint_checker')
finish
endif
let g:loaded_syntastic_html_htmlhint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_html_htmlhint_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 9, 13])
endfunction
function! SyntaxCheckers_html_htmlhint_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_before': '--format unix' })
let errorformat = '%f:%l:%c: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'html',
\ 'name': 'htmlhint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_html_proselint_checker')
finish
endif
let g:loaded_syntastic_html_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'html',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_markdown_proselint_checker')
finish
endif
let g:loaded_syntastic_markdown_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'markdown',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

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

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_nroff_proselint_checker')
finish
endif
let g:loaded_syntastic_nroff_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'nroff',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_pod_proselint_checker')
finish
endif
let g:loaded_syntastic_pod_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'pod',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_rst_proselint_checker')
finish
endif
let g:loaded_syntastic_rst_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'rst',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_tex_proselint_checker')
finish
endif
let g:loaded_syntastic_tex_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'tex',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_texinfo_proselint_checker')
finish
endif
let g:loaded_syntastic_texinfo_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'texinfo',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -0,0 +1,45 @@
"============================================================================
"File: proselint.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_text_proselint_checker')
finish
endif
let g:loaded_syntastic_text_proselint_checker = 1
if !exists('g:syntastic_text_proselint_sort')
let g:syntastic_text_proselint_sort = 1
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_text_proselint_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': { 'type': 'W', 'subtype': 'Style' },
\ 'preprocess': 'iconv',
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'text',
\ 'name': 'proselint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View file

@ -99,8 +99,7 @@ endfunction " }}}2
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'vim',
\ 'name': 'vimlint',
\ 'exec': '' })
\ 'name': 'vimlint' })
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.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_xhtml_proselint_checker')
finish
endif
let g:loaded_syntastic_xhtml_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'xhtml',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

1
sources_non_forked/tabular/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/doc/tags

View file

@ -0,0 +1,24 @@
Copyright (c) 2016, Matthew J. Wozniski
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of the contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,29 @@
Tabular
==============
Sometimes, it's useful to line up text. Naturally, it's nicer to have the
computer do this for you, since aligning things by hand quickly becomes
unpleasant. While there are other plugins for aligning text, the ones I've
tried are either impossibly difficult to understand and use, or too simplistic
to handle complicated tasks. This plugin aims to make the easy things easy
and the hard things possible, without providing an unnecessarily obtuse
interface. It's still a work in progress, and criticisms are welcome.
See [Aligning Text with Tabular.vim](http://vimcasts.org/episodes/aligning-text-with-tabular-vim/)
for a screencast that shows how Tabular.vim works.
See [doc/Tabular.txt](http://raw.github.com/godlygeek/tabular/master/doc/Tabular.txt)
for detailed documentation.
Installation
==============
If you don't have a preferred installation method, I recommend installing
[pathogen.vim](https://github.com/tpope/vim-pathogen), and then simply
copy and paste:
mkdir -p ~/.vim/bundle
cd ~/.vim/bundle
git clone git://github.com/godlygeek/tabular.git
Once help tags have been generated (either using Pathogen's `:Helptags`
command, or by pointing vim's `:helptags` command at the directory where you
installed Tabular), you can view the manual with `:help tabular`.

View file

@ -0,0 +1,73 @@
" Copyright (c) 2016, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are met:
" * Redistributions of source code must retain the above copyright notice,
" this list of conditions and the following disclaimer.
" * Redistributions in binary form must reproduce the above copyright
" notice, this list of conditions and the following disclaimer in the
" documentation and/or other materials provided with the distribution.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if !exists(':Tabularize') || get(g:, 'no_default_tabular_maps', 0)
finish " Tabular.vim wasn't loaded or the default maps are unwanted
endif
let s:save_cpo = &cpo
set cpo&vim
AddTabularPattern! assignment /[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1
AddTabularPattern! two_spaces / /l0
AddTabularPipeline! multiple_spaces / / map(a:lines, "substitute(v:val, ' *', ' ', 'g')") | tabular#TabularizeStrings(a:lines, ' ', 'l0')
AddTabularPipeline! argument_list /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')')
\ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0')
\ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")')
\ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")')
function! SplitCDeclarations(lines)
let rv = []
for line in a:lines
" split the line into declaractions
let split = split(line, '\s*[,;]\s*')
" separate the type from the first declaration
let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '')
" add the ; back on every declaration
call map(split, 'v:val . ";"')
" add the first element to the return as-is, and remove it from the list
let rv += [ remove(split, 0) ]
" transform the other elements by adding the type on at the beginning
call map(split, 'type . v:val')
" and add them all to the return
let rv += split
endfor
return rv
endfunction
AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines)
AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1
AddTabularPattern! cpp_io /<<\|>>/l1
AddTabularPattern! pascal_assign /:=/l1
AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1
let &cpo = s:save_cpo
unlet s:save_cpo

View file

@ -0,0 +1,409 @@
" Tabular: Align columnar data using regex-designated column boundaries
" Maintainer: Matthew Wozniski (godlygeek@gmail.com)
" Date: Thu, 03 May 2012 20:49:32 -0400
" Version: 1.0
"
" Long Description:
" Sometimes, it's useful to line up text. Naturally, it's nicer to have the
" computer do this for you, since aligning things by hand quickly becomes
" unpleasant. While there are other plugins for aligning text, the ones I've
" tried are either impossibly difficult to understand and use, or too simplistic
" to handle complicated tasks. This plugin aims to make the easy things easy
" and the hard things possible, without providing an unnecessarily obtuse
" interface. It's still a work in progress, and criticisms are welcome.
"
" License:
" Copyright (c) 2012, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are met:
" * Redistributions of source code must retain the above copyright notice,
" this list of conditions and the following disclaimer.
" * Redistributions in binary form must reproduce the above copyright
" notice, this list of conditions and the following disclaimer in the
" documentation and/or other materials provided with the distribution.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" Stupid vimscript crap {{{1
let s:savecpo = &cpo
set cpo&vim
" Private Functions {{{1
" Return the number of bytes in a string after expanding tabs to spaces. {{{2
" This expansion is done based on the current value of 'tabstop'
if exists('*strdisplaywidth')
" Needs vim 7.3
let s:Strlen = function("strdisplaywidth")
else
function! s:Strlen(string)
" Implement the tab handling part of strdisplaywidth for vim 7.2 and
" earlier - not much that can be done about handling doublewidth
" characters.
let rv = 0
let i = 0
for char in split(a:string, '\zs')
if char == "\t"
let rv += &ts - i
let i = 0
else
let rv += 1
let i = (i + 1) % &ts
endif
endfor
return rv
endfunction
endif
" Align a string within a field {{{2
" These functions do not trim leading and trailing spaces.
" Right align 'string' in a field of size 'fieldwidth'
function! s:Right(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '')
endfunction
" Left align 'string' in a field of size 'fieldwidth'
function! s:Left(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
return a:string . repeat(" ", spaces)
endfunction
" Center align 'string' in a field of size 'fieldwidth'
function! s:Center(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
let right = spaces / 2
let left = right + (right * 2 != spaces)
return repeat(" ", left) . a:string . repeat(" ", right)
endfunction
" Remove spaces around a string {{{2
" Remove all trailing spaces from a string.
function! s:StripTrailingSpaces(string)
return matchstr(a:string, '^.\{-}\ze\s*$')
endfunction
" Remove all leading spaces from a string.
function! s:StripLeadingSpaces(string)
return matchstr(a:string, '^\s*\zs.*$')
endfunction
" Split a string into fields and delimiters {{{2
" Like split(), but include the delimiters as elements
" All odd numbered elements are delimiters
" All even numbered elements are non-delimiters (including zero)
function! s:SplitDelim(string, delim)
let rv = []
let beg = 0
let len = len(a:string)
let searchoff = 0
while 1
let mid = match(a:string, a:delim, beg + searchoff, 1)
if mid == -1 || mid == len
break
endif
let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1)
let length = strlen(matchstr)
if length == 0 && beg == mid
" Zero-length match for a zero-length delimiter - advance past it
let searchoff += 1
continue
endif
if beg == mid
let rv += [ "" ]
else
let rv += [ a:string[beg : mid-1] ]
endif
let rv += [ matchstr ]
let beg = mid + length
let searchoff = 0
endwhile
let rv += [ strpart(a:string, beg) ]
return rv
endfunction
" Replace lines from `start' to `start + len - 1' with the given strings. {{{2
" If more lines are needed to show all strings, they will be added.
" If there are too few strings to fill all lines, lines will be removed.
function! s:SetLines(start, len, strings)
if a:start > line('$') + 1 || a:start < 1
throw "Invalid start line!"
endif
if len(a:strings) > a:len
let fensave = &fen
let view = winsaveview()
call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len))
call winrestview(view)
let &fen = fensave
elseif len(a:strings) < a:len
let fensave = &fen
let view = winsaveview()
sil exe (a:start + len(a:strings)) . ',' . (a:start + a:len - 1) . 'd_'
call winrestview(view)
let &fen = fensave
endif
call setline(a:start, a:strings)
endfunction
" Runs the given commandstring argument as an expression. {{{2
" The commandstring expression is expected to reference the a:lines argument.
" If the commandstring expression returns a list the items of that list will
" replace the items in a:lines, otherwise the expression is assumed to have
" modified a:lines itself.
function! s:FilterString(lines, commandstring)
exe 'let rv = ' . a:commandstring
if type(rv) == type(a:lines) && rv isnot a:lines
call filter(a:lines, 0)
call extend(a:lines, rv)
endif
endfunction
" Public API {{{1
if !exists("g:tabular_default_format")
let g:tabular_default_format = "l1"
endif
let s:formatelempat = '\%([lrc]\d\+\)'
function! tabular#ElementFormatPattern()
return s:formatelempat
endfunction
" Given a list of strings and a delimiter, split each string on every
" occurrence of the delimiter pattern, format each element according to either
" the provided format (optional) or the default format, and join them back
" together with enough space padding to guarantee that the nth delimiter of
" each string is aligned.
function! tabular#TabularizeStrings(strings, delim, ...)
if a:0 > 1
echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")"
return 1
endif
let formatstr = (a:0 ? a:1 : g:tabular_default_format)
if formatstr !~? s:formatelempat . '\+'
echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!"
return 1
endif
let format = split(formatstr, s:formatelempat . '\zs')
let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)')
" Strip spaces
" - Only from non-delimiters; spaces in delimiters must have been matched
" intentionally
" - Don't strip leading spaces from the first element; we like indenting.
for line in lines
if len(line) == 1 && s:do_gtabularize
continue " Leave non-matching lines unchanged for GTabularize
endif
if line[0] !~ '^\s*$'
let line[0] = s:StripTrailingSpaces(line[0])
endif
if len(line) >= 3
for i in range(2, len(line)-1, 2)
let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i]))
endfor
endif
endfor
" Find the max length of each field
let maxes = []
for line in lines
if len(line) == 1 && s:do_gtabularize
continue " non-matching lines don't affect field widths for GTabularize
endif
for i in range(len(line))
if i == len(maxes)
let maxes += [ s:Strlen(line[i]) ]
else
let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] )
endif
endfor
endfor
let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"'))
" Concatenate the fields, according to the format pattern.
for idx in range(len(lines))
let line = lines[idx]
if len(line) == 1 && s:do_gtabularize
let lines[idx] = line[0] " GTabularize doesn't change non-matching lines
continue
endif
for i in range(len(line))
let how = format[i % len(format)][0]
let pad = format[i % len(format)][1:-1]
if how =~? 'l'
let field = s:Left(line[i], maxes[i])
elseif how =~? 'r'
let field = s:Right(line[i], maxes[i])
elseif how =~? 'c'
let field = s:Center(line[i], maxes[i])
endif
let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad))
endfor
let lines[idx] = s:StripTrailingSpaces(join(line, ''))
endfor
endfunction
" Apply 0 or more filters, in sequence, to selected text in the buffer {{{2
" The lines to be filtered are determined as follows:
" If the function is called with a range containing multiple lines, then
" those lines will be used as the range.
" If the function is called with no range or with a range of 1 line, then
" if GTabularize mode is being used,
" the range will not be adjusted
" if "includepat" is not specified,
" that 1 line will be filtered,
" if "includepat" is specified and that line does not match it,
" no lines will be filtered
" if "includepat" is specified and that line does match it,
" all contiguous lines above and below the specified line matching the
" pattern will be filtered.
"
" The remaining arguments must each be a filter to apply to the text.
" Each filter must either be a String evaluating to a function to be called.
function! tabular#PipeRange(includepat, ...) range
exe a:firstline . ',' . a:lastline
\ . 'call tabular#PipeRangeWithOptions(a:includepat, a:000, {})'
endfunction
" Extended version of tabular#PipeRange, which
" 1) Takes the list of filters as an explicit list rather than as varargs
" 2) Supports passing a dictionary of options to control the routine.
" Currently, the only supported option is 'mode', which determines whether
" to behave as :Tabularize or as :GTabularize
" This allows me to add new features here without breaking API compatibility
" in the future.
function! tabular#PipeRangeWithOptions(includepat, filterlist, options) range
let top = a:firstline
let bot = a:lastline
let s:do_gtabularize = (get(a:options, 'mode', '') ==# 'GTabularize')
if !s:do_gtabularize
" In the default mode, apply range extension logic
if a:includepat != '' && top == bot
if top < 0 || top > line('$') || getline(top) !~ a:includepat
return
endif
while top > 1 && getline(top-1) =~ a:includepat
let top -= 1
endwhile
while bot < line('$') && getline(bot+1) =~ a:includepat
let bot += 1
endwhile
endif
endif
let lines = map(range(top, bot), 'getline(v:val)')
for filter in a:filterlist
if type(filter) != type("")
echoerr "PipeRange: Bad filter: " . string(filter)
endif
call s:FilterString(lines, filter)
unlet filter
endfor
call s:SetLines(top, bot - top + 1, lines)
endfunction
" Part of the public interface so interested pipelines can query this and
" adjust their behavior appropriately.
function! tabular#DoGTabularize()
return s:do_gtabularize
endfunction
function! s:SplitDelimTest(string, delim, expected)
let result = s:SplitDelim(a:string, a:delim)
if result !=# a:expected
echomsg 'Test failed!'
echomsg ' string=' . string(a:string) . ' delim=' . string(a:delim)
echomsg ' Returned=' . string(result)
echomsg ' Expected=' . string(a:expected)
endif
endfunction
function! tabular#SplitDelimUnitTest()
let assignment = '[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*='
let two_spaces = ' '
let ternary_operator = '^.\{-}\zs?\|:'
let cpp_io = '<<\|>>'
let pascal_assign = ':='
let trailing_c_comments = '\/\*\|\*\/\|\/\/'
call s:SplitDelimTest('a+=b', assignment, ['a', '+=', 'b'])
call s:SplitDelimTest('a-=b', assignment, ['a', '-=', 'b'])
call s:SplitDelimTest('a!=b', assignment, ['a!=b'])
call s:SplitDelimTest('a==b', assignment, ['a==b'])
call s:SplitDelimTest('a&=b', assignment, ['a', '&=', 'b'])
call s:SplitDelimTest('a|=b', assignment, ['a', '|=', 'b'])
call s:SplitDelimTest('a=b=c', assignment, ['a', '=', 'b', '=', 'c'])
call s:SplitDelimTest('a b c', two_spaces, ['a', ' ', 'b', ' ', 'c'])
call s:SplitDelimTest('a b c', two_spaces, ['a b', ' ', ' c'])
call s:SplitDelimTest('ab c', two_spaces, ['ab', ' ', '', ' ', 'c'])
call s:SplitDelimTest('a?b:c', ternary_operator, ['a', '?', 'b', ':', 'c'])
call s:SplitDelimTest('a<<b<<c', cpp_io, ['a', '<<', 'b', '<<', 'c'])
call s:SplitDelimTest('a:=b=c', pascal_assign, ['a', ':=', 'b=c'])
call s:SplitDelimTest('x//foo', trailing_c_comments, ['x', '//', 'foo'])
call s:SplitDelimTest('x/*foo*/',trailing_c_comments, ['x', '/*', 'foo', '*/', ''])
call s:SplitDelimTest('#ab#cd#ef', '[^#]*', ['#', 'ab', '#', 'cd', '#', 'ef', ''])
call s:SplitDelimTest('#ab#cd#ef', '#\zs', ['#', '', 'ab#', '', 'cd#', '', 'ef'])
endfunction
" Stupid vimscript crap, part 2 {{{1
let &cpo = s:savecpo
unlet s:savecpo
" vim:set sw=2 sts=2 fdm=marker:

View file

@ -0,0 +1,260 @@
*Tabular.txt* Configurable, flexible, intuitive text aligning
*tabular* *tabular.vim*
#|#|#|#|#| #| #| ~
#| #|#|#| #|#|#| #| #| #| #|#|#| #| #|#| ~
#| #| #| #| #| #| #| #| #| #| #|#| ~
#| #| #| #| #| #| #| #| #| #| #| ~
#| #|#|#| #|#|#| #|#|#| #| #|#|#| #| ~
For Vim version 7.0 or newer
By Matt Wozniski
mjw@drexel.edu
Reference Manual ~
*tabular-toc*
1. Description |tabular-intro|
2. Walkthrough |tabular-walkthrough|
3. Scripting |tabular-scripting|
The functionality mentioned here is a plugin, see |add-plugin|.
You can avoid loading this plugin by setting the "Tabular_loaded" global
variable in your |vimrc| file: >
:let g:tabular_loaded = 1
==============================================================================
1. Description *tabular-intro*
Sometimes, it's useful to line up text. Naturally, it's nicer to have the
computer do this for you, since aligning things by hand quickly becomes
unpleasant. While there are other plugins for aligning text, the ones I've
tried are either impossibly difficult to understand and use, or too simplistic
to handle complicated tasks. This plugin aims to make the easy things easy
and the hard things possible, without providing an unnecessarily obtuse
interface. It's still a work in progress, and criticisms are welcome.
==============================================================================
2. Walkthrough *tabular-walkthrough* *:Tabularize*
Tabular's commands are based largely on regular expressions. The basic
technique used by Tabular is taking some regex to match field delimiters,
splitting the input lines at those delimiters, trimming unnecessary spaces
from the non-delimiter parts, padding the non-delimiter parts of the lines
with spaces to make them the same length, and joining things back together
again.
For instance, consider starting with the following lines:
>
Some short phrase,some other phrase
A much longer phrase here,and another long phrase
<
Let's say we want to line these lines up at the commas. We can tell
Tabularize to do this by passing a pattern matching , to the Tabularize
command:
>
:Tabularize /,
Some short phrase , some other phrase
A much longer phrase here , and another long phrase
<
I encourage you to try copying those lines to another buffer and trying to
call :Tabularize. You'll want to take notice of two things quickly: First,
instead of requiring a range, Tabularize tries to figure out what you want to
happen. Since it knows that you want to act on lines matching a comma, it
will look upwards and downwards for lines around the current line that match a
comma, and consider all contiguous lines matching the pattern to be the range
to be acted upon. You can always override this by specifying a range, though.
The second thing you should notice is that you'll almost certainly be able to
abbreviate :Tabularize to :Tab - using this form in mappings and scripts is
discouraged as it will make conflicts with other scripts more likely, but for
interactive use it's a nice timesaver. Another convenience feature is that
running :Tabularize without providing a new pattern will cause it to reuse the
last pattern it was called with.
So, anyway, now the commas line up. Splitting the lines on commas, Tabular
realized that 'Some short phrase' would need to be padded with spaces to match
the length of 'A much longer phrase here', and it did that before joining the
lines back together. You'll also notice that, in addition to the spaces
inserting for padding, extra spaces were inserted between fields. That's
because by default, Tabular prints things left-aligned with one space between
fields. If you wanted to print things right-aligned with no spaces between
fields, you would provide a different format to the Tabularize command:
>
:Tabularize /,/r0
Some short phrase, some other phrase
A much longer phrase here,and another long phrase
<
A format specifier is either l, r, or c, followed by one or more digits. If
the letter is l, the field will be left aligned, similarly for r and right
aligning and c and center aligning. The number following the letter is the
number of spaces padding to insert before the start of the next field.
Multiple format specifiers can be added to the same command - each field will
be printed with the next format specifier in the list; when they all have been
used the first will be used again, and so on. So, the last command right
aligned every field, then inserted 0 spaces of padding before the next field.
What if we wanted to right align the text before the comma, and left align the
text after the comma? The command would look like this:
>
:Tabularize /,/r1c1l0
Some short phrase , some other phrase
A much longer phrase here , and another long phrase
<
That command would be read as "Align the matching text, splitting fields on
commas. Print everything before the first comma right aligned, then 1 space,
then the comma center aligned, then 1 space, then everything after the comma
left aligned." Notice that the alignment of the field the comma is in is
irrelevant - since it's only 1 cell wide, it looks the same whether it's right,
left, or center aligned. Also notice that the 0 padding spaces specified for
the 3rd field are unused - but they would be used if there were enough fields
to require looping through the fields again. For instance:
>
abc,def,ghi
a,b
a,b,c
:Tabularize /,/r1c1l0
abc , def, ghi
a , b
a , b , c
<
Notice that now, the format pattern has been reused; field 4 (the second comma)
is right aligned, field 5 is center aligned. No spaces were inserted between
the 3rd field (containing "def") and the 4th field (the second comma) because
the format specified 'l0'.
But, what if you only wanted to act on the first comma on the line, rather than
all of the commas on the line? Let's say we want everything before the first
comma right aligned, then the comma, then everything after the comma left
aligned:
>
abc,def,ghi
a,b
a,b,c
:Tabularize /^[^,]*\zs,/r0c0l0
abc,def,ghi
a,b
a,b,c
<
Here, we used a Vim regex that would only match the first comma on the line.
It matches the beginning of the line, followed by all the non-comma characters
up to the first comma, and then forgets about what it matched so far and
pretends that the match starts exactly at the comma.
But, now that this command does exactly what we want it to, it's become pretty
unwieldy. It would be unpleasant to need to type that more than once or
twice. The solution is to assign a name to it.
>
:AddTabularPattern first_comma /^[^,]*\zs,/r0c0l0
<
Now, typing ":Tabularize first_comma" will do the same thing as typing the
whole pattern out each time. Of course this is more useful if you store the
name in a file to be used later.
NOTE: In order to make these new commands available every time vim starts,
you'll need to put those new commands into a .vim file in a plugin directory
somewhere in your 'runtimepath'. In order to make sure that Tabular.vim has
already been loaded before your file tries to use :AddTabularPattern or
:AddTabularPipeline, the new file should be installed in an after/plugin
directory in 'runtimepath'. In general, it will be safe to find out where the
TabularMaps.vim plugin was installed, and place other files extending
Tabular.vim in the same directory as TabularMaps.vim. For more information,
and some suggested best practices, check out the |tabular-scripting| section.
Lastly, we'll approach the case where tabular cannot achieve your desired goal
just by splitting lines appart, trimming whitespace, padding with whitespace,
and rejoining the lines. As an example, consider the multiple_spaces command
from TabularMaps.vim. The goal is to split using two or more spaces as a
field delimiter, and join fields back together, properly lined up, with only
two spaces between the end of each field and the beginning of the next.
Unfortunately, Tabular can't do this with only the commands we know so far:
>
:Tabularize / /
<
The above function won't work, because it will consider "a b" as 5 fields
delimited by two pairs of 2 spaces ( 'a', ' ', '', ' ', 'b' ) instead of as
3 fields delimited by one set of 2 or more spaces ( 'a', ' ', 'b' ).
>
:Tabularize / \+/
<
The above function won't work either, because it will leave the delimiter as 4
spaces when used against "a b", meaning that we would fail at our goal of
collapsing everything down to two spaces between fields. So, we need a new
command to get around this:
>
:AddTabularPipeline multiple_spaces / \{2,}/
\ map(a:lines, "substitute(v:val, ' \{2,}', ' ', 'g')")
\ | tabular#TabularizeStrings(a:lines, ' ', 'l0')
<
Yeah. I know it looks complicated. Bear with me. I probably will try to add
in some shortcuts for this syntax, but this verbose will be guaranteed to
always work.
You should already recognize the name being assigned. The next thing to
happen is / \{2,}/ which is a pattern specifying which lines should
automatically be included in the range when no range is given. Without this,
there would be no pattern to use for extending the range. Everything after
that is a | separated list of expressions to be evaluated. In the context in
which they will be evaluated, a:lines will be set to a List of Strings
containing the text of the lines being filtered as they procede through the
pipeline you've set up. The \ at the start of the lines are just vim's line
continuation marker; you needn't worry much about them. So, the first
expression in the pipeline transforms each line by replacing every instance of
2 or more spaces with exactly two spaces. The second command in the pipeline
performs the equivalent of ":Tabularize / /l0"; the only difference is that
it is operating on a List of Strings rather than text in the buffer. At the
end of the pipeline, the Strings in the modified a:lines (or the return value
of the last expression in the pipeline, if it returns a List) will replace the
chosen range.
==============================================================================
3. Extending *tabular-scripting*
As mentioned above, the most important consideration when extending Tabular
with new maps or commands is that your plugin must be loaded after Tabular.vim
has finished loading, and only if Tabular.vim has loaded successfully. The
easiest approach to making sure it loads after Tabular.vim is simply putting
the new file (we'll call it "tabular_extra.vim" as an example) into an
"after/plugin/" directory in 'runtimepath', for instance:
>
~/.vim/after/plugin/tabular_extra.vim
<
The default set of mappings, found in "TabularMaps.vim", is installed in
the after/plugin/ subdirectory of whatever directory Tabular was installed to.
The other important consideration is making sure that your commands are only
called if Tabular.vim was actually loaded. The easiest way to do this is by
checking for the existence of the :Tabularize command at the start of your
plugin. A short example plugin would look like this:
>
" after/plugin/my_tabular_commands.vim
" Provides extra :Tabularize commands
if !exists(':Tabularize')
finish " Give up here; the Tabular plugin musn't have been loaded
endif
" Make line wrapping possible by resetting the 'cpo' option, first saving it
let s:save_cpo = &cpo
set cpo&vim
AddTabularPattern! asterisk /*/l1
AddTabularPipeline! remove_leading_spaces /^ /
\ map(a:lines, "substitute(v:val, '^ *', '', '')")
" Restore the saved value of 'cpo'
let &cpo = s:save_cpo
unlet s:save_cpo
<
==============================================================================
vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:

View file

@ -0,0 +1,346 @@
" Tabular: Align columnar data using regex-designated column boundaries
" Maintainer: Matthew Wozniski (godlygeek@gmail.com)
" Date: Thu, 03 May 2012 20:49:32 -0400
" Version: 1.0
"
" Long Description:
" Sometimes, it's useful to line up text. Naturally, it's nicer to have the
" computer do this for you, since aligning things by hand quickly becomes
" unpleasant. While there are other plugins for aligning text, the ones I've
" tried are either impossibly difficult to understand and use, or too simplistic
" to handle complicated tasks. This plugin aims to make the easy things easy
" and the hard things possible, without providing an unnecessarily obtuse
" interface. It's still a work in progress, and criticisms are welcome.
"
" License:
" Copyright (c) 2012, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are met:
" * Redistributions of source code must retain the above copyright notice,
" this list of conditions and the following disclaimer.
" * Redistributions in binary form must reproduce the above copyright
" notice, this list of conditions and the following disclaimer in the
" documentation and/or other materials provided with the distribution.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" Abort if running in vi-compatible mode or the user doesn't want us.
if &cp || exists('g:tabular_loaded')
if &cp && &verbose
echo "Not loading Tabular in compatible mode."
endif
finish
endif
let g:tabular_loaded = 1
" Stupid vimscript crap {{{1
let s:savecpo = &cpo
set cpo&vim
" Private Things {{{1
" Dictionary of command name to command
let s:TabularCommands = {}
" Generate tab completion list for :Tabularize {{{2
" Return a list of commands that match the command line typed so far.
" NOTE: Tries to handle commands with spaces in the name, but Vim doesn't seem
" to handle that terribly well... maybe I should give up on that.
function! s:CompleteTabularizeCommand(argstart, cmdline, cursorpos)
let names = keys(s:TabularCommands)
if exists("b:TabularCommands")
let names += keys(b:TabularCommands)
endif
let cmdstart = substitute(a:cmdline, '^\s*\S\+\s*', '', '')
return filter(names, 'v:val =~# ''^\V'' . escape(cmdstart, ''\'')')
endfunction
" Choose the proper command map from the given command line {{{2
" Returns [ command map, command line with leading <buffer> removed ]
function! s:ChooseCommandMap(commandline)
let map = s:TabularCommands
let cmd = a:commandline
if cmd =~# '^<buffer>\s\+'
if !exists('b:TabularCommands')
let b:TabularCommands = {}
endif
let map = b:TabularCommands
let cmd = substitute(cmd, '^<buffer>\s\+', '', '')
endif
return [ map, cmd ]
endfunction
" Parse '/pattern/format' into separate pattern and format parts. {{{2
" If parsing fails, return [ '', '' ]
function! s:ParsePattern(string)
if a:string[0] != '/'
return ['','']
endif
let pat = '\\\@<!\%(\\\\\)\{-}\zs/' . tabular#ElementFormatPattern() . '*$'
let format = matchstr(a:string[1:-1], pat)
if !empty(format)
let format = format[1 : -1]
let pattern = a:string[1 : -len(format) - 2]
else
let pattern = a:string[1 : -1]
endif
return [pattern, format]
endfunction
" Split apart a list of | separated expressions. {{{2
function! s:SplitCommands(string)
if a:string =~ '^\s*$'
return []
endif
let end = match(a:string, "[\"'|]")
" Loop until we find a delimiting | or end-of-string
while end != -1 && (a:string[end] != '|' || a:string[end+1] == '|')
if a:string[end] == "'"
let end = match(a:string, "'", end+1) + 1
if end == 0
throw "No matching end single quote"
endif
elseif a:string[end] == '"'
" Find a " preceded by an even number of \ (or 0)
let pattern = '\%(\\\@<!\%(\\\\\)*\)\@<="'
let end = matchend(a:string, pattern, end+1) + 1
if end == 0
throw "No matching end double quote"
endif
else " Found ||
let end += 2
endif
let end = match(a:string, "[\"'|]", end)
endwhile
if end == 0 || a:string[0 : end - (end > 0)] =~ '^\s*$'
throw "Empty element"
endif
if end == -1
let rv = [ a:string ]
else
let rv = [ a:string[0 : end-1] ] + s:SplitCommands(a:string[end+1 : -1])
endif
return rv
endfunction
" Public Things {{{1
" Command associating a command name with a simple pattern command {{{2
" AddTabularPattern[!] [<buffer>] name /pattern[/format]
"
" If <buffer> is provided, the command will only be available in the current
" buffer, and will be used instead of any global command with the same name.
"
" If a command with the same name and scope already exists, it is an error,
" unless the ! is provided, in which case the existing command will be
" replaced.
"
" pattern is a regex describing the delimiter to be used.
"
" format describes the format pattern to be used. The default will be used if
" none is provided.
com! -nargs=+ -bang AddTabularPattern
\ call AddTabularPattern(<q-args>, <bang>0)
function! AddTabularPattern(command, force)
try
let [ commandmap, rest ] = s:ChooseCommandMap(a:command)
let name = matchstr(rest, '.\{-}\ze\s*/')
let pattern = substitute(rest, '.\{-}\s*\ze/', '', '')
let [ pattern, format ] = s:ParsePattern(pattern)
if empty(name) || empty(pattern)
throw "Invalid arguments!"
endif
if !a:force && has_key(commandmap, name)
throw string(name) . " is already defined, use ! to overwrite."
endif
let command = "tabular#TabularizeStrings(a:lines, " . string(pattern)
if !empty(format)
let command .= ", " . string(format)
endif
let command .= ")"
let commandmap[name] = { 'pattern' : pattern, 'commands' : [ command ] }
catch
echohl ErrorMsg
echomsg "AddTabularPattern: " . v:exception
echohl None
endtry
endfunction
" Command associating a command name with a pipeline of functions {{{2
" AddTabularPipeline[!] [<buffer>] name /pattern/ func [ | func2 [ | func3 ] ]
"
" If <buffer> is provided, the command will only be available in the current
" buffer, and will be used instead of any global command with the same name.
"
" If a command with the same name and scope already exists, it is an error,
" unless the ! is provided, in which case the existing command will be
" replaced.
"
" pattern is a regex that will be used to determine which lines will be
" filtered. If the cursor line doesn't match the pattern, using the command
" will be a no-op, otherwise the cursor and all contiguous lines matching the
" pattern will be filtered.
"
" Each 'func' argument represents a function to be called. This function
" will have access to a:lines, a List containing one String per line being
" filtered.
com! -nargs=+ -bang AddTabularPipeline
\ call AddTabularPipeline(<q-args>, <bang>0)
function! AddTabularPipeline(command, force)
try
let [ commandmap, rest ] = s:ChooseCommandMap(a:command)
let name = matchstr(rest, '.\{-}\ze\s*/')
let pattern = substitute(rest, '.\{-}\s*\ze/', '', '')
let commands = matchstr(pattern, '^/.\{-}\\\@<!\%(\\\\\)\{-}/\zs.*')
let pattern = matchstr(pattern, '/\zs.\{-}\\\@<!\%(\\\\\)\{-}\ze/')
if empty(name) || empty(pattern)
throw "Invalid arguments!"
endif
if !a:force && has_key(commandmap, name)
throw string(name) . " is already defined, use ! to overwrite."
endif
let commandlist = s:SplitCommands(commands)
if empty(commandlist)
throw "Must provide a list of functions!"
endif
let commandmap[name] = { 'pattern' : pattern, 'commands' : commandlist }
catch
echohl ErrorMsg
echomsg "AddTabularPipeline: " . v:exception
echohl None
endtry
endfunction
" Tabularize /pattern[/format] {{{2
" Tabularize name
"
" Align text, either using the given pattern, or the command associated with
" the given name.
com! -nargs=* -range -complete=customlist,<SID>CompleteTabularizeCommand
\ Tabularize <line1>,<line2>call Tabularize(<q-args>)
function! Tabularize(command, ...) range
let piperange_opt = {}
if a:0
let piperange_opt = a:1
endif
if empty(a:command)
if !exists("s:last_tabularize_command")
echohl ErrorMsg
echomsg "Tabularize hasn't been called yet; no pattern/command to reuse!"
echohl None
return
endif
else
let s:last_tabularize_command = a:command
endif
let command = s:last_tabularize_command
let range = a:firstline . ',' . a:lastline
try
let [ pattern, format ] = s:ParsePattern(command)
if !empty(pattern)
let cmd = "tabular#TabularizeStrings(a:lines, " . string(pattern)
if !empty(format)
let cmd .= "," . string(format)
endif
let cmd .= ")"
exe range . 'call tabular#PipeRangeWithOptions(pattern, [ cmd ], '
\ . 'piperange_opt)'
else
if exists('b:TabularCommands') && has_key(b:TabularCommands, command)
let usercmd = b:TabularCommands[command]
elseif has_key(s:TabularCommands, command)
let usercmd = s:TabularCommands[command]
else
throw "Unrecognized command " . string(command)
endif
exe range . 'call tabular#PipeRangeWithOptions(usercmd["pattern"], '
\ . 'usercmd["commands"], piperange_opt)'
endif
catch
echohl ErrorMsg
echomsg "Tabularize: " . v:exception
echohl None
return
endtry
endfunction
" GTabularize /pattern[/format] {{{2
" GTabularize name
"
" Align text on only matching lines, either using the given pattern, or the
" command associated with the given name. Mnemonically, this is similar to
" the :global command, which takes some action on all rows matching a pattern
" in a range. This command is different from normal :Tabularize in 3 ways:
" 1) If a line in the range does not match the pattern, it will be left
" unchanged, and not in any way affect the outcome of other lines in the
" range (at least, normally - but Pipelines can and will still look at
" non-matching rows unless they are specifically written to be aware of
" tabular#DoGTabularize() and handle it appropriately).
" 2) No automatic range determination - :Tabularize automatically expands
" a single-line range (or a call with no range) to include all adjacent
" matching lines. That behavior does not make sense for this command.
" 3) If called without a range, it will act on all lines in the buffer (like
" :global) rather than only a single line
com! -nargs=* -range=% -complete=customlist,<SID>CompleteTabularizeCommand
\ GTabularize <line1>,<line2>
\ call Tabularize(<q-args>, { 'mode': 'GTabularize' } )
" Stupid vimscript crap, part 2 {{{1
let &cpo = s:savecpo
unlet s:savecpo
" vim:set sw=2 sts=2 fdm=marker:

View file

@ -108,6 +108,20 @@ This plugin goes well together with the following plugin:
and `<F9>`)
Max line lengths
----------------
One particular customization a lot of people like to make is relaxing the
maximum line length default. This is a config setting that should be set in
flake8 itself. (vim-flake8 "just" invokes it and deals with showing the output
in Vim's quickfix window.)
To do so, put the following into your `~/.config/flake8` file:
[flake8]
max-line-length = 120
History
-------
1.6: Deprecated configuring flake8 options through Vim settings. Instead,

View file

@ -468,8 +468,8 @@ endfun
function! s:repo_aliases() dict abort
if !has_key(self,'_aliases')
let self._aliases = {}
for line in split(self.git_chomp('config','--get-regexp','^alias[.]'),"\n")
let self._aliases[matchstr(line,'\.\zs\S\+')] = matchstr(line,' \zs.*')
for line in split(self.git_chomp('config','-z','--get-regexp','^alias[.]'),"\1")
let self._aliases[matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*')
endfor
endif
return self._aliases
@ -1776,13 +1776,17 @@ function! s:Diff(vert,keepfocus,...) abort
let nr = bufnr('')
execute 'leftabove '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`'
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
let nr2 = bufnr('')
call s:diffthis()
wincmd p
execute 'rightbelow '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
let nr3 = bufnr('')
call s:diffthis()
wincmd p
call s:diffthis()
execute 'nnoremap <buffer> <silent> d2o :diffget '.nr2.'<Bar>diffupdate<CR>'
execute 'nnoremap <buffer> <silent> d3o :diffget '.nr3.'<Bar>diffupdate<CR>'
return post
elseif len(args)
let arg = join(args, ' ')

View file

@ -2,10 +2,20 @@
* We have now a [logo for vim-go](https://github.com/fatih/vim-go/blob/master/assets/vim-go.png)! Thanks to @egonelbre for his work on this.
IMPROVEMENTS:
* Function calls are now highligted as wel when `g:go_highlight_functions` is enabled [gh-1048]
* Add completion support for uninported packages. This allows to complete even if the package is not improted [gh-1084]
* Tools that embeds GOROOT into their binaries do not work when people update their Go version and the GOROOT contains the vesion as part of their path (i.e: `/usr/local/Cellar/go/1.7.2/libexec`, [more info](https://blog.filippo.io/stale-goroot-and-gorebuild/)) . This is now fixed by introducing automatic GOROOT set/unset before each tool invoke. [gh-954]
BUG FIXES:
* Change back nil and iota highlighting color to the old type [gh-1049]
* Fix passing arguments to `:GoBuild` while using NeoVim [gh-1062]
* Do not open a split if `:GoDef` is used on a modified file [gh-1083]
* Highlight nested structs correctly [gh-1075]
* Highlight builtin functions correctly if `g:go_highlight_functions` is enabled [gh-1070]
* Fix `:GoSameIds` highlighting if a new buffer is opened in the same window [gh-1067]
## 1.9 (September 13, 2016)

View file

@ -56,3 +56,5 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The Go gopher was designed by Renee French. http://reneefrench.blogspot.com/ The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher

View file

@ -32,7 +32,9 @@ function! s:gocodeCommand(cmd, preargs, args)
" we might hit cache problems, as gocode doesn't handle well different
" GOPATHS: https://github.com/nsf/gocode/issues/239
let old_gopath = $GOPATH
let old_goroot = $GOROOT
let $GOPATH = go#path#Detect()
let $GOROOT = go#util#env("goroot")
let socket_type = get(g:, 'go_gocode_socket_type', s:sock_type)
let cmd = printf('%s -sock %s %s %s %s',
@ -45,6 +47,8 @@ function! s:gocodeCommand(cmd, preargs, args)
let result = go#util#System(cmd)
let $GOPATH = old_gopath
let $GOROOT = old_goroot
if go#util#ShellError() != 0
return "[\"0\", []]"
else
@ -74,6 +78,7 @@ function! s:gocodeEnableOptions()
call go#util#System(printf('%s set propose-builtins %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_propose_builtins', 1))))
call go#util#System(printf('%s set autobuild %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_autobuild', 1))))
call go#util#System(printf('%s set unimported-packages %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_unimported_packages', 1))))
endfunction
function! s:toBool(val)

View file

@ -129,8 +129,6 @@ function! s:jump_to_declaration(out, mode)
split
elseif a:mode == "vsplit"
vsplit
elseif &modified
split
endif
" open the file and jump to line and column

View file

@ -121,7 +121,9 @@ endfunction
function! go#tool#ExecuteInDir(cmd) abort
let old_gopath = $GOPATH
let old_goroot = $GOROOT
let $GOPATH = go#path#Detect()
let $GOROOT = go#util#env("goroot")
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
@ -132,6 +134,7 @@ function! go#tool#ExecuteInDir(cmd) abort
execute cd . fnameescape(dir)
endtry
let $GOROOT = old_goroot
let $GOPATH = old_gopath
return out
endfunction

View file

@ -43,6 +43,31 @@ function! go#util#IsWin()
return 0
endfunction
let s:env_cache = {}
" env returns the go environment variable for the given key. Where key can be
" GOARCH, GOOS, GOROOT, etc... It caches the result and returns the cached
" version.
function! go#util#env(key)
let l:key = tolower(a:key)
if has_key(s:env_cache, l:key)
return s:env_cache[l:key]
endif
if executable('go')
let l:var = call('go#util#'.l:key, [])
if go#util#ShellError() != 0
call go#util#EchoError(printf("'go env %s' failed", toupper(l:key)))
return ''
endif
else
let l:var = eval("$".toupper(a:key))
endif
let s:env_cache[l:key] = l:var
return l:var
endfunction
function! go#util#goarch()
return substitute(go#util#System('go env GOARCH'), '\n', '', 'g')
endfunction

View file

@ -1396,6 +1396,12 @@ to an autocompletion proposals. By default it is enabled.
>
let g:go_gocode_propose_builtins = 1
<
*'g:go_gocode_unimported_packages'*
Specifies whether `gocode` should include suggestions from unimported packages.
By default it is enabled
>
let g:go_gocode_unimported_packages = 1
*'g:go_gocode_socket_type'*
Specifies whether `gocode` should use a different socket type. By default

View file

@ -200,6 +200,10 @@ augroup vim-go
autocmd BufWritePre *.s call s:asmfmt_autosave()
autocmd BufWritePost *.go call s:metalinter_autosave()
autocmd BufNewFile *.go call s:template_autocreate()
" clear SameIds when the buffer is unloaded so that loading another buffer
" in the same window doesn't highlight the most recently matched
" identifier's positions.
autocmd BufWinEnter *.go call go#guru#ClearSameIds()
augroup END
" vim: sw=2 ts=2 et

View file

@ -302,16 +302,18 @@ if g:go_highlight_functions != 0
syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl
syn match goReceiverType /\w\+/ contained
syn match goFunction /\w\+/ contained
syn match goFunctionCall /\w\+\ze(/ contains=GoBuiltins,goDeclaration
else
syn keyword goDeclaration func
endif
hi def link goFunction Function
hi def link goFunctionCall Type
" Methods;
if g:go_highlight_methods != 0
syn match goMethod /\.\w\+\ze(/hs=s+1
syn match goMethodCall /\.\w\+\ze(/hs=s+1
endif
hi def link goMethod Type
hi def link goMethodCall Type
" Fields;
if g:go_highlight_fields != 0
@ -324,7 +326,7 @@ if g:go_highlight_types != 0
syn match goTypeConstructor /\<\w\+{/he=e-1
syn match goTypeDecl /\<type\>/ nextgroup=goTypeName skipwhite skipnl
syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl
syn match goDeclType /\<interface\|struct\>/ contained skipwhite skipnl
syn match goDeclType /\<interface\|struct\>/ skipwhite skipnl
hi def link goReceiverType Type
else
syn keyword goDeclType struct interface

View file

@ -32,9 +32,10 @@ syn cluster pugTop contains=pugBegin,pugComment,pugHtmlComment,pugJavascript
syn match pugBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=pugTag,pugClassChar,pugIdChar,pugPlainChar,pugJavascript,pugScriptConditional,pugScriptStatement,pugPipedText
syn match pugTag "+\?\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@pugComponent
syn cluster pugComponent contains=pugAttributes,pugIdChar,pugBlockExpansionChar,pugClassChar,pugPlainChar,pugJavascript,pugTagBlockChar,pugTagInlineText
syn match pugComment '\(\s\+\|^\)\/\/.*$'
syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" keepend
syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->"
syntax keyword pugCommentTodo contained TODO FIXME XXX TBD
syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo
syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo keepend
syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->" contains=pugCommentTodo
syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,pugHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent
syn match pugClassChar "\." contained nextgroup=pugClass
syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar
@ -93,6 +94,7 @@ hi def link pugInterpolationDelimiter Delimiter
hi def link pugInlineDelimiter Delimiter
hi def link pugFilter PreProc
hi def link pugDocType PreProc
hi def link pugCommentTodo Todo
hi def link pugComment Comment
hi def link pugCommentBlock Comment
hi def link pugHtmlConditionalComment pugComment

View file

@ -18,7 +18,7 @@ snippet box "A nice box with the current comment symbol" b
box = make_box(len(t[1]))
snip.rv = box[0]
snip += box[1]
`${1:content}`!p
`${1:${VISUAL:content}}`!p
box = make_box(len(t[1]))
snip.rv = box[2]
snip += box[3]`
@ -32,7 +32,7 @@ if not snip.c:
box = make_box(len(t[1]), width)
snip.rv = box[0]
snip += box[1]
`${1:content}`!p
`${1:${VISUAL:content}}`!p
box = make_box(len(t[1]), width)
snip.rv = box[2]
snip += box[3]`

View file

@ -258,7 +258,7 @@ snippet style "XHTML <style>" w
endsnippet
snippet table "XHTML <table>" w
<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}>
<table>
${0:${VISUAL}}
</table>
endsnippet
@ -317,4 +317,8 @@ snippet movie "Embed QT movie (movie)" b
`!p x(snip)`>
</object>
endsnippet
snippet viewport "Responsive viewport meta" w
<meta name="viewport" content="width=device-width, initial-scale=1">
endsnippet
# vim:ft=snippets:

View file

@ -158,14 +158,4 @@ snippet cw "console.warn" b
console.warn(${1:"${2:value}"});
endsnippet
# AMD (Asynchronous Module Definition) snippets
snippet def "define an AMD module"
define(${1:optional_name, }[${2:'jquery'}], ${3:callback});
endsnippet
snippet req "require an AMD module"
require([${1:'dependencies'}], ${2:callback});
endsnippet
# vim:ft=snippets:

View file

@ -121,9 +121,9 @@ class ${2:`!v expand('%:t:r')`} extends \Eloquent {
public $timestamps = ${5:false};
protected $hidden = array(${6});
protected $hidden = [${6}];
protected $guarded = array(${7:'id'});
protected $guarded = [${7:'id'}];
}
endsnippet
@ -162,7 +162,7 @@ abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface}
*
* \return Illuminate\Database\Eloquent\Collection
*/
public function all($columns = array('*')) {
public function all($columns = ['*']) {
return $this->model->all()->toArray();
}
@ -189,7 +189,7 @@ abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface}
*
* \return mixed
*/
public function find($id, $columns = array('*')) {
public function find($id, $columns = ['*']) {
return $this->model->find($id, $columns);
}
}

View file

@ -61,7 +61,7 @@ snippet sfa "Symfony 2 Controller action"
public function $1Action($2)
{
$3
return ${4:array();}$0
return ${4:[];}$0
}
endsnippet

View file

@ -32,7 +32,7 @@ def _parse_comments(s):
flags, text = next(i).split(':', 1)
if len(flags) == 0:
rv.append((text, text, text, ""))
rv.append(('OTHER', text, text, text, ""))
# parse 3-part comment, but ignore those with O flag
elif 's' in flags and 'O' not in flags:
ctriple = ["TRIPLE"]

View file

@ -1,8 +1,8 @@
snippet setup
void setup()
{
${0}
Serial.begin(9600);
Serial.begin(${1:9600});
${2}
}
snippet loop
@ -14,6 +14,9 @@ snippet loop
snippet inc
#include <${1}.h>
snippet def
#define ${1}
# if
snippet if
if (${1:/* condition */}) {
@ -50,12 +53,12 @@ snippet case
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
for (int ${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5}
}
# while
@ -93,14 +96,29 @@ snippet dwLow
# digitalRead
snippet dr
digitalRead(${1});
# analogRead
snippet ar
analogRead(${1});
# analogWrite
snippet aw
analogWrite(${1});
# serialRead
snippet sr
serialRead();
# serial.println
Serial.read();
# serialWrite
snippet sw
Serial.write();
# serial.print
snippet sp
serial.println(${1});
Serial.print(${1});
# serial.println
snippet sl
Serial.println(${1});
# delay
snippet dl
delay(${1});
# millis
snippet ml
millis();

View file

@ -104,12 +104,12 @@ snippet ret
## Loops
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
for (int ${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5}
}
# while
@ -164,6 +164,12 @@ snippet pr
# fprintf (again, this isn't as nice as TextMate's version, but it works)
snippet fpr
fprintf(${1:stderr}, "${2:%s}\n"${3});
snippet prd
printf("${1:} = %d\n", $1);
snippet prf
printf("${1:} = %f\n", $1);
snippet prx
printf("${1:} = %${2}\n", $1);
# getopt
snippet getopt
int choice;

View file

@ -88,6 +88,8 @@ snippet defmo
defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
${0}
end
snippet dfp
defp ${1:name}, do: ${2}
snippet defp
defp ${1:name} do
${0}
@ -100,6 +102,8 @@ snippet doc
@doc """
${0}
"""
snippet docf
@doc false
snippet fn
fn ${1:args} -> ${0} end
snippet mdoc

View file

@ -875,3 +875,5 @@ snippet video
<video src="${1} height="${2}" width="${3}" preload="${5:none}" autoplay="${6:autoplay}>${7}</video>
snippet wbr
<wbr />
snippet viewport
<meta name="viewport" content="width=device-width, initial-scale=1">

View file

@ -214,12 +214,20 @@ snippet wh
while (${1}) ${0}
##
## Main method
snippet psvm
public static void main (String[] args) {
${0}
}
snippet main
public static void main (String[] args) {
${0}
}
##
## Print Methods
snippet sout
System.out.println(${0});
snippet serr
System.err.println(${0});
snippet print
System.out.print("${0:Message}");
snippet printf

View file

@ -42,7 +42,7 @@ snippet e
snippet mo
mods : { ${1:modName} : '${2:modVal}' },
mi - BEM mix mod
# mi - BEM mix mod
snippet mi
mix : [ { ${1:block} : '${2:block}' } ],

View file

@ -6,6 +6,10 @@ snippet it "it" b
it('${1:}', () => {
${0}
});
snippet xit "xit" b
xit('${1:}', () => {
${0}
});
snippet exp "expect" b
expect(${1:})${0};
snippet expe "expect" b

View file

@ -0,0 +1,81 @@
# Import only React
snippet ri1
import React from 'react'
# Import both React and Component
snippet ri2
import React, { Component, PropTypes } from 'react'
# React class
snippet rcla
class ${1:MyComponent} extends Component {
render() {
return (
${0:<div></div>}
)
}
}
# React constructor
snippet rcon
constructor(props) {
super(props)
this.state = {
${1}: ${0},
}
}
# Proptypes for React Class
snippet rcpt
static propTypes = {
${1}: PropTypes.${0},
}
# Default props for React Class
snippet rcdp
static defaultProps = {
${1}: ${0},
}
# Presentational component
snippet rcom
(props) => {
return (
${0:<div></div>}
)
}
# Proptypes for Presentational component
snippet rpt
${1}.propTypes = {
${2}: PropTypes.${0},
}
# Default props for Presentational component
snippet rdp
${1}.defaultProps = {
${2}: ${0},
}
# Lifecycle Methods
snippet rcdm
componentDidMount() {
${0}
}
# State
snippet rsst
this.setState({
${1}: ${0},
})
snippet rtst
this.state.${0}
# Props
snippet rp
props.${0}
snippet rtp
this.props.${0}

View file

@ -0,0 +1,83 @@
snippet ir
import React from 'react';
snippet ird
import ReactDOM from 'react-dom';
snippet cdm
componentDidMount() {
${1}
}
snippet cdup
componentDidUpdate(prevProps, prevState) {
${1}
}
snippet cwm
componentWillMount() {
${1}
}
snippet cwr
componentWillReceiveProps(nextProps) {
${1}
}
snippet cwun
componentWillUnmount() {
${1}
}
snippet cwu
componentWillUpdate(nextProps, nextState) {
${1}
}
snippet fup
forceUpdate(${1:callback});
snippet dp
static defaultProps = {
${1}: ${2},
}
snippet st
state = {
${1}: ${2},
}
snippet pt
static propTypes = {
${1}: React.PropTypes.${2:type},
}
snippet rcc
class ${1:ClassName} extends React.Component {
render() {
return (
${0:<div />}
);
}
}
snippet rdr
ReactDOM.render(${1}, ${2})
snippet ercc
export default class ${1:ClassName} extends React.Component {
render() {
return (
${0:<div />}
);
}
}
snippet ctor
constructor() {
super();
${1}
}
snippet ren
render() {
return (
${1:<div />}
);
}
snippet sst
this.setState({
${1}: ${2}
});
snippet scu
shouldComponentUpdate(nextProps, nextState) {
${1}
}
snippet prp i
this.props.${1}
snippet ste i
this.state.${1}

View file

@ -12,6 +12,30 @@ snippet clax
class ${1} extends ${2} {
${0}
}
snippet clac
class ${1} {
constructor(${2}) {
${0}
}
}
# For of loop
snippet foro
for (let ${1:prop} of ${2:object}) {
${0:$1}
}
# Generator
snippet fun*
function* ${1:function_name}(${2}) {
${0}
}
snippet c=>
const ${1:function_name} = (${2}) => {
${0}
}
snippet caf
const ${1:function_name} = (${2}) => {
${0}
}
snippet =>
(${1}) => {
${0}

View file

@ -1,5 +1,4 @@
# Functions
# prototype
snippet proto
${1:class_name}.prototype.${2:method_name} = function(${3}) {
@ -44,9 +43,7 @@ snippet sdf
${0}
};
};
# Flow control
# if
snippet if
if (${1:true}) {
@ -100,9 +97,6 @@ snippet terr
# return
snippet ret
return ${0:result};
# Loops
# for loop
snippet for
for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2++) {
@ -128,9 +122,7 @@ snippet fori
for (var ${1:prop} in ${2:object}) {
${0:$2[$1]}
}
# Objects
# Object Method
snippet :f
${1:method_name}: function (${2:attribute}) {
@ -207,9 +199,7 @@ snippet prop
configurable : ${0:boolean}
}
);
# Documentation
# docstring
snippet /**
/**
@ -228,9 +218,7 @@ snippet jsonp
# JSON.stringify
snippet jsons
JSON.stringify(${0:object});
# DOM selectors
# Get elements
snippet get
getElementsBy${1:TagName}('${0}')
@ -249,7 +237,6 @@ snippet qs
# Query selector all
snippet qsa
${1:document}.querySelectorAll('${0:CSS selector}')
# Debugging
snippet de
debugger;
@ -265,6 +252,9 @@ snippet ce
# console.warn
snippet cw
console.warn(${0});
# console.info
snippet ci
console.info(${0});
# console.trace
snippet ct
console.trace(${0:label});
@ -277,13 +267,10 @@ snippet ca
# console.dir
snippet cdir
console.dir(${0:obj});
# Misc
# 'use strict';
snippet us
'use strict';
# setTimeout function
snippet timeout
setTimeout(function () {${0}}${2}, ${1:10});

View file

@ -351,8 +351,8 @@ snippet foreachkil "<?php foreach ($var as $key => $value): ?> ... <?php endfor
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
${0:<!-- html... -->}
<?php endforeach; ?>
snippet array "$... = array(...)"
$${1:arrayName} = array('${2}' => ${3});
snippet array "$... = ['' => ]"
$${1:arrayName} = ['${2}' => ${3}];
snippet try "try { ... } catch (Exception $e) { ... }"
try {
${0}
@ -466,7 +466,7 @@ snippet CSVWriter
? fopen($file_or_handle, $mode)
: $file_or_handle;
$this->fputcsv_args = array($this->f, null, $sep, $quot);
$this->fputcsv_args = [$this->f, null, $sep, $quot];
if (!$this->f) throw new Exception('bad file descriptor');
}
@ -502,7 +502,7 @@ snippet CSVIterator
* enclosure
* delimiter
*/
public function __construct( $file_or_handle, $opts = array(4096, ',') )
public function __construct( $file_or_handle, $opts = [4096, ','] )
{
$d = function($n) use(&$opts){ return isset($opts[$n]) ? $opts[$n] : false; };
@ -515,13 +515,13 @@ snippet CSVIterator
? fopen( $file_or_handle, 'r' )
: $file_or_handle;
if (!$this->f) throw new Exception('bad file descriptor');
$this->fgetcsv_args = array(
$this->fgetcsv_args = [
$this->f,
isset($opts['row_size']) ? $opts['row_size'] : 4096,
isset($opts['delimiter']) ? $opts['delimiter'] : ',',
isset($opts['enclosure']) ? $opts['enclosure'] : '"',
isset($opts['escape']) ? $opts['escape'] : '\\',
);
];
$this->start();
}

View file

@ -0,0 +1,58 @@
# Snippets for
# Authored by Trevor Sullivan <trevor@trevorsullivan.net>
# PowerShell Class
snippet class
class {
[string] ${0:FirstName}
}
# PowerShell Advanced Function
snippet function
function {0:name} {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $Param1
)
begin {
}
process {
}
end {
}
}
# PowerShell Splatting
snippet splatting
$Params = @{
${0:Param1} = 'Value1'
${1:Param2} = 'Value2'
}
${3:CommandName}
# PowerShell Enumeration
snippet enum
enum ${0:name} {
${1:item1}
${2:item2}
}
# PowerShell if..then
snippet if
if (${0:condition}) {
${1:statement}
}
# PowerShell While Loop
snippet while
while (${0:condition}) {
${1:statement}
}
# PowerShell Filter..Sort
snippet filtersort
${0:command} | Where-Object -FilterScript { $PSItem.${1:property} -${2:operator} '${3:expression}' } | Sort-Object -Property ${4:sortproperty}

View file

@ -993,3 +993,7 @@ snippet for
for ${1:i} in ${0}
snippet keyf
@keyframes ${0}
snippet jc:c
justify-content center
snippet jc
justify-content