diff --git a/README.md b/README.md index 7bd646b8..ff02c1d3 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,10 @@ This is useful to install on remote servers where you don't need many plugins an Use [msysgit](http://msysgit.github.com/) to checkout the repository and run the installation instructions above. No special instructions needed ;-) +## How to install on Linux + +If you have vim aliased as `vi` instead of `vim`, make sure to either alias it: `alias vi=vim`. Otherwise, `apt-get install vim` + ## How to update to latest version? Simply just do a git rebase! diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim index fef2544f..fc8b8830 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim @@ -1,8 +1,9 @@ " ============================================================================= " File: autoload/ctrlp.vim " Description: Fuzzy file, buffer, mru, tag, etc finder. -" Author: Kien Nguyen -" Version: 1.79 +" Author: CtrlP Dev Team +" Original: Kien Nguyen +" Version: 1.80 " ============================================================================= " ** Static variables {{{1 @@ -97,6 +98,8 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] = \ 'compare_lim': ['s:compare_lim', 3000], \ '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', @@ -203,11 +206,21 @@ let s:hlgrps = { \ } " lname, sname of the basic(non-extension) modes -let s:coretypes = [ - \ ['files', 'fil'], - \ ['buffers', 'buf'], - \ ['mru files', 'mru'], -\ ] +let s:types = ['fil', 'buf', 'mru'] +if !exists('g:ctrlp_types') + let g:ctrlp_types = s:types +el + call filter(g:ctrlp_types, "index(['fil', 'buf', 'mru'], v:val)!=-1") +en +let g:ctrlp_builtins = len(g:ctrlp_types)-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(...) @@ -317,11 +330,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() @@ -422,6 +435,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 = @@ -437,11 +455,17 @@ 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)) - else + el let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n") - end + en if exists('+ssl') && exists('ssl') let &ssl = ssl cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")') @@ -624,7 +648,7 @@ fu! s:Render(lines, pat) en if s:mw_order == 'btt' | cal reverse(lines) | en let s:lines = copy(lines) - cal map(lines, 's:formatline(v:val)') + cal map(lines, s:flfunc) cal setline(1, s:offset(lines, height)) cal s:unmarksigns() cal s:remarksigns() @@ -649,7 +673,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 @@ -719,7 +743,7 @@ fu! s:PrtBS() if empty(s:prompt[0]) && s:brfprt != 0 cal s:PrtExit() retu - endif + en unl! s:hstgot let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1] cal s:BuildPrompt(1) @@ -877,12 +901,13 @@ fu! s:PrtFocusMap(char) endf fu! s:PrtClearCache() - if s:itemtype == 0 + let ct = s:curtype() + if ct == 'fil' cal ctrlp#clr() - elsei s:itemtype > 2 + elsei s:itemtype >= len(s:coretypes) cal ctrlp#clr(s:statypes[s:itemtype][1]) en - if s:itemtype == 2 + if ct == 'mru' let g:ctrlp_lines = ctrlp#mrufiles#refresh() el cal ctrlp#setlines() @@ -893,9 +918,10 @@ fu! s:PrtClearCache() endf fu! s:PrtDeleteEnt() - if s:itemtype == 2 + let ct = s:curtype() + if ct == 'mru' cal s:PrtDeleteMRU() - elsei s:itemtype == 1 + elsei ct == 'buf' cal s:delbuf() elsei type(s:getextvar('wipe')) == 1 cal s:delent(s:getextvar('wipe')) @@ -903,16 +929,19 @@ fu! s:PrtDeleteEnt() endf fu! s:PrtDeleteMRU() - if s:itemtype == 2 + if s:curtype() == 'mru' cal s:delent('ctrlp#mrufiles#remove') en endf 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' en endf @@ -1011,7 +1040,7 @@ fu! s:ToggleByFname() endf fu! s:ToggleType(dir) - let max = len(g:ctrlp_ext_vars) + 2 + let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1 let next = s:walker(max, s:itemtype, a:dir) cal ctrlp#setlines(next) cal ctrlp#syntax() @@ -1151,7 +1180,7 @@ fu! s:AcceptSelection(action) if subm | if s:SpecInputs(str) | retu | en | en " Get the selected line let line = ctrlp#getcline() - if !subm && !s:itemtype && line == '' && line('.') > s:offset + if !subm && s:curtype() != 'fil' && line == '' && line('.') > s:offset \ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$' cal s:CreateNewFile(md) | retu en @@ -1161,7 +1190,7 @@ fu! s:AcceptSelection(action) let actfunc = s:openfunc[s:ctype] let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list' el - if s:itemtype < 3 + if s:itemtype < len(s:coretypes) let [actfunc, type] = ['ctrlp#acceptfile', 'dict'] el let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')] @@ -1206,15 +1235,16 @@ fu! s:CreateNewFile(...) endf " * OpenMulti() {{{1 fu! s:MarkToOpen() + let ct = s:curtype() if s:bufnr <= 0 || s:opmul == '0' - \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + \ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 ) retu en let line = ctrlp#getcline() " Do not allow to mark modified or current buffer let bufnr = s:bufnrfilpath(line)[0] - if (s:itemtype == 1 && s:delbufcond(bufnr)) + if (ct == 'buf' && s:delbufcond(bufnr)) retu en @@ -1247,7 +1277,7 @@ endf fu! s:OpenMulti(...) let has_marked = exists('s:marked') if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath - \ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 ) + \ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 ) retu -1 en " Get the options @@ -1442,7 +1472,8 @@ fu! s:shortest(lens) endf fu! s:mixedsort(...) - if s:itemtype == 1 + let ct = s:curtype() + if ct == 'buf' let pat = '[\/]\?\[\d\+\*No Name\]$' if a:1 =~# pat && a:2 =~# pat | retu 0 elsei a:1 =~# pat | retu 1 @@ -1453,10 +1484,10 @@ fu! s:mixedsort(...) let ms = [] if s:res_count < 21 let ms += [s:compfnlen(a:1, a:2)] - if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en + if ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en en - if s:itemtype =~ '^[12]$' + if ct =~ '^\(buf\|mru\)$' let ms += [s:compmref(a:1, a:2)] let cln = cml ? cln : 0 en @@ -1540,7 +1571,8 @@ endf " Line formatting {{{3 fu! s:formatline(str) let str = a:str - if s:itemtype == 1 + let ct = s:curtype() + if ct == 'buf' let bufnr = s:bufnrfilpath(str)[0] let parts = s:bufparts(bufnr) let str = printf('%'.s:bufnr_width.'s', bufnr) @@ -1552,7 +1584,7 @@ fu! s:formatline(str) let str .= printf(' %s', ''.parts[3].'') en el - let str .= printf(' %-5s %-30s %s', + let str .= printf(' %-5s %-30s', \ parts[0], \ parts[2]) if (!empty(s:bufpath_mod)) @@ -1560,7 +1592,7 @@ fu! s:formatline(str) en en en - let cond = s:itemtype != 1 &&s:ispath && ( s:winw - 4 ) < s:strwidth(str) + let cond = ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str) retu s:lineprefix.( cond ? s:pathshorten(str) : str ) endf @@ -1615,7 +1647,7 @@ fu! s:lash(...) endf fu! s:ispathitem() - retu s:itemtype < 3 || ( s:itemtype > 2 && s:getextvar('type') == 'path' ) + retu s:itemtype < len(s:coretypes) || s:getextvar('type') == 'path' endf fu! ctrlp#igncwd(cwd) @@ -1649,11 +1681,11 @@ fu! ctrlp#dirnfile(entries) endf fu! s:usrign(item, type) - if s:igntype == 1 | retu a:item =~ s:usrign | end + if s:igntype == 1 | retu a:item =~ s:usrign | en if s:igntype == 2 if call(s:usrign, [a:item, a:type]) retu 1 - end + en elsei s:igntype == 4 if has_key(s:usrign, a:type) && s:usrign[a:type] != '' \ && a:item =~ s:usrign[a:type] @@ -1661,8 +1693,8 @@ fu! s:usrign(item, type) elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' \ && call(s:usrign['func'], [a:item, a:type]) retu 1 - end - end + en + en retu 0 endf @@ -1772,7 +1804,7 @@ fu! ctrlp#syntax() exe "sy match CtrlPLinePre '^".escape(get(g:, 'ctrlp_line_prefix', '>'),'^$.*~\')."'" en - if s:itemtype == 1 && s:has_conceal + if s:curtype() == 'buf' && s:has_conceal sy region CtrlPBufferNr matchgroup=CtrlPLinePre start='^>\s\+' end='\s' sy region CtrlPBufferInd concealends matchgroup=Ignore start='' end='' sy region CtrlPBufferRegion concealends matchgroup=Ignore start='' end='' @@ -1810,7 +1842,7 @@ fu! s:highlight(pat, grp) if s:byfname() " Make sure there are no slashes in our match let beginning = beginning.'\([^\/]*$\)\@=' - end + en for i in range(len(chars)) " Surround our current target letter with \zs and \ze so it only @@ -1822,14 +1854,14 @@ fu! s:highlight(pat, grp) if i == 0 let charcopy[i] = '\zs'.charcopy[i].'\ze' let middle = join(charcopy, '.\{-}') - else + el let before = join(charcopy[0:i-1], '.\{-}') let after = join(charcopy[i+1:-1], '.\{-}') let c = charcopy[i] " for abc, match either ab.\{-}c or a.*b.\{-}c in that order let cpat = '\(\zs'.c.'\|'.'.*\zs'.c.'\)\ze.*' let middle = before.cpat.after - endif + en " Now we matchadd for each letter, the basic form being: " ^.*\zsx\ze.*$, but with our pattern we built above for the letter, @@ -1956,7 +1988,7 @@ fu! s:isabs(path) endf fu! s:bufnrfilpath(line) - if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/' + if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/' let filpath = a:line el let filpath = s:dyncwd.s:lash().a:line @@ -2026,7 +2058,7 @@ fu! s:checkbuf() endf fu! s:iscmdwin() - let ermsg = v:errmsg + let [ermsg, v:errmsg] = [v:errmsg, ''] sil! noa winc p sil! noa winc p let [v:errmsg, ermsg] = [ermsg, v:errmsg] @@ -2140,12 +2172,13 @@ fu! s:modevar() endf fu! s:nosort() - retu s:matcher != {} || s:nolim == 1 || ( s:itemtype == 2 && s:mrudef ) - \ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort + let ct = s:curtype() + retu s:matcher != {} || s:nolim == 1 || ( ct == 'mru' && s:mrudef ) + \ || ( ct =~ '^\(buf\|mru\)$' && s:prompt == ['', '', ''] ) || !s:dosort endf fu! s:byfname() - retu s:itemtype != 1 && s:ispath && s:byfname + retu s:curtype() != 'buf' && s:ispath && s:byfname endf fu! s:narrowable() @@ -2374,13 +2407,17 @@ fu! s:buildpat(lst) retu pat endf +fu! s:curtype() + return s:CurTypeName()[1] +endf + fu! s:mfunc() let mfunc = 'match' if s:byfname() let mfunc = 's:matchfname' - elsei s:itemtype == 1 + elsei s:curtype() == 'buf' let mfunc = 's:matchbuf' - elsei s:itemtype > 2 + elsei s:itemtype >= len(s:coretypes) let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' } if has_key(matchtypes, s:matchtype) let mfunc = matchtypes[s:matchtype] @@ -2439,7 +2476,7 @@ fu! s:insertcache(str) endf " Extensions {{{2 fu! s:mtype() - retu s:itemtype > 2 ? s:getextvar('type') : 'path' + retu s:itemtype >= len(s:coretypes) ? s:getextvar('type') : 'path' endf fu! s:execextvar(key) @@ -2450,8 +2487,8 @@ fu! s:execextvar(key) endf fu! s:getextvar(key) - if s:itemtype > 2 - let vars = g:ctrlp_ext_vars[s:itemtype - 3] + if s:itemtype >= len(s:coretypes) && len(g:ctrlp_ext_vars) > 0 + let vars = g:ctrlp_ext_vars[s:itemtype - len(s:coretypes)] retu has_key(vars, a:key) ? vars[a:key] : -1 en retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1) @@ -2505,7 +2542,8 @@ endf fu! ctrlp#setlines(...) if a:0 | let s:itemtype = a:1 | en cal s:modevar() - let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()'] + let inits = {'fil': 'ctrlp#files()', 'buf': 'ctrlp#buffers()', 'mru': 'ctrlp#mrufiles#list()'} + let types = map(copy(g:ctrlp_types), 'inits[v:val]') if !empty(g:ctrlp_ext_vars) cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])') en @@ -2514,11 +2552,11 @@ endf " Returns [lname, sname] fu! s:CurTypeName() - if s:itemtype < 3 - return s:coretypes[s:itemtype] - else + if s:itemtype < len(s:coretypes) + return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0] + el return [s:getextvar("lname"), s:getextvar('sname')] - endif + en endfu fu! s:ExitIfSingleCandidate() @@ -2526,7 +2564,7 @@ fu! s:ExitIfSingleCandidate() call s:AcceptSelection('e') call ctrlp#exit() return 1 - endif + en return 0 endfu @@ -2539,14 +2577,27 @@ fu! ctrlp#init(type, ...) cal s:SetWD(a:0 ? a:1 : {}) cal s:MapNorms() cal s:MapSpecs() - cal ctrlp#setlines(s:settype(a:type)) + 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 + let type = index(g:ctrlp_types, a:type) + if type == -1 + call ctrlp#exit() + retu + en + en + cal ctrlp#setlines(s:settype(type)) cal ctrlp#syntax() cal s:SetDefTxt() let curName = s:CurTypeName() let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0 if shouldExitSingle && s:ExitIfSingleCandidate() return 0 - endif + en cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en return 1 @@ -2556,7 +2607,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 diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx index ac4fa3b6..c2d69729 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx @@ -885,7 +885,8 @@ MRU mode options:~ 在匹配窗口和提示符面板之间切换焦点。 , - + , + 退出CtrlP。 移动:~ diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt index bd4fc095..1107497b 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt @@ -68,6 +68,7 @@ Overview:~ |ctrlp_open_single_match|.....Automatically accept when only one candidate. |ctrlp_brief_prompt|..........Exit CtrlP on empty prompt by . |ctrlp_match_current_file|....Include current file in match entries. + |ctrlp_types|.................Names of builtin types. MRU mode: |ctrlp_mruf_max|..............Max MRU entries to remember. @@ -254,8 +255,9 @@ plugins look for .git/, .hg/,... some other plugins look for external *.exe tools on Windows). So be a little mindful of what you put in your |wildignore|. *'g:ctrlp_custom_ignore'* -In addition to |'wildignore'|, use this for files and directories you want only -CtrlP to not show. Use regexp to specify the patterns: > +In addition to |'wildignore'| and |g:ctrlp_show_hidden|, use this for files +and directories you want only CtrlP to not show. Use regexp to specify the +patterns: > let g:ctrlp_custom_ignore = '' < Examples: > @@ -454,13 +456,19 @@ This option works well together with |g:ctrlp_open_single_match| *'g:ctrlp_match_current_file'* -Includes the current file in the match entries: +Includes the current file in the match entries: > let g:ctrlp_match_current_file = 1 By default, the current file is excluded from the list. Note: does not apply when |g:ctrlp_match_func| is used. + *'g:ctrlp_types'* +Set this to list of names to customize core types: > + let g:ctrlp_types = ['mru', 'fil'] + +By default, the types are: > + let g:ctrlp_types = ['fil', 'buf', 'mru']. *'g:ctrlp_abbrev'* Define input abbreviations that can be expanded (either internally or visibly) @@ -853,7 +861,8 @@ COMMANDS *ctrlp-commands* Open CtrlP in find file mode. If no argument is given, the value of |g:ctrlp_working_path_mode| will be - used to determine the starting directory. + used to determine the starting directory. See |:CtrlPCurFile| and + |:CtrlPCurWD| to temporarily override the setting. You can use to auto-complete the [starting-directory] when typing it. @@ -861,6 +870,16 @@ COMMANDS *ctrlp-commands* :CtrlPBuffer Open CtrlP in find buffer mode. + *:CtrlPCurFile* +:CtrlPCurFile + This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = '' and ignores + the variable's current value. + + *:CtrlPCurWD* +:CtrlPCurWD + This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = '' and ignores + the variable's current value. + *:CtrlPMRU* :CtrlPMRU Open CtrlP in find Most-Recently-Used file mode. @@ -924,7 +943,8 @@ Once inside the prompt:~ Toggle the focus between the match window and the prompt. , - + , + Exit CtrlP. Moving:~ @@ -1322,7 +1342,8 @@ Available extensions:~ Buffer Tag mode options:~ *'g:ctrlp_buftag_ctags_bin'* -If ctags isn't in your $PATH, use this to set its location: > +If ctags isn't in your $PATH, or a ctags binary exists in either +/opt/local/bin or /usr/local/bin, us this to set its location: > let g:ctrlp_buftag_ctags_bin = '' < @@ -1476,6 +1497,28 @@ Special thanks:~ =============================================================================== CHANGELOG *ctrlp-changelog* +Before 2016/11/28~ + + + New command: |YankLine()| to yank current line. + + New option: |g:ctrlp_types| to select builtin modes. + + New feature: asynchronized spawn of |g:ctrlp_user_command|. This enable + with set |g:user_command_async| to 1. + + Support buffertag for delphi, rust and golang. + + New option: |g:ctrlp_brief_prompt|, + |g:match_current_file|, + |g:ctrlp_compare_lim|. + + New feature: Auto-ignore extension. + + Support buffertag for ant, tex, dosbatch, matlab and vhdl. + + New option |g:ctrlp_line_prefix| for integrating third party plugins. + + New option |g:open_single_match| to open single file in matches. + + Add (ctrlp) for launch CtrlP. + + Accept bang for CtrlPBookmarkDirAdd to avoid confirm. + + Handle variable like "g:ctrlp_TYPE_MODE". + ex: let g:ctrlp_path_sort + + New option: |g:ctrlp_custom_ancestors| + +Before 2014/08/08~ + + New buffer explorer mode with highlighting (|+conceal| recommended) + New options: |g:ctrlp_bufname_mod|, |g:ctrlp_bufpath_mod| diff --git a/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim b/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim index 5f5303f1..f31b64a2 100644 --- a/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/plugin/ctrlp.vim @@ -18,9 +18,9 @@ if !exists('g:ctrlp_map') | let g:ctrlp_map = '' | en if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': }) -com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': }) +com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init('mru', { 'dir': }) -com! -bar CtrlPBuffer cal ctrlp#init(1) +com! -bar CtrlPBuffer cal ctrlp#init('buf') com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': }) com! -bar CtrlPClearCache cal ctrlp#clr() @@ -29,9 +29,9 @@ com! -bar CtrlPClearAllCaches cal ctrlp#clra() com! -bar ClearCtrlPCache cal ctrlp#clr() com! -bar ClearAllCtrlPCaches cal ctrlp#clra() -com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' }) -com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' }) -com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' }) +com! -bar CtrlPCurWD cal ctrlp#init('fil', { 'mode': '' }) +com! -bar CtrlPCurFile cal ctrlp#init('fil', { 'mode': 'c' }) +com! -bar CtrlPRoot cal ctrlp#init('fil', { 'mode': 'r' }) exe 'nn (ctrlp) :'.g:ctrlp_cmd.'' @@ -55,10 +55,10 @@ com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) com! -n=? -com=buffer CtrlPLine - \ cal ctrlp#init(ctrlp#line#cmd(1, )) + \ cal ctrlp#init(ctrlp#line#cmd('buf', )) com! -n=? -com=buffer CtrlPChange - \ cal ctrlp#init(ctrlp#changes#cmd(0, )) + \ cal ctrlp#init(ctrlp#changes#cmd('fil', )) com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1)) com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id()) diff --git a/sources_non_forked/ctrlp.vim/readme.md b/sources_non_forked/ctrlp.vim/readme.md index 66fc9e8c..5412b6de 100644 --- a/sources_non_forked/ctrlp.vim/readme.md +++ b/sources_non_forked/ctrlp.vim/readme.md @@ -64,6 +64,10 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi If more than one mode is specified, they will be tried in order until a directory is located. +* If a file is already open, open it again in a new pane instead of switching to the existing pane + + `let g:ctrlp_switch_buffer = 'et'` + * Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`. If a custom listing command is being used, exclusions are ignored: ```vim diff --git a/sources_non_forked/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md index 03f5da1b..2b80f35b 100644 --- a/sources_non_forked/lightline.vim/README.md +++ b/sources_non_forked/lightline.vim/README.md @@ -272,7 +272,7 @@ set noshowmode ``` -Now, let us get back to the tutorial (with the patched font for vim-powerline). +Now, let's get back to the tutorial (with the patched font for vim-powerline). You look into a help file to find the marks annoying. ![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/6.png) @@ -293,8 +293,8 @@ let g:lightline = { ![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/7.png) Huh? Weird! -The components do not collapse even if they have no information! -In order to avoid this situation, you set expressions to `g:lightline.component_visible_condition`, which should become 1 only when the corresponding components have information. +The subseparators are visible even if the components are empty. +In order to hide the subseparators, you can set expressions to `g:lightline.component_visible_condition`, which should be 1 only when the corresponding component is not empty. ```vim let g:lightline = { \ 'colorscheme': 'wombat', @@ -313,8 +313,8 @@ let g:lightline = { ![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/8.png) Okay. It works nice. - - +The configuration `component_visible_condition` is used to control the visibility of the subseparators. +You cannot use this variable to control the visibility of the components themselves. How does lightline decide the components to show in the statusline? It's very simple. @@ -340,16 +340,9 @@ let g:lightline = { \ } ``` If the plugin arranges all the components (in a situation you `set paste` and the file `.vimrc` is read-only, try to modify): + ![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png) -The mode component, the paste component, read-only component, filename component and modified component in a row. -Normally, the paste component does not show up. -![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/10.png) - -If the file is not read-only (more common cases), the read-only component does not show up. -![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/11.png) - - Again look into `g:lightline.active.left`. ```vim let g:lightline = { @@ -357,8 +350,6 @@ let g:lightline = { \ 'left': [ [ 'mode', 'paste' ], \ [ 'readonly', 'filename', 'modified' ] ] ... ``` -And the screen shot of all the components. -![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png) The mode and paste component are displayed in the same group. The read-only, filename and modified component are in the second group. @@ -369,11 +360,11 @@ You can configure the components in the statusline by the following four variabl + `g:lightline.inactive.left` + `g:lightline.inactive.right` -Of course, your settings in `.vimrc` have priority over the default settings in lightline. +Of course, your configurations in `.vimrc` have priority over the default settings in lightline. -GitHub branch is important for us. +Git branch is important for us. And it is a default component in [powerline](https://github.com/Lokaltog/powerline) and [vim-powerline](https://github.com/Lokaltog/vim-powerline). However, lightline does not provide the branch feature by default. @@ -424,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 @@ -444,7 +435,7 @@ function! LightLineModified() endif endfunction -function! LightLineReadonly() +function! LightlineReadonly() if &filetype == "help" return "" elseif &readonly @@ -454,7 +445,7 @@ function! LightLineReadonly() endif endfunction -function! LightLineFugitive() +function! LightlineFugitive() return exists('*fugitive#head') ? fugitive#head() : '' endfunction ``` @@ -473,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 @@ -494,7 +485,7 @@ function! LightLineModified() endif endfunction -function! LightLineReadonly() +function! LightlineReadonly() if &filetype == "help" return "" elseif &readonly @@ -504,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 : '' @@ -537,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. @@ -552,7 +543,7 @@ subseparator.left | '\|' | '' (\ue0b1) | '⮁' (\u2b81) subseparator.right | '\|' | '' (\ue0b3) | '⮃' (\u2b83) branch symbol | -- | '' (\ue0a0) | '⭠' (\u2b60) readonly symbol | -- | '' (\ue0a2) | '⭤' (\u2b64) -linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b81) +linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b61) ### My settings I show my settings. I use the patched font for vim-powerline. @@ -564,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 : '' @@ -602,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 ``` @@ -649,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': { @@ -666,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 : @@ -682,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 @@ -699,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' : diff --git a/sources_non_forked/lightline.vim/autoload/lightline.vim b/sources_non_forked/lightline.vim/autoload/lightline.vim index 045e2b85..6bcc09b4 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2016/06/12 22:40:00. +" Last Change: 2016/12/03 12:08:08. " ============================================================================= let s:save_cpo = &cpo @@ -111,6 +111,7 @@ let s:_lightline = { \ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell' \ }, \ 'component_function': {}, + \ 'component_function_visible_condition': {}, \ 'component_expand': { \ 'tabs': 'lightline#tabs' \ }, @@ -155,7 +156,7 @@ function! lightline#init() abort endfor call extend(s:lightline.tabline_separator, s:lightline.separator, 'keep') call extend(s:lightline.tabline_subseparator, s:lightline.subseparator, 'keep') - let s:lightline.tabline_configured = 0 + let s:lightline.tabline_configured = has_key(get(get(g:, 'lightline', {}), 'component_expand', {}), 'tabs') for components in deepcopy(s:lightline.tabline.left + s:lightline.tabline.right) if len(filter(components, 'v:val !=# "tabs" && v:val !=# "close"')) > 0 let s:lightline.tabline_configured = 1 @@ -190,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) @@ -203,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 @@ -228,16 +229,16 @@ function! lightline#link(...) abort for [p, l] in [['Left', len(s:lightline.active.left)], ['Right', len(s:lightline.active.right)]] for [i, t] in map(range(0, l), '[v:val, 0]') + types if i != l - exec printf('hi link LightLine%s_active_%s LightLine%s_%s_%s', p, i, p, mode, i) + exec printf('hi link Lightline%s_active_%s Lightline%s_%s_%s', p, i, p, mode, i) endif for [j, s] in map(range(0, l), '[v:val, 0]') + types if i + 1 == j || t || s && i != l - exec printf('hi link LightLine%s_active_%s_%s LightLine%s_%s_%s_%s', p, i, j, p, mode, i, j) + exec printf('hi link Lightline%s_active_%s_%s Lightline%s_%s_%s_%s', p, i, j, p, mode, i, j) endif endfor endfor endfor - exec printf('hi link LightLineMiddle_active LightLineMiddle_%s', mode) + exec printf('hi link LightlineMiddle_active LightlineMiddle_%s', mode) return '' endfunction @@ -278,26 +279,26 @@ function! lightline#highlight(...) abort for [i, t] in map(range(0, l), '[v:val, 0]') + types if i < l || i < 1 let r = t ? (has_key(get(c, d, []), i) ? c[d][i][0] : has_key(get(c, 'tabline', {}), i) ? c.tabline[i][0] : get(c.normal, i, zs)[0]) : get(zs, i, ms) - exec printf('hi LightLine%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', p, mode, i, r[0], r[1], r[2], r[3], s:term(r)) + exec printf('hi Lightline%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', p, mode, i, r[0], r[1], r[2], r[3], s:term(r)) endif for [j, s] in map(range(0, l), '[v:val, 0]') + types if i + 1 == j || t || s && i != l let q = s ? (has_key(get(c, d, []), j) ? c[d][j][0] : has_key(get(c, 'tabline', {}), j) ? c.tabline[j][0] : get(c.normal, j, zs)[0]) : (j != l ? get(zs, j, ms) :ms) - exec printf('hi LightLine%s_%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s', p, mode, i, j, r[1], q[1], r[3], q[3]) + exec printf('hi Lightline%s_%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s', p, mode, i, j, r[1], q[1], r[3], q[3]) endif endfor endfor endfor - exec printf('hi LightLineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms)) + exec printf('hi LightlineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms)) endfor endfunction function! s:subseparator(components, subseparator, expanded) abort - let [a, c, f, v] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition ] + let [a, c, f, v, u ] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition, s:lightline.component_function_visible_condition ] let xs = map(range(len(a:components)), 'a:expanded[v:val] ? "1" : - \ has_key(f, a[v:val]) ? (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"" : - \ has_key(v, a[v:val]) ? "(" . v[a[v:val]] . ")" : has_key(c, a[v:val]) ? "1" : "0"') - return '%{' . (xs[0] ==# '1' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' ? '' : ')') . '?"' . a:subseparator . '":""}' + \ has_key(f, a[v:val]) ? (has_key(u, a[v:val]) ? "(".u[a[v:val]].")" : (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"") : + \ has_key(v, a[v:val]) ? "(".v[a[v:val]].")" : has_key(c, a[v:val]) ? "1" : "0"') + return '%{' . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : ')') . '?"' . a:subseparator . '":""}' endfunction function! lightline#concatenate(xs, right) abort @@ -324,7 +325,7 @@ endfunction function! s:evaluate_expand(component) abort try - let result = call(a:component, []) + let result = eval(a:component . '()') if type(result) == 1 && result ==# '' return [] endif @@ -399,7 +400,7 @@ function! s:line(tabline, inactive) abort let r_ = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right let [rt, rc, rl] = s:expand(copy(r_)) for i in range(len(lt)) - let _ .= '%#LightLineLeft_' . mode . '_' . ll[i] . '#' + let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '#' for j in range(len(lt[i])) let x = lc[i][j] ? lt[i][j] : has_key(f, lt[i][j]) ? (exists('*' . f[lt[i][j]]) ? '%{' . f[lt[i][j]] . '()}' : '%{exists("*' . f[lt[i][j]] . '")?' . f[lt[i][j]] . '():""}') : get(c, lt[i][j], '') let _ .= has_key(t, lt[i][j]) && t[lt[i][j]] ==# 'raw' || x ==# '' ? x : '%( ' . x . ' %)' @@ -407,14 +408,14 @@ function! s:line(tabline, inactive) abort let _ .= s:subseparator(lt[i][(j):], s.left, lc[i][(j):]) endif endfor - let _ .= '%#LightLineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#' + let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#' let _ .= i < l + len(lt) - len(l_) && ll[i] < l || ll[i] != ll[i + 1] ? p.left : len(lt[i]) ? s.left : '' endfor - let _ .= '%#LightLineMiddle_' . mode . '#%=' + let _ .= '%#LightlineMiddle_' . mode . '#%=' for i in reverse(range(len(rt))) - let _ .= '%#LightLineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#' + let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#' let _ .= i < r + len(rt) - len(r_) && rl[i] < r || rl[i] != rl[i + 1] ? p.right : len(rt[i]) ? s.right : '' - let _ .= '%#LightLineRight_' . mode . '_' . rl[i] . '#' + let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '#' for j in range(len(rt[i])) let x = rc[i][j] ? rt[i][j] : has_key(f, rt[i][j]) ? (exists('*' . f[rt[i][j]]) ? '%{' . f[rt[i][j]] . '()}' : '%{exists("*' . f[rt[i][j]] . '")?' . f[rt[i][j]] . '():""}') : get(c, rt[i][j], '') let _ .= has_key(t, rt[i][j]) && t[rt[i][j]] ==# 'raw' || x ==# '' ? x : '%( ' . x . ' %)' diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Dracula.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Dracula.vim new file mode 100644 index 00000000..42f83f69 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Dracula.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim new file mode 100644 index 00000000..9d066a1b --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim @@ -0,0 +1,36 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/molokai.vim +" Author: challsted +" License: MIT License +" Last Change: 2016/11/17 00:27:58. +" ============================================================================= +" +let s:black = [ '#232526', 233 ] +let s:gray = [ '#808080', 244 ] +let s:white = [ '#f8f8f2', 234 ] +let s:cyan = [ '#66d9ef', 81 ] +let s:green = [ '#a6e22e', 118 ] +let s:orange = [ '#ef5939', 166 ] +let s:pink = [ '#f92672', 161 ] +let s:red = [ '#ff0000', 160 ] +let s:yellow = [ '#e6db74', 229 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ s:black, s:cyan ], [ s:orange, s:black ] ] +let s:p.normal.middle = [ [ s:orange, s:black ] ] +let s:p.normal.right = [ [ s:pink, s:black ], [ s:black, s:pink ] ] +let s:p.normal.error = [ [ s:pink, s:black ] ] +let s:p.normal.warning = [ [ s:yellow, s:black ] ] +let s:p.insert.left = [ [ s:black, s:green ], [ s:green, s:black ] ] +let s:p.visual.left = [ [ s:black, s:yellow ], [ s:yellow, s:black ] ] +let s:p.replace.left = [ [ s:black, s:red ], [ s:red, s:black ] ] +let s:p.inactive.left = [ [ s:pink, s:black ], [ s:white, s:black ] ] +let s:p.inactive.middle = [ [ s:gray, s:black ] ] +let s:p.inactive.right = [ [ s:white, s:pink ], [ s:pink, s:black ] ] +let s:p.tabline.left = [ [ s:pink, s:black ] ] +let s:p.tabline.middle = [ [ s:pink, s:black] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.tabsel = [ [ s:black, s:pink ] ] + +let g:lightline#colorscheme#molokai#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim new file mode 100644 index 00000000..f50de8c1 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim @@ -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) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim index 2695c357..577177e2 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim @@ -2,10 +2,79 @@ " Filename: autoload/lightline/colorscheme/solarized.vim " Author: itchyny " License: MIT License -" Last Change: 2013/08/27 10:24:28. +" Last Change: 2016/08/08 10:31:00. " ============================================================================= -if &background ==# 'light' - let g:lightline#colorscheme#solarized#palette = g:lightline#colorscheme#solarized_light#palette + +let s:cuicolors = { + \ 'base03': [ '8', '234', 'DarkGray' ], + \ 'base02': [ '0', '235', 'Black' ], + \ 'base01': [ '10', '239', 'LightGreen' ], + \ 'base00': [ '11', '240', 'LightYellow' ], + \ 'base0': [ '12', '244', 'LightBlue' ], + \ 'base1': [ '14', '245', 'LightCyan' ], + \ 'base2': [ '7', '187', 'LightGray' ], + \ 'base3': [ '15', '230', 'White' ], + \ 'yellow': [ '3', '136', 'DarkYellow' ], + \ 'orange': [ '9', '166', 'LightRed' ], + \ 'red': [ '1', '124', 'DarkRed' ], + \ 'magenta': [ '5', '125', 'DarkMagenta' ], + \ 'violet': [ '13', '61', 'LightMagenta' ], + \ 'blue': [ '4', '33', 'DarkBlue' ], + \ 'cyan': [ '6', '37', 'DarkCyan' ], + \ 'green': [ '2', '64', 'DarkGreen' ], + \ } + +" The following condition only applies for the console and is the same +" condition vim-colors-solarized uses to determine which set of colors +" to use. +let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256) +if s:solarized_termcolors != 256 && &t_Co >= 16 + let s:cuiindex = 0 +elseif s:solarized_termcolors == 256 + let s:cuiindex = 1 else - let g:lightline#colorscheme#solarized#palette = g:lightline#colorscheme#solarized_dark#palette + let s:cuiindex = 2 endif + +let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ] +let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ] +let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ] +let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ] +let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ] +let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ] +let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ] +let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ] +let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ] +let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ] +let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ] +let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ] +let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ] +let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ] +let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ] +let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ] + +if &background ==# 'light' + let [ s:base03, s:base3 ] = [ s:base3, s:base03 ] + let [ s:base02, s:base2 ] = [ s:base2, s:base02 ] + let [ s:base01, s:base1 ] = [ s:base1, s:base01 ] + let [ s:base00, s:base0 ] = [ s:base0, s:base00 ] +endif + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base03, s:blue ], [ s:base03, s:base00 ] ] +let s:p.normal.right = [ [ s:base03, s:base1 ], [ s:base03, s:base00 ] ] +let s:p.inactive.right = [ [ s:base03, s:base00 ], [ s:base0, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base0, s:base02 ] ] +let s:p.insert.left = [ [ s:base03, s:green ], [ s:base03, s:base00 ] ] +let s:p.replace.left = [ [ s:base03, s:red ], [ s:base03, s:base00 ] ] +let s:p.visual.left = [ [ s:base03, s:magenta ], [ s:base03, s:base00 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base01, s:base02 ] ] +let s:p.tabline.left = [ [ s:base03, s:base00 ] ] +let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ] +let s:p.tabline.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base03, s:yellow ] ] + +let g:lightline#colorscheme#solarized#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized_dark.vim deleted file mode 100644 index 37a3dc7e..00000000 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized_dark.vim +++ /dev/null @@ -1,73 +0,0 @@ -" ============================================================================= -" Filename: autoload/lightline/colorscheme/solarized_dark.vim -" Author: itchyny -" License: MIT License -" Last Change: 2014/05/31 01:04:15. -" ============================================================================= - -let s:cuicolors = { - \ 'base03': [ '8', '234', 'DarkGray' ], - \ 'base02': [ '0', '235', 'Black' ], - \ 'base01': [ '10', '239', 'LightGreen' ], - \ 'base00': [ '11', '240', 'LightYellow' ], - \ 'base0': [ '12', '244', 'LightBlue' ], - \ 'base1': [ '14', '245', 'LightCyan' ], - \ 'base2': [ '7', '187', 'LightGray' ], - \ 'base3': [ '15', '230', 'White' ], - \ 'yellow': [ '3', '136', 'DarkYellow' ], - \ 'orange': [ '9', '166', 'LightRed' ], - \ 'red': [ '1', '124', 'DarkRed' ], - \ 'magenta': [ '5', '125', 'DarkMagenta' ], - \ 'violet': [ '13', '61', 'LightMagenta' ], - \ 'blue': [ '4', '33', 'DarkBlue' ], - \ 'cyan': [ '6', '37', 'DarkCyan' ], - \ 'green': [ '2', '64', 'DarkGreen' ], - \ } - -" The following condition only applies for the console and is the same -" condition vim-colors-solarized uses to determine which set of colors -" to use. -let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256) -if s:solarized_termcolors != 256 && &t_Co >= 16 - let s:cuiindex = 0 -elseif s:solarized_termcolors == 256 - let s:cuiindex = 1 -else - let s:cuiindex = 2 -endif - -let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ] -let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ] -let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ] -let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ] -let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ] -let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ] -let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ] -let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ] -let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ] -let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ] -let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ] -let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ] -let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ] -let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ] -let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ] -let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ] - -let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ] -let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] -let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ] -let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] -let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ] -let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ] -let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ] -let s:p.normal.middle = [ [ s:base1, s:base02 ] ] -let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.left = [ [ s:base1, s:base00 ] ] -let s:p.tabline.tabsel = [ [ s:base3, s:base0 ] ] -let s:p.tabline.middle = [ [ s:base01, s:base02 ] ] -let s:p.tabline.right = copy(s:p.normal.right) -let s:p.normal.error = [ [ s:base2, s:red ] ] -let s:p.normal.warning = [ [ s:base02, s:yellow ] ] - -let g:lightline#colorscheme#solarized_dark#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized_light.vim deleted file mode 100644 index 99046afb..00000000 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized_light.vim +++ /dev/null @@ -1,80 +0,0 @@ -" ============================================================================= -" Filename: autoload/lightline/colorscheme/solarized_light.vim -" Author: itchyny -" License: MIT License -" Last Change: 2014/05/31 01:04:21. -" ============================================================================= - -let s:cuicolors = { - \ 'base03': [ '8', '234', 'DarkGray' ], - \ 'base02': [ '0', '235', 'Black' ], - \ 'base01': [ '10', '239', 'LightGreen' ], - \ 'base00': [ '11', '240', 'LightYellow' ], - \ 'base0': [ '12', '244', 'LightBlue' ], - \ 'base1': [ '14', '245', 'LightCyan' ], - \ 'base2': [ '7', '187', 'LightGray' ], - \ 'base3': [ '15', '230', 'White' ], - \ 'yellow': [ '3', '136', 'DarkYellow' ], - \ 'orange': [ '9', '166', 'LightRed' ], - \ 'red': [ '1', '124', 'DarkRed' ], - \ 'magenta': [ '5', '125', 'DarkMagenta' ], - \ 'violet': [ '13', '61', 'LightMagenta' ], - \ 'blue': [ '4', '33', 'DarkBlue' ], - \ 'cyan': [ '6', '37', 'DarkCyan' ], - \ 'green': [ '2', '64', 'DarkGreen' ], - \ } - -" The following condition only applies for the console and is the same -" condition vim-colors-solarized uses to determine which set of colors -" to use. -let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256) -if s:solarized_termcolors != 256 && &t_Co >= 16 - let s:cuiindex = 0 -elseif s:solarized_termcolors == 256 - let s:cuiindex = 1 -else - let s:cuiindex = 2 -endif - -let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ] -let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ] -let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ] -let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ] -let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ] -let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ] -let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ] -let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ] -let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ] -let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ] -let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ] -let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ] -let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ] -let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ] -let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ] -let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ] - -let [s:base03, s:base3] = [s:base3, s:base03] -let [s:base02, s:base2] = [s:base2, s:base02] -let [s:base01, s:base1] = [s:base1, s:base01] -let [s:base00, s:base0] = [s:base0, s:base00] - -let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ] -let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] -let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ] -let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] -let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ] -let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ] -let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ] -let s:p.normal.middle = [ [ s:base1, s:base02 ] ] -let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.left = [ [ s:base2, s:base01 ] ] -let s:p.tabline.tabsel = [ [ s:base2, s:base03 ] ] -let s:p.tabline.middle = [ [ s:base1, s:base02 ] ] -let s:p.tabline.right = copy(s:p.normal.right) -let s:p.normal.error = [ [ s:red, s:base01 ] ] -let s:p.normal.warning = [ [ s:yellow, s:base01 ] ] -let s:p.normal.error = [ [ s:base02, s:red ] ] -let s:p.normal.warning = [ [ s:base2, s:yellow ] ] - -let g:lightline#colorscheme#solarized_light#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/doc/lightline.txt b/sources_non_forked/lightline.vim/doc/lightline.txt index 99367251..8b0a580d 100644 --- a/sources_non_forked/lightline.vim/doc/lightline.txt +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -1,10 +1,10 @@ *lightline.txt* A light and configurable statusline/tabline for Vim -Version: 0.0 +Version: 0.1 Author: itchyny (https://github.com/itchyny) License: MIT License Repository: https://github.com/itchyny/lightline.vim -Last Change: 2016/05/26 21:57:34. +Last Change: 2016/10/24 08:12:28. CONTENTS *lightline-contents* @@ -19,7 +19,6 @@ Examples |lightline-examples| Nice Examples |lightline-nice-examples| Powerful Example |lightline-powerful-example| Troubleshooting |lightline-troubleshooting| -Changelog |lightline-changelog| ============================================================================== INTRODUCTION *lightline-introduction* @@ -115,10 +114,13 @@ OPTIONS *lightline-option* \ 'column': '%c' \ 'close': '%999X X ' } < - g:lightline.component_visible_condition *g:lightline.component_visible_condition* - Dictionary of boolean expressions for the components. + g:lightline.component_visible_condition + *g:lightline.component_visible_condition* + Dictionary to store the visible condition of the components. Each expression should correspond to the condition each - component have non-zero length. + component is not empty. This configuration is used to control + the visibility of the subseparators. You cannot use this + configuration to control the visibility of the components. The default value is: > let g:lightline.component_visible_condition = { @@ -135,6 +137,11 @@ OPTIONS *lightline-option* because the user does not have to set both component and component_visible_condition. If a component set to both component and component_function, the setting of component_function has priority. + + The default value is: +> + let g:lightline.component_function = {} +< For example, if you want a component for read-only mark, which disappears in help windows: > @@ -144,12 +151,25 @@ OPTIONS *lightline-option* \ [ 'myreadonly', 'filename', 'modified' ] ], \ }, \ 'component_function': { - \ 'myreadonly': 'LightLineReadonly' + \ 'myreadonly': 'LightlineReadonly' \ }, \ } - function! LightLineReadonly() + function! LightlineReadonly() return &ft !~? 'help' && &readonly ? 'RO' : '' endfunction +< + g:lightline.component_function_visible_condition + *g:lightline.component_function_visible_condition* + Dictionary to store the visible conditions of the function + components. Each expression should correspond to the condition + each component is not empty. This configuration is used to + control the visibility of the subseparators. You can use this + configuration to reduce the number of function calls for + function components by setting the value 1 (to tell lightline + that the component is always visible). + The default value is: +> + let g:lightline.component_function_visible_condition = {} < g:lightline.component_expand *g:lightline.component_expand* Another dictionary for components. You can create a component @@ -203,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, Molokai and 16color are available. The default value is: > let g:lightline.colorscheme = 'default' @@ -279,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 : '' @@ -304,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 : '' @@ -616,6 +636,16 @@ compiled version of your colorscheme. < Then copy and paste the result to the colorscheme file. +If you want to contribute a new colorscheme that is not currently available +please follow the following rules: + *) All hex codes should be lowercase only + *) Use 2 space soft tabs + *) If your colorscheme has both light and dark variants, use a single file + *) Normal Mode should default to Cyan + *) Insert Mode should default to Green + *) Visual Mode should default to Yellow + *) Replace Mode should default to Red + ============================================================================== EXAMPLES *lightline-examples* You can configure the appearance of statusline. @@ -635,22 +665,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 < @@ -690,25 +720,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 @@ -723,27 +753,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 : '' @@ -764,12 +794,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': { @@ -781,15 +811,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 : @@ -797,12 +827,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 @@ -814,19 +844,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' : @@ -1126,7 +1156,7 @@ Problem 9: *lightline-problem-9* subseparator.right '|' '' (\ue0b3) '⮃' (\u2b83) branch symbol -- '' (\ue0a0) '⭠' (\u2b60) readonly symbol -- '' (\ue0a2) '⭤' (\u2b64) - linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b81) + linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b61) Problem 10: *lightline-problem-10* Cool statusline disappears on |unite|, |vimfiler| and |vimshell| @@ -1169,10 +1199,10 @@ Problem 12: *lightline-problem-12* > let g:lightline = { \ 'component': { - \ 'modified': '%#ModifiedColor#%{LightLineModified()}', + \ 'modified': '%#ModifiedColor#%{LightlineModified()}', \ } \ } - function! LightLineModified() + function! LightlineModified() let map = { 'V': 'n', "\": 'n', 's': 'n', 'v': 'n', "\": 'n', 'c': 'n', 'R': 'n'} let mode = get(map, mode()[0], mode()[0]) let bgcolor = {'n': [240, '#585858'], 'i': [31, '#0087af']} @@ -1191,7 +1221,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 @@ -1202,8 +1232,7 @@ Problem 13: *lightline-problem-13* try if g:colors_name =~# 'wombat\|solarized\|landscape\|jellybeans\|seoul256\|Tomorrow' let g:lightline.colorscheme = - \ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '') . - \ (g:colors_name ==# 'solarized' ? '_' . &background : '') + \ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '') call lightline#init() call lightline#colorscheme() call lightline#update() @@ -1271,11 +1300,5 @@ Problem 17: *lightline-problem-17* Report/Request the issue/feature at https://github.com/itchyny/lightline.vim/issues. -============================================================================== -CHANGELOG *lightline-changelog* - -0.0 2013-08-21, ... - - Initial commit and implementation - ============================================================================== vim:tw=78:sw=4:ts=8:ft=help:norl:noet: diff --git a/sources_non_forked/lightline.vim/test/expand.vim b/sources_non_forked/lightline.vim/test/expand.vim index c2fc0ab9..37804eed 100644 --- a/sources_non_forked/lightline.vim/test/expand.vim +++ b/sources_non_forked/lightline.vim/test/expand.vim @@ -610,3 +610,15 @@ function! s:suite.duplicated_type_both_nil_right_most() \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '1']]) delfunction Custom endfunction + +function! s:suite.dictionary_function() + let g:lightline = { 'component_expand': { 'custom': 'g:lightline.Custom' } } + function! g:lightline.Custom() + return [ ['left'], ['middle'], ['right'] ] + endfunction + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']]) +endfunction diff --git a/sources_non_forked/lightline.vim/test/highlight.vim b/sources_non_forked/lightline.vim/test/highlight.vim index fe5182a3..0e9e6566 100644 --- a/sources_non_forked/lightline.vim/test/highlight.vim +++ b/sources_non_forked/lightline.vim/test/highlight.vim @@ -23,14 +23,14 @@ function! s:suite.highlight() call lightline#init() call lightline#colorscheme() let palette = lightline#palette() - call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0])) - call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1])) - call s:assert.match(s:hi('LightLineLeft_normal_2'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0])) - call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1])) - call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2])) - call s:assert.match(s:hi('LightLineRight_normal_3'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) + call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1])) + call s:assert.match(s:hi('LightlineLeft_normal_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1])) + call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2])) + call s:assert.match(s:hi('LightlineRight_normal_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction function! s:suite.insert() @@ -39,14 +39,14 @@ function! s:suite.insert() call lightline#colorscheme() call lightline#highlight('insert') let palette = lightline#palette() - call s:assert.match(s:hi('LightLineLeft_insert_0'), s:pattern(palette.insert.left[0])) - call s:assert.match(s:hi('LightLineLeft_insert_1'), s:pattern(palette.insert.left[1])) - call s:assert.match(s:hi('LightLineLeft_insert_2'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineRight_insert_0'), s:pattern(palette.insert.right[0])) - call s:assert.match(s:hi('LightLineRight_insert_1'), s:pattern(palette.insert.right[1])) - call s:assert.match(s:hi('LightLineRight_insert_2'), s:pattern(palette.insert.right[2])) - call s:assert.match(s:hi('LightLineRight_insert_3'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineMiddle_insert'), s:pattern(palette.insert.middle[0])) + call s:assert.match(s:hi('LightlineLeft_insert_0'), s:pattern(palette.insert.left[0])) + call s:assert.match(s:hi('LightlineLeft_insert_1'), s:pattern(palette.insert.left[1])) + call s:assert.match(s:hi('LightlineLeft_insert_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_insert_0'), s:pattern(palette.insert.right[0])) + call s:assert.match(s:hi('LightlineRight_insert_1'), s:pattern(palette.insert.right[1])) + call s:assert.match(s:hi('LightlineRight_insert_2'), s:pattern(palette.insert.right[2])) + call s:assert.match(s:hi('LightlineRight_insert_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_insert'), s:pattern(palette.insert.middle[0])) endfunction @@ -56,14 +56,14 @@ function! s:suite.visual() call lightline#colorscheme() call lightline#highlight('visual') let palette = lightline#palette() - call s:assert.match(s:hi('LightLineLeft_visual_0'), s:pattern(palette.visual.left[0])) - call s:assert.match(s:hi('LightLineLeft_visual_1'), s:pattern(palette.visual.left[1])) - call s:assert.match(s:hi('LightLineLeft_visual_2'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineRight_visual_0'), s:pattern(palette.normal.right[0])) - call s:assert.match(s:hi('LightLineRight_visual_1'), s:pattern(palette.normal.right[1])) - call s:assert.match(s:hi('LightLineRight_visual_2'), s:pattern(palette.normal.right[2])) - call s:assert.match(s:hi('LightLineRight_visual_3'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_visual_0'), s:pattern(palette.visual.left[0])) + call s:assert.match(s:hi('LightlineLeft_visual_1'), s:pattern(palette.visual.left[1])) + call s:assert.match(s:hi('LightlineLeft_visual_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_visual_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_visual_1'), s:pattern(palette.normal.right[1])) + call s:assert.match(s:hi('LightlineRight_visual_2'), s:pattern(palette.normal.right[2])) + call s:assert.match(s:hi('LightlineRight_visual_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction function! s:suite.replace() @@ -72,14 +72,14 @@ function! s:suite.replace() call lightline#colorscheme() call lightline#highlight('replace') let palette = lightline#palette() - call s:assert.match(s:hi('LightLineLeft_replace_0'), s:pattern(palette.replace.left[0])) - call s:assert.match(s:hi('LightLineLeft_replace_1'), s:pattern(palette.replace.left[1])) - call s:assert.match(s:hi('LightLineLeft_replace_2'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineRight_replace_0'), s:pattern(palette.replace.right[0])) - call s:assert.match(s:hi('LightLineRight_replace_1'), s:pattern(palette.replace.right[1])) - call s:assert.match(s:hi('LightLineRight_replace_2'), s:pattern(palette.replace.right[2])) - call s:assert.match(s:hi('LightLineRight_replace_3'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineMiddle_replace'), s:pattern(palette.replace.middle[0])) + call s:assert.match(s:hi('LightlineLeft_replace_0'), s:pattern(palette.replace.left[0])) + call s:assert.match(s:hi('LightlineLeft_replace_1'), s:pattern(palette.replace.left[1])) + call s:assert.match(s:hi('LightlineLeft_replace_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_replace_0'), s:pattern(palette.replace.right[0])) + call s:assert.match(s:hi('LightlineRight_replace_1'), s:pattern(palette.replace.right[1])) + call s:assert.match(s:hi('LightlineRight_replace_2'), s:pattern(palette.replace.right[2])) + call s:assert.match(s:hi('LightlineRight_replace_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_replace'), s:pattern(palette.replace.middle[0])) endfunction function! s:suite.left_right() @@ -92,18 +92,18 @@ function! s:suite.left_right() call lightline#init() call lightline#colorscheme() let palette = lightline#palette() - call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0])) - call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1])) - call s:assert.match(s:hi('LightLineLeft_normal_2'), s:pattern(palette.normal.middle[0])) - call s:assert.match(s:hi('LightLineLeft_normal_3'), s:pattern(palette.normal.middle[0])) - call s:assert.match(s:hi('LightLineLeft_normal_4'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0])) - call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1])) - call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2])) - call s:assert.match(s:hi('LightLineRight_normal_3'), s:pattern(palette.normal.middle[0])) - call s:assert.match(s:hi('LightLineRight_normal_4'), s:pattern(palette.normal.middle[0])) - call s:assert.match(s:hi('LightLineRight_normal_5'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) + call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1])) + call s:assert.match(s:hi('LightlineLeft_normal_2'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_3'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_4'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1])) + call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2])) + call s:assert.match(s:hi('LightlineRight_normal_3'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineRight_normal_4'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineRight_normal_5'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction function! s:suite.no_components() @@ -120,11 +120,11 @@ function! s:suite.no_components() call lightline#init() call lightline#colorscheme() let palette = lightline#palette() - call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0])) - call s:assert.match(s:hi('LightLineLeft_normal_1'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0])) - call s:assert.match(s:hi('LightLineRight_normal_1'), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) + call s:assert.match(s:hi('LightlineLeft_normal_1'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_normal_1'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) endfunction function! s:suite.subseparator() @@ -140,9 +140,9 @@ function! s:suite.subseparator() for i in range(4) for j in range(5) if i + 1 == j - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0]))) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0]))) else - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared') endif endfor endfor @@ -154,18 +154,18 @@ function! s:suite.component_type() call lightline#colorscheme() let palette = lightline#palette() for type in ['error', 'warning'] - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s', type)), s:pattern(palette.normal[type][0])) - call s:assert.match(s:hi(printf('LightLineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0])) - call s:assert.match(s:hi(printf('LightLineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0])) - call s:assert.match(s:hi(printf('LightLineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared') - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0])) - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1])) - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0])) - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s', type)), s:pattern(palette.normal[type][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared') endfor for type1 in ['error', 'warning'] for type2 in ['error', 'warning'] - call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0])) endfor endfor endfunction diff --git a/sources_non_forked/lightline.vim/test/link.vim b/sources_non_forked/lightline.vim/test/link.vim index ca867536..c0811c42 100644 --- a/sources_non_forked/lightline.vim/test/link.vim +++ b/sources_non_forked/lightline.vim/test/link.vim @@ -17,50 +17,50 @@ endfunction function! s:suite.link() call lightline#link() - call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_normal_0') - call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_normal_1') - call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_normal_0') - call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_normal_1') - call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_normal_2') - call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_normal') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') endfunction function! s:suite.insert() call lightline#link('i') - call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_insert_0') - call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_insert_1') - call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_insert_0') - call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_insert_1') - call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_insert_2') - call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_insert') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_insert_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_insert_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_insert_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_insert_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_insert_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_insert') endfunction function! s:suite.visual() call lightline#link('v') - call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_visual_0') - call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_visual_1') - call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_visual_0') - call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_visual_1') - call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_visual_2') - call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_visual') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_visual_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_visual_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_visual_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_visual_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_visual_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_visual') endfunction function! s:suite.replace() call lightline#link('R') - call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_replace_0') - call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_replace_1') - call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_replace_0') - call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_replace_1') - call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_replace_2') - call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_replace') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_replace_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_replace_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_replace_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_replace_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_replace_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_replace') endfunction function! s:suite.left_right() @@ -73,18 +73,18 @@ function! s:suite.left_right() call lightline#init() call lightline#colorscheme() call lightline#link() - call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_normal_0') - call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_normal_1') - call s:assert.match(s:hi('LightLineLeft_active_2'), 'LightLineLeft_normal_2') - call s:assert.match(s:hi('LightLineLeft_active_3'), 'LightLineLeft_normal_3') - call s:assert.match(s:hi('LightLineLeft_active_4'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_normal_0') - call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_normal_1') - call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_normal_2') - call s:assert.match(s:hi('LightLineRight_active_3'), 'LightLineRight_normal_3') - call s:assert.match(s:hi('LightLineRight_active_4'), 'LightLineRight_normal_4') - call s:assert.match(s:hi('LightLineRight_active_5'), 'E411: highlight group not found') - call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_normal') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'LightlineLeft_normal_2') + call s:assert.match(s:hi('LightlineLeft_active_3'), 'LightlineLeft_normal_3') + call s:assert.match(s:hi('LightlineLeft_active_4'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'LightlineRight_normal_3') + call s:assert.match(s:hi('LightlineRight_active_4'), 'LightlineRight_normal_4') + call s:assert.match(s:hi('LightlineRight_active_5'), 'E411: highlight group not found') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') endfunction function! s:suite.subseparator() @@ -100,9 +100,9 @@ function! s:suite.subseparator() for i in range(4) for j in range(5) if i + 1 == j - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', i, j)), printf('LightLineLeft_normal_%s_%s', i, j)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), printf('LightlineLeft_normal_%s_%s', i, j)) else - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', i, j)), 'E411: highlight group not found') + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), 'E411: highlight group not found') endif endfor endfor @@ -114,18 +114,18 @@ function! s:suite.component_type() call lightline#colorscheme() call lightline#link() for type in ['error', 'warning'] - call s:assert.match(s:hi(printf('LightLineLeft_active_%s', type)), printf('LightLineLeft_normal_%s', type)) - call s:assert.match(s:hi(printf('LightLineLeft_active_0_%s', type)), printf('LightLineLeft_normal_0_%s', type)) - call s:assert.match(s:hi(printf('LightLineLeft_active_1_%s', type)), printf('LightLineLeft_normal_1_%s', type)) - call s:assert.match(s:hi(printf('LightLineLeft_active_2_%s', type)), 'E411: highlight group not found') - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_0', type)), printf('LightLineLeft_normal_%s_0', type)) - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_1', type)), printf('LightLineLeft_normal_%s_1', type)) - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_2', type)), printf('LightLineLeft_normal_%s_2', type)) - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_3', type)), 'E411: highlight group not found') + call s:assert.match(s:hi(printf('LightlineLeft_active_%s', type)), printf('LightlineLeft_normal_%s', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_0_%s', type)), printf('LightlineLeft_normal_0_%s', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_1_%s', type)), printf('LightlineLeft_normal_1_%s', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_2_%s', type)), 'E411: highlight group not found') + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_0', type)), printf('LightlineLeft_normal_%s_0', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_1', type)), printf('LightlineLeft_normal_%s_1', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_2', type)), printf('LightlineLeft_normal_%s_2', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_3', type)), 'E411: highlight group not found') endfor for type1 in ['error', 'warning'] for type2 in ['error', 'warning'] - call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', type1, type2)), printf('LightLineLeft_normal_%s_%s', type1, type2)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', type1, type2)), printf('LightlineLeft_normal_%s_%s', type1, type2)) endfor endfor endfunction diff --git a/sources_non_forked/lightline.vim/test/subseparator.vim b/sources_non_forked/lightline.vim/test/subseparator.vim index 02cac4cc..2393840d 100644 --- a/sources_non_forked/lightline.vim/test/subseparator.vim +++ b/sources_non_forked/lightline.vim/test/subseparator.vim @@ -177,6 +177,111 @@ function! s:suite.subseparator_component_function_7() delfunction Custom3 endfunction +function! s:suite.subseparator_component_function_visible_condition_1() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_2() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0', 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_3() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_4() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_5() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return '' + endfunction + function! Custom3() + return '' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_6() + function! Custom1() + return '' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_7() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return '' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + function! s:suite.subseparator_component_expand() function! Custom1() return 'custom1' diff --git a/sources_non_forked/nerdtree/CHANGELOG b/sources_non_forked/nerdtree/CHANGELOG index 2e08dd2a..a23884a9 100644 --- a/sources_non_forked/nerdtree/CHANGELOG +++ b/sources_non_forked/nerdtree/CHANGELOG @@ -1,4 +1,20 @@ 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 + - Update to README - combine cd and git clone (zwhitchcox) #584 + - Update to README - Tip: start NERDTree when vim starts (therealplato) #593 + - Escape filename when moving an open buffer (zacharyvoase) #595 + - Fixed incorrect :helptags command in README (curran) #619 + - Fixed incomplete escaping of folder arrows (adityanatraj) #548 + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558 + - Replace strchars() with backward compatible workaround. + - Add support for copy command in Windows (SkylerLipthay) #231 + - Fixed typo in README.markdown - :Helptags -> :helptags - Rename "primary" and "secondary" trees to "tab" and "window" trees. - Move a bunch of buffer level variables into the NERDTree and UI classes. - Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing) diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index 3fb9ee70..4f5133a2 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -57,10 +57,9 @@ Installation ####[pathogen.vim](https://github.com/tpope/vim-pathogen) - cd ~/.vim/bundle - git clone https://github.com/scrooloose/nerdtree.git + git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree -Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. +Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`. ####[apt-vim](https://github.com/egalpin/apt-vim) @@ -101,6 +100,14 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` +--- +> How can I open NERDTree automatically when vim starts up on opening a directory? + + 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 + +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. + --- > How can I map a specific key or shortcut to open NERDTree? diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 3ad2a031..e0d86efa 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -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 diff --git a/sources_non_forked/nerdtree/doc/NERD_tree.txt b/sources_non_forked/nerdtree/doc/NERD_tree.txt index bf1ab5a8..d0af4a82 100644 --- a/sources_non_forked/nerdtree/doc/NERD_tree.txt +++ b/sources_non_forked/nerdtree/doc/NERD_tree.txt @@ -668,14 +668,18 @@ NERD tree. These options should be set in your vimrc. |'NERDTreeWinSize'| Sets the window size when the NERD tree is opened. -|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and +|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and 'Press ? for help' text. +|'NERDTreeCascadeSingleChildDir'| + Collapses on the same line directories that + have only one child directory. + |'NERDTreeCascadeOpenSingleChildDir'| Cascade open while selected directory has only one child that also is a directory. -|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove +|'NERDTreeAutoDeleteBuffer'| Tells the NERD tree to automatically remove a buffer when a file is being deleted or renamed via a context menu command. @@ -987,7 +991,18 @@ of the following lines to set this option: > < ------------------------------------------------------------------------------ - *'NERDTreeCascadeOpenSingleChildDir'* + *'NERDTreeCascadeSingleChildDir'* +Values: 0 or 1 +Default: 1. + +When displaying dir nodes, this option tells NERDTree to collapse dirs that +have only one child. Use one of the follow lines to set this option: > + let NERDTreeCascadeSingleChildDir=0 + let NERDTreeCascadeSingleChildDir=1 +< + +------------------------------------------------------------------------------ + *'NERDTreeCascadeOpenSingleChildDir'* Values: 0 or 1 Default: 1. @@ -1001,7 +1016,7 @@ useful for Java projects. Use one of the follow lines to set this option: > < ------------------------------------------------------------------------------ - *'NERDTreeAutoDeleteBuffer'* + *'NERDTreeAutoDeleteBuffer'* Values: 0 or 1 Default: 0. diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index 73a30f7a..1404cee0 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -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() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index 00947cdb..ac0f92eb 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -257,7 +257,7 @@ endfunction function! s:Opener._openDirectory(node) if self._nerdtree.isWinTree() call self._gotoTargetWin() - call g:NERDTreeCreator.CreateWindow(a:node.path.str()) + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) else call self._gotoTargetWin() if empty(self._where) diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index 674ca03e..5f3b16ad 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -174,11 +174,15 @@ function! s:Path.copy(dest) call s:Path.createParentDirectories(a:dest) - let dest = s:Path.WinToUnixPath(a:dest) + if exists('g:NERDTreeCopyCmd') + let cmd_prefix = g:NERDTreeCopyCmd + else + let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) + endif - let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars()) + let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(a:dest, self._escChars()) let success = system(cmd) - if success != 0 + if v:shell_error != 0 throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'" endif endfunction @@ -187,7 +191,7 @@ endfunction " "returns 1 if copying is supported for this OS function! s:Path.CopyingSupported() - return exists('g:NERDTreeCopyCmd') + return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd')) endfunction "FUNCTION: Path.copyingWillOverwrite(dest) {{{1 @@ -213,7 +217,7 @@ endfunction "FUNCTION: Path.createParentDirectories(path) {{{1 " "create parent directories for this path if needed -"without throwing any errors is those directories already exist +"without throwing any errors if those directories already exist " "Args: "path: full path of the node whose parent directories may need to be created @@ -226,8 +230,7 @@ endfunction "FUNCTION: Path.delete() {{{1 " -"Deletes the file represented by this path. -"Deletion of directories is not supported +"Deletes the file or directory represented by this path. " "Throws NERDTree.Path.Deletion exceptions function! s:Path.delete() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim index 48e9bda3..c41077df 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -117,28 +117,14 @@ endfunction "FUNCTION: TreeDirNode.getCascade() {{{1 "Return an array of dir nodes (starting from self) that can be cascade opened. function! s:TreeDirNode.getCascade() + if !self.isCascadable() + return [self] + endif - let rv = [self] - let node = self + let vc = self.getVisibleChildren() + let visChild = vc[0] - while 1 - let vc = node.getVisibleChildren() - if len(vc) != 1 - break - endif - - let visChild = vc[0] - - "TODO: optimize - if !visChild.path.isDirectory - break - endif - - call add(rv, visChild) - let node = visChild - endwhile - - return rv + return [self] + visChild.getCascade() endfunction "FUNCTION: TreeDirNode.getChildCount() {{{1 @@ -264,6 +250,10 @@ endfunction "FUNCTION: TreeDirNode.isCascadable() {{{1 "true if this dir has only one visible child - which is also a dir function! s:TreeDirNode.isCascadable() + if g:NERDTreeCascadeSingleChildDir == 0 + return 0 + endif + let c = self.getVisibleChildren() return len(c) == 1 && c[0].path.isDirectory endfunction @@ -466,7 +456,7 @@ function! s:TreeDirNode.refresh() " Regular expression is too expensive. Use simply string comparison " instead - if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && + if i[len(i)-3:2] != ".." && i[len(i)-2:2] != ".." && \ i[len(i)-2:1] != "." && i[len(i)-1] != "." try "create a new path and see if it exists in this nodes children diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index 094fa0f9..d107814c 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -282,7 +282,8 @@ endfunction function! s:UI._indentLevelFor(line) "have to do this work around because match() returns bytes, not chars let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']') - let leadChars = strchars(a:line[0:numLeadBytes-1]) + " The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+ + let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs')) return leadChars / s:UI.IndentWid() endfunction diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index 20a9fcd3..e563a947 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -74,7 +74,7 @@ endfunction function! s:promptToRenameBuffer(bufnum, msg, newFileName) echo a:msg if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' - let quotedFileName = "'" . 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 @@ -160,10 +160,10 @@ function! NERDTreeDeleteNode() let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 - if currentNode.path.isDirectory + if currentNode.path.isDirectory && currentNode.getChildCount() > 0 let choice =input("Delete the current node\n" . \ "==========================================================\n" . - \ "STOP! To delete this entire directory, type 'yes'\n" . + \ "STOP! Directory is not empty! To delete, type 'yes'\n" . \ "" . currentNode.path.str() . ": ") let confirmed = choice ==# 'yes' else diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index 0bcfe968..451b431b 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -75,6 +75,7 @@ else call s:initVariable("g:NERDTreeDirArrowCollapsible", "~") endif call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1) +call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1) if !exists("g:NERDTreeSortOrder") let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] @@ -103,6 +104,8 @@ call s:initVariable("g:NERDTreeWinSize", 31) "Note: the space after the command is important if nerdtree#runningWindows() call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') + call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ') + call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ') else call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ') diff --git a/sources_non_forked/nerdtree/syntax/nerdtree.vim b/sources_non_forked/nerdtree/syntax/nerdtree.vim index d2a94834..e93ca1df 100644 --- a/sources_non_forked/nerdtree/syntax/nerdtree.vim +++ b/sources_non_forked/nerdtree/syntax/nerdtree.vim @@ -25,7 +25,7 @@ syn match NERDTreeDirSlash #/# containedin=NERDTreeDir exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile' exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile' -let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~') +let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' @@ -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 diff --git a/sources_non_forked/syntastic/CONTRIBUTING.md b/sources_non_forked/syntastic/CONTRIBUTING.md index 1949415e..44eb13f8 100644 --- a/sources_non_forked/syntastic/CONTRIBUTING.md +++ b/sources_non_forked/syntastic/CONTRIBUTING.md @@ -97,9 +97,9 @@ let errorformat = \ '%-G%.%#' ``` -[bug_tracker]: https://github.com/scrooloose/syntastic/issues -[manual]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt -[github]: https://github.com/scrooloose/syntastic +[bug_tracker]: https://github.com/vim-syntastic/syntastic/issues +[manual]: https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic.txt +[github]: https://github.com/vim-syntastic/syntastic [branches]: https://github.com/dchelimsky/rspec/wiki/Topic-Branches#using-topic-branches-when-contributing-patches [variables]: http://www.refactoring.com/catalog/extractVariable.html -[guide]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide +[guide]: https://github.com/vim-syntastic/syntastic/wiki/Syntax-Checker-Guide diff --git a/sources_non_forked/syntastic/README.markdown b/sources_non_forked/syntastic/README.markdown index 7e493df2..7ed8cc87 100644 --- a/sources_non_forked/syntastic/README.markdown +++ b/sources_non_forked/syntastic/README.markdown @@ -25,21 +25,22 @@ 3. [Recommended settings](#settings) 4. [FAQ](#faq) 4.1. [I installed syntastic but it isn't reporting any errors...](#faqinfo) -4.2. [How can I check scripts written for different versions of Python?](#faqpython) -4.3. [How can I check scripts written for different versions of Ruby?](#faqruby) -4.4. [Are there any local checkers for HTML5 that I can use with syntastic?](#faqhtml5) -4.5. [The `perl` checker has stopped working...](#faqperl) -4.6. [What happened to the `rustc` checker?](#faqrust) -4.7. [What happened to the `xcrun` checker?](#faqxcrun) -4.8. [I run a checker and the location list is not updated...](#faqloclist) -4.8. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist) -4.9. [How can I pass additional arguments to a checker?](#faqargs) -4.10. [Syntastic supports several checkers for my filetype - how do I tell which one(s) to use?](#faqcheckers) -4.11. [What is the difference between syntax checkers and style checkers?](#faqstyle) -4.12. [I have enabled multiple checkers for the current filetype. How can I display all errors from all checkers together?](#faqaggregate) -4.13. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext) -4.14. [My favourite checker needs to load a configuration file from the project's root rather than the current directory...](#faqconfig) -4.15. [The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?](#faqbdelete) +4.2. [Syntastic supports several checkers for my filetype, how do I tell it which one(s) to use?](#faqcheckers) +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) - - - @@ -48,32 +49,33 @@ ## 1\. Introduction -Syntastic is a syntax checking plugin for [Vim][vim] that runs files through -external syntax checkers and displays any resulting errors to the user. This -can be done on demand, or automatically as files are saved. If syntax errors -are detected, the user is notified and is happy because they didn't have to -compile their code or execute their script to find them. +Syntastic is a syntax checking plugin for [Vim][vim] created by +[Martin Grenfell][scrooloose]. It runs files through external syntax checkers +and displays any resulting errors to the user. This can be done on demand, or +automatically as files are saved. If syntax errors are detected, the user is +notified and is happy because they didn't have to compile their code or execute +their script to find them. -At the time of this writing, syntastic has checking plugins for ActionScript, -Ada, Ansible configurations, API Blueprint, AppleScript, AsciiDoc, Assembly -languages, BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Chef, CoffeeScript, -Coco, Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dockerfile, Dust, Elixir, -Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe, -Handlebars, HSS, HTML, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo, LISP, -LLVM intermediate language, Lua, Markdown, 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, 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 corresponding supported checkers -(`:help syntastic-checkers` in Vim). +At the time of this writing, syntastic has checking plugins for ACPI +Source Language, ActionScript, Ada, Ansible configurations, API Blueprint, +AppleScript, AsciiDoc, Assembly languages, BEMHTML, Bro, Bourne shell, C, +C++, C#, Cabal, Chef, CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart, +DocBook, Dockerfile, Dust, Elixir, Erlang, eRuby, Fortran, Gentoo metadata, +GLSL, Go, Haml, Haskell, Haxe, Handlebars, HSS, HTML, Java, JavaScript, JSON, +JSX, LESS, Lex, Limbo, LISP, LLVM intermediate language, Lua, Markdown, +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, +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 example: [merlin][merlin], [omnisharp-vim][omnisharp], [rust.vim][rust], -[syntastic-extras][myint], [syntastic-more][roktas], [vim-crystal][crystal], -[vim-eastwood][eastwood], and [vim-swift][swift]. +A number of third-party Vim plugins also provide checkers for syntastic, for +example: [merlin][merlin], [omnisharp-vim][omnisharp], [rust.vim][rust], +[syntastic-extras][myint], [syntastic-more][roktas], [tsuquyomi][tsuquyomi], +[vim-crystal][crystal], [vim-eastwood][eastwood], and [vim-swift][swift]. Below is a screenshot showing the methods that Syntastic uses to display syntax errors. Note that, in practise, you will only have a subset of these methods @@ -105,9 +107,9 @@ version 7 or later with the "normal", "big", or "huge" feature sets should be fine. Syntastic should work with any modern plugin managers for Vim, such as -[NeoBundle][neobundle], [Pathogen][pathogen], [Vim-Addon-Manager][vam], [Vim-Plug][plug], or -[Vundle][vundle]. Instructions for installing syntastic with [Pathogen][pathogen] are -included below for completeness. +[NeoBundle][neobundle], [Pathogen][pathogen], [Vim-Addon-Manager][vam], +[Vim-Plug][plug], or [Vundle][vundle]. Instructions for installing syntastic +with [Pathogen][pathogen] are included below for completeness. Starting with Vim version 7.4.1486 you can also load syntastic using the standard mechanism of packages, without the help of third-party plugin managers @@ -152,7 +154,7 @@ You now have pathogen installed and can put syntastic into `~/.vim/bundle` like this: ```sh cd ~/.vim/bundle && \ -git clone --depth=1 https://github.com/scrooloose/syntastic.git +git clone --depth=1 https://github.com/vim-syntastic/syntastic.git ``` Quit vim and start it back up to reload it, then type: ```vim @@ -229,9 +231,194 @@ or the error output for a syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then post an [issue][bug_tracker] - or better yet, create a pull request. + + +__4.2. Q. Syntastic supports several checkers for my filetype, how do I tell it +which one(s) to use?__ + +A. Add a line like this to your `vimrc`: +```vim +let g:syntastic__checkers = [''] +``` + +To see the list of supported checkers for your filetype read the +[manual][checkers] (`:help syntastic-checkers` in Vim). + +For example, Python has the following checkers, among others: `flake8`, +`pyflakes`, `pylint` and a native `python` checker. To tell syntastic to use +`pylint`, you would use this setting: +```vim +let g:syntastic_python_checkers = ['pylint'] +``` + +Checkers can be chained together like this: +```vim +let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd'] +``` + +This is telling syntastic to run the `php` checker first, and if no errors are +found, run `phpcs`, and then `phpmd`. + +You can also run checkers explicitly by calling `:SyntasticCheck `. +For example to run `phpcs` and `phpmd`: +```vim +:SyntasticCheck phpcs phpmd +``` + +This works for any checkers available for the current filetype, even if they +aren't listed in `g:syntastic__checkers`. + + + +__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. + + + +__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`: +```vim +let g:syntastic_aggregate_errors = 1 +``` + +See `:help syntastic-aggregating-errors` for more details. + + + +__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 +customise every part of the command that gets run. You can set these options +using global variables. + +The general form of the global `args` variable is +`syntastic___args`. Thus if you wanted to pass +`--my --args --here` to the Ruby `mri` checker you would add this line to your +`vimrc`: +```vim +let g:syntastic_ruby_mri_args = "--my --args --here" +``` + +See `:help syntastic-checker-options` for more information. + +A number of checkers don't use the `makeprgBuild()` function mentioned above, +or have additional options that can be configured. For these checkers the exact +list of options should be included in the [manual][checkers] +(`:help syntastic-checkers` in Vim). + + + +__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 +location list to always be updated when you run the checkers, add this line to +your `vimrc`: +```vim +let g:syntastic_always_populate_loc_list = 1 +``` + + + +__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 +`:help :lprevious`. + +If you use these commands a lot then you may want to add shortcut mappings to +your `vimrc`, or install something like [unimpaired][unimpaired], which provides such +mappings (among other things). + + + +__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 +work around it: +```vim +nnoremap :lclose:bdelete +cabbrev bd =(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdelete' : 'bd') +``` + + + +__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 +current directory and upwards, and add it to the checker's options when found. +For example for `jscs`: + +```vim +function! FindConfig(prefix, what, where) + let cfg = findfile(a:what, escape(a:where, ' ') . ';') + return cfg !=# '' ? ' ' . a:prefix . ' ' . shellescape(cfg) : '' +endfunction + +autocmd FileType javascript let b:syntastic_javascript_jscs_args = + \ get(g:, 'syntastic_javascript_jscs_args', '') . + \ FindConfig('-c', '.jscsrc', expand(':p:h', 1)) +``` + + + +__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 +arbitrary. There is an ongoing effort to keep things consistent, so you can +_generally_ expect messages produced by syntax checkers to be _mostly_ related +to syntax, and messages produced by style checkers to be _mostly_ about style. +But there can be no formal guarantee that, say, a style checker that runs into +a syntax error wouldn't die with a fatal message, nor that a syntax checker +wouldn't give you warnings against using some constructs as being bad practice. +There is also no guarantee that messages marked as `style` are less severe than +the ones marked as `syntax` (whatever that might mean). And there are even a +few Frankenstein checkers (for example `flake8` and `pylama`) that, by their +nature, produce both kinds of messages. Syntastic is not smart enough to be +able to sort out these things by itself. + +Generally it's more useful to look at this from the perspective of filtering +unwanted messages, rather than as an indicator of severity levels. The +distinction between syntax and style is orthogonal to the distinction between +errors and warnings, and thus you can turn off messages based on level, on +type, or both. + +e.g. To disable all style messages: +```vim +let g:syntastic_quiet_messages = { "type": "style" } +``` +See `:help syntastic_quiet_messages` for more information. + -__4.2. 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 @@ -247,7 +434,7 @@ scripts. -__4.3. 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 @@ -260,29 +447,9 @@ virtual environment before running the actual checks. Then you'll need to point the relevant `g:syntastic_ruby__exec` variables to the wrapper scripts. - - -__4.4. Q. Are there any local checkers for HTML5 that I can use with syntastic?__ - -[HTML Tidy][tidy_old] has a fork named [HTML Tidy for HTML5][tidy]. It's a drop -in replacement, and syntastic can use it without changes. Just install it -somewhere and point `g:syntastic_html_tidy_exec` to its executable: -```vim -let g:syntastic_html_tidy_exec = 'tidy5' -``` -Alternatively, you can install [vnu.jar][vnu_jar] from the [validator.nu][vnu] -project and run it as a [HTTP server][vnu_server]: -```sh -$ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888 -``` -Then you can configure syntastic to use it: -```vim -let g:syntastic_html_validator_api = 'http://localhost:8888/' -``` - -__4.5. 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` @@ -298,175 +465,27 @@ let g:syntastic_enable_perl_checker = 1 -__4.6. 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. + + +__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 +install this plugin the checker should be picked up automatically by syntastic. + -__4.7. 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 install this plugin the checker should be picked up automatically by syntastic. - - -__4.8. Q. I run a checker and the location list is not updated...__ -__4.8. 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 -location list to always be updated when you run the checkers, add this line to -your `vimrc`: -```vim -let g:syntastic_always_populate_loc_list = 1 -``` - - - -__4.9. Q. How can I pass additional arguments to a checker?__ - -A. Almost all syntax checkers use the `makeprgBuild()` function. Those checkers -that do can be configured using global variables. The general form of the -global `args` variables is `syntastic___args`. - -So, If you wanted to pass `--my --args --here` to the ruby mri checker you -would add this line to your `vimrc`: -```vim -let g:syntastic_ruby_mri_args = "--my --args --here" -``` - -See `:help syntastic-checker-options` for more information. - - - -__4.10. Q. Syntastic supports several checkers for my filetype - how do I tell it -which one(s) to use?__ - -A. Stick a line like this in your `vimrc`: -```vim -let g:syntastic__checkers = [''] -``` - -To see the list of supported checkers for your filetype read the -[manual][checkers] (`:help syntastic-checkers` in Vim). - -e.g. Python has the following checkers, among others: `flake8`, `pyflakes`, -`pylint` and a native `python` checker. - -To tell syntastic to use `pylint`, you would use this setting: -```vim -let g:syntastic_python_checkers = ['pylint'] -``` - -Checkers can be chained together like this: -```vim -let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd'] -``` - -This is telling syntastic to run the `php` checker first, and if no errors are -found, run `phpcs`, and then `phpmd`. - -You can also run checkers explicitly by calling `:SyntasticCheck `. - -e.g. to run `phpcs` and `phpmd`: -```vim -:SyntasticCheck phpcs phpmd -``` - -This works for any checkers available for the current filetype, even if they -aren't listed in `g:syntastic__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`). - - - -__4.11. 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 -arbitrary. There is an ongoing effort to keep things consistent, so you can -_generally_ expect messages produced by syntax checkers to be _mostly_ related -to syntax, and messages produced by style checkers to be _mostly_ about style. -But there can be no formal guarantee that, say, a style checker that runs into -a syntax error wouldn't die with a fatal message, nor that a syntax checker -wouldn't give you warnings against using some constructs as being bad practice. -There is also no guarantee that messages marked as "style" are less severe than -the ones marked as "syntax" (whatever that might mean). And there are even a -few Frankenstein checkers (for example `flake8` and `pylama`) that, by their -nature, produce both kinds of messages. Syntastic is not smart enough to be -able to sort out these things by itself. - -In fact it's more useful to look at this from the perspective of filtering -unwanted messages, rather than as an indicator of severity levels. The -distinction between syntax and style is orthogonal to the distinction between -errors and warnings, and thus you can turn off messages based on level, on -type, or both. - -e.g. To disable all style messages: -```vim -let g:syntastic_quiet_messages = { "type": "style" } -``` -See `:help syntastic_quiet_messages` for details. - - - -__4.12. 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`: -```vim -let g:syntastic_aggregate_errors = 1 -``` - -See `:help syntastic-aggregating-errors` for more details. - - - -__4.13. Q. How can I jump between the different errors without using the location -list at the bottom of the window?__ - -A. Vim provides several built-in commands for this. See `:help :lnext` and -`:help :lprevious`. - -If you use these commands a lot then you may want to add shortcut mappings to -your `vimrc`, or install something like [unimpaired][unimpaired], which provides such -mappings (among other things). - - - -__4.14. 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 -current directory and upwards, and add it to the checker's options when found. -For example for `jscs`: - -```vim -function! FindConfig(prefix, what, where) - let cfg = findfile(a:what, escape(a:where, ' ') . ';') - return cfg !=# '' ? ' ' . a:prefix . ' ' . cfg : '' -endfunction - -autocmd FileType javascript let b:syntastic_javascript_jscs_args = - \ get(g:, 'syntastic_javascript_jscs_args', '') . - \ FindConfig('-c', '.jscsrc', expand(':p:h', 1)) -``` - - -__4.15. Q. The error window is closed automatically when I :quit the current buffer -but not when I :bdelete it?__ - -A. There is no safe way to handle that situation automatically, but you can -work around it: - -```vim -nnoremap :lclose:bdelete -cabbrev bd =(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdelete' : 'bd') -``` - ## 5\. Resources @@ -483,15 +502,16 @@ plugins that provide more functionality than syntastic. You might want to take a look at [ghcmod-vim][ghcmod], [jedi-vim][jedi], [python-mode][python_mode], [vim-go][vimgo], or [YouCompleteMe][ycm]. -[screenshot]: https://github.com/scrooloose/syntastic/raw/master/_assets/screenshot_1.png +[scrooloose]: https://github.com/scrooloose +[screenshot]: https://github.com/vim-syntastic/syntastic/raw/master/_assets/screenshot_1.png -[bug_tracker]: https://github.com/scrooloose/syntastic/issues -[checkers]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic-checkers.txt +[bug_tracker]: https://github.com/vim-syntastic/syntastic/issues +[checkers]: https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic-checkers.txt [crystal]: https://github.com/rhysd/vim-crystal [eastwood]: https://github.com/venantius/vim-eastwood [ghcmod]: https://github.com/eagletmt/ghcmod-vim [google_group]: https://groups.google.com/group/vim-syntastic -[guide]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide +[guide]: https://github.com/vim-syntastic/syntastic/wiki/Syntax-Checker-Guide [jedi]: https://github.com/davidhalter/jedi-vim [merlin]: https://github.com/the-lambda-church/merlin [myint]: https://github.com/myint/syntastic-extras @@ -508,8 +528,7 @@ a look at [ghcmod-vim][ghcmod], [jedi-vim][jedi], [python-mode][python_mode], [v [rvm]: https://rvm.io/ [stack_overflow]: http://stackoverflow.com/questions/tagged/syntastic [swift]: https://github.com/kballard/vim-swift -[tidy]: http://www.htacg.org/tidy-html5/ -[tidy_old]: http://tidy.sourceforge.net/ +[tsuquyomi]: https://github.com/Quramy/tsuquyomi/ [unimpaired]: https://github.com/tpope/vim-unimpaired [vam]: https://github.com/MarcWeber/vim-addon-manager [vim]: http://www.vim.org/ diff --git a/sources_non_forked/syntastic/autoload/syntastic/log.vim b/sources_non_forked/syntastic/autoload/syntastic/log.vim index 5ad562d2..d6d41a26 100644 --- a/sources_non_forked/syntastic/autoload/syntastic/log.vim +++ b/sources_non_forked/syntastic/autoload/syntastic/log.vim @@ -21,7 +21,7 @@ function! syntastic#log#warn(msg) abort " {{{2 endfunction " }}}2 function! syntastic#log#error(msg) abort " {{{2 - execute "normal \" + execute 'normal! \' 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([]) ? diff --git a/sources_non_forked/syntastic/autoload/syntastic/preprocess.vim b/sources_non_forked/syntastic/autoload/syntastic/preprocess.vim index cbab6fdd..9d25b849 100644 --- a/sources_non_forked/syntastic/autoload/syntastic/preprocess.vim +++ b/sources_non_forked/syntastic/autoload/syntastic/preprocess.vim @@ -89,11 +89,11 @@ function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2 call add(out, msg) endfor catch /\m^Vim\%((\a\+)\)\=:E716/ - call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format') + call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format (crashed checker?)') let out = [] endtry else - call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format') + call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format (crashed checker?)') endif return out endfunction " }}}2 @@ -132,18 +132,18 @@ function! syntastic#preprocess#flow(errors) abort " {{{2 call add(out, msg) catch /\m^Vim\%((\a\+)\)\=:E716/ - call syntastic#log#warn('checker javascript/flow: unrecognized error format') + call syntastic#log#warn('checker javascript/flow: unrecognized error format (crashed checker?)') let out = [] break endtry else - call syntastic#log#warn('checker javascript/flow: unrecognized error format') + call syntastic#log#warn('checker javascript/flow: unrecognized error format (crashed checker?)') let out = [] break endif endfor else - call syntastic#log#warn('checker javascript/flow: unrecognized error format') + call syntastic#log#warn('checker javascript/flow: unrecognized error format (crashed checker?)') endif return out @@ -178,11 +178,11 @@ function! syntastic#preprocess#jscs(errors) abort " {{{2 endtry endfor else - call syntastic#log#warn('checker javascript/jscs: unrecognized error format') + call syntastic#log#warn('checker javascript/jscs: unrecognized error format (crashed checker?)') endif endfor else - call syntastic#log#warn('checker javascript/jscs: unrecognized error format') + call syntastic#log#warn('checker javascript/jscs: unrecognized error format (crashed checker?)') endif return out endfunction " }}}2 @@ -238,7 +238,7 @@ function! syntastic#preprocess#prospector(errors) abort " {{{2 endif endfor else - call syntastic#log#warn('checker python/prospector: unrecognized error format') + call syntastic#log#warn('checker python/prospector: unrecognized error format (crashed checker?)') endif endif @@ -311,11 +311,11 @@ function! syntastic#preprocess#scss_lint(errors) abort " {{{2 endtry endfor else - call syntastic#log#warn('checker scss/scss_lint: unrecognized error format') + call syntastic#log#warn('checker scss/scss_lint: unrecognized error format (crashed checker?)') endif endfor else - call syntastic#log#warn('checker scss/scss_lint: unrecognized error format') + call syntastic#log#warn('checker scss/scss_lint: unrecognized error format (crashed checker?)') endif return out endfunction " }}}2 @@ -351,7 +351,7 @@ function! syntastic#preprocess#stylelint(errors) abort " {{{2 endtry endfor else - call syntastic#log#warn('checker css/stylelint: unrecognized error format') + call syntastic#log#warn('checker css/stylelint: unrecognized error format (crashed checker?)') endif endif return out @@ -398,7 +398,7 @@ echomsg string(json) endtry endfor else - call syntastic#log#warn('checker javascript/tern_lint: unrecognized error format') + call syntastic#log#warn('checker javascript/tern_lint: unrecognized error format (crashed checker?)') endif echomsg string(out) @@ -453,7 +453,7 @@ function! syntastic#preprocess#vint(errors) abort " {{{2 endif endfor else - call syntastic#log#warn('checker vim/vint: unrecognized error format') + call syntastic#log#warn('checker vim/vint: unrecognized error format (crashed checker?)') endif return out diff --git a/sources_non_forked/syntastic/autoload/syntastic/util.vim b/sources_non_forked/syntastic/autoload/syntastic/util.vim index 68eb06ea..deeb0f1f 100644 --- a/sources_non_forked/syntastic/autoload/syntastic/util.vim +++ b/sources_non_forked/syntastic/autoload/syntastic/util.vim @@ -37,8 +37,24 @@ function! syntastic#util#system(command) abort " {{{2 let $LC_MESSAGES = 'C' let $LC_ALL = '' + let crashed = 0 let cmd_start = reltime() - let out = system(a:command) + try + let out = system(a:command) + catch + let crashed = 1 + call syntastic#log#error('exception running system(' . string(a:command) . '): ' . v:exception) + if syntastic#util#isRunningWindows() + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMP = ' . string($TMP) . ', $TEMP = ' . string($TEMP)) + else + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TERM = ' . string($TERM)) + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMPDIR = ' . string($TMPDIR)) + endif + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '$PATH = ' . string($PATH)) + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd())) + call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS) + let out = '' + endtry let cmd_time = split(reltimestr(reltime(cmd_start)))[0] let $LC_ALL = old_lc_all @@ -46,7 +62,7 @@ function! syntastic#util#system(command) abort " {{{2 let &shell = old_shell - if exists('g:_SYNTASTIC_DEBUG_TRACE') + if !crashed && exists('g:_SYNTASTIC_DEBUG_TRACE') call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'system: command run in ' . cmd_time . 's') endif @@ -102,6 +118,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 +146,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 +195,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]) @@ -271,6 +296,36 @@ function! syntastic#util#findGlobInParent(what, where) abort " {{{2 return '' endfunction " }}}2 +" Returns the buffer number of a filename +" @vimlint(EVL104, 1, l:old_shellslash) +function! syntastic#util#fname2buf(fname) abort " {{{2 + if exists('+shellslash') + " bufnr() can't cope with backslashes + let old_shellslash = &shellslash + let &shellslash = 1 + endif + + " this is a best-effort attempt to escape file patterns (cf. :h file-pattern) + " XXX it fails for filenames containing something like \{2,3} + for md in [':~:.', ':~', ':p'] + let buf = bufnr('^' . escape(fnamemodify(a:fname, md), '\*?,{}[') . '$') + if buf != -1 + break + endif + endfor + if buf == -1 + " XXX definitely wrong, but hope is the last thing to die :) + let buf = bufnr(fnamemodify(a:fname, ':p')) + endif + + if exists('+shellslash') + let &shellslash = old_shellslash + endif + + return buf +endfunction " }}}2 +" @vimlint(EVL104, 0, l:old_shellslash) + " Returns unique elements in a list function! syntastic#util#unique(list) abort " {{{2 let seen = {} @@ -342,10 +397,8 @@ function! syntastic#util#stamp() abort " {{{2 return split( split(reltimestr(reltime(g:_SYNTASTIC_START)))[0], '\.' ) endfunction " }}}2 -function! syntastic#util#setChangedtick() abort " {{{2 - unlockvar! b:syntastic_changedtick - let b:syntastic_changedtick = b:changedtick - lockvar! b:syntastic_changedtick +function! syntastic#util#setLastTick(buf) abort " {{{2 + call setbufvar(a:buf, 'syntastic_lasttick', getbufvar(a:buf, 'changedtick')) endfunction " }}}2 let s:_wid_base = 'syntastic_' . getpid() . '_' . reltimestr(g:_SYNTASTIC_START) . '_' @@ -363,9 +416,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 @@ -487,6 +537,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') @@ -533,6 +588,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 @@ -544,6 +602,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 diff --git a/sources_non_forked/syntastic/doc/syntastic-checkers.txt b/sources_non_forked/syntastic/doc/syntastic-checkers.txt index 47948490..d8fb584d 100644 --- a/sources_non_forked/syntastic/doc/syntastic-checkers.txt +++ b/sources_non_forked/syntastic/doc/syntastic-checkers.txt @@ -6,6 +6,7 @@ SYNTAX CHECKERS BY LANGUAGE *syntastic-checkers-lang* |syntastic| comes with checkers for the following languages: + ACPI Source Language.....................|syntastic-checkers-asl| ActionScript.............................|syntastic-checkers-actionscript| Ada......................................|syntastic-checkers-ada| Ansible..................................|syntastic-checkers-ansible| @@ -100,6 +101,7 @@ SYNTAX CHECKERS BY LANGUAGE *syntastic-checkers-lang* Sh.......................................|syntastic-checkers-sh| Slim.....................................|syntastic-checkers-slim| SML......................................|syntastic-checkers-sml| + Solidity.................................|syntastic-checkers-solidity| SQL......................................|syntastic-checkers-sql| Stylus...................................|syntastic-checkers-stylus| @@ -115,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| @@ -132,6 +135,37 @@ SYNTAX CHECKERS BY LANGUAGE *syntastic-checkers-lang* Third-party checkers are available for additional languages. +============================================================================== +SYNTAX CHECKERS FOR ACPI SOURCE LANGUAGE *syntastic-checkers-asl* + +The following checkers are available for the ACPI Source Language (filetype +"asl"): + + 1. iasl.....................|syntastic-asl-iasl| + +------------------------------------------------------------------------------ +1. iasl *syntastic-asl-iasl* + +Name: iasl +Maintainer: Peter Wu + +"iasl" is a compiler/decompiler for ACPI Source Language (ASL) and ACPI +Machine Language (AML). See the project's page for details: + + https://acpica.org/ + +Checker options~ + +This checker is initialised using the "makeprgBuild()" function and thus it +accepts the standard options described at |syntastic-config-makeprg|. + +Note~ + +You probably also need a plugin to set |filetype| for ASL files, such as +"vim-acpi-asl": + + https://github.com/martinlroth/vim-acpi-asl + ============================================================================== SYNTAX CHECKERS FOR ACTIONSCRIPT *syntastic-checkers-actionscript* @@ -320,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* @@ -341,10 +376,31 @@ 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 + +"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* -The following checkers are available for asembly languages (filetype "asm"): +The following checkers are available for assembly languages (filetype "asm"): 1. GCC......................|syntastic-asm-gcc| @@ -432,7 +488,7 @@ The following checkers are available for BEMHTML (filetype "bemhtml"): Name: bemhtmllint Maintainer: Sergej Tatarincev -BEMHTML is a template engine intended for using with BEM methodology +BEMHTML is a template engine intended for using with the BEM methodology (http://bem.info/method/). See the project's page at GitHub for details: https://github.com/SevInf/bemhtml-lint @@ -492,9 +548,9 @@ Checker options~ This checker is initialised using the "makeprgBuild()" function and thus it accepts the standard options described at |syntastic-config-makeprg|. -Aditionally: +Additionally: - *g:syntastic_avrgcc_config_file* + *'g:syntastic_avrgcc_config_file'* Type: string Default: ".syntastic_avrgcc_config" File containing compilation flags (such as defines or include directories), @@ -895,17 +951,39 @@ SYNTAX CHECKERS FOR C++ *syntastic-checkers-cpp* The following checkers are available for C++ (filetype "cpp"): - 1. ClangCheck...............|syntastic-cpp-clang_check| - 2. Clang-Tidy...............|syntastic-cpp-clang_tidy| - 3. Cppcheck.................|syntastic-cpp-cppcheck| - 4. Cpplint..................|syntastic-cpp-cpplint| - 5. GCC......................|syntastic-cpp-gcc| - 6. OClint...................|syntastic-cpp-oclint| - 7. PC-Lint..................|syntastic-cpp-pc_lint| - 8. Vera++...................|syntastic-cpp-verapp| + 1. AVR-GCC..................|syntastic-cpp-avrgcc| + 2. ClangCheck...............|syntastic-cpp-clang_check| + 3. Clang-Tidy...............|syntastic-cpp-clang_tidy| + 4. Cppcheck.................|syntastic-cpp-cppcheck| + 5. Cpplint..................|syntastic-cpp-cpplint| + 6. GCC......................|syntastic-cpp-gcc| + 7. OClint...................|syntastic-cpp-oclint| + 8. PC-Lint..................|syntastic-cpp-pc_lint| + 9. Vera++...................|syntastic-cpp-verapp| ------------------------------------------------------------------------------ -1. ClangCheck *syntastic-cpp-clang_check* +1. AVR-GCC *syntastic-cpp-avrgcc* + +Name: avrgcc +Maintainer: Sławek Piotrowski + +Checker options~ + +This checker is initialised using the "makeprgBuild()" function and thus it +accepts the standard options described at |syntastic-config-makeprg|. + +Additionally: + + 'g:syntastic_avrgcc_config_file' +Type: string +Default: ".syntastic_avrgcc_config" +File containing compilation flags (such as defines or include directories), +one option per line (cf. |syntastic-config-files|). + +See also: |syntastic-c-avrgcc|. + +------------------------------------------------------------------------------ +2. ClangCheck *syntastic-cpp-clang_check* Name: clang_check Maintainer: Benjamin Bannier @@ -948,7 +1026,7 @@ then ignored. See also: |syntastic-c-clang_check|. ------------------------------------------------------------------------------ -2. Clang-Tidy *syntastic-cpp-clang_tidy* +3. Clang-Tidy *syntastic-cpp-clang_tidy* Name: clang_tidy Maintainer: Benjamin Bannier @@ -999,7 +1077,7 @@ then ignored. See also: |syntastic-c-clang_tidy|. ------------------------------------------------------------------------------ -3. Cppcheck *syntastic-cpp-cppcheck* +4. Cppcheck *syntastic-cpp-cppcheck* Name: cppcheck Maintainer: LCD 47 @@ -1025,7 +1103,7 @@ one option per line (cf. |syntastic-config-files|). See also: |syntastic-c-cppcheck|. ------------------------------------------------------------------------------ -4. Cpplint *syntastic-cpp-cpplint* +5. Cpplint *syntastic-cpp-cpplint* Name: cpplint Maintainer: LCD 47 @@ -1061,7 +1139,7 @@ However, if your "cpplint" was installed with "pip", the script's name is let g:syntastic_cpp_cpplint_exec = "cpplint" < ------------------------------------------------------------------------------ -5. GCC *syntastic-cpp-gcc* +6. GCC *syntastic-cpp-gcc* Name: gcc Maintainer: Gregor Uhlenheuer @@ -1158,7 +1236,7 @@ executable. See also: |syntastic-c-gcc|. ------------------------------------------------------------------------------ -6. OClint *syntastic-cpp-oclint* +7. OClint *syntastic-cpp-oclint* Name: oclint Maintainer: "UnCO" Lin @@ -1198,7 +1276,7 @@ Config files pointed to by 'g:syntastic_oclint_config_file' are then ignored. See also: |syntastic-c-oclint|. ------------------------------------------------------------------------------ -7. PC-Lint *syntastic-cpp-pc_lint* +8. PC-Lint *syntastic-cpp-pc_lint* Name: pc_lint Maintainer: Steve Bragg @@ -1225,7 +1303,7 @@ current directory and in parent directories; first such file found is used. See also: |syntastic-c-pc_lint|. ------------------------------------------------------------------------------ -8. Vera++ *syntastic-cpp-verapp* +9. Vera++ *syntastic-cpp-verapp* Name: verapp Maintainer: Lucas Verney @@ -1450,7 +1528,7 @@ The following checkers are available for Coq (filetype "coq"): Name: coqtop Maintainer: Matvey Aksenov -"Coqtop" is the top level intrface for Coq. See the project's page for +"Coqtop" is the top level interface for Coq. See the project's page for details: http://coq.inria.fr/ @@ -1931,7 +2009,7 @@ Security~ This checker executes the code in the files it checks: - https://github.com/scrooloose/syntastic/issues/1141 + https://github.com/vim-syntastic/syntastic/issues/1141 This is probably fine if you wrote the files yourself, but it can be a problem if you're trying to check third party files. If you are 100% willing to let @@ -1989,8 +2067,8 @@ Name: syntaxerl Maintainer: locojay "SyntaxErl" is a syntax checker for Erlang. It uses "rebar" -(https://github.com/basho/rebar) to determine correct deps and libs paths. -See the project's page for more information: +(https://github.com/basho/rebar) to determine correct dependencies and library +paths. See the project's page for more information: https://github.com/ten0s/syntaxerl @@ -2191,7 +2269,7 @@ If the magic comment does not exist, then the dictionary 'g:syntastic_glsl_extensions' is used to infer the appropriate profile from the current file's extension. If this dictionary does not exist either, a default dictionary is used instead. Finally, if the current file's extension -cannott be found in these dictionaries, the checker assumes a vertex shader +cannot be found in these dictionaries, the checker assumes a vertex shader profile. *'g:syntastic_glsl_options'* @@ -2199,6 +2277,13 @@ Type: string Default: unset Additional arguments to pass to "cgc". +Note~ + +You probably also need a plugin to set |filetype| for OpenGL files, such as +"vim-glsl": + + https://github.com/tikhomirov/vim-glsl + ============================================================================== SYNTAX CHECKERS FOR GO *syntastic-checkers-go* @@ -2307,7 +2392,7 @@ Maintainer: Kamil Kisiel See the tool's documentation for details: - https://godoc.org/golang.org/x/tools/cmd/vet + https://godoc.org/cmd/vet Note~ @@ -2531,10 +2616,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* @@ -2624,7 +2711,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 + +"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 @@ -2670,7 +2775,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 + +"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 @@ -2695,7 +2821,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 @@ -2768,7 +2894,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 @@ -2879,7 +3005,7 @@ point |'g:syntastic_java_checkstyle_classpath'| to it: http://iweb.dl.sourceforge.net/project/checkstyle/checkstyle/ http://checkstyle.sourceforge.net/cmdline.html#Usage_by_Classpath_update -Current builds at Maven Central do not package "checkstyles" with its +Current builds at Maven Central do not package "checkstyle" with its dependencies: http://search.maven.org/#search|gav|1|g%3A%22com.puppycrawl.tools%22%20AND%20a%3A%22checkstyle%22 @@ -2894,6 +3020,14 @@ Name: javac Maintainers: Jochen Keil Dmitry Geurkov +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: @@ -3092,13 +3226,13 @@ accepts the standard options described at |syntastic-config-makeprg|. Notes~ -Syntastic requires "Flow" version 0.6 or later. +Syntastic requires "Flow" version 0.18.1 or later. To use "Flow" with your projects, you must: a. Install it: - https://github.com/sindresorhus/flow-bin + https://github.com/flowtype/flow-bin b. Configure your project: > @@ -3629,7 +3763,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* @@ -3666,7 +3801,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 + +"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 @@ -3781,6 +3937,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* @@ -3820,6 +3977,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 + +"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* @@ -4307,6 +4485,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* @@ -4326,6 +4505,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 + +"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* @@ -4637,7 +4837,7 @@ Please note that transforming a file like this affects line numbers and column numbers, and syntastic has no way to make the necessary adjustments. Consequently, errors might appear on surprising lines if you enable this feature and the transformed file has code on different lines than the raw -file. For this reason the use of these transformations should be limitted +file. For this reason the use of these transformations should be limited to codecs that preserve line numbers, such as the "spec" codec provided by "NoseOfYeti": @@ -4741,7 +4941,7 @@ setting of "lint.style". Name: lintr Maintainer: Jim Hester -"lintr" is a static code analysys tool for R files. See the project's page at +"lintr" is a static code analysis tool for R files. See the project's page at GitHub for details: https://github.com/jimhester/lintr @@ -4794,7 +4994,7 @@ This is a checker for R files, using the R package "svTools": http://cran.r-project.org/web/packages/svTools/ In turn, this package delegates most of the work to the "checkUsage()" -function in the codetools package: +function in the "codetools" package: http://cran.r-project.org/web/packages/codetools/ @@ -4851,7 +5051,7 @@ The following checkers are available for R Markdown (filetype "rmd"): Name: lintr Maintainer: Jim Hester -"lintr" is a static code analysys tool for R files. See the project's page at +"lintr" is a static code analysis tool for R files. See the project's page at GitHub for details: https://github.com/jimhester/lintr @@ -4930,7 +5130,7 @@ Security~ This checker executes the code in the files it checks: - https://github.com/scrooloose/syntastic/issues/1773 + https://github.com/vim-syntastic/syntastic/issues/1773 This is probably fine if you wrote the files yourself, but it can be a problem if you're trying to check third party files. If you are 100% willing to let @@ -4979,12 +5179,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 + +"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 @@ -5002,7 +5224,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 @@ -5018,7 +5240,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 @@ -5060,7 +5282,7 @@ directory, or if you want to override the autodetected paths, options |'g:syntastic_rst_sphinx_source_dir'| and |'g:syntastic_rst_sphinx_config_dir'| take precedence over the detected values. -Please not also that the checker creates output files in a temporary directory +Please note also that the checker creates output files in a temporary directory that is created upon the first run in the current session, and is removed when Vim exits. If you need to change the location of this directory you can do so by exporting the environment variables "TMPDIR" or "TMP" (on UNIX and Mac @@ -5081,7 +5303,7 @@ The following checkers are available for Linux RPM packages (filetype "spec"): Name: rpmlint Maintainer: LCD 47 -"rpmlint" is a trool for checking Linux RPM packages. See the project's page +"rpmlint" is a tool for checking Linux RPM packages. See the project's page for details: http://sourceforge.net/projects/rpmlint/ @@ -5165,7 +5387,7 @@ Name: macruby Maintainer: Martin Grenfell "MacRuby" is an implementation of Ruby for Mac OS X. See the project's -pagefor details: +page for details: http://www.macruby.org/ @@ -5725,6 +5947,37 @@ 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 SOLIDITY *syntastic-checkers-solidity* + +The following checkers are available for Solidity (filetype "solidity"): + + 1. solc.....................|syntastic-solidity-solc| + +------------------------------------------------------------------------------ +1. solc *syntastic-solidity-solc* + +Name: solc +Maintainer: Jacob Cholewa + +"solc" is a compiler for Ethereum's smart-contract language "Solidity" +(https://solidity.readthedocs.io/). See the project's page for details: + + https://github.com/ethereum/solidity + +Checker options~ + +This checker is initialised using the "makeprgBuild()" function and thus it +accepts the standard options described at |syntastic-config-makeprg|. + +Note~ + +You probably also need a plugin to set |filetype| for Solidity files, such as +"vim-solidity": + + https://github.com/tomlion/vim-solidity + + ============================================================================== SYNTAX CHECKERS FOR SQL *syntastic-checkers-sql* @@ -5764,7 +6017,7 @@ Maintainer: LCD 47 "Stylint" is a linter for Stylus (http://learnboost.github.io/stylus). See the project's page at GitHub for details: - https://github.com/rossPatton/stylint + https://github.com/SimenB/stylint Checker options~ @@ -5806,6 +6059,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* @@ -5851,12 +6105,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 + +"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* @@ -5864,7 +6140,7 @@ The following checkers are available for Texinfo (filetype "texinfo"): Name: makeinfo Maintainer: LCD 47 -"Makeinfo" is a convertor for Texinfo files. It is distributed together with +"Makeinfo" is a converter for Texinfo files. It is distributed together with the GNU package "texinfo": http://www.gnu.org/software/texinfo/ @@ -5874,6 +6150,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 + +"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* @@ -5882,7 +6179,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* @@ -5945,7 +6243,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 + +"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 @@ -6087,8 +6406,7 @@ SYNTAX CHECKERS FOR TYPESCRIPT *syntastic-checkers-typescript* The following checkers are available for TypeScript (filetype "typescript"): 1. ESLint...................|syntastic-typescript-eslint| - 2. tsc......................|syntastic-typescript-tsc| - 3. TSLint...................|syntastic-typescript-tslint| + 2. TSLint...................|syntastic-typescript-tslint| ------------------------------------------------------------------------------ 1. ESLint *syntastic-typescript-eslint* @@ -6098,7 +6416,7 @@ Maintainer: LCD 47 "ESLint" is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. With the "babel-eslint" plugin -(https://github.com/babel/babel-eslint) "ESLint" can also can also be +(https://github.com/babel/babel-eslint) "ESLint" can also be used to check TypeScript files. See the project's page for details: https://github.com/nzakas/eslint @@ -6118,29 +6436,7 @@ as "typescript-vim": See also: |syntastic-html-eslint|, |syntastic-javascript-eslint|. ------------------------------------------------------------------------------ -2. tsc *syntastic-typescript-tsc* - -Name: tsc -Maintainer: Bill Casarin - -"tsc" is a compiler for TypeScript. See the project's page for details: - - http://www.typescriptlang.org/ - -Checker options~ - -This checker is initialised using the "makeprgBuild()" function and thus it -accepts the standard options described at |syntastic-config-makeprg|. - -Note~ - -You probably also need a plugin to set |filetype| for TypeScript files, such -as "typescript-vim": - - https://github.com/leafgarland/typescript-vim - ------------------------------------------------------------------------------- -3. TSLint *syntastic-typescript-tslint* +2. TSLint *syntastic-typescript-tslint* Name: tslint Maintainer: Seon-Wook Park @@ -6331,6 +6627,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 + +"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* @@ -6416,6 +6740,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* @@ -6490,6 +6815,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 + +"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* @@ -6861,6 +7207,7 @@ syntastic-specific configuration files: OpenCOBOL (|syntastic-cobol-cobc|) C++~ + AVR-GCC (|syntastic-cpp-avrgcc|) ClangCheck (|syntastic-cpp-clang_check|) Clang-Tidy (|syntastic-cpp-clang_tidy|) Cppcheck (|syntastic-cpp-cppcheck|) diff --git a/sources_non_forked/syntastic/doc/syntastic.txt b/sources_non_forked/syntastic/doc/syntastic.txt index 431638bb..db3e99e4 100644 --- a/sources_non_forked/syntastic/doc/syntastic.txt +++ b/sources_non_forked/syntastic/doc/syntastic.txt @@ -46,19 +46,22 @@ CONTENTS *syntastic-contents* 6.4.Saving Vim sessions....................|syntastic-sessions| 6.5.The location list callback.............|syntastic-loclist-callback| 7.Compatibility with other software............|syntastic-compatibility| - 7.1.The csh and tcsh shells................|syntastic-csh| - 7.2.Eclim..................................|syntastic-eclim| - 7.3.The fish shell.........................|syntastic-fish| - 7.4.The fizsh shell........................|syntastic-fizsh| - 7.5.flagship...............................|syntastic-flagship| - 7.6.powerline..............................|syntastic-powerline| - 7.7.The PowerShell shell...................|syntastic-powershell| - 7.8.python-mode............................|syntastic-pymode| - 7.9.vim-auto-save..........................|syntastic-vim-auto-save| - 7.10.vim-go................................|syntastic-vim-go| - 7.11.vim-virtualenv........................|syntastic-vim-virtualenv| - 7.12.YouCompleteMe.........................|syntastic-ycm| - 7.13.The zsh shell and MacVim..............|syntastic-zsh| + 7.1.airline................................|syntastic-airline| + 7.2.The csh and tcsh shells................|syntastic-csh| + 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| @@ -82,7 +85,7 @@ Take a look at the list of supported filetypes and checkers: |syntastic-checkers Note: This doc only deals with using syntastic. To learn how to write syntax checker integrations, see the guide on the GitHub wiki: - https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide + https://github.com/vim-syntastic/syntastic/wiki/Syntax-Checker-Guide ------------------------------------------------------------------------------ 1.1. Quick start *syntastic-quickstart* @@ -158,12 +161,17 @@ Something like this could be more useful: > set statusline+=%* < When syntax errors are detected a flag will be shown. The content of the flag -is derived from the |syntastic_stl_format| option. +is derived from the |'syntastic_stl_format'| option. Please note that these settings might conflict with other Vim plugins that -change the way statusline works. Refer to these plugins' documentation for -possible solutions. See also |syntastic-powerline| below if you're using the -"powerline" Vim plugin (https://github.com/powerline/powerline). +change the way statusline works. Refer to the |syntastic-compatibility| notes +below and to the respective plugins' documentation for possible solutions. + +In particular see |syntastic-airline| below if you're using the "airline" Vim +plugin (https://github.com/vim-airline/vim-airline). See |syntastic-flagship| +if you're using "flagship" (https://github.com/tpope/vim-flagship). See also +|syntastic-powerline| if you're using the "powerline" Vim plugin +(https://github.com/powerline/powerline). ------------------------------------------------------------------------------ 2.2. Error signs *syntastic-error-signs* @@ -195,6 +203,10 @@ following highlight groups: Example: > highlight SyntasticErrorLine guibg=#2f0000 < +With Vim 8.0 or later you can ask Vim not to turn off the sign column when no +errors are found, by setting 'signcolumn' to "yes": > + set signcolumn=yes +< ------------------------------------------------------------------------------ 2.3. The error window *syntastic-error-window* @@ -248,7 +260,7 @@ grouped together, and sorting within each group is decided by the variables |'syntastic___sort'|. ------------------------------------------------------------------------------ -2.6 Filtering errors *syntastic-filtering-errors* +2.6. Filtering errors *syntastic-filtering-errors* You can selectively disable some of the errors found by checkers either using |'syntastic_quiet_messages'|, or by specifying a list of patterns in @@ -290,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: +"/". + +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. @@ -732,7 +754,7 @@ filetypes. 5. Checker Options *syntastic-checker-options* ------------------------------------------------------------------------------ -5.1 Choosing which checkers to use *syntastic-filetype-checkers* +5.1. Choosing which checkers to use *syntastic-filetype-checkers* *'g:syntastic__checkers'* You can tell syntastic which checkers to run for a given filetype by setting a @@ -750,13 +772,17 @@ If neither |'g:syntastic__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|. Use `:SyntasticInfo` to see which checkers are available for a given filetype. ------------------------------------------------------------------------------ -5.2 Choosing the executable *syntastic-config-exec* +5.2. Choosing the executable *syntastic-config-exec* *'syntastic___exec'* The executable run by a checker is normally defined automatically, when the @@ -773,7 +799,7 @@ takes precedence over both 'b:syntastic___exec' and 'g:syntastic___exec' in the buffers where it is defined. ------------------------------------------------------------------------------ -5.3 Configuring specific checkers *syntastic-config-makeprg* +5.3. Configuring specific checkers *syntastic-config-makeprg* Checkers are run by constructing a command line and by passing it to a shell (see |'shell'| and |'syntastic_shell'|). In most cases this command line is @@ -797,7 +823,7 @@ The result is a command line of the form: > All fields above are optional, and can be overridden by setting global variables 'g:syntastic___' - even parameters not specified in the call to "makeprgBuild()". For example to -override the argguments and the tail: > +override the arguments and the tail: > let g:syntastic_c_pc_lint_args = "-w5 -Iz:/usr/include/linux" let g:syntastic_c_pc_lint_tail = "2>/dev/null" < @@ -843,13 +869,12 @@ 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|). ------------------------------------------------------------------------------ -5.4 Sorting errors *syntastic-config-sort* +5.4. Sorting errors *syntastic-config-sort* *'syntastic___sort'* Syntastic may decide to group the errors produced by some checkers by file, @@ -868,7 +893,7 @@ For aggregated lists (see |syntastic-aggregating-errors|) these variables are ignored if |'syntastic_sort_aggregated_errors'| is set (which is the default). ------------------------------------------------------------------------------ -5.5 Filtering errors *syntastic-config-filtering* +5.5. Filtering errors *syntastic-config-filtering* *'syntastic___quiet_messages'* Finally, variables 'g:syntastic___quiet_messages' can @@ -882,7 +907,7 @@ from the corresponding checkers are filtered. Example: > The syntax is of course identical to that of |syntastic_quiet_messages|. ------------------------------------------------------------------------------ -5.6 Debugging *syntastic-config-debug* +5.6. Debugging *syntastic-config-debug* *syntastic-debug* Syntastic can log a trace of its working to Vim's |message-history|. To verify @@ -902,7 +927,7 @@ Debug logs can be saved to a file; see |'syntastic_debug_file'| for details. Setting |'syntastic_debug'| to 0 turns off logging. ------------------------------------------------------------------------------ -5.7 Profiling *syntastic-profiling* +5.7. Profiling *syntastic-profiling* A very useful tool for debugging performance problems is Vim's built-in |profiler|. In order to enable profiling for syntastic you need to add two lines @@ -932,7 +957,7 @@ composite filetypes to simple ones using |'syntastic_filetype_map'|, e.g.: > let g:syntastic_filetype_map = { "handlebars.html": "handlebars" } < ------------------------------------------------------------------------------ -6.2 Editing files over network *syntastic-netrw* +6.2. Editing files over network *syntastic-netrw* The standard plugin |netrw| allows Vim to transparently edit files over network and inside archives. Currently syntastic doesn't support this mode @@ -940,7 +965,7 @@ of operation. It can only check files that can be accessed directly by local checkers, without any translation or conversion. ------------------------------------------------------------------------------ -6.3 The 'shellslash' option *syntastic-shellslash* +6.3. The 'shellslash' option *syntastic-shellslash* The 'shellslash' option is relevant only on Windows systems. This option determines (among other things) the rules for quoting command lines, and there @@ -951,7 +976,7 @@ shell. It should be turned off if your 'shell' (or |'syntastic_shell'|) is value. ------------------------------------------------------------------------------ -6.4 Saving Vim sessions *syntastic-sessions* +6.4. Saving Vim sessions *syntastic-sessions* If you use `:mksession` to save Vim sessions you should probably make sure to remove option "blank" from 'sessionoptions': > @@ -961,7 +986,7 @@ This will prevent `:mksession` from saving |syntastic-error-window| as empty quickfix windows. ------------------------------------------------------------------------------ -6.5 The location list callback *syntastic-loclist-callback* +6.5. The location list callback *syntastic-loclist-callback* *SyntasticCheckHook()* Syntastic also gives you direct access to the list of errors. A function @@ -987,7 +1012,17 @@ also affect window sizes.) 7. Compatibility with other software *syntastic-compatibility* ------------------------------------------------------------------------------ -7.1 The csh and tcsh shells *syntastic-csh* +7.1. airline *syntastic-airline* + +The "airline" Vim plugin (https://github.com/vim-airline/vim-airline) comes +packaged with a mechanism of showing flags on the |'statusline'| according +to your |'syntastic_stl_format'|. When using this plugin you do NOT need to +follow the recommendation outlined in the |syntastic-statusline-flag| section +above to modify your |'statusline'|; "airline" will make all necessary changes +automatically. + +------------------------------------------------------------------------------ +7.2. The csh and tcsh shells *syntastic-csh* The "csh" and "tcsh" shells are mostly compatible with syntastic. However, some checkers assume Bourne shell syntax for redirecting "stderr". For this @@ -996,7 +1031,16 @@ such as "zsh", "bash", "ksh", or even the original Bourne "sh": > let g:syntastic_shell = "/bin/sh" < ------------------------------------------------------------------------------ -7.2. 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 @@ -1009,7 +1053,15 @@ run Eclim's validation for others. Please consult Eclim's documentation for details. ------------------------------------------------------------------------------ -7.3 The fish shell *syntastic-fish* +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 +loclist windows even when configured to use |quickfix| lists. This interferes +with syntastic's functioning. + +------------------------------------------------------------------------------ +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 @@ -1019,7 +1071,7 @@ original Bourne "sh": > let g:syntastic_shell = "/bin/sh" < ------------------------------------------------------------------------------ -7.4. 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 @@ -1032,7 +1084,7 @@ interactive features of "fizsh". Using a more traditional shell such as "zsh", let g:syntastic_shell = "/bin/sh" < ------------------------------------------------------------------------------ -7.5 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" @@ -1042,7 +1094,7 @@ described in the |syntastic-statusline-flag| section above: > autocmd User Flags call Hoist("window", "SyntasticStatuslineFlag") < ------------------------------------------------------------------------------ -7.6. 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 @@ -1059,16 +1111,18 @@ packaged with a syntastic segment. To customize this segment create a file } < ------------------------------------------------------------------------------ -7.7. The PowerShell shell *syntastic-powershell* +7.10. The PowerShell shell *syntastic-powershell* -At the time of this writing, syntastic is not compatible with using "Windows -PowerShell" (http://technet.microsoft.com/en-us/library/bb978526.aspx) as Vim's -'shell'. You may still run Vim from 'PowerShell', but you do have to point -Vim's 'shell' to a more traditional program, such as "cmd.exe": > - set shell=cmd.exe +At the time of this writing syntastic is not compatible with using +"PowerShell" (https://msdn.microsoft.com/en-us/powershell) as Vim's 'shell'. +You may still run Vim from "PowerShell", but you do have to point Vim's +'shell' to a more traditional program, such as "cmd.exe" on Windows, or +"/bin/sh" on UNIX: > + set shell=c:\Windows\system32\cmd.exe + set shell=/bin/sh < ------------------------------------------------------------------------------ -7.8 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 @@ -1079,14 +1133,14 @@ for python in syntastic (see |'syntastic_mode_map'|), or disable lint checks in let g:pymode_lint_on_write = 0 < ------------------------------------------------------------------------------ -7.9. 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.10. 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 @@ -1103,7 +1157,7 @@ stick with |quickfix| lists: > let g:go_list_type = "quickfix" < ------------------------------------------------------------------------------ -7.11. 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 @@ -1111,7 +1165,7 @@ https://github.com/jmcantrell/vim-virtualenv). This is a limitation of "vim-virtualenv". ------------------------------------------------------------------------------ -7.12 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" @@ -1122,7 +1176,7 @@ have to set |g:ycm_show_diagnostics_ui| to 0. E.g.: > let g:ycm_show_diagnostics_ui = 0 < ------------------------------------------------------------------------------ -7.13 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 @@ -1142,7 +1196,7 @@ The core maintainers of syntastic are: Find the latest version of syntastic at: - http://github.com/scrooloose/syntastic + http://github.com/vim-syntastic/syntastic ============================================================================== 9. License *syntastic-license* diff --git a/sources_non_forked/syntastic/plugin/syntastic.vim b/sources_non_forked/syntastic/plugin/syntastic.vim index 8076eebe..2c8bdbad 100644 --- a/sources_non_forked/syntastic/plugin/syntastic.vim +++ b/sources_non_forked/syntastic/plugin/syntastic.vim @@ -19,7 +19,7 @@ if has('reltime') lockvar! g:_SYNTASTIC_START endif -let g:_SYNTASTIC_VERSION = '3.7.0-162' +let g:_SYNTASTIC_VERSION = '3.8.0-10' 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' @@ -126,20 +126,26 @@ endif " Debug {{{1 -let s:_DEBUG_DUMP_OPTIONS = [ +let g:_SYNTASTIC_SHELL_OPTIONS = [ \ 'shell', \ 'shellcmdflag', \ 'shellpipe', \ 'shellquote', \ 'shellredir', - \ 'shellslash', \ 'shelltemp', \ 'shellxquote' \ ] -if exists('+shellxescape') - call add(s:_DEBUG_DUMP_OPTIONS, 'shellxescape') -endif -lockvar! s:_DEBUG_DUMP_OPTIONS +for s:feature in [ + \ 'autochdir', + \ 'shellslash', + \ 'shellxescape', + \ ] + + if exists('+' . s:feature) + call add(g:_SYNTASTIC_SHELL_OPTIONS, s:feature) + endif +endfor +lockvar! g:_SYNTASTIC_SHELL_OPTIONS " debug constants let g:_SYNTASTIC_DEBUG_TRACE = 1 @@ -163,6 +169,7 @@ let s:registry = g:SyntasticRegistry.Instance() let s:notifiers = g:SyntasticNotifiers.Instance() let s:modemap = g:SyntasticModeMap.Instance() +let s:_check_stack = [] let s:_quit_pre = [] " Commands {{{1 @@ -171,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) @@ -207,14 +223,16 @@ command! SyntasticJavacEditConfig runtime! syntax_checkers/java/*.vim | Synta " Public API {{{1 function! SyntasticCheck(...) abort " {{{2 - call s:UpdateErrors(0, a:000) + call s:UpdateErrors(bufnr(''), 0, a:000) call syntastic#util#redraw(g:syntastic_full_redraws) 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, g:_SYNTASTIC_SHELL_OPTIONS) + call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES) endfunction " }}}2 function! SyntasticErrors() abort " {{{2 @@ -222,19 +240,19 @@ function! SyntasticErrors() abort " {{{2 endfunction " }}}2 function! SyntasticReset() abort " {{{2 - call s:ClearCache() + call s:ClearCache(bufnr('')) call s:notifiers.refresh(g:SyntasticLoclist.New([])) endfunction " }}}2 function! SyntasticToggleMode() abort " {{{2 call s:modemap.toggleMode() - call s:ClearCache() + call s:ClearCache(bufnr('')) call s:notifiers.refresh(g:SyntasticLoclist.New([])) call s:modemap.echoMode() endfunction " }}}2 function! SyntasticSetLoclist() abort " {{{2 - call g:SyntasticLoclist.current().setloclist() + call g:SyntasticLoclist.current().setloclist(0) endfunction " }}}2 " }}}1 @@ -243,54 +261,68 @@ endfunction " }}}2 augroup syntastic autocmd! - autocmd BufEnter * call s:BufEnterHook() + autocmd VimEnter * call s:VimEnterHook() + autocmd BufEnter * call s:BufEnterHook(expand('', 1)) + autocmd BufWinEnter * call s:BufWinEnterHook(expand('', 1)) augroup END if g:syntastic_nested_autocommands augroup syntastic - autocmd BufReadPost * nested call s:BufReadPostHook() - autocmd BufWritePost * nested call s:BufWritePostHook() + autocmd BufReadPost * nested call s:BufReadPostHook(expand('', 1)) + autocmd BufWritePost * nested call s:BufWritePostHook(expand('', 1)) augroup END else augroup syntastic - autocmd BufReadPost * call s:BufReadPostHook() - autocmd BufWritePost * call s:BufWritePostHook() + autocmd BufReadPost * call s:BufReadPostHook(expand('', 1)) + autocmd BufWritePost * call s:BufWritePostHook(expand('', 1)) augroup END endif if exists('##QuitPre') " QuitPre was added in Vim 7.3.544 augroup syntastic - autocmd QuitPre * call s:QuitPreHook(expand('', 1)) + autocmd QuitPre * call s:QuitPreHook(expand('', 1)) augroup END endif -function! s:BufReadPostHook() abort " {{{2 - if g:syntastic_check_on_open +function! s:BufReadPostHook(fname) abort " {{{2 + let buf = syntastic#util#fname2buf(a:fname) + if g:syntastic_check_on_open && buf > 0 call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, - \ 'autocmd: BufReadPost, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr(''))))) - call s:UpdateErrors(1, []) + \ 'autocmd: BufReadPost, buffer ' . buf . ' = ' . string(a:fname)) + if index(s:_check_stack, buf) == -1 + call add(s:_check_stack, buf) + endif endif endfunction " }}}2 -function! s:BufWritePostHook() abort " {{{2 +function! s:BufWritePostHook(fname) abort " {{{2 + let buf = syntastic#util#fname2buf(a:fname) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, - \ 'autocmd: BufWritePost, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr(''))))) - call s:UpdateErrors(1, []) + \ 'autocmd: BufWritePost, buffer ' . buf . ' = ' . string(a:fname)) + call s:UpdateErrors(buf, 1, []) endfunction " }}}2 -function! s:BufEnterHook() abort " {{{2 +function! s:BufEnterHook(fname) abort " {{{2 + let buf = syntastic#util#fname2buf(a:fname) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, - \ 'autocmd: BufEnter, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))) . - \ ', &buftype = ' . string(&buftype)) - if &buftype ==# '' - call s:notifiers.refresh(g:SyntasticLoclist.current()) + \ 'autocmd: BufEnter, buffer ' . buf . ' = ' . string(a:fname) . ', &buftype = ' . string(&buftype)) + if buf > 0 && getbufvar(buf, '&buftype') ==# '' + let idx = index(reverse(copy(s:_check_stack)), buf) + if idx >= 0 + if !has('vim_starting') + call remove(s:_check_stack, -idx - 1) + call s:UpdateErrors(buf, 1, []) + endif + elseif &buftype ==# '' + call s:notifiers.refresh(g:SyntasticLoclist.current()) + endif elseif &buftype ==# 'quickfix' " 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 owner = str2nr(getbufvar(bufnr(''), 'syntastic_owner_buffer')) + 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)' )) call SyntasticLoclistHide() @@ -298,8 +330,39 @@ function! s:BufEnterHook() abort " {{{2 endif endfunction " }}}2 +function! s:BufWinEnterHook(fname) abort " {{{2 + let buf = syntastic#util#fname2buf(a:fname) + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, + \ 'autocmd: BufWinEnter, buffer ' . buf . ' = ' . string(a:fname) . ', &buftype = ' . string(&buftype)) + if buf > 0 && getbufvar(buf, '&buftype') ==# '' + let idx = index(reverse(copy(s:_check_stack)), buf) + if idx >= 0 && !has('vim_starting') + call remove(s:_check_stack, -idx - 1) + call s:UpdateErrors(buf, 1, []) + endif + endif +endfunction " }}}2 + +function! s:VimEnterHook() abort " {{{2 + let g:syntastic_version = + \ g:_SYNTASTIC_VERSION . + \ ' (Vim ' . v:version . (has('nvim') ? ', Neovim' : '') . ', ' . + \ g:_SYNTASTIC_UNAME . + \ (has('gui') ? ', GUI' : '') . ')' + lockvar g:syntastic_version + + let buf = bufnr('') + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, + \ 'autocmd: VimEnter, buffer ' . buf . ' = ' . string(bufname(buf)) . ', &buftype = ' . string(&buftype)) + let idx = index(reverse(copy(s:_check_stack)), buf) + if idx >= 0 && getbufvar(buf, '&buftype') ==# '' + call remove(s:_check_stack, -idx - 1) + call s:UpdateErrors(buf, 1, []) + endif +endfunction " }}}2 + function! s:QuitPreHook(fname) abort " {{{2 - let buf = bufnr(fnameescape(a:fname)) + let buf = syntastic#util#fname2buf(a:fname) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, 'autocmd: QuitPre, buffer ' . buf . ' = ' . string(a:fname)) if !syntastic#util#var('check_on_wq') @@ -317,30 +380,28 @@ endfunction " }}}2 " Main {{{1 "refresh and redraw all the error info for this buf when saving or reading -function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2 +function! s:UpdateErrors(buf, auto_invoked, checker_names) abort " {{{2 call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'version') - call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS) + call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS) call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'UpdateErrors' . (a:auto_invoked ? ' (auto)' : '') . \ ': ' . (len(a:checker_names) ? join(a:checker_names) : 'default checkers')) call s:modemap.synch() - if s:_skip_file() + if s:_skip_file(a:buf) 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:checker_names) - call syntastic#util#setChangedtick() - else - if a:auto_invoked - return - endif + call s:CacheErrors(a:buf, a:checker_names) + call syntastic#util#setLastTick(a:buf) + elseif a:auto_invoked + return endif - let loclist = g:SyntasticLoclist.current() + let loclist = g:SyntasticLoclist.current(a:buf) if exists('*SyntasticCheckHook') call SyntasticCheckHook(loclist.getRaw()) @@ -356,14 +417,8 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2 let do_jump = 0 endif - let w:syntastic_loclist_set = [] if syntastic#util#var('always_populate_loc_list') || do_jump - call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist (new)') - call setloclist(0, loclist.getRaw()) - if !exists('b:syntastic_changedtick') - call syntastic#util#setChangedtick() - endif - let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick] + call loclist.setloclist(1) if run_checks && do_jump && !loclist.isEmpty() call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: jump') execute 'silent! lrewind ' . do_jump @@ -383,39 +438,44 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2 endfunction " }}}2 "clear the loc list for the buffer -function! s:ClearCache() abort " {{{2 - call s:notifiers.reset(g:SyntasticLoclist.current()) - call b:syntastic_loclist.destroy() +function! s:ClearCache(buf) abort " {{{2 + let loclist = g:SyntasticLoclist.current(a:buf) + call s:notifiers.reset(loclist) + call loclist.destroy() endfunction " }}}2 "detect and cache all syntax errors in this buffer -function! s:CacheErrors(checker_names) abort " {{{2 +function! s:CacheErrors(buf, checker_names) abort " {{{2 call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: ' . \ (len(a:checker_names) ? join(a:checker_names) : 'default checkers')) - call s:ClearCache() + call s:ClearCache(a:buf) let newLoclist = g:SyntasticLoclist.New([]) + call newLoclist.setOwner(a:buf) - if !s:_skip_file() + if !s:_skip_file(a:buf) " debug logging {{{3 call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors') + if syntastic#util#isRunningWindows() + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMP = ' . string($TMP) . ', $TEMP = ' . string($TEMP)) + else + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TERM = ' . string($TERM)) + call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMPDIR = ' . string($TMPDIR)) + endif call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$PATH = ' . string($PATH)) 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 @@ -436,7 +496,7 @@ function! s:CacheErrors(checker_names) abort " {{{2 call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'sorted:', loclist) endif - let newLoclist = newLoclist.extend(loclist) + call newLoclist.extend(loclist) if !aggregate_errors break @@ -556,7 +616,7 @@ function! SyntasticMake(options) abort " {{{2 let err_lines = call('syntastic#preprocess#' . a:options['preprocess'], [err_lines]) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'preprocess:', err_lines) endif - lgetexpr err_lines + noautocmd lgetexpr err_lines let errors = deepcopy(getloclist(0)) @@ -569,6 +629,12 @@ function! SyntasticMake(options) abort " {{{2 catch /\m^Vim\%((\a\+)\)\=:E380/ " E380: At bottom of quickfix stack call setloclist(0, [], 'r') + try + " Vim 7.4.2200 or later + call setloclist(0, [], 'r', { 'title': '' }) + catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/ + " do nothing + endtry catch /\m^Vim\%((\a\+)\)\=:E776/ " E776: No location list " do nothing @@ -630,11 +696,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 @@ -660,10 +721,10 @@ function! s:_is_quitting(buf) abort " {{{2 endfunction " }}}2 " Skip running in special buffers -function! s:_skip_file() abort " {{{2 - let fname = expand('%', 1) - let skip = s:_is_quitting(bufnr('%')) || get(b:, 'syntastic_skip_checks', 0) || - \ (&buftype !=# '') || !filereadable(fname) || getwinvar(0, '&diff') || +function! s:_skip_file(buf) abort " {{{2 + let fname = bufname(a:buf) + let skip = s:_is_quitting(a:buf) || getbufvar(a:buf, 'syntastic_skip_checks') || + \ (getbufvar(a:buf, '&buftype') !=# '') || !filereadable(fname) || getwinvar(0, '&diff') || \ getwinvar(0, '&previewwindow') || s:_ignore_file(fname) || \ fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions if skip @@ -674,17 +735,19 @@ endfunction " }}}2 " Explain why checks will be skipped for the current file function! s:_explain_skip(filetypes) abort " {{{2 - if empty(a:filetypes) && s:_skip_file() + let buf = bufnr('') + if empty(a:filetypes) && s:_skip_file(buf) let why = [] - let fname = expand('%', 1) + let fname = bufname(buf) + let bt = getbufvar(buf, '&buftype') - if s:_is_quitting(bufnr('%')) + if s:_is_quitting(buf) call add(why, 'quitting buffer') endif - if get(b:, 'syntastic_skip_checks', 0) + if getbufvar(buf, 'syntastic_skip_checks') call add(why, 'b:syntastic_skip_checks set') endif - if &buftype !=# '' + if bt !=# '' call add(why, 'buftype = ' . string(&buftype)) endif if !filereadable(fname) diff --git a/sources_non_forked/syntastic/plugin/syntastic/autoloclist.vim b/sources_non_forked/syntastic/plugin/syntastic/autoloclist.vim index 153b0bc9..415d5ab9 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/autoloclist.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/autoloclist.vim @@ -25,10 +25,27 @@ function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist) abort " {{{2 call a:loclist.show() endif else - if auto_loc_list == 1 || auto_loc_list == 2 - "TODO: this will close the loc list window if one was opened by - "something other than syntastic - lclose + if (auto_loc_list == 1 || auto_loc_list == 2) && !empty(get(w:, 'syntastic_loclist_set', [])) + try + " Vim 7.4.2200 or later + let title = get(getloclist(0, { 'title': 1 }), 'title', ':SyntasticCheck ') + catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/ + let title = ':SyntasticCheck ' + endtry + + if strpart(title, 0, 16) ==# ':SyntasticCheck ' + " TODO: this will close the loc list window if one was opened + " by something other than syntastic + call SyntasticLoclistHide() + + try + " Vim 7.4.2200 or later + call setloclist(0, [], 'r', { 'title': '' }) + catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/ + " do nothing + endtry + let w:syntastic_loclist_set = [] + endif endif endif endfunction " }}}2 diff --git a/sources_non_forked/syntastic/plugin/syntastic/checker.vim b/sources_non_forked/syntastic/plugin/syntastic/checker.vim index 22ad8205..345d2f03 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/checker.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/checker.vim @@ -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 = '' + 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 diff --git a/sources_non_forked/syntastic/plugin/syntastic/loclist.vim b/sources_non_forked/syntastic/plugin/syntastic/loclist.vim index 3e9528b5..3ad93750 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/loclist.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/loclist.vim @@ -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', '') ==# '' @@ -27,17 +27,18 @@ function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2 return newObj endfunction " }}}2 -function! g:SyntasticLoclist.current() abort " {{{2 - if !exists('b:syntastic_loclist') || empty(b:syntastic_loclist) - let b:syntastic_loclist = g:SyntasticLoclist.New([]) +function! g:SyntasticLoclist.current(...) abort " {{{2 + 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([]) endif - return b:syntastic_loclist + return loclist endfunction " }}}2 function! g:SyntasticLoclist.extend(other) abort " {{{2 - let list = self.copyRaw() - call extend(list, a:other.copyRaw()) - return g:SyntasticLoclist.New(list) + call extend(self._rawLoclist, a:other.copyRaw()) endfunction " }}}2 function! g:SyntasticLoclist.sort() abort " {{{2 @@ -167,7 +168,6 @@ function! g:SyntasticLoclist.setOwner(buffer) abort " {{{2 endfunction " }}}2 function! g:SyntasticLoclist.deploy() abort " {{{2 - call self.setOwner(bufnr('')) let self._stamp = syntastic#util#stamp() for buf in self.getBuffers() call setbufvar(buf, 'syntastic_loclist', self) @@ -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 ? @@ -289,23 +289,29 @@ function! g:SyntasticLoclist.filter(filters) abort " {{{2 return filter(copy(self._rawLoclist), filter) endfunction " }}}2 -function! g:SyntasticLoclist.setloclist() abort " {{{2 +function! g:SyntasticLoclist.setloclist(new) abort " {{{2 if !exists('w:syntastic_loclist_set') let w:syntastic_loclist_set = [] endif - if empty(w:syntastic_loclist_set) || w:syntastic_loclist_set != [bufnr(''), b:changedtick] - let replace = g:syntastic_reuse_loc_lists && !empty(w:syntastic_loclist_set) + if a:new || empty(w:syntastic_loclist_set) || w:syntastic_loclist_set != [self._owner, getbufvar(self._owner, 'changedtick')] + let replace = !a:new && g:syntastic_reuse_loc_lists && !empty(w:syntastic_loclist_set) call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist ' . (replace ? '(replace)' : '(new)')) call setloclist(0, self.getRaw(), replace ? 'r' : ' ') - call syntastic#util#setChangedtick() - let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick] + try + " Vim 7.4.2200 or later + call setloclist(0, [], 'r', { 'title': ':SyntasticCheck ' . self._name }) + catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/ + " do nothing + endtry + call syntastic#util#setLastTick(self._owner) + let w:syntastic_loclist_set = [self._owner, getbufvar(self._owner, 'syntastic_lasttick')] endif endfunction " }}}2 "display the cached errors for this buf in the location list function! g:SyntasticLoclist.show() abort " {{{2 call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: show') - call self.setloclist() + call self.setloclist(0) if !self.isEmpty() let num = winnr() diff --git a/sources_non_forked/syntastic/plugin/syntastic/modemap.vim b/sources_non_forked/syntastic/plugin/syntastic/modemap.vim index 501c82b7..74b09a71 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/modemap.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/modemap.vim @@ -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 @@ -72,7 +73,7 @@ function! g:SyntasticModeMap.echoMode() abort " {{{2 endfunction " }}}2 function! g:SyntasticModeMap.modeInfo(filetypes) abort " {{{2 - echomsg 'Syntastic version: ' . g:_SYNTASTIC_VERSION . ' (Vim ' . v:version . ', ' . g:_SYNTASTIC_UNAME . ')' + echomsg 'Syntastic version: ' . g:syntastic_version let type = len(a:filetypes) ? a:filetypes[0] : &filetype echomsg 'Info for filetype: ' . type @@ -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 diff --git a/sources_non_forked/syntastic/plugin/syntastic/notifiers.vim b/sources_non_forked/syntastic/plugin/syntastic/notifiers.vim index fe158ca1..6a3b8239 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/notifiers.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/notifiers.vim @@ -23,7 +23,7 @@ function! g:SyntasticNotifiers.Instance() abort " {{{2 endfunction " }}}2 function! g:SyntasticNotifiers.refresh(loclist) abort " {{{2 - if !a:loclist.isEmpty() && !a:loclist.isNewerThan([]) + if !syntastic#util#bufIsActive(bufnr('')) || (!a:loclist.isEmpty() && !a:loclist.isNewerThan([])) " loclist not fully constructed yet return endif diff --git a/sources_non_forked/syntastic/plugin/syntastic/registry.vim b/sources_non_forked/syntastic/plugin/syntastic/registry.vim index 0c2d261f..69ef5817 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/registry.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/registry.vim @@ -12,6 +12,7 @@ let s:_DEFAULT_CHECKERS = { \ 'apiblueprint': ['drafter'], \ 'applescript': ['osacompile'], \ 'asciidoc': ['asciidoc'], + \ 'asl': ['iasl'], \ 'asm': ['gcc'], \ 'bro': ['bro'], \ 'bemhtml': ['bemhtmllint'], @@ -42,6 +43,7 @@ let s:_DEFAULT_CHECKERS = { \ 'handlebars': ['handlebars'], \ 'haskell': ['hdevtools', 'hlint'], \ 'haxe': ['haxe'], + \ 'help': [], \ 'hss': ['hss'], \ 'html': ['tidy'], \ 'jade': ['jade_lint'], @@ -84,6 +86,7 @@ let s:_DEFAULT_CHECKERS = { \ 'slim': ['slimrb'], \ 'sml': ['smlnj'], \ 'spec': ['rpmlint'], + \ 'solidity': ['solc'], \ 'sql': ['sqlint'], \ 'stylus': ['stylint'], \ 'tcl': ['nagelfar'], @@ -93,7 +96,7 @@ let s:_DEFAULT_CHECKERS = { \ 'trig': ['rapper'], \ 'turtle': ['rapper'], \ 'twig': ['twiglint'], - \ 'typescript': ['tsc'], + \ 'typescript': [], \ 'vala': ['valac'], \ 'verilog': ['verilator'], \ 'vhdl': ['ghdl'], @@ -186,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 @@ -240,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 = [] @@ -255,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) @@ -272,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 @@ -319,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 @@ -336,8 +370,18 @@ function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2 endfunction " }}}2 " Check for obsolete variable g:syntastic__checker -function! g:SyntasticRegistry._checkDeprecation(filetype) abort " {{{2 - if exists('g:syntastic_' . a:filetype . '_checker') && !exists('g:syntastic_' . a:filetype . '_checkers') +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('') + let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker] call syntastic#log#oneTimeWarn('variable g:syntastic_' . a:filetype . '_checker is deprecated') endif @@ -370,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: diff --git a/sources_non_forked/syntastic/syntax_checkers/asciidoc/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/asciidoc/proselint.vim new file mode 100644 index 00000000..7bc719fc --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/asciidoc/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/asl/iasl.vim b/sources_non_forked/syntastic/syntax_checkers/asl/iasl.vim new file mode 100644 index 00000000..0aae5d29 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/asl/iasl.vim @@ -0,0 +1,59 @@ +"============================================================================ +"File: iasl.vim +"Description: Syntax checking plugin for syntastic using iasl +"Maintainer: Peter Wu +"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_asl_iasl_checker') + finish +endif +let g:loaded_syntastic_asl_iasl_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_asl_iasl_GetLocList() dict + let tmpdir = syntastic#util#tmpdir() . syntastic#util#Slash() + let makeprg = self.makeprgBuild({ + \ 'args': '-vi', + \ 'args_after': ['-p', tmpdir] }) + + let errorformat = + \ '%f(%l) : %trror %n - %m,' . + \ '%f(%l) : %tarning %n - %m,' . + \ '%f(%l) : %temark %n - %m,' . + \ '%f(%l) : %tptimize %n - %m,' . + \ '%f(%l) : %m' + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'returns': [0, 255] }) + + for e in loclist + if e['type'] =~? 'r' + let e['type'] = 'W' + elseif e['type'] =~? 'o' + let e['type'] = 'W' + let e['subtype'] = 'Style' + endif + endfor + + call syntastic#util#rmrf(tmpdir) + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'asl', + \ 'name': 'iasl'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/syntastic/syntax_checkers/c/avrgcc.vim b/sources_non_forked/syntastic/syntax_checkers/c/avrgcc.vim index 0fbb9840..a4124975 100644 --- a/sources_non_forked/syntastic/syntax_checkers/c/avrgcc.vim +++ b/sources_non_forked/syntastic/syntax_checkers/c/avrgcc.vim @@ -1,6 +1,6 @@ "============================================================================ "File: avrgcc.vim -"Description: Syntax checking plugin for syntastic.vim +"Description: Syntax checking plugin for syntastic "Maintainer: Karel "License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute @@ -22,10 +22,12 @@ endif let s:save_cpo = &cpo set cpo&vim +let s:opt_x = { 'c': 'c', 'cpp': 'c++' } + function! SyntaxCheckers_c_avrgcc_GetLocList() dict let makeprg = self.makeprgBuild({ \ 'args_before': syntastic#c#ReadConfig(g:syntastic_avrgcc_config_file), - \ 'args_after': '-x c -fsyntax-only' }) + \ 'args_after': '-x ' . get(s:opt_x, self.getFiletype(), '') . ' -fsyntax-only' }) let errorformat = \ '%-G%f:%s:,' . diff --git a/sources_non_forked/syntastic/syntax_checkers/cpp/avrgcc.vim b/sources_non_forked/syntastic/syntax_checkers/cpp/avrgcc.vim new file mode 100644 index 00000000..cc48b74f --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/cpp/avrgcc.vim @@ -0,0 +1,24 @@ +"============================================================================ +"File: avrgcc.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: Sławek Piotrowski +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_cpp_avrgcc_checker') + finish +endif +let g:loaded_syntastic_cpp_avrgcc_checker = 1 + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'cpp', + \ 'name': 'avrgcc', + \ 'exec': 'avr-g++', + \ 'redirect': 'c/avrgcc'}) + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/syntastic/syntax_checkers/dockerfile/dockerfile_lint.vim b/sources_non_forked/syntastic/syntax_checkers/dockerfile/dockerfile_lint.vim index 3a5b7694..4858a6b5 100644 --- a/sources_non_forked/syntastic/syntax_checkers/dockerfile/dockerfile_lint.vim +++ b/sources_non_forked/syntastic/syntax_checkers/dockerfile/dockerfile_lint.vim @@ -1,7 +1,7 @@ "============================================================================ "File: dockerfile_lint.vim "Description: Syntax checking plugin for syntastic.vim using dockerfile-lint -" (https://github.com/projectatomic/dockerfile-lint). +" (https://github.com/projectatomic/dockerfile_lint). "Maintainer: Tim Carry "License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute diff --git a/sources_non_forked/syntastic/syntax_checkers/haskell/ghc-mod.vim b/sources_non_forked/syntastic/syntax_checkers/haskell/ghc-mod.vim deleted file mode 100644 index 928e5b30..00000000 --- a/sources_non_forked/syntastic/syntax_checkers/haskell/ghc-mod.vim +++ /dev/null @@ -1,94 +0,0 @@ -"============================================================================ -"File: ghc-mod.vim -"Description: Syntax checking plugin for syntastic.vim -"Maintainer: Anthony Carapetis -"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/haskell/hdevtools.vim b/sources_non_forked/syntastic/syntax_checkers/haskell/hdevtools.vim index 4b0a80fb..f2313b3f 100644 --- a/sources_non_forked/syntastic/syntax_checkers/haskell/hdevtools.vim +++ b/sources_non_forked/syntastic/syntax_checkers/haskell/hdevtools.vim @@ -31,12 +31,12 @@ function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict let errorformat = \ '%-Z %#,'. - \ '%W%f:%l:%v: Warning: %m,'. - \ '%W%f:%l:%v: Warning:,'. - \ '%E%f:%l:%v: %m,'. - \ '%E%>%f:%l:%v:,'. + \ '%W%\m%f:%l:%v%\%%(-%\d%\+%\)%\=: Warning: %m,'. + \ '%W%\m%f:%l:%v%\%%(-%\d%\+%\)%\=: Warning:,'. + \ '%E%\m%f:%l:%v%\%%(-%\d%\+%\)%\=: %m,'. + \ '%E%>%\m%f:%l:%v%\%%(-%\d%\+%\)%\=:,'. \ '%+C %#%m,'. - \ '%W%>%f:%l:%v:,'. + \ '%W%>%\m%f:%l:%v%\%%(-%\d%\+%\)%\=:,'. \ '%+C %#%tarning: %m,' return SyntasticMake({ diff --git a/sources_non_forked/syntastic/syntax_checkers/help/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/help/proselint.vim new file mode 100644 index 00000000..53ea3854 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/help/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/html/htmlhint.vim b/sources_non_forked/syntastic/syntax_checkers/html/htmlhint.vim new file mode 100644 index 00000000..3518b7ee --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/html/htmlhint.vim @@ -0,0 +1,46 @@ +"============================================================================ +"File: html.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/html/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/html/proselint.vim new file mode 100644 index 00000000..fc364df6 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/html/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/javascript/flow.vim b/sources_non_forked/syntastic/syntax_checkers/javascript/flow.vim index 13ee47a3..02826548 100644 --- a/sources_non_forked/syntastic/syntax_checkers/javascript/flow.vim +++ b/sources_non_forked/syntastic/syntax_checkers/javascript/flow.vim @@ -25,7 +25,7 @@ function! SyntaxCheckers_javascript_flow_IsAvailable() dict if !executable(self.getExec()) return 0 endif - return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 6]) + return syntastic#util#versionIsAtLeast(self.getVersion(self.getExecEscaped() . ' version'), [0, 18, 1]) endfunction function! SyntaxCheckers_javascript_flow_GetLocList() dict diff --git a/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim b/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim index 178f76a5..f37e923e 100644 --- a/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim +++ b/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim @@ -47,7 +47,7 @@ endfunction function! SyntaxCheckers_lua_luac_GetLocList() dict let makeprg = self.makeprgBuild({ 'args_after': '-p' }) - let errorformat = 'luac: %#%f:%l: %m' + let errorformat = '%*\f: %#%f:%l: %m' return SyntasticMake({ \ 'makeprg': makeprg, diff --git a/sources_non_forked/syntastic/syntax_checkers/markdown/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/markdown/proselint.vim new file mode 100644 index 00000000..3f275749 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/markdown/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/nasm/nasm.vim b/sources_non_forked/syntastic/syntax_checkers/nasm/nasm.vim index e309c1f3..7ea86d1a 100644 --- a/sources_non_forked/syntastic/syntax_checkers/nasm/nasm.vim +++ b/sources_non_forked/syntastic/syntax_checkers/nasm/nasm.vim @@ -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() }) diff --git a/sources_non_forked/syntastic/syntax_checkers/nroff/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/nroff/proselint.vim new file mode 100644 index 00000000..d969490e --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/nroff/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim b/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim index e039518a..ca3d0d76 100644 --- a/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim +++ b/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim @@ -1,6 +1,6 @@ "============================================================================ "File: perl.vim -"Description: Syntax checking plugin for syntastic.vim +"Description: Syntax checking plugin for syntastic "Maintainer: Anthony Carapetis , " Eric Harmon "License: This program is free software. It comes without any warranty, @@ -23,7 +23,7 @@ " " let g:syntastic_enable_perl_checker = 1 " -" References: +" Reference: " " - http://perldoc.perl.org/perlrun.html#*-c* @@ -55,15 +55,15 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict " {{{1 call syntastic#log#oneTimeWarn('variable g:syntastic_perl_lib_path should be a list') let includes = split(g:syntastic_perl_lib_path, ',') else - let includes = copy(syntastic#util#var('perl_lib_path')) + let includes = copy(syntastic#util#var('perl_lib_path', [])) endif let shebang = syntastic#util#parseShebang() - let extra = join(map(includes, '"-I" . v:val')) . - \ (index(shebang['args'], '-T') >= 0 ? ' -T' : '') . - \ (index(shebang['args'], '-t') >= 0 ? ' -t' : '') + let extra = map(includes, '"-I" . v:val') + + \ (index(shebang['args'], '-T') >= 0 ? ['-T'] : []) + + \ (index(shebang['args'], '-t') >= 0 ? ['-t'] : []) let errorformat = '%f:%l:%m' - let makeprg = self.makeprgBuild({ 'args_before': '-c -X ' . extra }) + let makeprg = self.makeprgBuild({ 'args_before': ['-c', '-X '] + extra }) let errors = SyntasticMake({ \ 'makeprg': makeprg, @@ -74,7 +74,7 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict " {{{1 return errors endif - let makeprg = self.makeprgBuild({ 'args_before': '-c -Mwarnings ' . extra }) + let makeprg = self.makeprgBuild({ 'args_before': ['-c', '-Mwarnings'] + extra }) return SyntasticMake({ \ 'makeprg': makeprg, diff --git a/sources_non_forked/syntastic/syntax_checkers/pod/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/pod/proselint.vim new file mode 100644 index 00000000..bcb67b2f --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/pod/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/rst/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/rst/proselint.vim new file mode 100644 index 00000000..07e8b648 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/rst/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/scala/fsc.vim b/sources_non_forked/syntastic/syntax_checkers/scala/fsc.vim index 25d6a4d7..0398e7ac 100644 --- a/sources_non_forked/syntastic/syntax_checkers/scala/fsc.vim +++ b/sources_non_forked/syntastic/syntax_checkers/scala/fsc.vim @@ -25,11 +25,12 @@ function! SyntaxCheckers_scala_fsc_GetLocList() dict " working directory changing after being started " that's why we better pass an absolute path let makeprg = self.makeprgBuild({ - \ 'args_after': '-Ystop-after:parser', + \ 'args': '-Ystop-after:parser', \ 'fname': syntastic#util#shexpand('%:p') }) let errorformat = \ '%E%f:%l: %trror: %m,' . + \ '%W%f:%l: %tarning:%m,' . \ '%Z%p^,' . \ '%-G%.%#' diff --git a/sources_non_forked/syntastic/syntax_checkers/solidity/solc.vim b/sources_non_forked/syntastic/syntax_checkers/solidity/solc.vim new file mode 100644 index 00000000..e401c3e0 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/solidity/solc.vim @@ -0,0 +1,38 @@ +"============================================================================ +"File: solc.vim +"Description: Solidity syntax checker - using solc +"Maintainer: Jacob Cholewa +"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_solidity_solc_checker') + finish +endif +let g:loaded_syntastic_solidity_solc_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_solidity_solc_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + let errorformat = '%f:%l:%c: %trror: %m' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'solidity', + \ 'name': 'solc'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/syntastic/syntax_checkers/stylus/stylint.vim b/sources_non_forked/syntastic/syntax_checkers/stylus/stylint.vim index f489910e..b32b745e 100644 --- a/sources_non_forked/syntastic/syntax_checkers/stylus/stylint.vim +++ b/sources_non_forked/syntastic/syntax_checkers/stylus/stylint.vim @@ -19,13 +19,25 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_stylus_stylint_GetLocList() dict + if !exists('s:stylint_new') + let s:stylint_new = syntastic#util#versionIsAtLeast(self.getVersion(), [1, 5, 7]) + endif + let makeprg = self.makeprgBuild({}) - let errorformat = - \ '%WWarning: %m,' . - \ '%EError: %m,' . - \ '%CFile: %f,' . - \ '%CLine: %l:%.%#' + if s:stylint_new + let errorformat = + \ '%P%f,' . + \ '%-Q,' . + \ '%\m%l:%c%\s%\+%t%\%%(rror%\|arning%\)%\s%\+%m%\s%\+%\S%\+%\s%#,' . + \ '%\m%l%\s%\+%t%\%%(rror%\|arning%\)%\s%\+%m%\s%\+%\S%\+%\s%#' + else + let errorformat = + \ '%WWarning: %m,' . + \ '%EError: %m,' . + \ '%CFile: %f,' . + \ '%CLine: %l:%.%#' + endif return SyntasticMake({ \ 'makeprg': makeprg, diff --git a/sources_non_forked/syntastic/syntax_checkers/tex/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/tex/proselint.vim new file mode 100644 index 00000000..657503a3 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/tex/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/texinfo/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/texinfo/proselint.vim new file mode 100644 index 00000000..1afac027 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/texinfo/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/text/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/text/proselint.vim new file mode 100644 index 00000000..9aa95132 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/text/proselint.vim @@ -0,0 +1,45 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/syntastic/syntax_checkers/typescript/tsc.vim b/sources_non_forked/syntastic/syntax_checkers/typescript/tsc.vim deleted file mode 100644 index de9242e5..00000000 --- a/sources_non_forked/syntastic/syntax_checkers/typescript/tsc.vim +++ /dev/null @@ -1,66 +0,0 @@ -"============================================================================ -"File: tsc.vim -"Description: TypeScript syntax checker -"Maintainer: Bill Casarin -" -"============================================================================ - -if exists('g:loaded_syntastic_typescript_tsc_checker') - finish -endif -let g:loaded_syntastic_typescript_tsc_checker = 1 - -if !exists('g:syntastic_typescript_tsc_sort') - let g:syntastic_typescript_tsc_sort = 1 -endif - -let s:save_cpo = &cpo -set cpo&vim - -function! SyntaxCheckers_typescript_tsc_IsAvailable() dict - if !executable(self.getExec()) - return 0 - endif - - let version_output = split(syntastic#util#system(self.getExecEscaped() . ' --version'), '\n', 1) - let ver = filter(copy(version_output), 'v:val =~# ''\m\= 0 -endfunction - -function! SyntaxCheckers_typescript_tsc_GetLocList() dict - let makeprg = self.makeprgBuild({ - \ 'args': '--module commonjs', - \ 'args_after': (s:tsc_new ? '--noEmit' : '--out ' . syntastic#util#DevNull()) }) - - let errorformat = - \ '%E%f %#(%l\,%c): error %m,' . - \ '%E%f %#(%l\,%c): %m,' . - \ '%Eerror %m,' . - \ '%C%\s%\+%m' - - return SyntasticMake({ - \ 'makeprg': makeprg, - \ 'errorformat': errorformat, - \ 'postprocess': ['guards'], - \ 'defaults': {'bufnr': bufnr('')} }) -endfunction - -call g:SyntasticRegistry.CreateAndRegisterChecker({ - \ 'filetype': 'typescript', - \ 'name': 'tsc'}) - -let &cpo = s:save_cpo -unlet s:save_cpo - -" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim b/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim index 0e03ed0b..19cab49e 100644 --- a/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim +++ b/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim @@ -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 diff --git a/sources_non_forked/syntastic/syntax_checkers/xhtml/proselint.vim b/sources_non_forked/syntastic/syntax_checkers/xhtml/proselint.vim new file mode 100644 index 00000000..aea24a81 --- /dev/null +++ b/sources_non_forked/syntastic/syntax_checkers/xhtml/proselint.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: proselint.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/sources_non_forked/tabular/.gitignore b/sources_non_forked/tabular/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/tabular/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/tabular/LICENSE.md b/sources_non_forked/tabular/LICENSE.md new file mode 100644 index 00000000..2cc76e9d --- /dev/null +++ b/sources_non_forked/tabular/LICENSE.md @@ -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. diff --git a/sources_non_forked/tabular/README.md b/sources_non_forked/tabular/README.md new file mode 100644 index 00000000..adbfeb00 --- /dev/null +++ b/sources_non_forked/tabular/README.md @@ -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`. diff --git a/sources_non_forked/tabular/after/plugin/TabularMaps.vim b/sources_non_forked/tabular/after/plugin/TabularMaps.vim new file mode 100644 index 00000000..998346fc --- /dev/null +++ b/sources_non_forked/tabular/after/plugin/TabularMaps.vim @@ -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 diff --git a/sources_non_forked/tabular/autoload/tabular.vim b/sources_non_forked/tabular/autoload/tabular.vim new file mode 100644 index 00000000..f60a73ca --- /dev/null +++ b/sources_non_forked/tabular/autoload/tabular.vim @@ -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< + :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: diff --git a/sources_non_forked/tabular/plugin/Tabular.vim b/sources_non_forked/tabular/plugin/Tabular.vim new file mode 100644 index 00000000..e73329ac --- /dev/null +++ b/sources_non_forked/tabular/plugin/Tabular.vim @@ -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 removed ] +function! s:ChooseCommandMap(commandline) + let map = s:TabularCommands + let cmd = a:commandline + + if cmd =~# '^\s\+' + if !exists('b:TabularCommands') + let b:TabularCommands = {} + endif + let map = b:TabularCommands + let cmd = substitute(cmd, '^\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 = '\\\@ 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[!] [] name /pattern[/format] +" +" If 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(, 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[!] [] name /pattern/ func [ | func2 [ | func3 ] ] +" +" If 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(, 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, '^/.\{-}\\\@CompleteTabularizeCommand + \ Tabularize ,call Tabularize() + +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,CompleteTabularizeCommand + \ GTabularize , + \ call Tabularize(, { 'mode': 'GTabularize' } ) + +" Stupid vimscript crap, part 2 {{{1 +let &cpo = s:savecpo +unlet s:savecpo + +" vim:set sw=2 sts=2 fdm=marker: diff --git a/sources_non_forked/vim-coffee-script/after/syntax/haml.vim b/sources_non_forked/vim-coffee-script/after/syntax/haml.vim index 4c517ebb..3e186cdc 100644 --- a/sources_non_forked/vim-coffee-script/after/syntax/haml.vim +++ b/sources_non_forked/vim-coffee-script/after/syntax/haml.vim @@ -3,6 +3,11 @@ " URL: http://github.com/kchmck/vim-coffee-script " License: WTFPL + +if exists('b:current_syntax') + let s:current_syntax_save = b:current_syntax +endif + " Inherit coffee from html so coffeeComment isn't redefined and given higher " priority than hamlInterpolation. syn cluster hamlCoffeescript contains=@htmlCoffeeScript @@ -11,3 +16,8 @@ syn region hamlCoffeescriptFilter matchgroup=hamlFilter \ end="^\%(\z1 \| *$\)\@!" \ contains=@hamlCoffeeScript,hamlInterpolation \ keepend + +if exists('s:current_syntax_save') + let b:current_syntax = s:current_syntax_save + unlet s:current_syntax_save +endif diff --git a/sources_non_forked/vim-coffee-script/after/syntax/html.vim b/sources_non_forked/vim-coffee-script/after/syntax/html.vim index 82b44f13..aa01e7e9 100644 --- a/sources_non_forked/vim-coffee-script/after/syntax/html.vim +++ b/sources_non_forked/vim-coffee-script/after/syntax/html.vim @@ -3,9 +3,18 @@ " URL: http://github.com/kchmck/vim-coffee-script " License: WTFPL +if exists('b:current_syntax') + let s:current_syntax_save = b:current_syntax +endif + " Syntax highlighting for text/coffeescript script tags syn include @htmlCoffeeScript syntax/coffee.vim syn region coffeeScript start=##me=s-1 keepend \ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc \ containedin=htmlHead + +if exists('s:current_syntax_save') + let b:current_syntax = s:current_syntax_save + unlet s:current_syntax_save +endif diff --git a/sources_non_forked/vim-coffee-script/syntax/coffee.vim b/sources_non_forked/vim-coffee-script/syntax/coffee.vim index bfb252f5..973bb547 100644 --- a/sources_non_forked/vim-coffee-script/syntax/coffee.vim +++ b/sources_non_forked/vim-coffee-script/syntax/coffee.vim @@ -32,7 +32,7 @@ hi def link coffeeConditional Conditional syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display hi def link coffeeException Exception -syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\)\>/ +syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\)\>/ \ display " The `own` keyword is only a keyword after `for`. syn match coffeeKeyword /\/ contained containedin=coffeeRepeat @@ -107,7 +107,7 @@ hi def link coffeeFloat Float " An error for reserved keywords, taken from the RESERVED array: " http://coffeescript.org/documentation/docs/lexer.html#section-67 -syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|export\|import\|native\|__hasProp\|__extends\|__slice\|__bind\|__indexOf\|implements\|interface\|package\|private\|protected\|public\|static\)\>/ +syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|native\|implements\|interface\|package\|private\|protected\|public\|static\)\>/ \ display hi def link coffeeReservedError Error diff --git a/sources_non_forked/vim-flake8/README.mdown b/sources_non_forked/vim-flake8/README.mdown index 692baadf..00d49515 100644 --- a/sources_non_forked/vim-flake8/README.mdown +++ b/sources_non_forked/vim-flake8/README.mdown @@ -41,7 +41,7 @@ the `` key if so. For example, to remap it to `` instead, use: For flake8 configuration options please consult the following page: -https://flake8.readthedocs.org/en/latest/config.html +http://flake8.pycqa.org/en/latest/user/configuration.html To customize the location of your flake8 binary, set `g:flake8_cmd`: @@ -108,6 +108,20 @@ This plugin goes well together with the following plugin: and ``) +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, diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index 805518ae..576dda19 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -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 @@ -859,7 +859,7 @@ function! s:StageUndo() abort let hash = repo.git_chomp('hash-object', '-w', filename) if !empty(hash) if section ==# 'untracked' - call repo.git_chomp_in_tree('clean', '--', filename) + call repo.git_chomp_in_tree('clean', '-f', '--', filename) elseif section ==# 'unmerged' call repo.git_chomp_in_tree('rm', '--', filename) elseif section ==# 'unstaged' @@ -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 dp :diffput '.nr.'diffupdate' + let nr2 = bufnr('') call s:diffthis() wincmd p execute 'rightbelow '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`' execute 'nnoremap dp :diffput '.nr.'diffupdate' + let nr3 = bufnr('') call s:diffthis() wincmd p call s:diffthis() + execute 'nnoremap d2o :diffget '.nr2.'diffupdate' + execute 'nnoremap d3o :diffget '.nr3.'diffupdate' return post elseif len(args) let arg = join(args, ' ') @@ -2317,7 +2321,7 @@ function! s:Browse(bang,line1,count,...) abort if empty(url) && raw ==# '.' call s:throw("Instaweb failed to start") elseif empty(url) - call s:throw('"'.remote."' is not a supported remote") + call s:throw("'".remote."' is not a supported remote") endif let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))') diff --git a/sources_non_forked/vim-go/.github/ISSUE_TEMPLATE.md b/sources_non_forked/vim-go/.github/ISSUE_TEMPLATE.md index 0adaff3c..467b1287 100644 --- a/sources_non_forked/vim-go/.github/ISSUE_TEMPLATE.md +++ b/sources_non_forked/vim-go/.github/ISSUE_TEMPLATE.md @@ -1,16 +1,14 @@ -### Actual behavior +### Behavior -Write here what's happening ... - -### Expected behavior - -Write here what you're expecting ... +Write here what's happening and what you're expecting instead of... ### Steps to reproduce: -Please create a reproducible case of your problem. Re produce it -with a minimal `vimrc` with all plugins disabled and only `vim-go` -enabled: +Please create a reproducible case of your problem. If this step is +not provided, the issue will be **closed** + +Re produce it with a minimal `vimrc` with all plugins disabled and +only `vim-go` enabled: 1. 2. @@ -22,7 +20,7 @@ Add here your current configuration and additional information that might be useful, such as: * `vimrc` you used to reproduce -* vim version: -* vim-go version -* go version +* vim version: +* vim-go version: +* go version: diff --git a/sources_non_forked/vim-go/.gitignore b/sources_non_forked/vim-go/.gitignore index 926ccaaf..bdeb2b82 100644 --- a/sources_non_forked/vim-go/.gitignore +++ b/sources_non_forked/vim-go/.gitignore @@ -1 +1,2 @@ doc/tags +.DS_Store diff --git a/sources_non_forked/vim-go/CHANGELOG.md b/sources_non_forked/vim-go/CHANGELOG.md index c332edfc..0a6be1cf 100644 --- a/sources_non_forked/vim-go/CHANGELOG.md +++ b/sources_non_forked/vim-go/CHANGELOG.md @@ -1,17 +1,203 @@ -## 1.8 (unplanned) +## 1.11 - Unplanned FEATURES: -* If you open a new buffer with a Go filename it get automatically populated based on the directory. If there are no Go files a simple main package is created, otherwise the file will include the package declaration line based on the package in the current directory. Checkout the demo to see it in action: https://twitter.com/fatih/status/748333086643994624. This is enabled by default. Can be disabled with `let g:go_template_autocreate = 0`. You can use your own template with `let g:go_template_file = "foo.go"` and putting the file under the `templates/` folder. [gh-918] -* The snippet expansion `json` is now much more smarter. It pre populates the placeholder according to the first word and it also applies `snake_case` or `camelCase` conversion. Checkout the demo to see it in action: https://github.com/fatih/vim-go/pull/927 [gh-927] -* **`:GoSameIds`** support. When called highlights all same identifiers in the current file. Can be also enabled to highlight identifiers automatically. Checkout the demo to see it in action: https://twitter.com/fatih/status/753673709278339072. [gh-936] +* Add new `g:go_updatetime` setting to change the default updatetime (which was hardcoded previously) [gh-1055] +* Add new `g:go_template_use_pkg` setting to enable to use cwd as package name instead of basic template file [gh-1124] + +IMPROVEMENTS: + +* Add `statusline` support for `:GoMetaLinter` [gh-1120] +* Quickfix and Location lists contain now a descriptive title (requires at least Vim `7.4.2200`)[gh-1004] + +BUG FIXES: + +* Always use full path to detect packages to be shown in statusline [gh-1121] +* Use `echom` to persist errors in case of multiple echos [gh-1122] +* Fix a race condition where a quickfix window was not closed if a job has succeeded [gh-1123] +* Do not expand coverage arguments for non job execution of `:GoCoverage` [gh-1127] +* `:GoCoverage` doesn't mess up custom syntax anymore [gh-1128] +* Disable autoformat for `asm` files as they might be non Go ASM format [gh-1141] +* Fix indentation broken when using a action with a minus sign like `{{-` [gh-1143] +* Fix breaking Neovim change of passing less arguments to callbacks [gh-1145] +* Fix `guru` commands if custom build tags were set [gh-1136] +* Fix referencing a non defined variable for async commands when bang (!) was used +* Fix `:GoDef` failing for a modified buffer if `hidden` was not set [gh-1132] +* Fix `:GoDefStack` to allow popping from jump list when buffer is modified [gh-1133] + + +## 1.10 (November 24, 2016) + +FEATURES: + +* **Vim 8.0 support!** This is the initial version to add Vim 8.0 based support to + all basic commands (check out below for more information). With time we'll + going to extend it to other commands. All the features are only enabled if + you have at least Vim 8.0.0087. Backwards compatible with Vim 7.4.x. + If you see any problems, please open an issue. + +* 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. +* `:GoBuild`, `:GoTest`, `:GoTestCompile`, `:GoInstall` commands are now fully + async. Async means it doesn't block your UI anymore. If the command finished + it echoes the status. For a better experience use the statusline information + (more info below) + +* `:GoCoverage` and `:GoCoverageBrowser` commands are fully async. +* `:GoDef` is fully async if `guru` is used as command. +* `:GoRename` is fully async . + +* `:GoMetaLinter` is fully asnyc. Also works with the current autosave linting + feature. As a reminder, to enable auto linting on save either call + `:GoMetaLinterAutoSaveToggle` (temporary) or add `let + g:go_metalinter_autosave = 1` (persistent) to your virmc). + +* All `guru` commands run asynchronously if Vim 8.0 is being used. Current + Commands: + * GoImplements + * GoWhicherrs + * GoCallees + * GoDescribe + * GoCallers + * GoCallstack + * GoFreevars + * GoChannelPeers + * GoReferrers + +* `:GoSameIds` also runs asynchronously. This makes it useful especially for + auto sameids mode. In this mode it constantly evaluates the identifier under the + cursor whenever it's in hold position and then calls :GoSameIds. As a + reminder, to enable auto info either call `:GoSameIdsAutoToggle`(temporary) + or add `let g:go_auto_sameids = 1` (persistent) to your vimrc. + +* `:GoInfo` is now non blocking and works in async mode if `guru` is used in + `g:go_info_mode`. This makes it useful especially for autoinfo mode. In this + mode it constantly evaluates the identifier under the cursor whenever it's in + hold position and then calls :GoInfo. As a reminder, to enable auto info + either call `:GoAutoTypeInfoToggle`(temporary) or add `let + g:go_auto_type_info = 1` (persistent) to your vimrc. To use `guru` instead of + `gocode` add following to your vimrc: `let g:go_info_mode = 'guru'` + + The `guru` is more accurate and reliabed due the usage of `guru` describe. It + doesn't rely on `pkg/` folder like `gocode` does. However it's slower than + `gocode` as there is no caching mechanism in `guru` yet. + +* **New**: Statusline function: `go#statusline#Show()` which can be plugged into + the statusline bar. Works only with vim 8.0. It shows all asynchronously + called functions status real time. Checkout it in action: + https://twitter.com/fatih/status/800473735467847680. To enable it add the + following to your `vimrc`. If you use lightline, airline, .. check out their + respective documentation on how to add a custom function: + +```viml +" go command status (requires vim-go) +set statusline+=%#goStatuslineColor# +set statusline+=%{go#statusline#Show()} +set statusline+=%* +``` + +IMPROVEMENTS: + +* **:GoDocBrowser** is now capable to to understand the identifier under the cursor (just like :GoDoc) +* Function calls are now highlighted as well when `g:go_highlight_functions` is enabled [gh-1048] +* Add completion support for un-imported packages. This allows to complete even + if the package is not imported. By default it's disabled, enable by adding + `let g:go_gocode_unimported_packages = 1` [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] +* Added new setting `g:go_echo_go_info` to enable/disable printing identifier + information when completion is done [gh-1101] +* Added new `go_echo_command_info` setting is added, which is enabled by + default. It's just a switch for disabling messages of commands, such as + `:GoBuild`, `:GoTest`, etc.. Useful to *disable* if `go#statusline#Show()` is + being used in Statusline, to prevent to see duplicates notifications. +* goSameId highlighting is now linked to `Search`, which is much more clear as + it changes according to the users colorscheme +* Add plug mapping `(go-lint)` for :GoLint [gh-1089] + + +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] +* Internal: add `abort` to all vim function to return in case of errors [gh-1100] +* Fix `:GoCoverage` to be executed if working dir is not inside the test dir [gh-1033] + +BACKWARDS INCOMPATIBILITIES: + +* remove vim-dispatch and vimproc.vim support. vim 8.0 has now the necessary + API to invoke async jobs and timers. Going forward we should use those. Also + this will remove the burden to maintain compatibility with those plugins. + +* `go#jobcontrol#Statusline()` is removed in favor of the new, global and + extensible `go#statusline#Show()` + +## 1.9 (September 13, 2016) + +IMPROVEMENTS: + +* **guru** uses now the `-modified` flag, which allows us use guru on modified + buffers as well. This affects all commands where `guru` is used. Such as + `:GoDef`, `:GoReferrers`, etc.. [gh-944] +* **:GoDoc** uses now the `-modified` flag under the hood (for `gogetdoc), which allows us to get documentation for the identifier under the cursor ina modified buffer. [gh-1014] +* Cleanup and improve documentation [gh-987] +* Add new `g:go_gocode_socket_type` setting to change the underlying socket type passed to `gocode`. Usefull to fallback to `tcp` on cases such as Bash on Windows [gh-1000] +* `:GoSameIds` is now automatically re-evaluated in cases of buffer reloads (such as `:GoRename`) [gh-998] +* Improve docs about `go_auto_sameids` [gh-1017] +* Improve error message by printing the full path if an incompatible `goimports` is being used [gh-1006] +* `iota` and `nil` are now highlighted correctly and are not treated as booleans [gh-1030] + +BUG FIXES: + +* Fix system calls on Windows [gh-988] +* Fix :GoSameIds and :GoCoverage for light background and after changing color schemes [gh-983] +* Fix TagBar and `GoCallers` for Windows user [gh-999] +* Set updatetime for for `auto_sameids` feature as well [gh-1016] +* Update docs about missing `go_highlight_generate_tags` setting [gh-1023] +* Fix updating the jumplist if `:GoDef` is used [gh-1029] +* Fix highlighting literal percent sign (`%%`) in strings [gh-1011] +* Fix highlighting of nested fields [gh-1007] +* Fix checking for `exepath` feature for the upcoming vim 8.0 release [gh-1046] + +BACKWARDS INCOMPATIBILITIES: + +* Rename `GoMetalinterAutoSaveToggle` to `GoMetaLinterAutoSaveToggle` to make it compatible with the existing `:GoMetaLinter` command [gh-1020] + +## 1.8 (July 31, 2016) + +FEATURES: +* New **`:GoAddTags`** command that adds field tags for the fields of a struct automatically based on the field names. Checkout the demo to see it in action: https://twitter.com/fatih/status/759822857773907968 [gh-971] +* The snippet expansion `json` is now much more smarter. It pre populates the placeholder according to the first word and it also applies `snake_case` or `camelCase` conversion. Together with `:GoAddTags` it gives `vim-go` users flexible ways of populating a field tag. Checkout the demo to see it in action: https://twitter.com/fatih/status/754477622042689536 [gh-927] +* New **`:GoSameIds`** command. When called highlights all same identifiers in the current file. Can be also enabled to highlight identifiers automatically (with `:GoSameIdsAutoToggle` or `g:go_auto_sameids`). Checkout the demo to see it in action: https://twitter.com/fatih/status/753673709278339072. [gh-936] +* New **`:GoWhicherrs`** command. It shows all possible values of the selected error variable. [gh-948] * Add new `errp` snippet to expand an `if err != nil { panic() }` clause [gh-926] +* If you open a new buffer with a Go filename it get automatically populated based on the directory. If there are no Go files a simple main package is created, otherwise the file will include the package declaration line based on the package in the current directory. Checkout the demo to see it in action: https://twitter.com/fatih/status/748333086643994624. This is enabled by default. Can be disabled with `let g:go_template_autocreate = 0`. You can use your own template with `let g:go_template_file = "foo.go"` and putting the file under the `templates/` folder. [gh-918] +* Added new toggle commands to enable/disable feature that run for your + automatic. For example if you have `let g:go_auto_type_info = 1` enabled, you + can now easily enable/disable it on the fly. Support added with the following + commands: `:GoAutoTypeInfoToggle`, `:GoFmtAutoSaveToggle`, + `:GoAsmFmtAutoSaveToggle`, `:GoMetalinterAutoSaveToggle`, + `:GoTemplateAutoCreateToggle` [gh-945] + IMPROVEMENTS: * `:GoDoc` accepts arguments now which are passed directly to `godoc`. So usages like `:GoDoc flag` works again (it was changed in previous versions [gh-894] * `:GoDef` works now for modified files as well [gh-910] +* Internal: pass filename to the `--srcdir` flag to enable upcoming `goimports` features [gh-957] * Internal: fix indentations on all files to **2-spaces/no tabs**. This is now the default vim-go style across all VimL files [gh-915] +* Internal: autocmd settings can be now dynamically enabled/disabled [gh-939] +* Internal: automatically detect `GOPATH` for :GoInstall [gh-980] +* Internal: shell executions uses now by default `sh` and then resets it back to the user preference. [gh-967] * Syntax: improved syntax highglighting performance for methods, fields, structs and interface type declarations [gh-917] +* Syntax: moved `:GoCoverage` highlight definition into go's syntax file for more customizability [gh-962] + BUG FIXES: @@ -21,6 +207,7 @@ BUG FIXES: * Fix `:GoFmt` not picking up `-srcdir` if the command was set to use `goimports` [gh-904] * Fix `:GoTestCompile` to not leave behind artifacts if the cwd and the test files's directory do not match [gh-909] * Fix `:GoDocBrowser` to not fail if godoc doesn't exist [gh-920] +* Fix `:GoFmt` to not change the permissions of saved file. Now original file permissions are restored [gh-922] BACKWARDS INCOMPATIBILITIES: diff --git a/sources_non_forked/vim-go/LICENSE b/sources_non_forked/vim-go/LICENSE index e9cc0dcd..fd538bde 100644 --- a/sources_non_forked/vim-go/LICENSE +++ b/sources_non_forked/vim-go/LICENSE @@ -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 diff --git a/sources_non_forked/vim-go/README.md b/sources_non_forked/vim-go/README.md index b65ca08e..504149b2 100644 --- a/sources_non_forked/vim-go/README.md +++ b/sources_non_forked/vim-go/README.md @@ -1,5 +1,9 @@ # vim-go +

+ Vim-go logo +

+ Go (golang) support for Vim, which comes with pre-defined sensible settings (like auto gofmt on save), with autocomplete, snippet support, improved syntax highlighting, go toolchain commands, and more. If needed vim-go installs all @@ -7,8 +11,6 @@ necessary binaries for providing seamless Vim integration with current commands. It's highly customizable and each individual feature can be disabled/enabled easily. -![vim-go](https://dl.dropboxusercontent.com/u/174404/vim-go-2.png) - ## Features * Improved Syntax highlighting with items such as Functions, Operators, Methods. @@ -44,16 +46,20 @@ disabled/enabled easily. * Custom vim text objects such as `a function` or `inner function` list. * Jump to function or type declarations with `:GoDecls` or `:GoDeclsDir` -* A async launcher for the go command is implemented for Neovim, fully async - building and testing (beta). -* Integrated with the Neovim terminal, launch `:GoRun` and other go commands - in their own new terminal. (beta) +* Vim 8.0 support. Async execution for most commands, various underlying improvements. +* NeoVim support (beta). Async execution for some commands. * Alternate between implementation and test code with `:GoAlternate` +Checkout the official [tutorial](https://github.com/fatih/vim-go-tutorial) +that goes literally over all features and shows many tips and tricks. It shows +how to install vim-go and explains many unknown use cases. Recommended for +beginners as well as advanced users: https://github.com/fatih/vim-go-tutorial + ## Install -Master branch is supposed to be a development branch. So stuff here can break and change. -Please try use always the [latest release](https://github.com/fatih/vim-go/releases/latest) +Master branch is supposed to be a development branch. So stuff here can break +and change. Please try use always the [latest +release](https://github.com/fatih/vim-go/releases/latest) Vim-go follows the standard runtime path structure, so I highly recommend to use a common and well known plugin manager to install vim-go. Do not use vim-go @@ -69,6 +75,8 @@ command. * `NeoBundle 'fatih/vim-go'` * [Vundle](https://github.com/gmarik/vundle) * `Plugin 'fatih/vim-go'` +* [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528) + * `git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go` Please be sure all necessary binaries are installed (such as `gocode`, `godef`, `goimports`, etc.). You can easily install them with the included @@ -84,7 +92,8 @@ installed binaries. completion (completion by type) install: [neocomplete](https://github.com/Shougo/neocomplete.vim) for Vim or [deoplete](https://github.com/Shougo/deoplete.nvim) and -[deoplete-go](https://github.com/zchee/deoplete-go) for NeoVim +[deoplete-go](https://github.com/zchee/deoplete-go) for NeoVim or +[SimpleAutoCmplPop](https://github.com/roxma/SimpleAutoComplPop) * To display source code tag information on a sidebar install [tagbar](https://github.com/majutsushi/tagbar). * For snippet features install: @@ -226,9 +235,10 @@ let g:go_get_update = 0 ### Using with Neovim (beta) Note: Neovim currently is not a first class citizen for vim-go. You are free -to open bugs but I'm not going to look at them. Even though I'm using Neovim -myself, Neovim itself is still alpha. So vim-go might not work well as good as -in Vim. I'm happy to accept pull requests or very detailed bug reports. +to open bug, however I'm not using Neovim so it's hard for me to test it. +vim-go might not work well as good as in Vim. I'm happy to accept pull requests +or very detailed bug reports. If you're interested to improve the state of +Neovim in vim-go you're always welcome! Run `:GoRun` in a new tab, horizontal split or vertical split terminal @@ -270,7 +280,6 @@ To resolve this: let g:go_list_type = "quickfix" ``` - ## More info Check out the [Wiki](https://github.com/fatih/vim-go/wiki) page for more @@ -282,8 +291,12 @@ other [various pieces](https://github.com/fatih/vim-go/wiki) of information. ## Donation People have asked for this for a long time, now you can be a fully supporter by -[being a patron](https://www.patreon.com/fatih)! This is fully optional and is -just a way to support vim-go's ongoing development directly. Thanks! +[being a patron](https://www.patreon.com/fatih)! + +By being a patron, you are enabling vim-go to grow and mature, helping me to +invest in bug fixes, new documentation, and improving both current and future +features. It's completely optional and is just a direct way to support Vim-go's +ongoing development. Thanks! [https://www.patreon.com/fatih](https://www.patreon.com/fatih) diff --git a/sources_non_forked/vim-go/assets/screenshot.png b/sources_non_forked/vim-go/assets/screenshot.png new file mode 100644 index 00000000..8b2923d7 Binary files /dev/null and b/sources_non_forked/vim-go/assets/screenshot.png differ diff --git a/sources_non_forked/vim-go/assets/vim-go.png b/sources_non_forked/vim-go/assets/vim-go.png new file mode 100644 index 00000000..cb26e2c0 Binary files /dev/null and b/sources_non_forked/vim-go/assets/vim-go.png differ diff --git a/sources_non_forked/vim-go/assets/vim-go.svg b/sources_non_forked/vim-go/assets/vim-go.svg new file mode 100644 index 00000000..8471db59 --- /dev/null +++ b/sources_non_forked/vim-go/assets/vim-go.svg @@ -0,0 +1,821 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources_non_forked/vim-go/autoload/ctrlp/decls.vim b/sources_non_forked/vim-go/autoload/ctrlp/decls.vim index 7af2cda7..e1465adb 100644 --- a/sources_non_forked/vim-go/autoload/ctrlp/decls.vim +++ b/sources_non_forked/vim-go/autoload/ctrlp/decls.vim @@ -14,12 +14,12 @@ else let g:ctrlp_ext_vars = [s:go_decls_var] endif -function! ctrlp#decls#init() +function! ctrlp#decls#init() abort cal s:enable_syntax() return s:decls endfunction -function! ctrlp#decls#exit() +function! ctrlp#decls#exit() abort unlet! s:decls s:current_dir s:target endfunction @@ -28,7 +28,7 @@ endfunction " a:mode the mode that has been chosen by pressing or " the values are 'e', 'v', 't' and 'h', respectively " a:str the selected string -function! ctrlp#decls#accept(mode, str) +function! ctrlp#decls#accept(mode, str) abort let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' let dir = getcwd() try @@ -56,7 +56,7 @@ function! ctrlp#decls#accept(mode, str) endtry endfunction -function! ctrlp#decls#enter() +function! ctrlp#decls#enter() abort let s:current_dir = fnameescape(expand('%:p:h')) let s:decls = [] @@ -130,7 +130,7 @@ function! ctrlp#decls#enter() endfor endfunc -function! s:enable_syntax() +function! s:enable_syntax() abort if !(has('syntax') && exists('g:syntax_on')) return endif @@ -148,7 +148,7 @@ endfunction let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) -function! ctrlp#decls#cmd(mode, ...) +function! ctrlp#decls#cmd(mode, ...) abort let s:mode = a:mode if a:0 && !empty(a:1) let s:target = a:1 diff --git a/sources_non_forked/vim-go/autoload/go/alternate.vim b/sources_non_forked/vim-go/autoload/go/alternate.vim index dc5643dc..f2cb210f 100644 --- a/sources_non_forked/vim-go/autoload/go/alternate.vim +++ b/sources_non_forked/vim-go/autoload/go/alternate.vim @@ -4,7 +4,7 @@ if !exists("g:go_alternate_mode") endif " Test alternates between the implementation of code and the test code. -function! go#alternate#Switch(bang, cmd) +function! go#alternate#Switch(bang, cmd) abort let file = expand('%') if empty(file) call go#util#EchoError("no buffer name") diff --git a/sources_non_forked/vim-go/autoload/go/asmfmt.vim b/sources_non_forked/vim-go/autoload/go/asmfmt.vim index 711e3274..07779b57 100644 --- a/sources_non_forked/vim-go/autoload/go/asmfmt.vim +++ b/sources_non_forked/vim-go/autoload/go/asmfmt.vim @@ -11,7 +11,7 @@ " " Options: " -" g:go_asmfmt_autosave [default=1] +" g:go_asmfmt_autosave [default=0] " " Flag to automatically call :Fmt when file is saved. @@ -19,7 +19,7 @@ let s:got_fmt_error = 0 " This is a trimmed-down version of the logic in fmt.vim. -function! go#asmfmt#Format() +function! go#asmfmt#Format() abort " Save state. let l:curw = winsaveview() @@ -41,7 +41,11 @@ function! go#asmfmt#Format() " Replace the current file with the temp file; then reload the buffer. let old_fileformat = &fileformat + " save old file permissions + let original_fperm = getfperm(expand('%')) call rename(l:tmpname, expand('%')) + " restore old file permissions + call setfperm(expand('%'), original_fperm) silent edit! let &fileformat = old_fileformat let &syntax = &syntax @@ -51,4 +55,15 @@ function! go#asmfmt#Format() call winrestview(l:curw) endfunction +function! go#asmfmt#ToggleAsmFmtAutoSave() abort + if get(g:, "go_asmfmt_autosave", 0) + let g:go_asmfmt_autosave = 1 + call go#util#EchoProgress("auto asmfmt enabled") + return + end + + let g:go_asmfmt_autosave = 0 + call go#util#EchoProgress("auto asmfmt disabled") +endfunction + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/cmd.vim b/sources_non_forked/vim-go/autoload/go/cmd.vim index a01e30d3..e7a5daf7 100644 --- a/sources_non_forked/vim-go/autoload/go/cmd.vim +++ b/sources_non_forked/vim-go/autoload/go/cmd.vim @@ -1,32 +1,38 @@ -if !exists("g:go_dispatch_enabled") - let g:go_dispatch_enabled = 0 -endif - -function! go#cmd#autowrite() +function! go#cmd#autowrite() abort if &autowrite == 1 - silent wall + silent! wall endif endfunction - " Build builds the source code without producting any output binary. We live in " an editor so the best is to build it to catch errors and fix them. By " default it tries to call simply 'go build', but it first tries to get all " dependent files for the current folder and passes it to go build. -function! go#cmd#Build(bang, ...) +function! go#cmd#Build(bang, ...) abort " expand all wildcards(i.e: '%' to the current file name) let goargs = map(copy(a:000), "expand(v:val)") " escape all shell arguments before we pass it to make - let goargs = go#util#Shelllist(goargs, 1) - + if !has('nvim') + let goargs = go#util#Shelllist(goargs, 1) + endif " create our command arguments. go build discards any results when it " compiles multiple packages. So we pass the `errors` package just as an " placeholder with the current folder (indicated with '.') let args = ["build"] + goargs + [".", "errors"] - " if we have nvim, call it asynchronously and return early ;) - if has('nvim') + if go#util#has_job() + if get(g:, 'go_echo_command_info', 1) + call go#util#EchoProgress("building dispatched ...") + endif + + call s:cmd_job({ + \ 'cmd': ['go'] + args, + \ 'bang': a:bang, + \}) + return + elseif has('nvim') + " if we have nvim, call it asynchronously and return early ;) call go#util#EchoProgress("building dispatched ...") call go#jobcontrol#Spawn(a:bang, "build", args) return @@ -44,10 +50,7 @@ function! go#cmd#Build(bang, ...) let dir = getcwd() try execute cd . fnameescape(expand("%:p:h")) - if g:go_dispatch_enabled && exists(':Make') == 2 - call go#util#EchoProgress("building dispatched ...") - silent! exe 'Make' - elseif l:listtype == "locationlist" + if l:listtype == "locationlist" silent! exe 'lmake!' else silent! exe 'make!' @@ -59,11 +62,8 @@ function! go#cmd#Build(bang, ...) let errors = go#list#Get(l:listtype) call go#list#Window(l:listtype, len(errors)) - - if !empty(errors) - if !a:bang - call go#list#JumpToFirst(l:listtype) - endif + if !empty(errors) && !a:bang + call go#list#JumpToFirst(l:listtype) else call go#util#EchoSuccess("[build] SUCCESS") endif @@ -74,7 +74,7 @@ endfunction " Run runs the current file (and their dependencies if any) in a new terminal. -function! go#cmd#RunTerm(bang, mode, files) +function! go#cmd#RunTerm(bang, mode, files) abort if empty(a:files) let cmd = "go run ". go#util#Shelljoin(go#tool#Files()) else @@ -87,12 +87,18 @@ endfunction " This is intented to test small programs and play with them. It's not " suitable for long running apps, because vim is blocking by default and " calling long running apps will block the whole UI. -function! go#cmd#Run(bang, ...) +function! go#cmd#Run(bang, ...) abort if has('nvim') call go#cmd#RunTerm(a:bang, '', a:000) return endif + if go#util#has_job() + " NOTE(arslan): 'term': 'open' case is not implement for +jobs. This means + " executions waiting for stdin will not work. That's why we don't do + " anything. Once this is implemented we're going to make :GoRun async + endif + let old_gopath = $GOPATH let $GOPATH = go#path#Detect() @@ -118,9 +124,7 @@ function! go#cmd#Run(bang, ...) let l:listtype = go#list#Type("quickfix") - if g:go_dispatch_enabled && exists(':Make') == 2 - silent! exe 'Make' - elseif l:listtype == "locationlist" + if l:listtype == "locationlist" exe 'lmake!' else exe 'make!' @@ -129,7 +133,7 @@ function! go#cmd#Run(bang, ...) let items = go#list#Get(l:listtype) let errors = go#tool#FilterValids(items) - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, &makeprg) call go#list#Window(l:listtype, len(errors)) if !empty(errors) && !a:bang call go#list#JumpToFirst(l:listtype) @@ -140,9 +144,30 @@ function! go#cmd#Run(bang, ...) endfunction " Install installs the package by simple calling 'go install'. If any argument -" is given(which are passed directly to 'go install') it tries to install those -" packages. Errors are populated in the location window. -function! go#cmd#Install(bang, ...) +" is given(which are passed directly to 'go install') it tries to install +" those packages. Errors are populated in the location window. +function! go#cmd#Install(bang, ...) abort + " use vim's job functionality to call it asynchronously + if go#util#has_job() + " expand all wildcards(i.e: '%' to the current file name) + let goargs = map(copy(a:000), "expand(v:val)") + + " escape all shell arguments before we pass it to make + let goargs = go#util#Shelllist(goargs, 1) + + if get(g:, 'go_echo_command_info', 1) + call go#util#EchoProgress("installing dispatched ...") + endif + + call s:cmd_job({ + \ 'cmd': ['go', 'install'] + goargs, + \ 'bang': a:bang, + \}) + return + endif + + let old_gopath = $GOPATH + let $GOPATH = go#path#Detect() let default_makeprg = &makeprg " :make expands '%' and '#' wildcards, so they must also be escaped @@ -156,10 +181,7 @@ function! go#cmd#Install(bang, ...) let dir = getcwd() try execute cd . fnameescape(expand("%:p:h")) - if g:go_dispatch_enabled && exists(':Make') == 2 - call go#util#EchoProgress("building dispatched ...") - silent! exe 'Make' - elseif l:listtype == "locationlist" + if l:listtype == "locationlist" silent! exe 'lmake!' else silent! exe 'make!' @@ -171,21 +193,20 @@ function! go#cmd#Install(bang, ...) let errors = go#list#Get(l:listtype) call go#list#Window(l:listtype, len(errors)) - if !empty(errors) - if !a:bang - call go#list#JumpToFirst(l:listtype) - endif + if !empty(errors) && !a:bang + call go#list#JumpToFirst(l:listtype) else - redraws! | echon "vim-go: " | echohl Function | echon "installed to ". $GOPATH | echohl None + call go#util#EchoSuccess("installed to ". $GOPATH) endif + let $GOPATH = old_gopath let &makeprg = default_makeprg endfunction " Test runs `go test` in the current directory. If compile is true, it'll " compile the tests instead of running them (useful to catch errors in the " test files). Any other argument is appendend to the final `go test` command -function! go#cmd#Test(bang, compile, ...) +function! go#cmd#Test(bang, compile, ...) abort let args = ["test"] " don't run the test, only compile it. Useful to capture and fix errors. @@ -195,9 +216,15 @@ function! go#cmd#Test(bang, compile, ...) endif if a:0 - " expand all wildcards(i.e: '%' to the current file name) - let goargs = map(copy(a:000), "expand(v:val)") - if !has('nvim') + let goargs = a:000 + + " do not expand for coverage mode as we're passing the arg ourself + if a:1 != '-coverprofile' + " expand all wildcards(i.e: '%' to the current file name) + let goargs = map(copy(a:000), "expand(v:val)") + endif + + if !(has('nvim') || go#util#has_job()) let goargs = go#util#Shelllist(goargs, 1) endif @@ -208,13 +235,29 @@ function! go#cmd#Test(bang, compile, ...) call add(args, printf("-timeout=%s", timeout)) endif - if a:compile - echon "vim-go: " | echohl Identifier | echon "compiling tests ..." | echohl None - else - echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None + if get(g:, 'go_echo_command_info', 1) + if a:compile + echon "vim-go: " | echohl Identifier | echon "compiling tests ..." | echohl None + else + echon "vim-go: " | echohl Identifier | echon "testing ..." | echohl None + endif endif - if has('nvim') + if go#util#has_job() + " use vim's job functionality to call it asynchronously + let job_args = { + \ 'cmd': ['go'] + args, + \ 'bang': a:bang, + \ } + + if a:compile + let job_args['custom_cb'] = function('s:test_compile', [compile_file]) + endif + + call s:cmd_job(job_args) + return + elseif has('nvim') + " use nvims's job functionality if get(g:, 'go_term_enabled', 0) let id = go#term#new(a:bang, ["go"] + args) else @@ -248,7 +291,7 @@ function! go#cmd#Test(bang, compile, ...) let errors = go#tool#ParseErrors(split(out, '\n')) let errors = go#tool#FilterValids(errors) - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, command) call go#list#Window(l:listtype, len(errors)) if !empty(errors) && !a:bang call go#list#JumpToFirst(l:listtype) @@ -272,7 +315,7 @@ endfunction " Testfunc runs a single test that surrounds the current cursor position. " Arguments are passed to the `go test` command. -function! go#cmd#TestFunc(bang, ...) +function! go#cmd#TestFunc(bang, ...) abort " search flags legend (used only) " 'b' search backward instead of forward " 'c' accept a match at the cursor position @@ -300,7 +343,7 @@ function! go#cmd#TestFunc(bang, ...) endfunction " Generate runs 'go generate' in similar fashion to go#cmd#Build() -function! go#cmd#Generate(bang, ...) +function! go#cmd#Generate(bang, ...) abort let default_makeprg = &makeprg let old_gopath = $GOPATH @@ -318,9 +361,7 @@ function! go#cmd#Generate(bang, ...) let l:listtype = go#list#Type("quickfix") echon "vim-go: " | echohl Identifier | echon "generating ..."| echohl None - if g:go_dispatch_enabled && exists(':Make') == 2 - silent! exe 'Make' - elseif l:listtype == "locationlist" + if l:listtype == "locationlist" silent! exe 'lmake!' else silent! exe 'make!' @@ -342,12 +383,79 @@ function! go#cmd#Generate(bang, ...) endfunction +" --------------------- +" | Vim job callbacks | +" --------------------- + +function s:cmd_job(args) abort + let status_dir = expand('%:p:h') + let started_at = reltime() + + call go#statusline#Update(status_dir, { + \ 'desc': "current status", + \ 'type': a:args.cmd[1], + \ 'state': "started", + \}) + + " autowrite is not enabled for jobs + call go#cmd#autowrite() + + function! s:error_info_cb(job, exit_status, data) closure abort + let status = { + \ 'desc': 'last status', + \ 'type': a:args.cmd[1], + \ 'state': "success", + \ } + + if a:exit_status + let status.state = "failed" + endif + + let elapsed_time = reltimestr(reltime(started_at)) + " strip whitespace + let elapsed_time = substitute(elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '') + let status.state .= printf(" (%ss)", elapsed_time) + + call go#statusline#Update(status_dir, status) + endfunction + + let a:args.error_info_cb = function('s:error_info_cb') + let callbacks = go#job#Spawn(a:args) + + let start_options = { + \ 'callback': callbacks.callback, + \ 'close_cb': callbacks.close_cb, + \ } + + " modify GOPATH if needed + let old_gopath = $GOPATH + let $GOPATH = go#path#Detect() + + " pre start + let dir = getcwd() + let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' + let jobdir = fnameescape(expand("%:p:h")) + execute cd . jobdir + + call job_start(a:args.cmd, start_options) + + " post start + execute cd . fnameescape(dir) + let $GOPATH = old_gopath +endfunction + + +" test_compile is called when a GoTestCompile call is finished +function! s:test_compile(test_file, job, exit_status, data) abort + call delete(a:test_file) +endfunction + " ----------------------- " | Neovim job handlers | " ----------------------- let s:test_compile_handlers = {} -function! s:test_compile_handler(job, exit_status, data) +function! s:test_compile_handler(job, exit_status, data) abort if !has_key(s:test_compile_handlers, a:job.id) return endif diff --git a/sources_non_forked/vim-go/autoload/go/complete.vim b/sources_non_forked/vim-go/autoload/go/complete.vim index 96fc36c8..2663afbd 100644 --- a/sources_non_forked/vim-go/autoload/go/complete.vim +++ b/sources_non_forked/vim-go/autoload/go/complete.vim @@ -1,4 +1,6 @@ -function! s:gocodeCurrentBuffer() +let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix' + +function! s:gocodeCurrentBuffer() abort let buf = getline(1, '$') if &encoding != 'utf-8' let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")') @@ -14,7 +16,7 @@ function! s:gocodeCurrentBuffer() return file endfunction -function! s:gocodeCommand(cmd, preargs, args) +function! s:gocodeCommand(cmd, preargs, args) abort for i in range(0, len(a:args) - 1) let a:args[i] = go#util#Shellescape(a:args[i]) endfor @@ -30,11 +32,22 @@ 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 result = go#util#System(printf('%s %s %s %s', go#util#Shellescape(bin_path), join(a:preargs), go#util#Shellescape(a:cmd), join(a:args))) + let socket_type = get(g:, 'go_gocode_socket_type', s:sock_type) + let cmd = printf('%s -sock %s %s %s %s', + \ go#util#Shellescape(bin_path), + \ socket_type, + \ join(a:preargs), + \ go#util#Shellescape(a:cmd), + \ join(a:args) + \ ) + let result = go#util#System(cmd) let $GOPATH = old_gopath + let $GOROOT = old_goroot if go#util#ShellError() != 0 return "[\"0\", []]" @@ -46,12 +59,12 @@ function! s:gocodeCommand(cmd, preargs, args) endif endfunction -function! s:gocodeCurrentBufferOpt(filename) +function! s:gocodeCurrentBufferOpt(filename) abort return '-in=' . a:filename endfunction let s:optionsEnabled = 0 -function! s:gocodeEnableOptions() +function! s:gocodeEnableOptions() abort if s:optionsEnabled return endif @@ -65,13 +78,14 @@ 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', 0)))) endfunction -function! s:toBool(val) +function! s:toBool(val) abort if a:val | return 'true ' | else | return 'false' | endif endfunction -function! s:gocodeAutocomplete() +function! s:gocodeAutocomplete() abort call s:gocodeEnableOptions() let filename = s:gocodeCurrentBuffer() @@ -82,7 +96,7 @@ function! s:gocodeAutocomplete() return result endfunction -function! go#complete#GetInfo() +function! go#complete#GetInfo() abort let offset = go#util#OffsetCursor()+1 let filename = s:gocodeCurrentBuffer() let result = s:gocodeCommand('autocomplete', @@ -123,7 +137,7 @@ function! go#complete#GetInfo() return "" endfunction -function! go#complete#Info(auto) +function! go#complete#Info(auto) abort " auto is true if we were called by g:go_auto_type_info's autocmd let result = go#complete#GetInfo() if !empty(result) @@ -133,12 +147,12 @@ function! go#complete#Info(auto) endif endfunction -function! s:trim_bracket(val) +function! s:trim_bracket(val) abort let a:val.word = substitute(a:val.word, '[(){}\[\]]\+$', '', '') return a:val endfunction -function! go#complete#Complete(findstart, base) +function! go#complete#Complete(findstart, base) abort "findstart = 1 when we need to get the text length if a:findstart == 1 execute "silent let g:gocomplete_completions = " . s:gocodeAutocomplete() @@ -153,4 +167,16 @@ function! go#complete#Complete(findstart, base) endif endf +function! go#complete#ToggleAutoTypeInfo() abort + if get(g:, "go_auto_type_info", 0) + let g:go_auto_type_info = 0 + call go#util#EchoProgress("auto type info disabled") + return + end + + let g:go_auto_type_info = 1 + call go#util#EchoProgress("auto type info enabled") +endfunction + + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/coverage.vim b/sources_non_forked/vim-go/autoload/go/coverage.vim index 83082174..9b027861 100644 --- a/sources_non_forked/vim-go/autoload/go/coverage.vim +++ b/sources_non_forked/vim-go/autoload/go/coverage.vim @@ -3,7 +3,7 @@ let s:toggle = 0 " Buffer creates a new cover profile with 'go test -coverprofile' and changes " the current buffers highlighting to show covered and uncovered sections of " the code. If run again it clears the annotation. -function! go#coverage#BufferToggle(bang, ...) +function! go#coverage#BufferToggle(bang, ...) abort if s:toggle call go#coverage#Clear() return @@ -20,7 +20,7 @@ endfunction " teh current buffers highlighting to show covered and uncovered sections of " the code. Calling it again reruns the tests and shows the last updated " coverage. -function! go#coverage#Buffer(bang, ...) +function! go#coverage#Buffer(bang, ...) abort " we use matchaddpos() which was introduce with 7.4.330, be sure we have " it: http://ftp.vim.org/vim/patches/7.4/7.4.330 if !exists("*matchaddpos") @@ -43,8 +43,17 @@ function! go#coverage#Buffer(bang, ...) let s:toggle = 1 let l:tmpname = tempname() - let args = [a:bang, 0, "-coverprofile", l:tmpname] + if go#util#has_job() + call s:coverage_job({ + \ 'cmd': ['go', 'test', '-coverprofile', l:tmpname], + \ 'custom_cb': function('s:coverage_callback', [l:tmpname]), + \ 'bang': a:bang, + \ }) + return + endif + + let args = [a:bang, 0, "-coverprofile", l:tmpname] if a:0 call extend(args, a:000) endif @@ -75,11 +84,8 @@ function! go#coverage#Buffer(bang, ...) endfunction " Clear clears and resets the buffer annotation matches -function! go#coverage#Clear() - " only reset the syntax if the user has syntax enabled - if !empty(&syntax) - if exists("g:syntax_on") | syntax enable | endif - endif +function! go#coverage#Clear() abort + call clearmatches() if exists("s:toggle") | let s:toggle = 0 | endif @@ -87,25 +93,34 @@ function! go#coverage#Clear() if exists("#BufWinLeave#") autocmd! BufWinLeave endif - - call clearmatches() endfunction " Browser creates a new cover profile with 'go test -coverprofile' and opens " a new HTML coverage page from that profile in a new browser -function! go#coverage#Browser(bang, ...) +function! go#coverage#Browser(bang, ...) abort let l:tmpname = tempname() - let args = [a:bang, 0, "-coverprofile", l:tmpname] + if go#util#has_job() + call s:coverage_job({ + \ 'cmd': ['go', 'test', '-coverprofile', l:tmpname], + \ 'custom_cb': function('s:coverage_browser_callback', [l:tmpname]), + \ 'bang': a:bang, + \ }) + return + endif + let args = [a:bang, 0, "-coverprofile", l:tmpname] if a:0 call extend(args, a:000) endif + let id = call('go#cmd#Test', args) if has('nvim') call go#jobcontrol#AddHandler(function('s:coverage_browser_handler')) let s:coverage_browser_handler_jobs[id] = l:tmpname return endif + + if go#util#ShellError() == 0 let openHTML = 'go tool cover -html='.l:tmpname call go#tool#ExecuteInDir(openHTML) @@ -116,7 +131,7 @@ endfunction " Parses a single line from the cover file generated via go test -coverprofile " and returns a single coverage profile block. -function! go#coverage#parsegocoverline(line) +function! go#coverage#parsegocoverline(line) abort " file:startline.col,endline.col numstmt count let mx = '\([^:]\+\):\(\d\+\)\.\(\d\+\),\(\d\+\)\.\(\d\+\)\s\(\d\+\)\s\(\d\+\)' let tokens = matchlist(a:line, mx) @@ -133,10 +148,10 @@ endfunction " Generates matches to be added to matchaddpos for the given coverage profile " block -function! go#coverage#genmatch(cov) - let color = 'covered' +function! go#coverage#genmatch(cov) abort + let color = 'goCoverageCovered' if a:cov.cnt == 0 - let color = 'uncover' + let color = 'goCoverageUncover' endif let matches = [] @@ -183,7 +198,7 @@ function! go#coverage#genmatch(cov) endfunction " Reads the given coverprofile file and annotates the current buffer -function! go#coverage#overlay(file) +function! go#coverage#overlay(file) abort if !filereadable(a:file) return endif @@ -195,16 +210,16 @@ function! go#coverage#overlay(file) " contains matches for matchaddpos() let matches = [] - " first mark all lines as normaltext. We use a custom group to not + " first mark all lines as goCoverageNormalText. We use a custom group to not " interfere with other buffers highlightings. Because the priority is " lower than the cover and uncover matches, it'll be overriden. let cnt = 1 while cnt <= line('$') - call add(matches, {'group': 'normaltext', 'pos': [cnt], 'priority': 1}) + call add(matches, {'group': 'goCoverageNormalText', 'pos': [cnt], 'priority': 1}) let cnt += 1 endwhile - let fname = expand('%:t') + let fname = expand('%') " when called for a _test.go file, run the coverage for the actuall file " file @@ -221,6 +236,9 @@ function! go#coverage#overlay(file) exe ":edit ". fnamemodify(fname, ":p") endif + " cov.file includes only the filename itself, without full path + let fname = fnamemodify(fname, ":t") + for line in lines[1:] let cov = go#coverage#parsegocoverline(line) @@ -233,11 +251,6 @@ function! go#coverage#overlay(file) call extend(matches, go#coverage#genmatch(cov)) endfor - syntax manual - highlight normaltext term=bold ctermfg=darkgrey guifg=#75715E - highlight covered term=bold ctermfg=green guifg=#A6E22E - highlight uncover term=bold ctermfg=red guifg=#F92672 - " clear the matches if we leave the buffer autocmd BufWinLeave call go#coverage#Clear() @@ -247,6 +260,78 @@ function! go#coverage#overlay(file) endfunction +" --------------------- +" | Vim job callbacks | +" --------------------- +" +function s:coverage_job(args) + " autowrite is not enabled for jobs + call go#cmd#autowrite() + + let status_dir = expand('%:p:h') + function! s:error_info_cb(job, exit_status, data) closure + let status = { + \ 'desc': 'last status', + \ 'type': "coverage", + \ 'state': "finished", + \ } + + if a:exit_status + let status.state = "failed" + endif + + call go#statusline#Update(status_dir, status) + endfunction + + let a:args.error_info_cb = function('s:error_info_cb') + let callbacks = go#job#Spawn(a:args) + + let start_options = { + \ 'callback': callbacks.callback, + \ 'close_cb': callbacks.close_cb, + \ } + + " modify GOPATH if needed + let old_gopath = $GOPATH + let $GOPATH = go#path#Detect() + + " pre start + let dir = getcwd() + let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' + let jobdir = fnameescape(expand("%:p:h")) + execute cd . jobdir + + call go#statusline#Update(status_dir, { + \ 'desc': "current status", + \ 'type': "coverage", + \ 'state': "started", + \}) + + call job_start(a:args.cmd, start_options) + + " post start + execute cd . fnameescape(dir) + let $GOPATH = old_gopath +endfunction + +" coverage_callback is called when the coverage execution is finished +function! s:coverage_callback(coverfile, job, exit_status, data) + if a:exit_status == 0 + call go#coverage#overlay(a:coverfile) + endif + + call delete(a:coverfile) +endfunction + +function! s:coverage_browser_callback(coverfile, job, exit_status, data) + if a:exit_status == 0 + let openHTML = 'go tool cover -html='.a:coverfile + call go#tool#ExecuteInDir(openHTML) + endif + + call delete(a:coverfile) +endfunction + " ----------------------- " | Neovim job handlers | " ----------------------- @@ -254,7 +339,7 @@ endfunction let s:coverage_handler_jobs = {} let s:coverage_browser_handler_jobs = {} -function! s:coverage_handler(job, exit_status, data) +function! s:coverage_handler(job, exit_status, data) abort if !has_key(s:coverage_handler_jobs, a:job.id) return endif @@ -267,7 +352,7 @@ function! s:coverage_handler(job, exit_status, data) unlet s:coverage_handler_jobs[a:job.id] endfunction -function! s:coverage_browser_handler(job, exit_status, data) +function! s:coverage_browser_handler(job, exit_status, data) abort if !has_key(s:coverage_browser_handler_jobs, a:job.id) return endif @@ -282,4 +367,5 @@ function! s:coverage_browser_handler(job, exit_status, data) unlet s:coverage_browser_handler_jobs[a:job.id] endfunction + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/def.vim b/sources_non_forked/vim-go/autoload/go/def.vim index bea95117..d3b51c26 100644 --- a/sources_non_forked/vim-go/autoload/go/def.vim +++ b/sources_non_forked/vim-go/autoload/go/def.vim @@ -1,17 +1,11 @@ let s:go_stack = [] let s:go_stack_level = 0 -function! go#def#Jump(mode) +function! go#def#Jump(mode) abort let old_gopath = $GOPATH let $GOPATH = go#path#Detect() let fname = fnamemodify(expand("%"), ':p:gs?\\?/?') - if &modified - " Write current unsaved buffer to a temp file and use the modified content - let l:tmpname = tempname() - call writefile(getline(1, '$'), l:tmpname) - let fname = l:tmpname - endif " so guru right now is slow for some people. previously we were using " godef which also has it's own quirks. But this issue come up so many @@ -19,6 +13,13 @@ function! go#def#Jump(mode) " covers all edge cases, but now anyone can switch to godef if they wish let bin_name = get(g:, 'go_def_mode', 'guru') if bin_name == 'godef' + if &modified + " Write current unsaved buffer to a temp file and use the modified content + let l:tmpname = tempname() + call writefile(getline(1, '$'), l:tmpname) + let fname = l:tmpname + endif + let bin_path = go#path#CheckBinPath("godef") if empty(bin_path) let $GOPATH = old_gopath @@ -26,11 +27,9 @@ function! go#def#Jump(mode) endif let command = printf("%s -f=%s -o=%s -t", bin_path, fname, go#util#OffsetCursor()) let out = go#util#System(command) - - " append the type information to the same line so our - " jump_to_declaration() function can parse it. This makes it - " compatible with guru definition as well too - let out = join(split(out, '\n'), ':') + if exists("l:tmpname") + call delete(l:tmpname) + endif elseif bin_name == 'guru' let bin_path = go#path#CheckBinPath("guru") if empty(bin_path) @@ -38,36 +37,78 @@ function! go#def#Jump(mode) return endif - let flags = "" - if exists('g:go_guru_tags') - let tags = get(g:, 'go_guru_tags') - let flags = printf(" -tags %s", tags) + let cmd = [bin_path] + let stdin_content = "" + + if &modified + let sep = go#util#LineEnding() + let content = join(getline(1, '$'), sep) + let stdin_content = fname . "\n" . strlen(content) . "\n" . content + call add(cmd, "-modified") endif - let fname = shellescape(fname.':#'.go#util#OffsetCursor()) - let command = printf("%s %s definition %s", bin_path, flags, fname) - let out = go#util#System(command) + if exists('g:go_guru_tags') + let tags = get(g:, 'go_guru_tags') + call extend(cmd, ["-tags", tags]) + endif + + let fname = fname.':#'.go#util#OffsetCursor() + call extend(cmd, ["definition", fname]) + + if go#util#has_job() + let l:spawn_args = { + \ 'cmd': cmd, + \ 'custom_cb': function('s:jump_to_declaration_cb', [a:mode, bin_name]), + \ } + + if &modified + let l:spawn_args.input = stdin_content + endif + + call go#util#EchoProgress("searching declaration ...") + + call s:def_job(spawn_args) + return + endif + + let command = join(cmd, " ") + if &modified + let out = go#util#System(command, stdin_content) + else + let out = go#util#System(command) + endif else call go#util#EchoError('go_def_mode value: '. bin_name .' is not valid. Valid values are: [godef, guru]') return endif - if exists("l:tmpname") - call delete(l:tmpname) - endif - if go#util#ShellError() != 0 call go#util#EchoError(out) return endif - call s:jump_to_declaration(out, a:mode) + call s:jump_to_declaration(out, a:mode, bin_name) let $GOPATH = old_gopath endfunction -function! s:jump_to_declaration(out, mode) +function! s:jump_to_declaration_cb(mode, bin_name, job, exit_status, data) abort + if a:exit_status != 0 + return + endif + + call s:jump_to_declaration(a:data[0], a:mode, a:bin_name) +endfunction + +function! s:jump_to_declaration(out, mode, bin_name) abort + let final_out = a:out + if a:bin_name == "godef" + " append the type information to the same line so our we can parse it. + " This makes it compatible with guru output. + let final_out = join(split(a:out, '\n'), ':') + endif + " strip line ending - let out = split(a:out, go#util#LineEnding())[0] + let out = split(final_out, go#util#LineEnding())[0] if go#util#IsWin() let parts = split(out, '\(^[a-zA-Z]\)\@ q :call go#ui#CloseWindow() endfunction -function! go#def#StackClear(...) +function! go#def#StackClear(...) abort let s:go_stack = [] let s:go_stack_level = 0 endfunction -function! go#def#StackPop(...) +function! go#def#StackPop(...) abort if len(s:go_stack) == 0 call go#util#EchoError("godef stack empty") return @@ -200,7 +252,7 @@ function! go#def#StackPop(...) call go#def#Stack(newLevel + 1) endfunction -function! go#def#Stack(...) +function! go#def#Stack(...) abort if len(s:go_stack) == 0 call go#util#EchoError("godef stack empty") return @@ -228,7 +280,13 @@ function! go#def#Stack(...) let target = s:go_stack[s:go_stack_level] " jump - exec 'edit '.target["file"] + if expand('%:p') != target["file"] + if &modified + exec 'hide edit' target["file"] + else + exec 'edit' target["file"] + endif + endif call cursor(target["line"], target["col"]) normal! zz else @@ -236,4 +294,27 @@ function! go#def#Stack(...) endif endfunction +function s:def_job(args) abort + function! s:error_info_cb(job, exit_status, data) closure + " do not print anything during async definition search&jump + endfunction + + let a:args.error_info_cb = function('s:error_info_cb') + let callbacks = go#job#Spawn(a:args) + + let start_options = { + \ 'callback': callbacks.callback, + \ 'close_cb': callbacks.close_cb, + \ } + + if &modified + let l:tmpname = tempname() + call writefile(split(a:args.input, "\n"), l:tmpname, "b") + let l:start_options.in_io = "file" + let l:start_options.in_name = l:tmpname + endif + + call job_start(a:args.cmd, start_options) +endfunction + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/doc.vim b/sources_non_forked/vim-go/autoload/go/doc.vim index 70250109..3756167d 100644 --- a/sources_non_forked/vim-go/autoload/go/doc.vim +++ b/sources_non_forked/vim-go/autoload/go/doc.vim @@ -12,57 +12,39 @@ if !exists("g:go_doc_options") let g:go_doc_options = "" endif -" returns the package and exported name. exported name might be empty. -" ie: fmt and Println -" ie: github.com/fatih/set and New -function! s:godocWord(args) - if !executable('godoc') - let msg = "godoc command not found." - let msg .= " install with: go get golang.org/x/tools/cmd/godoc" - call go#util#EchoWarning(msg) - return [] +function! go#doc#OpenBrowser(...) abort + " check if we have gogetdoc as it gives us more and accurate information. + " Only supported if we have json_decode as it's not worth to parse the plain + " non-json output of gogetdoc + let bin_path = go#path#CheckBinPath('gogetdoc') + if !empty(bin_path) && exists('*json_decode') + let json_out = s:gogetdoc(1) + if go#util#ShellError() != 0 + call go#util#EchoError(json_out) + return + endif + + let out = json_decode(json_out) + if type(out) != type({}) + call go#util#EchoError("gogetdoc output is malformed") + endif + + let import = out["import"] + let name = out["name"] + + " if import is empty, it means we selected a package name + if import ==# "" + let godoc_url = "https://godoc.org/" . name + else + let godoc_url = "https://godoc.org/" . import . "#" . name + endif + + echo godoc_url + + call go#tool#OpenBrowser(godoc_url) + return endif - if !len(a:args) - let oldiskeyword = &iskeyword - setlocal iskeyword+=. - let word = expand('') - let &iskeyword = oldiskeyword - let word = substitute(word, '[^a-zA-Z0-9\\/._~-]', '', 'g') - let words = split(word, '\.\ze[^./]\+$') - else - let words = a:args - endif - - if !len(words) - return [] - endif - - let pkg = words[0] - if len(words) == 1 - let exported_name = "" - else - let exported_name = words[1] - endif - - let packages = go#tool#Imports() - - if has_key(packages, pkg) - let pkg = packages[pkg] - endif - - return [pkg, exported_name] -endfunction - -function! s:godocNotFound(content) - if len(a:content) == 0 - return 1 - endif - - return a:content =~# '^.*: no such file or directory\n$' -endfunction - -function! go#doc#OpenBrowser(...) let pkgs = s:godocWord(a:000) if empty(pkgs) return @@ -76,7 +58,7 @@ function! go#doc#OpenBrowser(...) call go#tool#OpenBrowser(godoc_url) endfunction -function! go#doc#Open(newmode, mode, ...) +function! go#doc#Open(newmode, mode, ...) abort if len(a:000) " check if we have 'godoc' and use it automatically let bin_path = go#path#CheckBinPath('godoc') @@ -85,21 +67,11 @@ function! go#doc#Open(newmode, mode, ...) endif let command = printf("%s %s", bin_path, join(a:000, ' ')) + let out = go#util#System(command) else - " check if we have 'gogetdoc' and use it automatically - let bin_path = go#path#CheckBinPath('gogetdoc') - if empty(bin_path) - return - endif - - let offset = go#util#OffsetCursor() - let fname = expand("%:p:gs!\\!/!") - let pos = shellescape(fname.':#'.offset) - - let command = printf("%s -pos %s", bin_path, pos) + let out = s:gogetdoc(0) endif - let out = go#util#System(command) if go#util#ShellError() != 0 call go#util#EchoError(out) return @@ -108,7 +80,7 @@ function! go#doc#Open(newmode, mode, ...) call s:GodocView(a:newmode, a:mode, out) endfunction -function! s:GodocView(newposition, position, content) +function! s:GodocView(newposition, position, content) abort " reuse existing buffer window if it exists otherwise create a new one if !bufexists(s:buf_nr) execute a:newposition @@ -152,4 +124,96 @@ function! s:GodocView(newposition, position, content) noremap :close endfunction +function! s:gogetdoc(json) abort + " check if we have 'gogetdoc' and use it automatically + let bin_path = go#path#CheckBinPath('gogetdoc') + if empty(bin_path) + return -1 + endif + + let cmd = [bin_path] + + let offset = go#util#OffsetCursor() + let fname = expand("%:p:gs!\\!/!") + let pos = shellescape(fname.':#'.offset) + + let cmd += ["-pos", pos] + if a:json + let cmd += ["-json"] + endif + + let command = join(cmd, " ") + + if &modified + " gogetdoc supports the same archive format as guru for dealing with + " modified buffers. + " use the -modified flag + " write each archive entry on stdin as: + " filename followed by newline + " file size followed by newline + " file contents + let in = "" + let sep = go#util#LineEnding() + let content = join(getline(1, '$'), sep) + let in = fname . "\n" . strlen(content) . "\n" . content + let command .= " -modified" + let out = go#util#System(command, in) + else + let out = go#util#System(command) + endif + + return out +endfunction + +" returns the package and exported name. exported name might be empty. +" ie: fmt and Println +" ie: github.com/fatih/set and New +function! s:godocWord(args) abort + if !executable('godoc') + let msg = "godoc command not found." + let msg .= " install with: go get golang.org/x/tools/cmd/godoc" + call go#util#EchoWarning(msg) + return [] + endif + + if !len(a:args) + let oldiskeyword = &iskeyword + setlocal iskeyword+=. + let word = expand('') + let &iskeyword = oldiskeyword + let word = substitute(word, '[^a-zA-Z0-9\\/._~-]', '', 'g') + let words = split(word, '\.\ze[^./]\+$') + else + let words = a:args + endif + + if !len(words) + return [] + endif + + let pkg = words[0] + if len(words) == 1 + let exported_name = "" + else + let exported_name = words[1] + endif + + let packages = go#tool#Imports() + + if has_key(packages, pkg) + let pkg = packages[pkg] + endif + + return [pkg, exported_name] +endfunction + +function! s:godocNotFound(content) abort + if len(a:content) == 0 + return 1 + endif + + return a:content =~# '^.*: no such file or directory\n$' +endfunction + + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/fmt.vim b/sources_non_forked/vim-go/autoload/go/fmt.vim index eb49553d..391fca93 100644 --- a/sources_non_forked/vim-go/autoload/go/fmt.vim +++ b/sources_non_forked/vim-go/autoload/go/fmt.vim @@ -43,7 +43,7 @@ if !exists("g:go_fmt_experimental") let g:go_fmt_experimental = 0 endif -" we have those problems : +" we have those problems : " http://stackoverflow.com/questions/12741977/prevent-vim-from-updating-its-undo-tree " http://stackoverflow.com/questions/18532692/golang-formatter-and-vim-how-to-destroy-history-record?rq=1 " @@ -51,7 +51,7 @@ endif " it doesn't undo changes and break undo history. If you are here reading " this and have VimL experience, please look at the function for " improvements, patches are welcome :) -function! go#fmt#Format(withGoimport) +function! go#fmt#Format(withGoimport) abort if g:go_fmt_experimental == 1 " Using winsaveview to save/restore cursor state has the problem of " closing folds on save: @@ -115,7 +115,7 @@ function! go#fmt#Format(withGoimport) if !exists('b:goimports_vendor_compatible') let out = go#util#System(bin_path . " --help") if out !~ "-srcdir" - call go#util#EchoWarning("vim-go: goimports does not support srcdir. update with: :GoUpdateBinaries") + call go#util#EchoWarning(printf("vim-go: goimports (%s) does not support srcdir. Update with: :GoUpdateBinaries", bin_path)) else let b:goimports_vendor_compatible = 1 endif @@ -124,7 +124,7 @@ function! go#fmt#Format(withGoimport) if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible let ssl_save = &shellslash set noshellslash - let command = command . '-srcdir ' . shellescape(expand("%:p:h")) + let command = command . '-srcdir ' . shellescape(expand("%:p")) let &shellslash = ssl_save endif endif @@ -149,7 +149,15 @@ function! go#fmt#Format(withGoimport) " Replace current file with temp file, then reload buffer let old_fileformat = &fileformat + if exists("*getfperm") + " save old file permissions + let original_fperm = getfperm(expand('%')) + endif call rename(l:tmpname, expand('%')) + " restore old file permissions + if exists("*setfperm") && original_fperm != '' + call setfperm(expand('%'), original_fperm) + endif silent edit! let &fileformat = old_fileformat let &syntax = &syntax @@ -177,7 +185,7 @@ function! go#fmt#Format(withGoimport) % | " Couldn't detect gofmt error format, output errors endif if !empty(errors) - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, 'Format') echohl Error | echomsg "Gofmt returned error" | echohl None endif @@ -207,4 +215,14 @@ function! go#fmt#Format(withGoimport) endif endfunction +function! go#fmt#ToggleFmtAutoSave() abort + if get(g:, "go_fmt_autosave", 1) + let g:go_fmt_autosave = 0 + call go#util#EchoProgress("auto fmt disabled") + return + end + + let g:go_fmt_autosave = 1 + call go#util#EchoProgress("auto fmt enabled") +endfunction " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/guru.vim b/sources_non_forked/vim-go/autoload/go/guru.vim index 5ddc99d0..78cacc0b 100644 --- a/sources_non_forked/vim-go/autoload/go/guru.vim +++ b/sources_non_forked/vim-go/autoload/go/guru.vim @@ -1,50 +1,63 @@ " guru.vim -- Vim integration for the Go guru. -func! s:RunGuru(mode, format, selected, needs_scope) range abort +" guru_cmd returns a dict that contains the command to execute guru. option +" is dict with following options: +" mode : guru mode, such as 'implements' +" format : output format, either 'plain' or 'json' +" needs_scope : if 1, adds the current package to the scope +" selected : if 1, means it's a range of selection, otherwise it picks up the +" offset under the cursor +" example output: +" {'cmd' : ['guru', '-json', 'implements', 'demo/demo.go:#66']} +function! s:guru_cmd(args) range abort + let mode = a:args.mode + let format = a:args.format + let needs_scope = a:args.needs_scope + let selected = a:args.selected + + let result = {} + let dirname = expand('%:p:h') + let pkg = go#package#ImportPath(dirname) + + " this is important, check it! + if pkg == -1 && needs_scope + return {'err': "current directory is not inside of a valid GOPATH"} + endif + "return with a warning if the binary doesn't exist let bin_path = go#path#CheckBinPath("guru") if empty(bin_path) return {'err': "bin path not found"} endif + " start constructing the command + let cmd = [bin_path] + let filename = fnamemodify(expand("%"), ':p:gs?\\?/?') - if !filereadable(filename) - " this might happen for new buffers which are not written yet - return {'err': "file does not exist"} - endif - + let stdin_content = "" if &modified - " Write current unsaved buffer to a temp file and use the modified content - let l:tmpname = tempname() - call writefile(getline(1, '$'), l:tmpname) - let filename = l:tmpname + let sep = go#util#LineEnding() + let content = join(getline(1, '$'), sep ) + let result.stdin_content = filename . "\n" . strlen(content) . "\n" . content + call add(cmd, "-modified") endif - let dirname = expand('%:p:h') - let pkg = go#package#ImportPath(dirname) - - " this is important, check it! - if pkg == -1 && a:needs_scope - return {'err': "current directory is not inside of a valid GOPATH"} - endif - - " start constructing the 'command' variable - let command = bin_path " enable outputting in json format - if a:format == "json" - let command .= " -json" + if format == "json" + call add(cmd, "-json") endif " check for any tags if exists('g:go_guru_tags') let tags = get(g:, 'go_guru_tags') - let command .= printf(" -tags %s", tags) + call extend(cmd, ["-tags", tags]) + let result.tags = tags endif " some modes require scope to be defined (such as callers). For these we " choose a sensible setting, which is using the current file's package let scopes = [] - if a:needs_scope + if needs_scope let scopes = [pkg] endif @@ -69,241 +82,421 @@ func! s:RunGuru(mode, format, selected, needs_scope) range abort let scopes = go#util#StripTrailingSlash(scopes) " create shell-safe entries of the list - let scopes = go#util#Shelllist(scopes) + if !go#util#has_job() | let scopes = go#util#Shelllist(scopes) | endif " guru expect a comma-separated list of patterns, construct it - let scope = join(scopes, ",") - let command .= printf(" -scope %s", scope) + let l:scope = join(scopes, ",") + let result.scope = l:scope + call extend(cmd, ["-scope", l:scope]) endif let pos = printf("#%s", go#util#OffsetCursor()) - if a:selected != -1 + if selected != -1 " means we have a range, get it let pos1 = go#util#Offset(line("'<"), col("'<")) let pos2 = go#util#Offset(line("'>"), col("'>")) let pos = printf("#%s,#%s", pos1, pos2) endif - " this is our final command let filename .= ':'.pos - let command .= printf(' %s %s', a:mode, shellescape(filename)) + call extend(cmd, [mode, filename]) + + let result.cmd = cmd + return result +endfunction + +" sync_guru runs guru in sync mode with the given arguments +function! s:sync_guru(args) abort + let result = s:guru_cmd(a:args) + if has_key(result, 'err') + call go#util#EchoError(result.err) + return -1 + endif + + if !has_key(a:args, 'disable_progress') + if a:args.needs_scope + call go#util#EchoProgress("analysing with scope ". result.scope . " ...") + elseif a:args.mode !=# 'what' + " the query might take time, let us give some feedback + call go#util#EchoProgress("analysing ...") + endif + endif let old_gopath = $GOPATH let $GOPATH = go#path#Detect() - if a:mode !=# 'what' - " the query might take time, let us give some feedback - call go#util#EchoProgress("analysing ...") - endif - " run, forrest run!!! - let out = go#util#System(command) - - if exists("l:tmpname") - call delete(l:tmpname) + let command = join(result.cmd, " ") + if &modified + let out = go#util#System(command, result.stdin_content) + else + let out = go#util#System(command) endif let $GOPATH = old_gopath - if go#util#ShellError() != 0 - " the output contains the error message - return {'err' : out} + + if has_key(a:args, 'custom_parse') + call a:args.custom_parse(go#util#ShellError(), out) + else + call s:parse_guru_output(go#util#ShellError(), out, a:args.mode) endif - return {'out': out} + return out endfunc -" This uses Vim's errorformat to parse the output from Guru's 'plain output -" and put it into location list. I believe using errorformat is much more -" easier to use. If we need more power we can always switch back to parse it -" via regex. -func! s:loclistSecond(output) - " backup users errorformat, will be restored once we are finished - let old_errorformat = &errorformat - - " match two possible styles of errorformats: - " - " 'file:line.col-line2.col2: message' - " 'file:line:col: message' - " - " We discard line2 and col2 for the first errorformat, because it's not - " useful and location only has the ability to show one line and column - " number - let errformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m" - call go#list#ParseFormat("locationlist", errformat, split(a:output, "\n")) - - let errors = go#list#Get("locationlist") - call go#list#Window("locationlist", len(errors)) -endfun - - -function! go#guru#Scope(...) - if a:0 - if a:0 == 1 && a:1 == '""' - unlet g:go_guru_scope - call go#util#EchoSuccess("guru scope is cleared") - else - let g:go_guru_scope = a:000 - call go#util#EchoSuccess("guru scope changed to: ". join(a:000, ",")) - endif - +" async_guru runs guru in async mode with the given arguments +function! s:async_guru(args) abort + let result = s:guru_cmd(a:args) + if has_key(result, 'err') + call go#util#EchoError(result.err) return endif - if !exists('g:go_guru_scope') - call go#util#EchoError("guru scope is not set") - else - call go#util#EchoSuccess("current guru scope: ". join(g:go_guru_scope, ",")) - endif -endfunction + let status_dir = expand('%:p:h') + let statusline_type = printf("%s", a:args.mode) -function! go#guru#Tags(...) - if a:0 - if a:0 == 1 && a:1 == '""' - unlet g:go_guru_tags - call go#util#EchoSuccess("guru tags is cleared") - else - let g:go_guru_tags = a:1 - call go#util#EchoSuccess("guru tags changed to: ". a:1) + if !has_key(a:args, 'disable_progress') + if a:args.needs_scope + call go#util#EchoProgress("analysing with scope ". result.scope . " ...") + endif + endif + + function! s:close_cb(chan) closure + let messages = [] + while ch_status(a:chan, {'part': 'out'}) == 'buffered' + let msg = ch_read(a:chan, {'part': 'out'}) + call add(messages, msg) + endwhile + + while ch_status(a:chan, {'part': 'err'}) == 'buffered' + let msg = ch_read(a:chan, {'part': 'err'}) + call add(messages, msg) + endwhile + + let l:job = ch_getjob(a:chan) + let l:info = job_info(l:job) + + let out = join(messages, "\n") + + let status = { + \ 'desc': 'last status', + \ 'type': statusline_type, + \ 'state': "finished", + \ } + + if l:info.exitval + let status.state = "failed" endif - return + call go#statusline#Update(status_dir, status) + + if has_key(a:args, 'custom_parse') + call a:args.custom_parse(l:info.exitval, out) + else + call s:parse_guru_output(l:info.exitval, out, a:args.mode) + endif + endfunction + + let start_options = { + \ 'close_cb': function("s:close_cb"), + \ } + + if &modified + let l:tmpname = tempname() + call writefile(split(result.stdin_content, "\n"), l:tmpname, "b") + let l:start_options.in_io = "file" + let l:start_options.in_name = l:tmpname endif - if !exists('g:go_guru_tags') - call go#util#EchoSuccess("guru tags is not set") - else - call go#util#EchoSuccess("current guru tags: ". a:1) + call go#statusline#Update(status_dir, { + \ 'desc': "current status", + \ 'type': statusline_type, + \ 'state': "analysing", + \}) + + return job_start(result.cmd, start_options) +endfunc + +" run_guru runs the given guru argument +function! s:run_guru(args) abort + if go#util#has_job() + return s:async_guru(a:args) endif + + return s:sync_guru(a:args) endfunction " Show 'implements' relation for selected package -function! go#guru#Implements(selected) - let out = s:RunGuru('implements', 'plain', a:selected, 1) - if has_key(out, 'err') - call go#util#EchoError(out.err) - return - endif +function! go#guru#Implements(selected) abort + let args = { + \ 'mode': 'implements', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } - call s:loclistSecond(out.out) + call s:run_guru(args) +endfunction + +" Report the possible constants, global variables, and concrete types that may +" appear in a value of type error +function! go#guru#Whicherrs(selected) abort + let args = { + \ 'mode': 'whicherrs', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } + + + " TODO(arslan): handle empty case for both sync/async + " if empty(out.out) + " call go#util#EchoSuccess("no error variables found. Try to change the scope with :GoGuruScope") + " return + " endif + call s:run_guru(args) endfunction " Describe selected syntax: definition, methods, etc -function! go#guru#Describe(selected) - let out = s:RunGuru('describe', 'plain', a:selected, 0) - if has_key(out, 'err') - call go#util#EchoError(out.err) +function! go#guru#Describe(selected) abort + let args = { + \ 'mode': 'describe', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } + + call s:run_guru(args) +endfunction + +function! go#guru#DescribeInfo() abort + " json_encode() and friends are introduced with this patch (7.4.1304) + " vim: https://groups.google.com/d/msg/vim_dev/vLupTNhQhZ8/cDGIk0JEDgAJ + " nvim: https://github.com/neovim/neovim/pull/4131 + if !exists("*json_decode") + call go#util#EchoError("requires 'json_decode'. Update your Vim/Neovim version.") return endif - call s:loclistSecond(out.out) + function! s:info(exit_val, output) + if a:exit_val != 0 + return + endif + + if a:output[0] !=# '{' + return + endif + + if empty(a:output) || type(a:output) != type("") + return + endif + + let result = json_decode(a:output) + if type(result) != type({}) + call go#util#EchoError(printf("malformed output from guru: %s", a:output)) + return + endif + + if !has_key(result, 'detail') + " if there is no detail check if there is a description and print it + if has_key(result, "desc") + call go#util#EchoInfo(result["desc"]) + return + endif + + call go#util#EchoError("detail key is missing. Please open a bug report on vim-go repo.") + return + endif + + let detail = result['detail'] + let info = "" + + " guru gives different information based on the detail mode. Let try to + " extract the most useful information + + if detail == "value" + if !has_key(result, 'value') + call go#util#EchoError("value key is missing. Please open a bug report on vim-go repo.") + return + endif + + let val = result["value"] + if !has_key(val, 'type') + call go#util#EchoError("type key is missing (value.type). Please open a bug report on vim-go repo.") + return + endif + + let info = val["type"] + elseif detail == "type" + if !has_key(result, 'type') + call go#util#EchoError("type key is missing. Please open a bug report on vim-go repo.") + return + endif + + let type = result["type"] + if !has_key(type, 'type') + call go#util#EchoError("type key is missing (type.type). Please open a bug report on vim-go repo.") + return + endif + + let info = type["type"] + elseif detail == "package" + if !has_key(result, 'package') + call go#util#EchoError("package key is missing. Please open a bug report on vim-go repo.") + return + endif + + let package = result["package"] + if !has_key(package, 'path') + call go#util#EchoError("path key is missing (package.path). Please open a bug report on vim-go repo.") + return + endif + + let info = printf("package %s", package["path"]) + elseif detail == "unknown" + let info = result["desc"] + else + call go#util#EchoError(printf("unknown detail mode found '%s'. Please open a bug report on vim-go repo", detail)) + return + endif + + call go#util#EchoInfo(info) + endfunction + + let args = { + \ 'mode': 'describe', + \ 'format': 'json', + \ 'selected': -1, + \ 'needs_scope': 1, + \ 'custom_parse': function('s:info'), + \ 'disable_progress': 1, + \ } + + call s:run_guru(args) endfunction " Show possible targets of selected function call -function! go#guru#Callees(selected) - let out = s:RunGuru('callees', 'plain', a:selected, 1) - if has_key(out, 'err') - call go#util#EchoError(out.err) - return - endif +function! go#guru#Callees(selected) abort + let args = { + \ 'mode': 'callees', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } - call s:loclistSecond(out.out) + call s:run_guru(args) endfunction " Show possible callers of selected function -function! go#guru#Callers(selected) - let out = s:RunGuru('callers', 'plain', a:selected, 1) - if has_key(out, 'err') - call go#util#EchoError(out.err) - return - endif +function! go#guru#Callers(selected) abort + let args = { + \ 'mode': 'callers', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } - call s:loclistSecond(out.out) + call s:run_guru(args) endfunction " Show path from callgraph root to selected function -function! go#guru#Callstack(selected) - let out = s:RunGuru('callstack', 'plain', a:selected, 1) - if has_key(out, 'err') - call go#util#EchoError(out.err) - return - endif +function! go#guru#Callstack(selected) abort + let args = { + \ 'mode': 'callstack', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } - call s:loclistSecond(out.out) + call s:run_guru(args) endfunction " Show free variables of selection -function! go#guru#Freevars(selected) +function! go#guru#Freevars(selected) abort " Freevars requires a selection if a:selected == -1 call go#util#EchoError("GoFreevars requires a selection (range) of code") return endif - let out = s:RunGuru('freevars', 'plain', a:selected, 0) - if has_key(out, 'err') - call go#util#EchoError(out.err) - return - endif + let args = { + \ 'mode': 'freevars', + \ 'format': 'plain', + \ 'selected': 1, + \ 'needs_scope': 0, + \ } - call s:loclistSecond(out.out) + call s:run_guru(args) endfunction " Show send/receive corresponding to selected channel op -function! go#guru#ChannelPeers(selected) - let out = s:RunGuru('peers', 'plain', a:selected, 1) - if has_key(out, 'err') - call go#util#EchoError(out.err) - return - endif +function! go#guru#ChannelPeers(selected) abort + let args = { + \ 'mode': 'peers', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 1, + \ } - call s:loclistSecond(out.out) + call s:run_guru(args) endfunction " Show all refs to entity denoted by selected identifier -function! go#guru#Referrers(selected) - let out = s:RunGuru('referrers', 'plain', a:selected, 0) - if has_key(out, 'err') - call go#util#EchoError(out.err) +function! go#guru#Referrers(selected) abort + let args = { + \ 'mode': 'referrers', + \ 'format': 'plain', + \ 'selected': a:selected, + \ 'needs_scope': 0, + \ } + + call s:run_guru(args) +endfunction + +function! go#guru#SameIdsTimer() abort + call timer_start(200, function('go#guru#SameIds'), {'repeat': -1}) +endfunction + +function! go#guru#SameIds() abort + " we use matchaddpos() which was introduce with 7.4.330, be sure we have + " it: http://ftp.vim.org/vim/patches/7.4/7.4.330 + if !exists("*matchaddpos") + call go#util#EchoError("GoSameIds requires 'matchaddpos'. Update your Vim/Neovim version.") return endif - call s:loclistSecond(out.out) + " json_encode() and friends are introduced with this patch (7.4.1304) + " vim: https://groups.google.com/d/msg/vim_dev/vLupTNhQhZ8/cDGIk0JEDgAJ + " nvim: https://github.com/neovim/neovim/pull/4131 + if !exists("*json_decode") + call go#util#EchoError("GoSameIds requires 'json_decode'. Update your Vim/Neovim version.") + return + endif + + let args = { + \ 'mode': 'what', + \ 'format': 'json', + \ 'selected': -1, + \ 'needs_scope': 0, + \ 'custom_parse': function('s:same_ids_highlight'), + \ } + + call s:run_guru(args) endfunction -function! go#guru#What(selected) - " nvim doesn't have JSON support, though they work on it: - " https://github.com/neovim/neovim/pull/4131 - if has('nvim') - return {'err': "GoWhat is not supported in Neovim"} +function! s:same_ids_highlight(exit_val, output) abort + call go#guru#ClearSameIds() " run after calling guru to reduce flicker. + + if a:output[0] !=# '{' + if !get(g:, 'go_auto_sameids', 0) + call go#util#EchoError(a:output) + endif + return endif - " json_encode() and friends are introduced with this patch - " https://groups.google.com/d/msg/vim_dev/vLupTNhQhZ8/cDGIk0JEDgAJ - if !has('patch-7.4.1304') - return {'err': "GoWhat is supported with Vim version 7.4-1304 or later"} - endif - - let out = s:RunGuru('what', 'json', a:selected, 0) - if has_key(out, 'err') - return {'err': out.err} - endif - - let result = json_decode(out.out) - - if type(result) != type({}) - return {'err': "malformed output from guru"} - endif - - return result -endfunction - -function! go#guru#SameIds(selected) - call go#guru#ClearSameIds() - - let result = go#guru#What(a:selected) - if has_key(result, 'err') && !get(g:, 'go_auto_sameids', 0) - " only echo if it's called via `:GoSameIds, but not if it's in automode - call go#util#EchoError(result.err) + let result = json_decode(a:output) + if type(result) != type({}) && !get(g:, 'go_auto_sameids', 0) + call go#util#EchoError("malformed output from guru") return endif @@ -327,23 +520,123 @@ function! go#guru#SameIds(selected) return endif - hi goSameId term=bold cterm=bold ctermbg=white ctermfg=black - let same_ids = result['sameids'] " highlight the lines for item in same_ids let pos = split(item, ':') call matchaddpos('goSameId', [[str2nr(pos[-2]), str2nr(pos[-1]), str2nr(poslen)]]) endfor + + if get(g:, "go_auto_sameids", 0) + " re-apply SameIds at the current cursor position at the time the buffer + " is redisplayed: e.g. :edit, :GoRename, etc. + autocmd BufWinEnter nested call go#guru#SameIds() + endif endfunction -function! go#guru#ClearSameIds() +function! go#guru#ClearSameIds() abort let m = getmatches() for item in m if item['group'] == 'goSameId' call matchdelete(item['id']) endif endfor + + " remove the autocmds we defined + if exists("#BufWinEnter") + autocmd! BufWinEnter + endif +endfunction + +function! go#guru#ToggleSameIds() abort + if len(getmatches()) != 0 + call go#guru#ClearSameIds() + else + call go#guru#SameIds() + endif +endfunction + +function! go#guru#AutoToogleSameIds() abort + if get(g:, "go_auto_sameids", 0) + call go#util#EchoProgress("sameids auto highlighting disabled") + call go#guru#ClearSameIds() + let g:go_auto_sameids = 0 + return + endif + + call go#util#EchoSuccess("sameids auto highlighting enabled") + let g:go_auto_sameids = 1 +endfunction + + +"""""""""""""""""""""""""""""""""""""""" +"" HELPER FUNCTIONS +"""""""""""""""""""""""""""""""""""""""" + +" This uses Vim's errorformat to parse the output from Guru's 'plain output +" and put it into location list. I believe using errorformat is much more +" easier to use. If we need more power we can always switch back to parse it +" via regex. Match two possible styles of errorformats: +" +" 'file:line.col-line2.col2: message' +" 'file:line:col: message' +" +" We discard line2 and col2 for the first errorformat, because it's not +" useful and location only has the ability to show one line and column +" number +function! s:parse_guru_output(exit_val, output, title) abort + if a:exit_val + call go#util#EchoError(a:output) + return + endif + + let old_errorformat = &errorformat + let errformat = "%f:%l.%c-%[%^:]%#:\ %m,%f:%l:%c:\ %m" + call go#list#ParseFormat("locationlist", errformat, a:output, a:title) + let &errorformat = old_errorformat + + let errors = go#list#Get("locationlist") + call go#list#Window("locationlist", len(errors)) +endfun + +function! go#guru#Scope(...) abort + if a:0 + if a:0 == 1 && a:1 == '""' + unlet g:go_guru_scope + call go#util#EchoSuccess("guru scope is cleared") + else + let g:go_guru_scope = a:000 + call go#util#EchoSuccess("guru scope changed to: ". join(a:000, ",")) + endif + + return + endif + + if !exists('g:go_guru_scope') + call go#util#EchoError("guru scope is not set") + else + call go#util#EchoSuccess("current guru scope: ". join(g:go_guru_scope, ",")) + endif +endfunction + +function! go#guru#Tags(...) abort + if a:0 + if a:0 == 1 && a:1 == '""' + unlet g:go_guru_tags + call go#util#EchoSuccess("guru tags is cleared") + else + let g:go_guru_tags = a:1 + call go#util#EchoSuccess("guru tags changed to: ". a:1) + endif + + return + endif + + if !exists('g:go_guru_tags') + call go#util#EchoSuccess("guru tags is not set") + else + call go#util#EchoSuccess("current guru tags: ". a:1) + endif endfunction " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/impl.vim b/sources_non_forked/vim-go/autoload/go/impl.vim index e0ffac45..139dba75 100644 --- a/sources_non_forked/vim-go/autoload/go/impl.vim +++ b/sources_non_forked/vim-go/autoload/go/impl.vim @@ -1,4 +1,4 @@ -function! go#impl#Impl(...) +function! go#impl#Impl(...) abort let binpath = go#path#CheckBinPath('impl') if empty(binpath) return @@ -69,14 +69,14 @@ else endfunction endif -function! s:root_dirs() +function! s:root_dirs() abort let dirs = [] - let root = go#util#GOROOT() + let root = go#util#goroot() if root !=# '' && isdirectory(root) call add(dirs, root) endif - let paths = map(split(go#util#GOPATH(), go#util#PathListSep()), "substitute(v:val, '\\\\', '/', 'g')") + let paths = map(split(go#util#gopath(), go#util#PathListSep()), "substitute(v:val, '\\\\', '/', 'g')") if go#util#ShellError() return [] endif @@ -88,16 +88,16 @@ function! s:root_dirs() return dirs endfunction -function! s:go_packages(dirs) +function! s:go_packages(dirs) abort let pkgs = [] for d in a:dirs - let pkg_root = expand(d . '/pkg/' . go#util#OSARCH()) + let pkg_root = expand(d . '/pkg/' . go#util#osarch()) call extend(pkgs, split(globpath(pkg_root, '**/*.a', 1), "\n")) endfor return map(pkgs, "fnamemodify(v:val, ':t:r')") endfunction -function! s:interface_list(pkg) +function! s:interface_list(pkg) abort let contents = split(go#util#System('go doc ' . a:pkg), "\n") if go#util#ShellError() return [] @@ -108,7 +108,7 @@ function! s:interface_list(pkg) endfunction " Complete package and interface for {interface} -function! go#impl#Complete(arglead, cmdline, cursorpos) +function! go#impl#Complete(arglead, cmdline, cursorpos) abort let words = split(a:cmdline, '\s\+', 1) if words[-1] ==# '' return s:uniq(sort(s:go_packages(s:root_dirs()))) diff --git a/sources_non_forked/vim-go/autoload/go/import.vim b/sources_non_forked/vim-go/autoload/go/import.vim index 69658916..8d9e8d4c 100644 --- a/sources_non_forked/vim-go/autoload/go/import.vim +++ b/sources_non_forked/vim-go/autoload/go/import.vim @@ -4,7 +4,7 @@ " " Check out the docs for more information at /doc/vim-go.txt " -function! go#import#SwitchImport(enabled, localname, path, bang) +function! go#import#SwitchImport(enabled, localname, path, bang) abort let view = winsaveview() let path = substitute(a:path, '^\s*\(.\{-}\)\s*$', '\1', '') @@ -205,7 +205,7 @@ function! go#import#SwitchImport(enabled, localname, path, bang) endfunction -function! s:Error(s) +function! s:Error(s) abort echohl Error | echo a:s | echohl None endfunction diff --git a/sources_non_forked/vim-go/autoload/go/job.vim b/sources_non_forked/vim-go/autoload/go/job.vim new file mode 100644 index 00000000..e60b2b45 --- /dev/null +++ b/sources_non_forked/vim-go/autoload/go/job.vim @@ -0,0 +1,109 @@ +" Spawn returns callbacks to be used with job_start. It's abstracted to be +" used with various go command, such as build, test, install, etc.. This avoid +" us to write the same callback over and over for some commands. It's fully +" customizable so each command can change it to it's own logic. +function go#job#Spawn(args) + let cbs = { + \ 'winnr': winnr(), + \ 'dir': getcwd(), + \ 'jobdir': fnameescape(expand("%:p:h")), + \ 'messages': [], + \ 'args': a:args.cmd, + \ 'bang': 0, + \ } + + if has_key(a:args, 'bang') + let cbs.bang = a:args.bang + endif + + " add final callback to be called if async job is finished + " The signature should be in form: func(job, exit_status, messages) + if has_key(a:args, 'custom_cb') + let cbs.custom_cb = a:args.custom_cb + endif + + if has_key(a:args, 'error_info_cb') + let cbs.error_info_cb = a:args.error_info_cb + endif + + function cbs.callback(chan, msg) dict + call add(self.messages, a:msg) + endfunction + + function cbs.close_cb(chan) dict + let l:job = ch_getjob(a:chan) + let l:status = job_status(l:job) + + " the job might be in fail status, we assume by default it's failed. + " However if it's dead, we can use the real exitval + let exitval = 1 + if l:status == "dead" + let l:info = job_info(l:job) + let exitval = l:info.exitval + endif + + if has_key(self, 'custom_cb') + call self.custom_cb(l:job, exitval, self.messages) + endif + + if has_key(self, 'error_info_cb') + call self.error_info_cb(l:job, exitval, self.messages) + endif + + if get(g:, 'go_echo_command_info', 1) + if exitval == 0 + call go#util#EchoSuccess("SUCCESS") + else + call go#util#EchoError("FAILED") + endif + endif + + let l:listtype = go#list#Type("quickfix") + if exitval == 0 + call go#list#Clean(l:listtype) + call go#list#Window(l:listtype) + return + endif + + call self.show_errors(l:listtype) + endfunction + + function cbs.show_errors(listtype) dict + let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' + try + execute cd self.jobdir + let errors = go#tool#ParseErrors(self.messages) + let errors = go#tool#FilterValids(errors) + finally + execute cd . fnameescape(self.dir) + endtry + + if !len(errors) + " failed to parse errors, output the original content + call go#util#EchoError(join(self.messages, " ")) + call go#util#EchoError(self.dir) + return + endif + + if self.winnr == winnr() + call go#list#Populate(a:listtype, errors, join(self.args)) + call go#list#Window(a:listtype, len(errors)) + if !empty(errors) && !self.bang + call go#list#JumpToFirst(a:listtype) + endif + endif + endfunction + + " override callback handler if user provided it + if has_key(a:args, 'callback') + let cbs.callback = a:args.callback + endif + + " override close callback handler if user provided it + if has_key(a:args, 'close_cb') + let cbs.close_cb = a:args.close_cb + endif + + return cbs +endfunction +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/jobcontrol.vim b/sources_non_forked/vim-go/autoload/go/jobcontrol.vim index e03c75d6..189ed5f4 100644 --- a/sources_non_forked/vim-go/autoload/go/jobcontrol.vim +++ b/sources_non_forked/vim-go/autoload/go/jobcontrol.vim @@ -9,7 +9,7 @@ let s:handlers = {} " Spawn is a wrapper around s:spawn. It can be executed by other files and " scripts if needed. Desc defines the description for printing the status " during the job execution (useful for statusline integration). -function! go#jobcontrol#Spawn(bang, desc, args) +function! go#jobcontrol#Spawn(bang, desc, args) abort " autowrite is not enabled for jobs call go#cmd#autowrite() @@ -17,31 +17,8 @@ function! go#jobcontrol#Spawn(bang, desc, args) return job.id endfunction -" Statusline returns the current status of the job -function! go#jobcontrol#Statusline() abort - if empty(s:jobs) - return '' - endif - - let import_path = go#package#ImportPath(expand('%:p:h')) - - for job in values(s:jobs) - if job.importpath != import_path - continue - endif - - if job.state == "SUCCESS" - return '' - endif - - return printf("%s ... [%s]", job.desc, job.state) - endfor - - return '' -endfunction - " AddHandler adds a on_exit callback handler and returns the id. -function! go#jobcontrol#AddHandler(handler) +function! go#jobcontrol#AddHandler(handler) abort let i = len(s:handlers) while has_key(s:handlers, string(i)) let i += 1 @@ -52,7 +29,7 @@ function! go#jobcontrol#AddHandler(handler) endfunction " RemoveHandler removes a callback handler by id. -function! go#jobcontrol#RemoveHandler(id) +function! go#jobcontrol#RemoveHandler(id) abort unlet s:handlers[a:id] endfunction @@ -60,10 +37,10 @@ endfunction " a job is started a reference will be stored inside s:jobs. spawn changes the " GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the " current files folder. -function! s:spawn(bang, desc, args) - let job = { - \ 'desc': a:desc, - \ 'bang': a:bang, +function! s:spawn(bang, desc, args) abort + let job = { + \ 'desc': a:desc, + \ 'bang': a:bang, \ 'winnr': winnr(), \ 'importpath': go#package#ImportPath(expand('%:p:h')), \ 'state': "RUNNING", @@ -113,7 +90,7 @@ endfunction " references and also displaying errors in the quickfix window collected by " on_stderr handler. If there are no errors and a quickfix window is open, " it'll be closed. -function! s:on_exit(job_id, exit_status) +function! s:on_exit(job_id, exit_status, event) dict abort let std_combined = self.stderr + self.stdout let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' @@ -122,9 +99,10 @@ function! s:on_exit(job_id, exit_status) call s:callback_handlers_on_exit(s:jobs[a:job_id], a:exit_status, std_combined) + let l:listtype = go#list#Type("quickfix") if a:exit_status == 0 - call go#list#Clean(0) - call go#list#Window(0) + call go#list#Clean(l:listtype) + call go#list#Window(l:listtype) let self.state = "SUCCESS" call go#util#EchoSuccess("SUCCESS") @@ -149,8 +127,7 @@ function! s:on_exit(job_id, exit_status) " if we are still in the same windows show the list if self.winnr == winnr() - let l:listtype = "locationlist" - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, self.desc) call go#list#Window(l:listtype, len(errors)) if !empty(errors) && !self.bang call go#list#JumpToFirst(l:listtype) @@ -159,7 +136,7 @@ function! s:on_exit(job_id, exit_status) endfunction " callback_handlers_on_exit runs all handlers for job on exit event. -function! s:callback_handlers_on_exit(job, exit_status, data) +function! s:callback_handlers_on_exit(job, exit_status, data) abort if empty(s:handlers) return endif @@ -170,45 +147,15 @@ function! s:callback_handlers_on_exit(job, exit_status, data) endfunction " on_stdout is the stdout handler for jobstart(). It collects the output of -" stderr and stores them to the jobs internal stdout list. -function! s:on_stdout(job_id, data) +" stderr and stores them to the jobs internal stdout list. +function! s:on_stdout(job_id, data) dict abort call extend(self.stdout, a:data) endfunction " on_stderr is the stderr handler for jobstart(). It collects the output of " stderr and stores them to the jobs internal stderr list. -function! s:on_stderr(job_id, data) +function! s:on_stderr(job_id, data) dict abort call extend(self.stderr, a:data) endfunction -" abort_all aborts all current jobs created with s:spawn() -function! s:abort_all() - if empty(s:jobs) - return - endif - - for id in keys(s:jobs) - if id > 0 - silent! call jobstop(id) - endif - endfor - - let s:jobs = {} -endfunction - -" abort aborts the job with the given name, where name is the first argument -" passed to s:spawn() -function! s:abort(path) - if empty(s:jobs) - return - endif - - for job in values(s:jobs) - if job.importpath == path && job.id > 0 - silent! call jobstop(job.id) - unlet s:jobs['job.id'] - endif - endfor -endfunction - " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/lint.vim b/sources_non_forked/vim-go/autoload/go/lint.vim index 1a2ef9aa..d81072a1 100644 --- a/sources_non_forked/vim-go/autoload/go/lint.vim +++ b/sources_non_forked/vim-go/autoload/go/lint.vim @@ -29,37 +29,42 @@ function! go#lint#Gometa(autosave, ...) abort let goargs = go#util#Shelljoin(a:000) endif - let meta_command = "gometalinter --disable-all" + let bin_path = go#path#CheckBinPath("gometalinter") + if empty(bin_path) + return + endif + + let cmd = [bin_path] + let cmd += ["--disable-all"] + if a:autosave || empty(g:go_metalinter_command) - let bin_path = go#path#CheckBinPath("gometalinter") - if empty(bin_path) - return - endif - - if a:autosave - " include only messages for the active buffer - let meta_command .= " --include='^" . expand('%:p') . ".*$'" - endif - " linters let linters = a:autosave ? g:go_metalinter_autosave_enabled : g:go_metalinter_enabled for linter in linters - let meta_command .= " --enable=".linter + let cmd += ["--enable=".linter] endfor - " deadline - let meta_command .= " --deadline=" . g:go_metalinter_deadline - " path - let meta_command .= " " . goargs + let cmd += [expand('%:p:h')] else " the user wants something else, let us use it. - let meta_command = g:go_metalinter_command + let cmd += [split(g:go_metalinter_command, " ")] endif - " comment out the following two lines for debugging - " echo meta_command - " return + if go#util#has_job() && has('lambda') + call s:lint_job({'cmd': cmd}) + return + endif + + " we add deadline only for sync mode + let cmd += ["--deadline=" . g:go_metalinter_deadline] + if a:autosave + " include only messages for the active buffer + let cmd += ["--include='^" . expand('%:p') . ".*$'"] + endif + + + let meta_command = join(cmd, " ") let out = go#tool#ExecuteInDir(meta_command) @@ -77,7 +82,7 @@ function! go#lint#Gometa(autosave, ...) abort let errformat = "%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m" " Parse and populate our location list - call go#list#ParseFormat(l:listtype, errformat, split(out, "\n")) + call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"), 'GoMetaLinter') let errors = go#list#Get(l:listtype) call go#list#Window(l:listtype, len(errors)) @@ -117,7 +122,7 @@ endfunction " Vet calls 'go vet' on the current directory. Any warnings are populated in " the location list -function! go#lint#Vet(bang, ...) +function! go#lint#Vet(bang, ...) abort call go#cmd#autowrite() echon "vim-go: " | echohl Identifier | echon "calling vet..." | echohl None if a:0 == 0 @@ -129,7 +134,7 @@ function! go#lint#Vet(bang, ...) let l:listtype = "quickfix" if go#util#ShellError() != 0 let errors = go#tool#ParseErrors(split(out, '\n')) - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, 'Vet') call go#list#Window(l:listtype, len(errors)) if !empty(errors) && !a:bang call go#list#JumpToFirst(l:listtype) @@ -171,7 +176,7 @@ function! go#lint#Errcheck(...) abort let errformat = "%f:%l:%c:\ %m, %f:%l:%c\ %#%m" " Parse and populate our location list - call go#list#ParseFormat(l:listtype, errformat, split(out, "\n")) + call go#list#ParseFormat(l:listtype, errformat, split(out, "\n"), 'Errcheck') let errors = go#list#Get(l:listtype) @@ -182,7 +187,7 @@ function! go#lint#Errcheck(...) abort endif if !empty(errors) - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, 'Errcheck') call go#list#Window(l:listtype, len(errors)) if !empty(errors) call go#list#JumpToFirst(l:listtype) @@ -196,4 +201,99 @@ function! go#lint#Errcheck(...) abort endfunction +function! go#lint#ToggleMetaLinterAutoSave() abort + if get(g:, "go_metalinter_autosave", 0) + let g:go_metalinter_autosave = 0 + call go#util#EchoProgress("auto metalinter disabled") + return + end + + let g:go_metalinter_autosave = 1 + call go#util#EchoProgress("auto metalinter enabled") +endfunction + +function s:lint_job(args) + let status_dir = expand('%:p:h') + let started_at = reltime() + + call go#statusline#Update(status_dir, { + \ 'desc': "current status", + \ 'type': "gometalinter", + \ 'state': "analysing", + \}) + + " autowrite is not enabled for jobs + call go#cmd#autowrite() + + let l:listtype = go#list#Type("quickfix") + let l:errformat = '%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m' + + function! s:callback(chan, msg) closure + let old_errorformat = &errorformat + let &errorformat = l:errformat + caddexpr a:msg + let &errorformat = old_errorformat + + " TODO(arslan): cursor still jumps to first error even If I don't want + " it. Seems like there is a regression somewhere, but not sure where. + copen + endfunction + + function! s:close_cb(chan) closure + let l:job = ch_getjob(a:chan) + let l:status = job_status(l:job) + + let exitval = 1 + if l:status == "dead" + let l:info = job_info(l:job) + let exitval = l:info.exitval + endif + + let status = { + \ 'desc': 'last status', + \ 'type': "gometaliner", + \ 'state': "finished", + \ } + + if exitval + let status.state = "failed" + endif + + let elapsed_time = reltimestr(reltime(started_at)) + " strip whitespace + let elapsed_time = substitute(elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '') + let status.state .= printf(" (%ss)", elapsed_time) + + call go#statusline#Update(status_dir, status) + + let errors = go#list#Get(l:listtype) + if empty(errors) + call go#list#Window(l:listtype, len(errors)) + elseif has("patch-7.4.2200") + if l:listtype == 'quickfix' + call setqflist([], 'a', {'title': 'GoMetaLinter'}) + else + call setloclist(0, [], 'a', {'title': 'GoMetaLinter'}) + endif + endif + + if get(g:, 'go_echo_command_info', 1) + call go#util#EchoSuccess("linting finished") + endif + endfunction + + let start_options = { + \ 'callback': function("s:callback"), + \ 'close_cb': function("s:close_cb"), + \ } + + call job_start(a:args.cmd, start_options) + + call go#list#Clean(l:listtype) + + if get(g:, 'go_echo_command_info', 1) + call go#util#EchoProgress("linting started ...") + endif +endfunction + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/list.vim b/sources_non_forked/vim-go/autoload/go/list.vim index 6859a9f3..56d6115d 100644 --- a/sources_non_forked/vim-go/autoload/go/list.vim +++ b/sources_non_forked/vim-go/autoload/go/list.vim @@ -5,7 +5,7 @@ endif " Window opens the list with the given height up to 10 lines maximum. " Otherwise g:go_loclist_height is used. If no or zero height is given it " closes the window -function! go#list#Window(listtype, ...) +function! go#list#Window(listtype, ...) abort let l:listtype = go#list#Type(a:listtype) " we don't use lwindow to close the location list as we need also the " ability to resize the window. So, we are going to use lopen and lclose @@ -40,7 +40,7 @@ endfunction " Get returns the current list of items from the location list -function! go#list#Get(listtype) +function! go#list#Get(listtype) abort let l:listtype = go#list#Type(a:listtype) if l:listtype == "locationlist" return getloclist(0) @@ -50,22 +50,27 @@ function! go#list#Get(listtype) endfunction " Populate populate the location list with the given items -function! go#list#Populate(listtype, items) +function! go#list#Populate(listtype, items, title) abort let l:listtype = go#list#Type(a:listtype) if l:listtype == "locationlist" call setloclist(0, a:items, 'r') + + " The last argument ({what}) is introduced with 7.4.2200: + " https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640 + if has("patch-7.4.2200") | call setloclist(0, [], 'a', {'title': a:title}) | endif else call setqflist(a:items, 'r') + if has("patch-7.4.2200") | call setqflist([], 'a', {'title': a:title}) | endif endif endfunction -function! go#list#PopulateWin(winnr, items) +function! go#list#PopulateWin(winnr, items) abort call setloclist(a:winnr, a:items, 'r') endfunction " Parse parses the given items based on the specified errorformat nad " populates the location list. -function! go#list#ParseFormat(listtype, errformat, items) +function! go#list#ParseFormat(listtype, errformat, items, title) abort let l:listtype = go#list#Type(a:listtype) " backup users errorformat, will be restored once we are finished let old_errorformat = &errorformat @@ -74,8 +79,10 @@ function! go#list#ParseFormat(listtype, errformat, items) let &errorformat = a:errformat if l:listtype == "locationlist" lgetexpr a:items + if has("patch-7.4.2200") | call setloclist(0, [], 'a', {'title': a:title}) | endif else cgetexpr a:items + if has("patch-7.4.2200") | call setqflist([], 'a', {'title': a:title}) | endif endif "restore back @@ -84,7 +91,7 @@ endfunction " Parse parses the given items based on the global errorformat and " populates the location list. -function! go#list#Parse(listtype, items) +function! go#list#Parse(listtype, items) abort let l:listtype = go#list#Type(a:listtype) if l:listtype == "locationlist" lgetexpr a:items @@ -94,7 +101,7 @@ function! go#list#Parse(listtype, items) endfunction " JumpToFirst jumps to the first item in the location list -function! go#list#JumpToFirst(listtype) +function! go#list#JumpToFirst(listtype) abort let l:listtype = go#list#Type(a:listtype) if l:listtype == "locationlist" ll 1 @@ -104,7 +111,7 @@ function! go#list#JumpToFirst(listtype) endfunction " Clean cleans the location list -function! go#list#Clean(listtype) +function! go#list#Clean(listtype) abort let l:listtype = go#list#Type(a:listtype) if l:listtype == "locationlist" lex [] @@ -113,7 +120,7 @@ function! go#list#Clean(listtype) endif endfunction -function! go#list#Type(listtype) +function! go#list#Type(listtype) abort if g:go_list_type == "locationlist" return "locationlist" elseif g:go_list_type == "quickfix" diff --git a/sources_non_forked/vim-go/autoload/go/package.vim b/sources_non_forked/vim-go/autoload/go/package.vim index 2aefd5d6..b12c7b71 100644 --- a/sources_non_forked/vim-go/autoload/go/package.vim +++ b/sources_non_forked/vim-go/autoload/go/package.vim @@ -28,12 +28,12 @@ if len(s:goarch) == 0 endif endif -function! go#package#Paths() +function! go#package#Paths() abort let dirs = [] if !exists("s:goroot") if executable('go') - let s:goroot = substitute(go#util#System('go env GOROOT'), '\n', '', 'g') + let s:goroot = go#util#goroot() if go#util#ShellError() != 0 echomsg '''go env GOROOT'' failed' endif @@ -54,12 +54,12 @@ function! go#package#Paths() return dirs endfunction -function! go#package#ImportPath(arg) +function! go#package#ImportPath(arg) abort let path = fnamemodify(resolve(a:arg), ':p') let dirs = go#package#Paths() for dir in dirs - if len(dir) && match(path, dir) == 0 + if len(dir) && matchstr(escape(path, '\/'), escape(dir, '\/')) == 0 let workspace = dir endif endfor @@ -68,11 +68,16 @@ function! go#package#ImportPath(arg) return -1 endif - let srcdir = substitute(workspace . '/src/', '//', '/', '') - return substitute(path, srcdir, '', '') + if go#util#IsWin() + let srcdir = substitute(workspace . '\src\', '//', '/', '') + return path[len(srcdir):] + else + let srcdir = substitute(workspace . '/src/', '//', '/', '') + return substitute(path, srcdir, '', '') + endif endfunction -function! go#package#FromPath(arg) +function! go#package#FromPath(arg) abort let path = fnamemodify(resolve(a:arg), ':p') let dirs = go#package#Paths() @@ -94,7 +99,7 @@ function! go#package#FromPath(arg) endif endfunction -function! go#package#CompleteMembers(package, member) +function! go#package#CompleteMembers(package, member) abort silent! let content = go#util#System('godoc ' . a:package) if go#util#ShellError() || !len(content) return [] @@ -113,7 +118,7 @@ function! go#package#CompleteMembers(package, member) endtry endfunction -function! go#package#Complete(ArgLead, CmdLine, CursorPos) +function! go#package#Complete(ArgLead, CmdLine, CursorPos) abort let words = split(a:CmdLine, '\s\+', 1) " do not complete package members for these commands diff --git a/sources_non_forked/vim-go/autoload/go/path.vim b/sources_non_forked/vim-go/autoload/go/path.vim index 16c4d926..a9b74e97 100644 --- a/sources_non_forked/vim-go/autoload/go/path.vim +++ b/sources_non_forked/vim-go/autoload/go/path.vim @@ -8,7 +8,7 @@ let s:initial_go_path = "" " echoes the current GOPATH, if an argument is passed it replaces the current " GOPATH with it. If two double quotes are passed (the empty string in go), " it'll clear the GOPATH and will restore to the initial GOPATH. -function! go#path#GoPath(...) +function! go#path#GoPath(...) abort " we have an argument, replace GOPATH if len(a:000) " clears the current manually set GOPATH and restores it to the @@ -35,7 +35,7 @@ endfunction " Default returns the default GOPATH. If there is a single GOPATH it returns " it. For multiple GOPATHS separated with a the OS specific separator, only " the first one is returned -function! go#path#Default() +function! go#path#Default() abort let go_paths = split($GOPATH, go#util#PathListSep()) if len(go_paths) == 1 @@ -47,7 +47,7 @@ endfunction " HasPath checks whether the given path exists in GOPATH environment variable " or not -function! go#path#HasPath(path) +function! go#path#HasPath(path) abort let go_paths = split($GOPATH, go#util#PathListSep()) let last_char = strlen(a:path) - 1 @@ -69,7 +69,7 @@ endfunction " Godeps, GB, it will modify the GOPATH so those directories take precedence " over the current GOPATH. It also detects diretories whose are outside " GOPATH. -function! go#path#Detect() +function! go#path#Detect() abort let gopath = $GOPATH " don't lookup for godeps if autodetect is disabled. @@ -115,7 +115,7 @@ endfunction " BinPath returns the binary path of installed go tools. -function! go#path#BinPath() +function! go#path#BinPath() abort let bin_path = "" " check if our global custom path is set, if not check if $GOBIN is set so @@ -135,7 +135,7 @@ endfunction " CheckBinPath checks whether the given binary exists or not and returns the " path of the binary. It returns an empty string doesn't exists. -function! go#path#CheckBinPath(binpath) +function! go#path#CheckBinPath(binpath) abort " remove whitespaces if user applied something like 'goimports ' let binpath = substitute(a:binpath, '^\s*\(.\{-}\)\s*$', '\1', '') " save off original path @@ -151,7 +151,7 @@ function! go#path#CheckBinPath(binpath) " if it's in PATH just return it if executable(binpath) - if v:version == 704 && has('patch235') + if exists('*exepath') let binpath = exepath(binpath) endif let $PATH = old_path @@ -161,7 +161,7 @@ function! go#path#CheckBinPath(binpath) " just get the basename let basename = fnamemodify(binpath, ":t") if !executable(basename) - echo "vim-go: could not find '" . basename . "'. Run :GoInstallBinaries to fix it." + echom "vim-go: could not find '" . basename . "'. Run :GoInstallBinaries to fix it." " restore back! let $PATH = old_path return "" diff --git a/sources_non_forked/vim-go/autoload/go/play.vim b/sources_non_forked/vim-go/autoload/go/play.vim index 44cf3eca..ac5bba42 100644 --- a/sources_non_forked/vim-go/autoload/go/play.vim +++ b/sources_non_forked/vim-go/autoload/go/play.vim @@ -3,7 +3,7 @@ if !exists("g:go_play_open_browser") endif -function! go#play#Share(count, line1, line2) +function! go#play#Share(count, line1, line2) abort if !executable('curl') echohl ErrorMsg | echomsg "vim-go: require 'curl' command" | echohl None return @@ -42,7 +42,7 @@ function! go#play#Share(count, line1, line2) endfunction -function! s:get_visual_content() +function! s:get_visual_content() abort let save_regcont = @" let save_regtype = getregtype('"') silent! normal! gvy @@ -55,7 +55,7 @@ endfunction " http://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript " another function that returns the content of visual selection, it's not used " but might be useful in the future -function! s:get_visual_selection() +function! s:get_visual_selection() abort let [lnum1, col1] = getpos("'<")[1:2] let [lnum2, col2] = getpos("'>")[1:2] @@ -72,7 +72,7 @@ endfunction " following two functions are from: https://github.com/mattn/gist-vim " thanks @mattn -function! s:get_browser_command() +function! s:get_browser_command() abort let go_play_browser_command = get(g:, 'go_play_browser_command', '') if go_play_browser_command == '' if has('win32') || has('win64') diff --git a/sources_non_forked/vim-go/autoload/go/rename.vim b/sources_non_forked/vim-go/autoload/go/rename.vim index d65256c5..df8047e1 100644 --- a/sources_non_forked/vim-go/autoload/go/rename.vim +++ b/sources_non_forked/vim-go/autoload/go/rename.vim @@ -6,22 +6,22 @@ if !exists("g:go_gorename_prefill") let g:go_gorename_prefill = 1 endif -function! go#rename#Rename(bang, ...) - let to = "" +function! go#rename#Rename(bang, ...) abort + let to_identifier = "" if a:0 == 0 let from = expand("") let ask = printf("vim-go: rename '%s' to: ", from) if g:go_gorename_prefill - let to = input(ask, from) + let to_identifier = input(ask, from) else - let to = input(ask) + let to_identifier = input(ask) endif redraw! - if empty(to) + if empty(to_identifier) return endif else - let to = a:1 + let to_identifier = a:1 endif "return with a warning if the bin doesn't exist @@ -32,10 +32,79 @@ function! go#rename#Rename(bang, ...) let fname = expand('%:p') let pos = go#util#OffsetCursor() - let cmd = printf('%s -offset %s -to %s', shellescape(bin_path), shellescape(printf('%s:#%d', fname, pos)), shellescape(to)) + let offset = printf('%s:#%d', fname, pos) - let out = go#tool#ExecuteInDir(cmd) + " no need to escape for job call + let bin_path = go#util#has_job() ? bin_path : shellescape(bin_path) + let offset = go#util#has_job() ? offset : shellescape(offset) + let to_identifier = go#util#has_job() ? to_identifier : shellescape(to_identifier) + let cmd = [bin_path, "-offset", offset, "-to", to_identifier] + + if go#util#has_job() + call go#util#EchoProgress(printf("renaming to '%s' ...", to_identifier)) + call s:rename_job({ + \ 'cmd': cmd, + \ 'bang': a:bang, + \}) + return + endif + + let command = join(cmd, " ") + let out = go#tool#ExecuteInDir(command) + + let splitted = split(out, '\n') + call s:parse_errors(go#util#ShellError(), a:bang, splitted) +endfunction + +function s:rename_job(args) + let messages = [] + function! s:callback(chan, msg) closure + call add(messages, a:msg) + endfunction + + let status_dir = expand('%:p:h') + + function! s:close_cb(chan) closure + let l:job = ch_getjob(a:chan) + let l:info = job_info(l:job) + + let status = { + \ 'desc': 'last status', + \ 'type': "gorename", + \ 'state': "finished", + \ } + + if l:info.exitval + let status.state = "failed" + endif + + call go#statusline#Update(status_dir, status) + + call s:parse_errors(l:info.exitval, a:args.bang, messages) + endfunction + + let start_options = { + \ 'callback': function("s:callback"), + \ 'close_cb': function("s:close_cb"), + \ } + + " modify GOPATH if needed + let old_gopath = $GOPATH + let $GOPATH = go#path#Detect() + + call go#statusline#Update(status_dir, { + \ 'desc': "current status", + \ 'type': "gorename", + \ 'state': "started", + \}) + + call job_start(a:args.cmd, start_options) + + let $GOPATH = old_gopath +endfunction + +function s:parse_errors(exit_val, bang, out) " reload all files to reflect the new changes. We explicitly call " checktime to trigger a reload of all files. See " http://www.mail-archive.com/vim@vim.org/msg05900.html for more info @@ -45,28 +114,28 @@ function! go#rename#Rename(bang, ...) silent! checktime let &autoread = current_autoread - " strip out newline on the end that gorename puts. If we don't remove, it - " will trigger the 'Hit ENTER to continue' prompt - let clean = split(out, '\n') - let l:listtype = "quickfix" - if go#util#ShellError() != 0 - let errors = go#tool#ParseErrors(split(out, '\n')) - call go#list#Populate(l:listtype, errors) + if a:exit_val != 0 + call go#util#EchoError("FAILED") + let errors = go#tool#ParseErrors(a:out) + call go#list#Populate(l:listtype, errors, 'Rename') call go#list#Window(l:listtype, len(errors)) if !empty(errors) && !a:bang call go#list#JumpToFirst(l:listtype) elseif empty(errors) " failed to parse errors, output the original content - call go#util#EchoError(out) + call go#util#EchoError(join(a:out, "")) endif + return - else - call go#list#Clean(l:listtype) - call go#list#Window(l:listtype) - redraw | echon "vim-go: " | echohl Function | echon clean[0] | echohl None endif + " strip out newline on the end that gorename puts. If we don't remove, it + " will trigger the 'Hit ENTER to continue' prompt + call go#list#Clean(l:listtype) + call go#list#Window(l:listtype) + call go#util#EchoSuccess(a:out[0]) + " refresh the buffer so we can see the new content " TODO(arslan): also find all other buffers and refresh them too. For this " we need a way to get the list of changes from gorename upon an success diff --git a/sources_non_forked/vim-go/autoload/go/statusline.vim b/sources_non_forked/vim-go/autoload/go/statusline.vim new file mode 100644 index 00000000..c832797c --- /dev/null +++ b/sources_non_forked/vim-go/autoload/go/statusline.vim @@ -0,0 +1,112 @@ +" Statusline +"""""""""""""""""""""""""""""""" + +" s:statuses is a global reference to all statuses. It stores the statuses per +" import paths (map[string]status), where each status is unique per its +" type. Current status dict is in form: +" { +" 'desc' : 'Job description', +" 'state' : 'Job state, such as success, failure, etc..', +" 'type' : 'Job type, such as build, test, etc..' +" 'created_at' : 'Time it was created as seconds since 1st Jan 1970' +" } +let s:statuses = {} + +" timer_id for cleaner +let s:timer_id = 0 + +" last_status stores the last generated text per status +let s:last_status = "" + +" Show returns the current status of the job for 20 seconds (configurable). It +" displays it in form of 'desc: [type|state]' if there is any state available, +" if not it returns an empty string. This function should be plugged directly +" into the statusline. +function! go#statusline#Show() abort + " lazy initialiation of the cleaner + if !s:timer_id + " clean every 60 seconds all statuses + let interval = get(g:, 'go_statusline_duration', 60000) + let s:timer_id = timer_start(interval, function('go#statusline#Clear'), {'repeat': -1}) + endif + + " nothing to show + if empty(s:statuses) + return '' + endif + + let status_dir = expand('%:p:h') + + if !has_key(s:statuses, status_dir) + return '' + endif + + let status = s:statuses[status_dir] + if !has_key(status, 'desc') || !has_key(status, 'state') || !has_key(status, 'type') + return '' + endif + + let status_text = printf("[%s|%s]", status.type, status.state) + if empty(status_text) + return '' + endif + + " only update highlight if status has changed. + if status_text != s:last_status + if status.state =~ "success" || status.state =~ "finished" + hi goStatusLineColor cterm=bold ctermbg=76 ctermfg=22 + elseif status.state =~ "started" || status.state =~ "analysing" + hi goStatusLineColor cterm=bold ctermbg=208 ctermfg=88 + elseif status.state =~ "failed" + hi goStatusLineColor cterm=bold ctermbg=196 ctermfg=52 + endif + endif + + let s:last_status = status_text + return status_text +endfunction + +" Update updates (adds) the statusline for the given status_dir with the +" given status dict. It overrides any previously set status. +function! go#statusline#Update(status_dir, status) abort + let a:status.created_at = reltime() + let s:statuses[a:status_dir] = a:status + + " force to update the statusline, otherwise the user needs to move the + " cursor + exe 'let &ro = &ro' + + " before we stop the timer, check if we have any previous jobs to be cleaned + " up. Otherwise every job will reset the timer when this function is called + " and thus old jobs will never be cleaned + call go#statusline#Clear(0) + + " also reset the timer, so the user has time to see it in the statusline. + " Setting the timer_id to 0 will trigger a new cleaner routine. + call timer_stop(s:timer_id) + let s:timer_id = 0 +endfunction + +" Clear clears all currently stored statusline data. The timer_id argument is +" just a placeholder so we can pass it to a timer_start() function if needed. +function! go#statusline#Clear(timer_id) abort + for [status_dir, status] in items(s:statuses) + let elapsed_time = reltimestr(reltime(status.created_at)) + " strip whitespace + let elapsed_time = substitute(elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '') + + if str2nr(elapsed_time) > 10 + call remove(s:statuses, status_dir) + endif + endfor + + if len(s:statuses) == 0 + let s:statuses = {} + endif + + " force to update the statusline, otherwise the user needs to move the + " cursor + exe 'let &ro = &ro' +endfunction + +" vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/template.vim b/sources_non_forked/vim-go/autoload/go/template.vim index 73b37e86..0a92988f 100644 --- a/sources_non_forked/vim-go/autoload/go/template.vim +++ b/sources_non_forked/vim-go/autoload/go/template.vim @@ -1,6 +1,7 @@ let s:current_file = expand("") -function! go#template#create() +function! go#template#create() abort + let l:go_template_use_pkg = get(g:, 'go_template_use_pkg', 0) let l:root_dir = fnamemodify(s:current_file, ':h:h:h') let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' @@ -10,13 +11,20 @@ function! go#template#create() let l:package_name = go#tool#PackageName() " if we can't figure out any package name(no Go files or non Go package - " files) from the directory create the template - if l:package_name == -1 + " files) from the directory create the template or use the cwd + " as the name + if l:package_name == -1 && l:go_template_use_pkg != 1 let l:template_file = get(g:, 'go_template_file', "hello_world.go") let l:template_path = go#util#Join(l:root_dir, "templates", l:template_file) - exe '0r ' . l:template_path + exe '0r ' . fnameescape(l:template_path) $delete _ - else + elseif l:package_name == -1 && l:go_template_use_pkg == 1 + " cwd is now the dir of the package + let l:path = fnamemodify(getcwd(), ':t') + let l:content = printf("package %s", l:path) + call append(0, l:content) + $delete _ + else let l:content = printf("package %s", l:package_name) call append(0, l:content) $delete _ @@ -28,4 +36,15 @@ function! go#template#create() execute cd . fnameescape(dir) endfunction +function! go#template#ToggleAutoCreate() abort + if get(g:, "go_template_autocreate", 1) + let g:go_template_autocreate = 0 + call go#util#EchoProgress("auto template create disabled") + return + end + + let g:go_template_autocreate = 1 + call go#util#EchoProgress("auto template create enabled") +endfunction + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/autoload/go/term.vim b/sources_non_forked/vim-go/autoload/go/term.vim index 08947fa9..9404ca9e 100644 --- a/sources_non_forked/vim-go/autoload/go/term.vim +++ b/sources_non_forked/vim-go/autoload/go/term.vim @@ -7,12 +7,12 @@ let s:jobs = {} " new creates a new terminal with the given command. Mode is set based on the " global variable g:go_term_mode, which is by default set to :vsplit -function! go#term#new(bang, cmd) +function! go#term#new(bang, cmd) abort return go#term#newmode(a:bang, a:cmd, g:go_term_mode) endfunction " new creates a new terminal with the given command and window mode. -function! go#term#newmode(bang, cmd, mode) +function! go#term#newmode(bang, cmd, mode) abort let mode = a:mode if empty(mode) let mode = g:go_term_mode @@ -36,7 +36,7 @@ function! go#term#newmode(bang, cmd, mode) setlocal noswapfile setlocal nobuflisted - let job = { + let job = { \ 'stderr' : [], \ 'stdout' : [], \ 'bang' : a:bang, @@ -53,6 +53,7 @@ function! go#term#newmode(bang, cmd, mode) let $GOPATH = old_gopath let job.id = id + let job.cmd = a:cmd startinsert " resize new term if needed. @@ -74,7 +75,7 @@ function! go#term#newmode(bang, cmd, mode) return id endfunction -function! s:on_stdout(job_id, data) +function! s:on_stdout(job_id, data, event) dict abort if !has_key(s:jobs, a:job_id) return endif @@ -83,7 +84,7 @@ function! s:on_stdout(job_id, data) call extend(job.stdout, a:data) endfunction -function! s:on_stderr(job_id, data) +function! s:on_stderr(job_id, data, event) dict abort if !has_key(s:jobs, a:job_id) return endif @@ -92,7 +93,7 @@ function! s:on_stderr(job_id, data) call extend(job.stderr, a:data) endfunction -function! s:on_exit(job_id, exit_status) +function! s:on_exit(job_id, exit_status, event) dict abort if !has_key(s:jobs, a:job_id) return endif @@ -113,9 +114,9 @@ function! s:on_exit(job_id, exit_status) if !empty(errors) " close terminal we don't need it anymore - close + close - call go#list#Populate(l:listtype, errors) + call go#list#Populate(l:listtype, errors, job.cmd) call go#list#Window(l:listtype, len(errors)) if !self.bang call go#list#JumpToFirst(l:listtype) diff --git a/sources_non_forked/vim-go/autoload/go/textobj.vim b/sources_non_forked/vim-go/autoload/go/textobj.vim index 53dfacd4..be0c7718 100644 --- a/sources_non_forked/vim-go/autoload/go/textobj.vim +++ b/sources_non_forked/vim-go/autoload/go/textobj.vim @@ -13,7 +13,7 @@ endif " < > " t for tag -function! go#textobj#Function(mode) +function! go#textobj#Function(mode) abort let offset = go#util#OffsetCursor() let fname = shellescape(expand("%:p")) @@ -84,7 +84,7 @@ function! go#textobj#Function(mode) call cursor(info.rbrace.line-1, 1) endfunction -function! go#textobj#FunctionJump(mode, direction) +function! go#textobj#FunctionJump(mode, direction) abort " get count of the motion. This should be done before all the normal " expressions below as those reset this value(because they have zero " count!). We abstract -1 because the index starts from 0 in motion. diff --git a/sources_non_forked/vim-go/autoload/go/tool.vim b/sources_non_forked/vim-go/autoload/go/tool.vim index 487b933d..7b7e1af2 100644 --- a/sources_non_forked/vim-go/autoload/go/tool.vim +++ b/sources_non_forked/vim-go/autoload/go/tool.vim @@ -1,4 +1,4 @@ -function! go#tool#Files() +function! go#tool#Files() abort if go#util#IsWin() let format = '{{range $f := .GoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}' else @@ -9,7 +9,7 @@ function! go#tool#Files() return split(out, '\n') endfunction -function! go#tool#Deps() +function! go#tool#Deps() abort if go#util#IsWin() let format = '{{range $f := .Deps}}{{$f}}{{printf \"\n\"}}{{end}}' else @@ -20,7 +20,7 @@ function! go#tool#Deps() return split(out, '\n') endfunction -function! go#tool#Imports() +function! go#tool#Imports() abort let imports = {} if go#util#IsWin() let format = '{{range $f := .Imports}}{{$f}}{{printf \"\n\"}}{{end}}' @@ -43,8 +43,19 @@ function! go#tool#Imports() return imports endfunction -function! go#tool#PackageName() - let command = "go list -f '{{.Name}}'" +function! go#tool#Info(auto) abort + let l:mode = get(g:, 'go_info_mode', 'gocode') + if l:mode == 'gocode' + call go#complete#Info(a:auto) + elseif l:mode == 'guru' + call go#guru#DescribeInfo() + else + call go#util#EchoError('go_info_mode value: '. l:mode .' is not valid. Valid values are: [gocode, guru]') + endif +endfunction + +function! go#tool#PackageName() abort + let command = "go list -f \"{{.Name}}\"" let out = go#tool#ExecuteInDir(command) if go#util#ShellError() != 0 return -1 @@ -53,7 +64,7 @@ function! go#tool#PackageName() return split(out, '\n')[0] endfunction -function! go#tool#ParseErrors(lines) +function! go#tool#ParseErrors(lines) abort let errors = [] for line in a:lines @@ -85,7 +96,7 @@ endfunction "FilterValids filters the given items with only items that have a valid "filename. Any non valid filename is filtered out. -function! go#tool#FilterValids(items) +function! go#tool#FilterValids(items) abort " Remove any nonvalid filename from the location list to avoid opening an " empty buffer. See https://github.com/fatih/vim-go/issues/287 for " details. @@ -121,7 +132,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,13 +145,14 @@ function! go#tool#ExecuteInDir(cmd) abort execute cd . fnameescape(dir) endtry + let $GOROOT = old_goroot let $GOPATH = old_gopath return out endfunction " Exists checks whether the given importpath exists or not. It returns 0 if " the importpath exists under GOPATH. -function! go#tool#Exists(importpath) +function! go#tool#Exists(importpath) abort let command = "go list ". a:importpath let out = go#tool#ExecuteInDir(command) @@ -152,7 +166,7 @@ endfunction " following two functions are from: https://github.com/mattn/gist-vim " thanks @mattn -function! s:get_browser_command() +function! s:get_browser_command() abort let go_play_browser_command = get(g:, 'go_play_browser_command', '') if go_play_browser_command == '' if go#util#IsWin() @@ -170,7 +184,7 @@ function! s:get_browser_command() return go_play_browser_command endfunction -function! go#tool#OpenBrowser(url) +function! go#tool#OpenBrowser(url) abort let cmd = s:get_browser_command() if len(cmd) == 0 redraw diff --git a/sources_non_forked/vim-go/autoload/go/ui.vim b/sources_non_forked/vim-go/autoload/go/ui.vim index ad8b517b..3f612576 100644 --- a/sources_non_forked/vim-go/autoload/go/ui.vim +++ b/sources_non_forked/vim-go/autoload/go/ui.vim @@ -1,7 +1,7 @@ let s:buf_nr = -1 "OpenWindow opens a new scratch window and put's the content into the window -function! go#ui#OpenWindow(title, content, filetype) +function! go#ui#OpenWindow(title, content, filetype) abort " Ensure there's only one return window in this session/tabpage call go#util#Windo("unlet! w:vim_go_return_window") " Mark the window we're leaving as such @@ -54,7 +54,7 @@ function! go#ui#OpenWindow(title, content, filetype) echon endfunction -function! go#ui#GetReturnWindow() +function! go#ui#GetReturnWindow() abort for l:wn in range(1, winnr("$")) if !empty(getwinvar(l:wn, "vim_go_return_window")) return l:wn @@ -63,7 +63,7 @@ function! go#ui#GetReturnWindow() endfunction " CloseWindow closes the current window -function! go#ui#CloseWindow() +function! go#ui#CloseWindow() abort " Close any window associated with the ui buffer, if it's there if bufexists(s:buf_nr) let ui_window_number = bufwinnr(s:buf_nr) @@ -82,7 +82,7 @@ endfunction " OpenDefinition parses the current line and jumps to it by openening a new " tab -function! go#ui#OpenDefinition(filter) +function! go#ui#OpenDefinition(filter) abort let curline = getline('.') " don't touch our first line or any blank line diff --git a/sources_non_forked/vim-go/autoload/go/util.vim b/sources_non_forked/vim-go/autoload/go/util.vim index 591606ff..aaf7273d 100644 --- a/sources_non_forked/vim-go/autoload/go/util.vim +++ b/sources_non_forked/vim-go/autoload/go/util.vim @@ -1,5 +1,5 @@ " PathSep returns the appropriate OS specific path separator. -function! go#util#PathSep() +function! go#util#PathSep() abort if go#util#IsWin() return '\' endif @@ -7,7 +7,7 @@ function! go#util#PathSep() endfunction " PathListSep returns the appropriate OS specific path list separator. -function! go#util#PathListSep() +function! go#util#PathListSep() abort if go#util#IsWin() return ";" endif @@ -15,7 +15,7 @@ function! go#util#PathListSep() endfunction " LineEnding returns the correct line ending, based on the current fileformat -function! go#util#LineEnding() +function! go#util#LineEnding() abort if &fileformat == 'dos' return "\r\n" elseif &fileformat == 'mac' @@ -27,12 +27,12 @@ endfunction " Join joins any number of path elements into a single path, adding a " Separator if necessary and returns the result -function! go#util#Join(...) +function! go#util#Join(...) abort return join(a:000, go#util#PathSep()) endfunction " IsWin returns 1 if current OS is Windows or 0 otherwise -function! go#util#IsWin() +function! go#util#IsWin() abort let win = ['win16', 'win32', 'win64', 'win95'] for w in win if (has(w)) @@ -43,70 +43,80 @@ function! go#util#IsWin() return 0 endfunction -function! go#util#GOARCH() +function! go#util#has_job() abort + " job was introduced in 7.4.xxx however there are multiple bug fixes and one + " of the latest is 8.0.0087 which is required for a stable async API. + return has('job') && has("patch-8.0.0087") +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) abort + 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() abort return substitute(go#util#System('go env GOARCH'), '\n', '', 'g') endfunction -function! go#util#GOOS() +function! go#util#goos() abort return substitute(go#util#System('go env GOOS'), '\n', '', 'g') endfunction -function! go#util#GOROOT() +function! go#util#goroot() abort return substitute(go#util#System('go env GOROOT'), '\n', '', 'g') endfunction -function! go#util#GOPATH() +function! go#util#gopath() abort return substitute(go#util#System('go env GOPATH'), '\n', '', 'g') endfunction -function! go#util#OSARCH() - return go#util#GOOS() . '_' . go#util#GOARCH() +function! go#util#osarch() abort + return go#util#goos() . '_' . go#util#goarch() endfunction - -"Check if has vimproc -function! s:has_vimproc() - if !exists('g:go#use_vimproc') - if go#util#IsWin() - try - call vimproc#version() - let exists_vimproc = 1 - catch - let exists_vimproc = 0 - endtry - else - let exists_vimproc = 0 - endif - - let g:go#use_vimproc = exists_vimproc +" System runs a shell command. It will reset the shell to /bin/sh for Unix-like +" systems if it is executable. +function! go#util#System(str, ...) abort + let l:shell = &shell + if !go#util#IsWin() && executable('/bin/sh') + let &shell = '/bin/sh' endif - return g:go#use_vimproc + try + let l:output = call('system', [a:str] + a:000) + return l:output + finally + let &shell = l:shell + endtry endfunction -if s:has_vimproc() - let s:vim_system = get(g:, 'gocomplete#system_function', 'vimproc#system2') - let s:vim_shell_error = get(g:, 'gocomplete#shell_error_function', 'vimproc#get_last_status') -else - let s:vim_system = get(g:, 'gocomplete#system_function', 'system') - let s:vim_shell_error = '' -endif - -function! go#util#System(str, ...) - return call(s:vim_system, [a:str] + a:000) +function! go#util#ShellError() abort + return v:shell_error endfunction -function! go#util#ShellError() - if empty(s:vim_shell_error) - return v:shell_error - endif - return call(s:vim_shell_error, []) -endfunction - - " StripPath strips the path's last character if it's a path separator. " example: '/foo/bar/' -> '/foo/bar' -function! go#util#StripPathSep(path) +function! go#util#StripPathSep(path) abort let last_char = strlen(a:path) - 1 if a:path[last_char] == go#util#PathSep() return strpart(a:path, 0, last_char) @@ -117,13 +127,13 @@ endfunction " StripTrailingSlash strips the trailing slash from the given path list. " example: ['/foo/bar/'] -> ['/foo/bar'] -function! go#util#StripTrailingSlash(paths) +function! go#util#StripTrailingSlash(paths) abort return map(copy(a:paths), 'go#util#StripPathSep(v:val)') endfunction " Shelljoin returns a shell-safe string representation of arglist. The " {special} argument of shellescape() may optionally be passed. -function! go#util#Shelljoin(arglist, ...) +function! go#util#Shelljoin(arglist, ...) abort try let ssl_save = &shellslash set noshellslash @@ -138,9 +148,6 @@ function! go#util#Shelljoin(arglist, ...) endfunction fu! go#util#Shellescape(arg) - if s:has_vimproc() - return vimproc#shellescape(a:arg) - endif try let ssl_save = &shellslash set noshellslash @@ -152,7 +159,7 @@ endf " Shelllist returns a shell-safe representation of the items in the given " arglist. The {special} argument of shellescape() may optionally be passed. -function! go#util#Shelllist(arglist, ...) +function! go#util#Shelllist(arglist, ...) abort try let ssl_save = &shellslash set noshellslash @@ -166,7 +173,7 @@ function! go#util#Shelllist(arglist, ...) endfunction " Returns the byte offset for line and column -function! go#util#Offset(line, col) +function! go#util#Offset(line, col) abort if &encoding != 'utf-8' let sep = go#util#LineEnding() let buf = a:line == 1 ? '' : (join(getline(1, a:line-1), sep) . sep) @@ -177,13 +184,13 @@ function! go#util#Offset(line, col) endfunction " " Returns the byte offset for the cursor -function! go#util#OffsetCursor() +function! go#util#OffsetCursor() abort return go#util#Offset(line('.'), col('.')) endfunction " Windo is like the built-in :windo, only it returns to the window the command " was issued from -function! go#util#Windo(command) +function! go#util#Windo(command) abort let s:currentWindow = winnr() try execute "windo " . a:command @@ -195,7 +202,7 @@ endfunction " snippetcase converts the given word to given preferred snippet setting type " case. -function! go#util#snippetcase(word) +function! go#util#snippetcase(word) abort let l:snippet_case = get(g:, 'go_snippet_case_type', "snakecase") if l:snippet_case == "snakecase" return go#util#snakecase(a:word) @@ -208,7 +215,7 @@ endfunction " snakecase converts a string to snake case. i.e: FooBar -> foo_bar " Copied from tpope/vim-abolish -function! go#util#snakecase(word) +function! go#util#snakecase(word) abort let word = substitute(a:word,'::','/','g') let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g') @@ -219,7 +226,7 @@ endfunction " camelcase converts a string to camel case. i.e: FooBar -> fooBar " Copied from tpope/vim-abolish -function! go#util#camelcase(word) +function! go#util#camelcase(word) abort let word = substitute(a:word, '-', '_', 'g') if word !~# '_' && word =~# '\l' return substitute(word,'^.','\l&','') @@ -228,24 +235,74 @@ function! go#util#camelcase(word) endif endfunction +function! go#util#AddTags(line1, line2, ...) abort + " default is json + let l:keys = ["json"] + if a:0 + let l:keys = a:000 + endif + + let l:line1 = a:line1 + let l:line2 = a:line2 + + " If we're inside a struct and just call this function let us add the tags + " to all fields + " TODO(arslan): I don't like using patterns. Check if we can move it to + " `motion` and do it via AST based position + let ln1 = searchpair('struct {', '', '}', 'bcnW') + if ln1 == 0 + echon "vim-go: " | echohl ErrorMsg | echon "cursor is outside the struct" | echohl None + return + endif + + " searchpair only returns a single position + let ln2 = search('}', "cnW") + + " if no range is given we apply for the whole struct + if l:line1 == l:line2 + let l:line1 = ln1 + 1 + let l:line2 = ln2 - 1 + endif + + for line in range(l:line1, l:line2) + " get the field name (word) that are not part of a commented line + let l:matched = matchstr(getline(line), '\(\/\/.*\)\@ git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go < - * https://github.com/junegunn/vim-plug > Plug 'fatih/vim-go' -< * https://github.com/Shougo/neobundle.vim > NeoBundle 'fatih/vim-go' < - * https://github.com/gmarik/vundle > Plugin 'fatih/vim-go' +* Vim |packages| (since Vim 7.4.1528) +> + git clone https://github.com/fatih/vim-go.git \ + ~/.vim/pack/plugins/start/vim-go < * Manual > Copy all of the files into your `~/.vim` directory < -Please be sure all necessary binaries are installed (such as `gocode`, `godef`, -`goimports`, etc..). You can easily install them with the included -|GoInstallBinaries| command. If you invoke it, all necessary binaries will be -automatically downloaded and installed to your `$GOBIN` environment (if not set -it will use `$GOPATH/bin`). It requires `git` for fetching the individual Go -packages. +Please be sure all necessary binaries are installed (such as `gocode`, +`godef`, `goimports`, etc.). You can easily install them with the included +|:GoInstallBinaries| command. If you invoke it, all necessary binaries will be +automatically downloaded and installed to your `$GOBIN` environment (if not +set it will use `$GOPATH/bin`). It requires `git` for fetching the individual +Go packages. * Autocompletion is enabled by default via ``, to get real-time completion (completion by type) install: @@ -121,20 +127,21 @@ https://github.com/majutsushi/tagbar. * For snippet feature install: https://github.com/Shougo/neosnippet.vim or https://github.com/SirVer/ultisnips. -* For a better documentation viewer checkout: https://github.com/garyburd/go-explorer +* For a better documentation viewer check out: + https://github.com/garyburd/go-explorer -=============================================================================== -COMMANDS *go-commands* +============================================================================== +COMMANDS *go-commands* - *:GoPath* + *:GoPath* :GoPath [path] GoPath sets and overrides GOPATH with the given {path}. If no {path} is given it shows the current GOPATH. If `""` is given as path, it clears - current `GOPATH` which was set with |GoPath| and restores `GOPATH` back to - the initial value which was sourced when Vim was started. + current `GOPATH` which was set with |:GoPath| and restores `GOPATH` back + to the initial value which was sourced when Vim was started. - *:GoImport* + *:GoImport* :GoImport[!] [path] Import ensures that the provided package {path} is imported in the current @@ -143,36 +150,36 @@ COMMANDS *go-commands* If [!] is given it will download the package with `go get` - *:GoImportAs* + *:GoImportAs* :GoImportAs [localname] [path] Same as Import, but uses a custom local name for the package. - *:GoDrop* + *:GoDrop* :GoDrop [path] Remove the import line for the provided package {path}, if present in the current Go buffer. If {path} is not being imported, an error will be displayed and the buffer will be untouched. - *:GoLint* + *:GoLint* :GoLint [packages] Run golint for the current Go file, or for given packages. - *:GoDoc* + *:GoDoc* :GoDoc [word] Open the relevant GoDoc in split window for either the word[s] passed to the command or by default, the word under the cursor. - *:GoDocBrowser* + *:GoDocBrowser* :GoDocBrowser [word] Open the relevant GoDoc in browser for either the word[s] passed to the command or by default, the word under the cursor. - *:GoFmt* + *:GoFmt* :GoFmt Filter the current Go buffer through gofmt. It tries to preserve cursor @@ -183,7 +190,7 @@ COMMANDS *go-commands* Filter the current Go buffer through goimports (needs to be installed). `goimports` automatically discards/add import path based on the code. Like - |GoFmt|, It tries to preserve cursor position and avoids replacing the + |:GoFmt|, It tries to preserve cursor position and avoids replacing the buffer with stderr output. *:GoPlay* @@ -194,14 +201,14 @@ COMMANDS *go-commands* is copied to system clipboard if Vim is compiled with 'clipboard' or 'xterm-clipboard' otherwise it's get yanked into the `""` register. - *:GoVet* + *:GoVet* :GoVet[!] [options] Run `go vet` for the directory under your current file. Vet examines Go source code and reports suspicious constructs, such as Printf calls whose - arguments do not align with the format string. Vet uses heuristics that do not - guarantee all reports are genuine problems, but it can find errors not caught - by the compilers. + arguments do not align with the format string. Vet uses heuristics that do + not guarantee all reports are genuine problems, but it can find errors not + caught by the compilers. You may optionally pass any valid go tool vet flags/options. In this case, `go tool vet` is run in place of `go vet`. For a full list please see @@ -209,7 +216,7 @@ COMMANDS *go-commands* If [!] is not given the first error is jumped to. - *:GoDef* + *:GoDef* :GoDef [identifier] gd CTRL-] @@ -217,67 +224,68 @@ CTRL-] Goto declaration/definition for the given [identifier]. If no argument is given, it will jump to the declaration under the cursor. By default the CTRL-] key and the mapping `gd` are enabled to invoke :GoDef for the - identifier under the cursor. See |g:go_def_mapping_enabled| to disable them. + identifier under the cursor. See |'g:go_def_mapping_enabled'| to disable + them. - vim-go also keeps a per-window location stack, roughly analagous to how - vim's internal |tags| functionality works. This is pushed to every time a - jump is made using the GoDef functionality. In essence, this is a LIFO list - of file locations you have visited with :GoDef that is retained to help you - navigate software. For more information on displaying the stack, see - |:GoDefJump| + vim-go also keeps a per-window location stack, roughly analogous to how + Vim's internal |tags| functionality works. This is pushed to every time a + jump is made using the GoDef functionality. In essence, this is a LIFO + list of file locations you have visited with :GoDef that is retained to + help you navigate software. - *:GoDefStack* + *:GoDefStack* :GoDefStack [number] - This command Jumps to a given location in the jumpstack, retaining all other - entries. Jumps to non-existent entries will print an informative message, - but are otherwise a noop. + This command Jumps to a given location in the jumpstack, retaining all + other entries. Jumps to non-existent entries will print an informative + message, but are otherwise a noop. - If no argument is given, it will print out an interactive list of all items - in the stack. Its output looks like this: + If no argument is given, it will print out an interactive list of all + items in the stack. Its output looks like this: - 1 /path/to/first/file.go|1187 col 16|AddThing func(t *Thing) - > 2 /path/to/thing/thing.go|624 col 19|String() string - 3 /path/to/thing/thing.go|744 col 6|func Sprintln(a ...interface{}) string + 1 /path/first/file.go|1187 col 16|AddThing func(t *Thing) + > 2 /path/thing/thing.go|624 col 19|String() string + 3 /path/thing/thing.go|744 col 6|func Sprintln(a ...interface{}) string This list shows the identifiers that you jumped to and the file and cursor - position before that jump. The older jumps are at the top, the newer at the - bottom. + position before that jump. The older jumps are at the top, the newer at + the bottom. - The '>' points to the active entry. This entry and any newer entries below - it will be replaced if |:GoDef| is done from this location. The CTRL-t and - |:GoDefPop| command will jump to the position above the active entry. + The '>' points to the active entry. This entry and any newer entries + below it will be replaced if |:GoDef| is done from this location. The + CTRL-t and |:GoDefPop| command will jump to the position above the active + entry. Jumps to non-existent entries will print an informative message, but are otherwise a noop. *:GoDefStackClear* -:GoDefStackClear +:GoDefStackClear Clears the current stack list and resets it. - *:GoDefPop* + *:GoDefPop* :GoDefPop [count] CTRL-t - Navigate to the [count] earlier entry in the jump stack, retaining the newer - entries. If no argument is given, it will jump to the next most recent entry - (`:GoDefPop 1`). If [count] is greater than the number of prior entries, - an error will be printed and no jump will be performed. + Navigate to the [count] earlier entry in the jump stack, retaining the + newer entries. If no argument is given, it will jump to the next most + recent entry (`:GoDefPop 1`). If [count] is greater than the number of + prior entries, an error will be printed and no jump will be performed. If you have used :GoDefPop to jump to an earlier location, and you issue another :GoDef command, the current entry will be replaced, and all newer entries will be removed, effectively resuming the stack at that location. - By default [count]CTRL-t is enabled to invoke :GoDefPop. Similarly, hitting - CTRL-t without a prior count is equivalent to `:GoDefPop 1`. See - |g:go_def_mapping_enabled| to disable this. + By default [count]CTRL-t is enabled to invoke :GoDefPop. Similarly, + hitting CTRL-t without a prior count is equivalent to `:GoDefPop 1`. See + |'g:go_def_mapping_enabled'| to disable this. - *:GoRun* + *:GoRun* :GoRun[!] [expand] Build and run your current main package. By default all main files for the - current file is used. If an argument is passed, 'expand' is used as file + current file is used. If an argument is passed, [expand] is used as file selector. For example use `:GoRun %` to select the current file only. You may optionally pass any valid go run flags/options. For a full list @@ -286,73 +294,75 @@ CTRL-t If [!] is not given the first error is jumped to. If using neovim then `:GoRun` will run in a new terminal according to - |g:go_term_mode|. + |'g:go_term_mode'|. - *:GoBuild* + *:GoBuild* :GoBuild[!] [expand] Build your package with `go build`. Errors are populated in the quickfix window. It automatically builds only the files that depends on the current file. `:GoBuild` doesn't produce a result file. - Use 'make' to create a result file. + Use |:make| to create a result file. You may optionally pass any valid go build flags/options. For a full list - please see `go help build`. Options are expanded with 'expand'. + please see `go help build`. Options are expanded with [expand]. If [!] is not given the first error is jumped to. If using neovim then this command is fully async, it does not block the UI. - *:GoGenerate* + *:GoGenerate* :GoGenerate[!] [expand] Creates or updates your auto-generated source files by running `go generate`. - You may optionally pass any valid go generate flags/options. For a full list - please see `go help generate`. Options are expanded with 'expand'. + You may optionally pass any valid go generate flags/options. For a full + list please see `go help generate`. Options are expanded with [expand]. If [!] is not given the first error is jumped to. - *:GoInfo* + *:GoInfo* :GoInfo Show type information about the identifier under the cursor. For example putting it above a function call is going to show the full function - signature. It uses gocode to get the type informations. + signature. By default it uses `gocode` to get the type informations. To + change the underlying tool from `gocode` to another tool, see + |g:go_info_mode|. - *:GoInstall* + *:GoInstall* :GoInstall[!] [options] Install your package with `go install`. - You may optionally pass any valid go install flags/options. For a full list - please see `go help install`. + You may optionally pass any valid go install flags/options. For a full + list please see `go help install`. If [!] is not given the first error is jumped to. - *:GoTest* + *:GoTest* :GoTest[!] [expand] Run the tests on your _test.go files via in your current directory. Errors - are populated in the quickfix window. If an argument is passed, 'expand' + are populated in the quickfix window. If an argument is passed, [expand] is used as file selector (useful for cases like `:GoTest ./...`). You may optionally pass any valid go test flags/options. For a full list please see `go help test`. GoTest timesout automatically after 10 seconds. To customize the timeout - use |g:go_test_timeout|. This feature is disabled if any arguments are + use |'g:go_test_timeout'|. This feature is disabled if any arguments are passed to the `:GoTest` command. If [!] is not given the first error is jumped to. If using neovim `:GoTest` will run in a new terminal or run asynchronously - in the background according to |g:go_term_enabled|. You can set the mode of - the new terminal with |g:go_term_mode|. + in the background according to |'g:go_term_enabled'|. You can set the mode + of the new terminal with |'g:go_term_mode'|. - *:GoTestFunc* + *:GoTestFunc* :GoTestFunc[!] [expand] Runs :GoTest, but only on the single test function immediate to your @@ -364,15 +374,15 @@ CTRL-t If [!] is not given the first error is jumped to. - If using neovim `:GoTestFunc` will run in a new terminal or run asynchronously - in the background according to |g:go_term_enabled|. You can set the mode of - the new terminal with |g:go_term_mode|. + If using neovim `:GoTestFunc` will run in a new terminal or run + asynchronously in the background according to |'g:go_term_enabled'|. You + can set the mode of the new terminal with |'g:go_term_mode'|. *:GoTestCompile* :GoTestCompile[!] [expand] Compile your _test.go files via in your current directory. Errors are - populated in the quickfix window. If an argument is passed, 'expand' is + populated in the quickfix window. If an argument is passed, [expand] is used as file selector (useful for cases like `:GoTest ./...`). Useful to not run the tests and capture/fix errors before running the tests or to create test binary. @@ -380,10 +390,10 @@ CTRL-t If [!] is not given the first error is jumped to. If using neovim `:GoTestCompile` will run in a new terminal or run - asynchronously in the background according to |g:go_term_enabled|. You can - set the mode of the new terminal with |g:go_term_mode|. + asynchronously in the background according to |'g:go_term_enabled'|. You + can set the mode of the new terminal with |'g:go_term_mode'|. - *:GoCoverage* + *:GoCoverage* :GoCoverage[!] [options] Create a coverage profile and annotates the current file's source code. If @@ -391,7 +401,7 @@ CTRL-t If [!] is not given the first error is jumped to. - *:GoCoverageToggle* + *:GoCoverageToggle* :GoCoverageToggle[!] [options] Create a coverage profile and annotates the current file's source code. If @@ -399,7 +409,7 @@ CTRL-t If [!] is not given the first error is jumped to. - *:GoCoverageClear* + *:GoCoverageClear* :GoCoverageClear [options] Clears the coverage annotation. @@ -416,7 +426,7 @@ CTRL-t If [!] is not given the first error is jumped to. - *:GoErrCheck* + *:GoErrCheck* :GoErrCheck [options] Check for unchecked errors in you current package. Errors are populated in @@ -425,12 +435,12 @@ CTRL-t You may optionally pass any valid errcheck flags/options. For a full list please see `errcheck -h`. - *:GoFiles* + *:GoFiles* :GoFiles Show source files that depends for the current package - *:GoDeps* + *:GoDeps* :GoDeps Show dependencies for the current package @@ -439,23 +449,23 @@ CTRL-t :GoInstallBinaries Download and Install all necessary Go tool binaries such as `godef`, - `goimports`, `gocode`, etc.. under `g:go_bin_path`. Set |g:go_get_update| - to disable updating dependencies. + `goimports`, `gocode`, etc. under `g:go_bin_path`. Set + |'g:go_get_update'| to disable updating dependencies. - *:GoUpdateBinaries* + *:GoUpdateBinaries* :GoUpdateBinaries Download and Update previously installed Go tool binaries such as `godef`, `goimports`, `gocode`, etc.. under `g:go_bin_path`. This can be used to update the necessary Go binaries. - *:GoImplements* + *:GoImplements* :GoImplements - Show 'implements' relation for a selected package. A list of interfaces + Show "implements" relation for a selected package. A list of interfaces for the type that implements an interface under the cursor (or selected package) is shown in a location list. - *:GoRename* + *:GoRename* :GoRename[!] [to] Rename the identifier under the cursor to the desired new name. If no @@ -464,13 +474,13 @@ CTRL-t If [!] is not given the first error is jumped to. - *:GoGuruScope* + *:GoGuruScope* :GoGuruScope [pattern] [pattern2] ... [patternN] - Changes the custom |g:go_guru_scope| setting and overrides it with the + Changes the custom |'g:go_guru_scope'| setting and overrides it with the given package patterns. The custom scope is cleared (unset) if `""` is given as the only path. If no arguments is given it prints the current - custom scope. Example patterns are: + custom scope. Example patterns are: > golang.org/x/tools/cmd/guru # a single package golang.org/x/tools/... # all packages beneath dir @@ -488,21 +498,21 @@ CTRL-t Under the hood, the patterns are all joined to a comma-separated list and passed to `guru`'s `-scope` flag. - *:GoCallees* + *:GoCallees* :GoCallees - Show 'callees' relation for a selected package. A list of possible call + Show "callees" relation for a selected package. A list of possible call targets for the type under the cursor (or selected package) is shown in a location list. - *:GoCallers* + *:GoCallers* :GoCallers - Show 'callers' relation for a selected function. A list of possible + Show "callers" relation for a selected function. A list of possible callers for the selected function under the cursor is shown in a location list. - *:GoDescribe* + *:GoDescribe* :GoDescribe Shows various properties of the selected syntax: its syntactic kind, its @@ -511,15 +521,15 @@ CTRL-t identifier), etc. Almost any piece of syntax may be described, and the guru will try to print all the useful information it can. - *:GoCallstack* + *:GoCallstack* :GoCallstack - Shows 'callstack' relation for the selected function. An arbitrary path + Shows "callstack" relation for the selected function. An arbitrary path from the root of the callgraph to the selected function is shown in a location list. This may be useful to understand how the function is reached in a given program. - *:GoFreevars* + *:GoFreevars* :GoFreevars Enumerates the free variables of the selection. “Free variables” is a @@ -532,106 +542,122 @@ CTRL-t understand what the inputs are to a complex block of code even if you don’t plan to change it. - *:GoChannelPeers* + *:GoChannelPeers* :GoChannelPeers Shows the set of possible sends/receives on the channel operand of the - selected send or receive operation; the selection must be a <- token. + selected send or receive operation; the selection must be a `<-` token. For example, visually select a channel operand in the form of: - - "done <- true" - - and call |GoChannelPeers| on it. It will show where it was allocated, and +> + done <- true +< + And call |:GoChannelPeers| on it. It will show where it was allocated, and the sending and receiving endings. - *:GoReferrers* + *:GoReferrers* :GoReferrers The referrers query shows the set of identifiers that refer to the same object as does the selected identifier, within any package in the analysis scope. - *:GoSameIds* + *:GoSameIds* :GoSameIds Highlights all identifiers that are equivalent to the identifier under the cursor. - *:GoSameIdsClear* + *:GoSameIdsClear* :GoSameIdsClear Clears all SameIds highlights from a |:GoSameIds| call. - *:GoMetaLinter* + *:GoSameIdsToggle* +:GoSameIdsToggle + + Toggle between |:GoSameIds| and |:GoSameIdsClear|. + + *:GoSameIdsAutoToggle* +:GoSameIdsAutoToggle + + Enables or disables automatic highlighting of |:GoSameIds| while moving + the cursor. This basically toggles the option |'g:go_auto_sameids'| + on/off. + If enabled it starts highlighting whenever your cursor is staying at the + same position for a configurable period of time (see 'updatetime'). If + disabled it clears and stops automatic highlighting. + + *:GoMetaLinter* :GoMetaLinter [path] Calls the underlying `gometalinter` tool and displays all warnings and - errors in the quickfix window. By default the following linters are - enabled: "'vet', 'golint', 'errcheck'". This can be changed with the - |g:go_metalinter_enabled| variable. To override the command completely use - the variable |g:go_metalinter_command|. To override the maximum linters - execution time use |g:go_metalinter_deadline| variable. + errors in the |quickfix| window. By default the following linters are + enabled: `vet`, `golint`, and `errcheck`. This can be changed with the + |'g:go_metalinter_enabled'| variable. To override the command completely + use the variable |'g:go_metalinter_command'|. To override the maximum + linters execution time use |'g:go_metalinter_deadline'| variable. - *:GoGuruTags* + *:GoGuruTags* :GoGuruTags [tags] - Changes the custom |g:go_guru_tags| setting and overrides it with the + Changes the custom |'g:go_guru_tags'| setting and overrides it with the given build tags. This command cooperate with GoReferrers command when - there exist mulitiple build tags in your project, then you can set one - of the build tags for GoReferrers to find more accurate. + there exist mulitiple build tags in your project, then you can set one of + the build tags for GoReferrers to find more accurate. The custom build tags is cleared (unset) if `""` is given. If no arguments is given it prints the current custom build tags. *:AsmFmt* :AsmFmt - Filter the current Go asm buffer through asmfmt. It tries to preserve cursor - position and avoids replacing the buffer with stderr output. + Filter the current Go asm buffer through asmfmt. It tries to preserve + cursor position and avoids replacing the buffer with stderr output. - - *:GoAlternate* + *:GoAlternate* :GoAlternate[!] - Alternates between the implementation and test code. For example if in main.go, - switch to main_test.go. Uses the |g:go_alternate_mode| setting as the command - to open the file. + Alternates between the implementation and test code. For example if in + main.go, switch to main_test.go. Uses the |'g:go_alternate_mode'| setting + as the command to open the file. - If [!] is given then it switches to the new file even if it does not exist. + If [!] is given then it switches to the new file even if it does not + exist. - If you would like to override the traditional commands for alternating, add - the following to your .vimrc: + If you would like to override the traditional commands for alternating, + add the following to your .vimrc: > augroup go autocmd! - autocmd Filetype go command! -bang A call go#alternate#Switch(0, 'edit') - autocmd Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') - autocmd Filetype go command! -bang AS call go#alternate#Switch(0, 'split') + autocmd Filetype go + \ command! -bang A call go#alternate#Switch(0, 'edit') + \| command! -bang AV call go#alternate#Switch(0, 'vsplit') + \| command! -bang AS call go#alternate#Switch(0, 'split') augroup END < - *:GoDecls* + *:GoWhicherrs* +:GoWhicherrs + + Show the list of possible constants, global variables, and concrete types + for the error type under the cursor in a location list. + + *:GoDecls* :GoDecls [file] - + Only enabled if `ctrlp.vim` is installed. If run shows all function and type declarations for the current file. If [file] is non empty it parses - the given file. - By default `type` and `func` declarations are being showed. This can be - changed via |g:go_decls_includes|, which accepts a comma delimited list of - definitions. By default set to: `"func,type"`. Possible options are: - `{func,type}` + the given file. + By default `type` and `func` declarations are shown. This can be changed + via |'g:go_decls_includes'|. - *:GoDeclsDir* + *:GoDeclsDir* :GoDeclsDir [dir] - + Only enabled if `ctrlp.vim` is installed. If run shows all function and type declarations for the current directory. If [dir] is given it parses the given directory. - By default `type` and `func` declarations are being showed. This can be - changed via |g:go_decls_includes|, which accepts a comma delimited list of - definitions. By default set to: `"func,type"`. Possible options are: - `{func,type}` - *:GoImpl* + *:GoImpl* :GoImpl [receiver] [interface] Generates method stubs for implementing an interface. If no arguments is @@ -642,9 +668,48 @@ CTRL-t :GoImpl f *Foo io.Writer :GoImpl T io.ReadWriteCloser < - + *:GoAddTags* +:[range]GoAddTags [key] [key1] ... -=============================================================================== + Adds field tags for the fields of a struct. If called inside a struct it + automatically add field tags with the `json` key and the value + automatically generated based on the field name. An error message is given + if it's called outside a struct definition. + + If [range] is given, only the selected fields will be changed. + + The default `json` can be changed by providing one or more [key] + arguments. An example of adding `xml` and `db` would be: +> + :GoAddTags xml db +< + *:GoAutoTypeInfoToggle* +:GoAutoTypeInfoToggle + + Toggles |'g:go_auto_type_info'|. + + *:GoFmtAutoSaveToggle* +:GoFmtAutoSaveToggle + + Toggles |'g:go_fmt_autosave'|. + + *:GoAsmFmtAutoSaveToggle* +:GoAsmFmtAutoSaveToggle + + Toggles |'g:go_asmfmt_autosave'|. + + *:GoMetaLinterAutoSaveToggle* +:GoMetaLinterAutoSaveToggle + + Toggles |'g:go_metalinter_autosave'|. + + *:GoTemplateAutoCreateToggle* +:GoTemplateAutoCreateToggle + + Toggles |'g:go_template_autocreate'|. + + +============================================================================== MAPPINGS *go-mappings* vim-go has several keys which can be used to create custom mappings @@ -657,11 +722,11 @@ As always one is free to create more advanced mappings or functions based with |go-commands|. For more information please check out the mappings command documentation in the |go-commands| section. Available keys are: - *(go-run)* + *(go-run)* Calls `go run` for the current main package - *(go-run-tab)* + *(go-run-tab)* Calls `go run` for the current file in a new terminal tab This option is neovim only. @@ -671,46 +736,45 @@ This option is neovim only. Calls `go run` for the current file in a new terminal horizontal split This option is neovim only. - *(go-run-vertical)* + *(go-run-vertical)* Calls `go run` for the current file in a new terminal vertical split This option is neovim only. - - *(go-build)* + *(go-build)* Calls `go build` for the current package - *(go-generate)* + *(go-generate)* Calls `go generate` for the current package - *(go-info)* + *(go-info)* Shows type information for the word under the cursor - *(go-install)* + *(go-install)* Calls `go install` for the current package - *(go-test)* + *(go-test)* Calls `go test` for the current package - *(go-test-func)* + *(go-test-func)* Calls `go test -run '...'` for the test function immediate to cursor - *(go-test-compile)* + *(go-test-compile)* Calls `go test -c` for the current package - *(go-coverage)* + *(go-coverage)* Calls `go test -coverprofile-temp.out` for the current package and shows the coverage annotation. - *(go-coverage-clear)* + *(go-coverage-clear)* Clears the coverage annotation @@ -724,64 +788,66 @@ annotation. Calls `goimports` for the current package - *(go-vet)* + *(go-lint)* + +Calls `golint` for the current package + + *(go-vet)* Calls `go vet` for the current package - *(go-files)* + *(go-files)* Show source files that depends for the current package - *(go-deps)* + *(go-deps)* Show dependencies for the current package - *(go-doc)* + *(go-doc)* Show the relevant GoDoc for the word under the cursor in a split window leftabove (default mode). - *(go-doc-split)* + *(go-doc-split)* Show the relevant GoDoc for the word under the cursor in a split window. - *(go-doc-vertical)* + *(go-doc-vertical)* Show the relevant GoDoc for the word under the cursor in a vertical split window. - - *(go-doc-tab)* + *(go-doc-tab)* Show the relevant GoDoc for the word under the cursor in a tab window. - *(go-doc-browser)* + *(go-doc-browser)* Show the relevant GoDoc for the word under in browser - *(go-def)* + *(go-def)* Goto declaration/definition. Results are shown in the current buffer. + *(go-def-split)* - *(go-def-split)* +Goto declaration/definition. Results are shown in a split window. +Jumps to an existing buffer if |'g:go_def_reuse_buffer'| is enabled. -Goto declaration/definition. Results are shown in a split window. -Jumps to an existing buffer if |g:go_def_reuse_buffer| is enabled. - - *(go-def-vertical)* + *(go-def-vertical)* Goto declaration/definition. Results are shown in a vertical split window. -Jumps to an existing buffer if |g:go_def_reuse_buffer| is enabled. +Jumps to an existing buffer if |'g:go_def_reuse_buffer'| is enabled. - *(go-def-tab)* + *(go-def-tab)* Goto declaration/definition. Results are shown in a tab window. -Jumps to an existing buffer if |g:go_def_reuse_buffer| is enabled. +Jumps to an existing buffer if |'g:go_def_reuse_buffer'| is enabled. *(go-def-stack)* @@ -791,77 +857,76 @@ Shows the godef tag stack Resets and clears the tag stack - *(go-def-pop)* + *(go-def-pop)* Jump to previous entry in the tag stack - *(go-implements)* + *(go-implements)* Show the interfaces that the type under the cursor implements. - *(go-rename)* + *(go-rename)* Rename the identifier under the cursor to the desired new name - *(go-callees)* + *(go-callees)* Show the call targets for the type under the cursor - *(go-callers)* + *(go-callers)* Show possible callers of selected function - *(go-describe)* + *(go-describe)* Describe selected syntax: definition, methods, etc - - *(go-callstack)* + *(go-callstack)* Show path from callgraph root to selected function - *(go-freevars)* + *(go-freevars)* Show free variables of selection - *(go-channelpeers)* + *(go-channelpeers)* Show send/receive corresponding to selected channel op - *(go-referrers)* + *(go-referrers)* Show all refs to entity denoted by selected identifier - *(go-metalinter)* + *(go-metalinter)* Calls `go-metalinter` for the current directory - *(go-alternate-edit)* + *(go-alternate-edit)* Alternates between the implementation and test code in the current window - *(go-alternate-split)* + *(go-alternate-split)* Alternates between the implementation and test code in a new horizontal split - *(go-alternate-vertical)* + *(go-alternate-vertical)* Alternates between the implementation and test code in a new vertical split - *(go-import)* + *(go-import)* Calls `:GoImport` for the current package -=============================================================================== +============================================================================== TEXT OBJECTS *go-text-objects* vim-go comes with several custom |text-objects| that can be used to operate upon regions of text. vim-go currently defines the following text objects: *go-v_af* *go-af* -af "a function", select contents from a function definition to the - closing bracket. If |g:go_textobj_include_function_doc| is +af "a function", select contents from a function definition to the + closing bracket. If |'g:go_textobj_include_function_doc'| is enabled it also includes the comment doc for a function declaration. This text-object also supports literal functions. @@ -874,9 +939,9 @@ if "inside a function", select contents of a function, vim-go also defines the following text motion objects: *go-v_]]* *go-]]* -]] [count] forward to next function declaration. If - |g:go_textobj_include_function_doc| is enabled and if your - on a comment, it skips the function which the comment +]] [count] forward to next function declaration. If + |'g:go_textobj_include_function_doc'| is enabled and if your + on a comment, it skips the function which the comment belongs and forwards to the next function declaration. *go-v_[[* *go-[[* @@ -884,34 +949,37 @@ vim-go also defines the following text motion objects: -=============================================================================== +============================================================================== FUNCTIONS *go-functions* - *go#jobcontrol#Statusline()* + *go#statusline#Show()* Shows the status of a job running asynchronously. Can be used to plug into the statusline. It works to show the status per package instead of per -file. Assume you have three files open, all belonging to the same package, -if the package build (`:GoBuild`) is successful, all statusline's will be empty -(means SUCCESS), if you it fails all file's statusline will show FAILED. +file. Assume you have three files open, all belonging to the same package, if +the package build (`:GoBuild`) is successful, all statusline's will show +`success`, if you it fails all file's statusline will show `failed`. - *go#complete#GetInfo()* +To avoid always showing old status information, the status information is +cleaned for each package after `60` seconds. This can be changed with the +|g:go_statusline_duration| setting. + + *go#complete#GetInfo()* Returns the description of the identifer under the cursor. Can be used to plug -into the statusline. This function is also used for |g:go_auto_type_info|. +into the statusline. This function is also used for |'g:go_auto_type_info'|. -=============================================================================== +============================================================================== SETTINGS *go-settings* - *'g:go_test_timeout'* + *'g:go_test_timeout'* Use this option to change the test timeout of |:GoTest|. By default it is set to 10 seconds . > let g:go_test_timeout= '10s' < - - *'g:go_play_browser_command'* + *'g:go_play_browser_command'* Use this option to change the browser that is used to open the snippet url posted to play.golang.org with |:GoPlay| or for the relevant documentation @@ -920,29 +988,48 @@ the current OS. > let g:go_play_browser_command = '' < - *'g:go_play_open_browser'* + *'g:go_play_open_browser'* Use this option to open browser after posting the snippet to play.golang.org with |:GoPlay|. By default it's enabled. > let g:go_play_open_browser = 1 < - *'g:go_auto_type_info'* + *'g:go_auto_type_info'* -Use this option to show the type info (|:GoInfo|) for the word under the cursor -automatically. Whenever the cursor changes the type info will be updated. -By default it's disabled. +Use this option to show the type info (|:GoInfo|) for the word under the +cursor automatically. Whenever the cursor changes the type info will be +updated. By default it's disabled. The delay can be configured with the +'g:go_updatetime' setting. > let g:go_auto_type_info = 0 < - *'g:go_auto_sameids'* + + *'g:go_info_mode'* + +Use this option to define the command to be used for |:GoInfo|. By default +`gocode` is being used as it's the fastest option. But one might also use +`guru` as it's covers more cases and is more accurate. Current valid options +are: `[gocode, guru]` > + + let g:go_info_mode = 'gocode' +< + *'g:go_auto_sameids'* Use this option to highlight all uses of the identifier under the cursor -(:GoSameIds) automatically. By default it's disabled. +(:GoSameIds) automatically. By default it's disabled. The delay can be +configured with the 'g:go_updatetime' setting. > let g:go_auto_sameids = 0 < - *'g:go_jump_to_error'* + *'g:go_updatetime'* + +Use this option to configure the a custom 'updatetime' for Go source files. If +set to 0, no custom time will be configured. By default it's set to 800ms. +> + let g:go_updatetime = 800 +< + *'g:go_jump_to_error'* Use this option to enable/disable passing the bang attribute to the mappings |(go-build)|, |(go-run)|, etc.. When enabled it will jump to the first error @@ -953,36 +1040,34 @@ changing the behaviour of our custom static mappings. By default it's enabled. > let g:go_jump_to_error = 1 < - *'g:go_fmt_autosave'* + *'g:go_fmt_autosave'* Use this option to auto |:GoFmt| on save. By default it's enabled > let g:go_fmt_autosave = 1 < - *'g:go_fmt_command'* + *'g:go_fmt_command'* Use this option to define which tool is used to gofmt. By default `gofmt` is used > let g:go_fmt_command = "gofmt" < - *'g:go_fmt_options'* + *'g:go_fmt_options'* -Use this option to add additional options to the |g:go_fmt_command|. Default +Use this option to add additional options to the |'g:go_fmt_command'|. Default is empty. > let g:go_fmt_options = '' < + *'g:go_fmt_fail_silently'* - *'g:go_fmt_fail_silently'* - -Use this option to disable showing a location list when |g:go_fmt_command| +Use this option to disable showing a location list when |'g:go_fmt_command'| fails. By default the location list is shown. > let g:go_fmt_fail_silently = 0 < - - *'g:go_fmt_experimental'* + *'g:go_fmt_experimental'* Use this option to enable fmt's experimental mode. This experimental mode is superior to the current mode as it fully saves the undo history, so undo/redo @@ -991,15 +1076,15 @@ it's causing problems on some Vim versions. By default it's disabled. > let g:go_fmt_experimental = 0 < - *'g:go_doc_keywordprg_enabled'* + *'g:go_doc_keywordprg_enabled'* -Use this option to run `godoc` on words under the cursor with the default -K , keywordprg shortcut. Usually this shortcut is set to use the program `man`. -In Go, using `godoc` is more idiomatic. Default is enabled. > +Use this option to run `godoc` on words under the cursor with the default K , +keywordprg shortcut. Usually this shortcut is set to use the program `man`. In +Go, using `godoc` is more idiomatic. Default is enabled. > let g:go_doc_keywordprg_enabled = 1 < - *'g:go_def_mode'* + *'g:go_def_mode'* Use this option to define the command to be used for |:GoDef|. By default `guru` is being used as it covers all edge cases. But one might also use @@ -1007,11 +1092,11 @@ Use this option to define the command to be used for |:GoDef|. By default let g:go_def_mode = 'guru' < - *'g:go_def_mapping_enabled'* + *'g:go_def_mapping_enabled'* Use this option to enable/disable the default mapping of CTRL-] and (`gd`) for -GoDef and CTRL-t for :GoDefPop. Disabling it allows you to map something else to -these keys or mappings. Default is enabled. > +GoDef and CTRL-t for :GoDefPop. Disabling it allows you to map something else +to these keys or mappings. Default is enabled. > let g:go_def_mapping_enabled = 1 < @@ -1022,25 +1107,16 @@ mappings of |:GoDef|. By default it's disabled. > let g:go_def_reuse_buffer = 0 < - - *'g:go_dispatch_enabled'* - -Use this option to enable/disable the use of Dispatch to execute the -`:GoRun`, `:GoBuild` and `:GoGenerate` commands. More information about Dispatch -is available at https://github.com/tpope/vim-dispatch. Default is disabled. > - - let g:go_dispatch_enabled = 0 -< - *'g:go_doc_command'* + *'g:go_doc_command'* Use this option to define which tool is used to godoc. By default `godoc` is used > let g:go_doc_command = "godoc" < - *'g:go_doc_options'* + *'g:go_doc_options'* -Use this option to add additional options to the |g:go_doc_command|. Default +Use this option to add additional options to the |'g:go_doc_command'|. Default is empty. > let g:go_doc_options = '' @@ -1048,20 +1124,19 @@ is empty. > < *'g:go_bin_path'* Use this option to change default path for vim-go tools when using -|GoInstallBinaries| and |GoUpdateBinaries|. If not set `$GOBIN` or +|:GoInstallBinaries| and |:GoUpdateBinaries|. If not set `$GOBIN` or `$GOPATH/bin` is used. > let g:go_bin_path = "" < - *'g:go_snippet_engine'* + *'g:go_snippet_engine'* Use this option to define the default snippet engine. By default "ultisnips" is used. Use "neosnippet" for neosnippet.vim: > let g:go_snippet_engine = "ultisnips" < - - *'g:go_snippet_case_type'* + *'g:go_snippet_case_type'* Use this option to define the default conversion type of snippet expansion for field tags. For the following case, if `snakecase` is used the `json` snippet @@ -1078,38 +1153,44 @@ If "camelcase" is used: FooBarQuz string `json:"fooBarQuz" } < -By default "snakecase" is used. Current values are: ["snakecase", "camelcase"]. +By default "snakecase" is used. Current values are: ["snakecase", +"camelcase"]. > let g:go_snippet_case_type = "snakecase" < + *'g:go_get_update'* - *'g:go_get_update'* - -Use this option to disable updating dependencies with |GoInstallBinaries|. By +Use this option to disable updating dependencies with |:GoInstallBinaries|. By default this is enabled. > let g:go_get_update = 1 < - - *'g:go_guru_scope'* + *'g:go_guru_scope'* Use this option to define the scope of the analysis to be passed for guru -related commands, such as |GoImplements|, |GoCallers|, etc.You can change it -on-the-fly with |GoGuruScope|. The input should be a a list of package +related commands, such as |:GoImplements|, |:GoCallers|, etc. You can change +it on-the-fly with |:GoGuruScope|. The input should be a a list of package pattern. An example input might be: -`["github.com/fatih/color","github.com/fatih/structs"]` By default it's not set, -so the relevant commands defaults are being used. +`["github.com/fatih/color","github.com/fatih/structs"]` By default it's not +set, so the relevant commands defaults are being used. > let g:go_guru_scope = [] < + *'g:go_guru_tags'* - *'g:go_highlight_array_whitespace_error'* +These options that will be automatically passed to the `-tags` option of +`go guru` when it's invoked with |:GoDef|. You can use |:GoGuruTags| to set +this. By default it's not set. +> + let g:go_guru_tags = '' +< + + *'g:go_highlight_array_whitespace_error'* Highlights white space after "[]". > let g:go_highlight_array_whitespace_error = 1 < - *'g:go_highlight_chan_whitespace_error'* Highlights white space around the communications operator (`<-`) that doesn't @@ -1117,14 +1198,12 @@ follow the standard style. > let g:go_highlight_chan_whitespace_error = 1 < - *'g:go_highlight_extra_types'* Highlights commonly used library types (io.Reader, etc.). > let g:go_highlight_extra_types = 1 < - *'g:go_highlight_space_tab_error'* Highlights instances of tabs following spaces. > @@ -1136,100 +1215,112 @@ Highlights instances of tabs following spaces. > Highlights trailing white space. > let g:go_highlight_trailing_whitespace_error = 1 - < *'g:go_highlight_operators'* Highlights operators such as `:=` , `==`, `-=`, etc. By default it's disabled. > - let g:go_highlight_operators = 0 + let g:go_highlight_operators = 0 < - *'g:go_highlight_functions'* + *'g:go_highlight_functions'* Highlights function names. By default it's disabled. > - let g:go_highlight_functions = 0 + let g:go_highlight_functions = 0 < - *'g:go_highlight_methods'* + *'g:go_highlight_methods'* Highlights method names. By default it's disabled. > - let g:go_highlight_methods = 0 + let g:go_highlight_methods = 0 < - *'g:go_highlight_types'* + *'g:go_highlight_types'* Highlights struct and interface names. By default it's disabled. > let g:go_highlight_types = 0 < - *'g:go_highlight_fields'* + *'g:go_highlight_fields'* Highlights field names. By default it's disabled. > let g:go_highlight_fields = 0 < - *'g:go_highlight_build_constraints'* + *'g:go_highlight_build_constraints'* Highlights build constraints. By default it's disabled. > - let g:go_highlight_build_constraints = 0 + let g:go_highlight_build_constraints = 0 < - *'g:go_highlight_string_spellcheck* + *'g:go_highlight_generate_tags'* + +Highlights go:generate directives. By default it's disabled. > + + let g:go_highlight_generate_tags = 0 +< + *'g:go_highlight_string_spellcheck'* Use this option to highlight spelling errors in strings when |spell| is also enabled. By default it's enabled. > - let g:go_highlight_string_spellcheck = 1 + let g:go_highlight_string_spellcheck = 1 < - *'g:go_highlight_format_strings* + *'g:go_highlight_format_strings'* Use this option to highlight printf-style operators inside string literals. By default it's enabled. > - let g:go_highlight_format_strings = 1 + let g:go_highlight_format_strings = 1 < - *'g:go_autodetect_gopath'* + *'g:go_autodetect_gopath'* Automatically modifies GOPATH for certain directory structures, such as for the tool `godep` which has his own dependencies via the `Godeps` folder. What this means is that all tools are now working with the newly modified GOPATH. -So |GoDef| for example jumps to the source inside the `Godeps` (vendored) +So |:GoDef| for example jumps to the source inside the `Godeps` (vendored) source. Currently `godep` and `gb` is supported, in the near future more tool supports will be added. By default it's enabled. > - let g:go_autodetect_gopath = 1 + let g:go_autodetect_gopath = 1 < - *'g:go_textobj_enabled'* + *'g:go_textobj_enabled'* Adds custom text objects. By default it's enabled. > - let g:go_textobj_enabled = 1 + let g:go_textobj_enabled = 1 < - *'g:go_metalinter_autosave'* + *'g:go_textobj_include_function_doc'* + +Consider the comment above a function to be part of the function when using +the `af` text object and `[[` motion. By default it's enabled. > + + let g:go_textobj_include_function_doc = 1 +< + *'g:go_metalinter_autosave'* Use this option to auto |:GoMetaLinter| on save. Only linter messages for the active buffer will be shown. By default it's disabled > let g:go_metalinter_autosave = 0 < - *'g:go_metalinter_autosave_enabled'* + *'g:go_metalinter_autosave_enabled'* -Specifies the enabled linters for auto |GoMetaLinter| on save. By +Specifies the enabled linters for auto |:GoMetaLinter| on save. By default it's using `vet` and `golint`. > let g:go_metalinter_autosave_enabled = ['vet', 'golint'] < - *'g:go_metalinter_enabled'* + *'g:go_metalinter_enabled'* -Specifies the currently enabled linters for the |GoMetaLinter| command. By +Specifies the currently enabled linters for the |:GoMetaLinter| command. By default it's using `vet`, `golint` and `errcheck`. > let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck'] < - *'g:go_metalinter_command'* + *'g:go_metalinter_command'* -Overrides the command to be executed when |GoMetaLinter| is called. This is +Overrides the command to be executed when |:GoMetaLinter| is called. This is an advanced settings and is for users who want to have a complete control over how `gometalinter` should be executed. By default it's empty. > @@ -1242,7 +1333,7 @@ seconds. > let g:go_metalinter_deadline = "5s" < - *'g:go_list_height'* + *'g:go_list_height'* Specifies the window height for the quickfix and location list windows. The default value (empty) automatically sets the height to the number of items @@ -1251,7 +1342,7 @@ explicitly overrides this behavior. For standard Vim behavior, set it to 10. > let g:go_list_height = 0 < - *'g:go_list_type'* + *'g:go_list_type'* Specifies the type of list to use. The default value (empty) will use the appropriate kind of list for the command that was called. Supported values are @@ -1259,13 +1350,13 @@ appropriate kind of list for the command that was called. Supported values are let g:go_list_type = "" < - *'g:go_asmfmt_autosave'* + *'g:go_asmfmt_autosave'* -Use this option to auto |:AsmFmt| on save. By default it's enabled. > +Use this option to auto |:AsmFmt| on save. By default it's disabled. > - let g:go_asmfmt_autosave = 1 + let g:go_asmfmt_autosave = 0 < - *g:go_term_mode* + *'g:go_term_mode'* This option is Neovim only. Use it to change the default command used to open a new terminal for go commands such as |:GoRun|. @@ -1273,8 +1364,8 @@ The default is vsplit. > let g:go_term_mode = "vsplit" < - *g:go_term_height* - *g:go_term_width* + *'g:go_term_height'* + *'g:go_term_width'* These options are Neovim only. Use them to control the height and width of a terminal split. By default these are not set, meaning that the height and @@ -1286,118 +1377,182 @@ For example here is how to set each to 30. let g:go_term_height = 30 let g:go_term_width = 30 < - *g:go_term_enabled* + *'g:go_term_enabled'* This option is Neovim only. Use it to change the behavior of the test commands. If set to 1 it opens the test commands inside a new terminal -according to |g:go_term_mode|, otherwise it will run them in the background -just like `:GoBuild` and then display the status with |go#jobcontrol#Statusline()|. -By default it is disabled. +according to |'g:go_term_mode'|, otherwise it will run them in the background +just like `:GoBuild` and then display the status with +|go#jobcontrol#Statusline()|. By default it is disabled. > let g:go_term_enabled = 0 < - *g:go_alternate_mode* + *'g:go_alternate_mode'* Specifies the command that |:GoAlternate| uses to open the alternate file. By default it is set to edit. > let g:go_alternate_mode = "edit" < - *g:go_gorename_prefill* + *'g:go_gorename_prefill'* Specifies whether |:GoRename| prefills the new identifier name with the word under the cursor. By default it is enabled. > let g:go_gorename_prefill = 1 < - *g:go_gocode_autobuild* + *'g:go_gocode_autobuild'* Specifies whether `gocode` should automatically build out-of-date packages -when their source fiels are modified, in order to obtahin the freshes +when their source fields are modified, in order to obtain the freshest autocomplete results for them. By default it is enabled. > let g:go_gocode_autobuild = 1 < - *g:go_gocode_propose_builtins* + *'g:go_gocode_propose_builtins'* Specifies whether `gocode` should add built-in types, functions and constants to an autocompletion proposals. By default it is enabled. > let g:go_gocode_propose_builtins = 1 < - *g:go_template_autocreate* + *'g:go_gocode_unimported_packages'* + +Specifies whether `gocode` should include suggestions from unimported packages. +By default it is disabled. +> + let g:go_gocode_unimported_packages = 0 +< + + *'g:go_gocode_socket_type'* + +Specifies whether `gocode` should use a different socket type. By default +`unix` is enabled. Possible values: `unix`, `tcp` +> + let g:go_gocode_socket_type = 'unix' +< + *'g:go_template_autocreate'* When a new Go file is created, vim-go automatically fills the buffer content with a Go code template. By default the template under `templates/hello_world.go` is used. This can be changed with the -|g:go_template_file| setting. +|'g:go_template_file'| setting. If the new file is created in an already prepopulated package (with other Go files), in this case a Go code template with only the Go package declaration (which is automatically determined according to the current package) is added. +To always use the package name instead of the template, enable the +|`g:go_template_use_pkg`| setting. + By default it is enabled. > let g:go_template_autocreate = 1 < - *g:go_template_file* + *'g:go_template_file'* Specifies the file under the `templates` folder that is used if a new Go file -is created. Checkout |g:go_template_autocreate| for more info. By default the -`hello_world.go` file is used. +is created. Checkout |'g:go_template_autocreate'| for more info. By default +the `hello_world.go` file is used. > let g:go_template_file = "hello_world.go" < -=============================================================================== + *'g:go_template_use_pkg'* + +Specifies that, rather than using a template, the package name is used if a new +Go file is created. Checkout |'g:go_template_autocreate'| for more info. By +default the template file specified by |'g:go_template_file'| is used. + +> + let g:go_template_use_pkg = 0 +< + *'g:go_decls_includes'* + +Only useful if `ctrlp.vim` is installed. This sets which declarations to show +for |:GoDecls|. It is a Comma delimited list Possible options are: +{func,type}. The default is: > + + let g:go_decls_includes = 'func,type' +< + *'g:go_echo_command_info'* + +Echoes information about various Go commands, such as `:GoBuild`, `:GoTest`, +`:GoCoverage`, etc... Useful to disable if you use the statusline integration, +i.e: |go#statusline#Show()|. By default it's enabled +> + let g:go_echo_command_info = 1 +< + *'g:go_echo_go_info'* + +Use this option to show the identifier information when completion is done. By +default it's enabled > + + let g:go_echo_go_info = 1 +< + *'g:go_statusline_duration'* + +Specifices the duration of statusline information being showed per package. By +default it's 60 seconds. Must be in milliseconds. +> + let g:go_statusline_duration = 60000 +< +============================================================================== TROUBLESHOOTING *go-troubleshooting* -I'm using Fish shell but have some problems using vim-go~ +I get "not an editor command" error when I invoke :GoXXX~ -First environment variables in Fish are applied differently, it should be like: +This happens if vim-go is not installed properly. Be sure you have added this +line into your vimrc: > - set -x GOPATH /your/own/gopath + filetype plugin indent on < -Second, Vim needs a POSIX compatible shell (more info here: -https://github.com/dag/vim-fish#teach-a-vim-to-fish). If you use Fish to open -Vim, it will make certain shell based commands fail (means vim-go will fail -too). To overcome this problem change the default shell by adding the -following into your .vimrc (on the top of the file): -> - if $SHELL =~ 'fish' - set shell='/bin/sh' - endif -< -or -> - set shell='/bin/sh' -> -I'm seeing weird errors during installation of binaries with -GoInstallBinaries: +I get a "command not found" error when I invoke :GoXXX~ + +If you try to call |:GoDef|, |:GoInfo| and get a command not found, check that +you have the binaries installed by using |:GoInstallBinaries|. + +Before opening vim, check your current $PATH: +> + echo $PATH +< +After opening vim, run `:echo $PATH`, the output must be your current `$PATH` +plus `$GOPATH/bin` (the location where |:GoInstallBinaries| installed the +binaries). + + +Vim becomes slow while editing Go files~ + +Don't enable these options: +> + let g:go_highlight_types = 0 + let g:go_highlight_operators = 0 +< + +I get errors when using GoInstallBinaries~ If you see errors like this: > - Error installing code.google.com/p/go.tools/cmd/goimports: - Error installing code.google.com/p/rog-go/exp/cmd/godef: + Error installing golang.org/x/tools/cmd/goimports < that means your local Go setup is broken or the remote website is down. For -example sometimes code.google.com times out. To test, just execute a simple go -get: +example sometimes code.google.com times out. To test, just execute a simple +`go get`: -> - go get code.google.com/p/go.tools/cmd/goimports + go get golang.org/x/tools/cmd/goimports < You'll see a more detailed error. If this works, vim-go will work too. -=============================================================================== + +============================================================================== CREDITS *go-credits* -* Go Authors for official vim plugins +* Go Authors for official Vim plugins. * Gocode, Godef, Golint, Guru, Goimports, Errcheck projects and authors of those projects. * Other vim-plugins, thanks for inspiration (vim-golang, go.vim, vim-gocode, - vim-godef) -* vim-go contributors: https://github.com/fatih/vim-go/graphs/contributors + vim-godef). +* vim-go contributors: https://github.com/fatih/vim-go/graphs/contributors. vim:ft=help:et:ts=2:sw=2:sts=2:norl diff --git a/sources_non_forked/vim-go/ftplugin/go.vim b/sources_non_forked/vim-go/ftplugin/go.vim index e4e993aa..de830f9c 100644 --- a/sources_non_forked/vim-go/ftplugin/go.vim +++ b/sources_non_forked/vim-go/ftplugin/go.vim @@ -56,8 +56,76 @@ if get(g:, "go_textobj_enabled", 1) xnoremap [[ :call go#textobj#FunctionJump('v', 'prev') endif -if get(g:, "go_auto_type_info", 0) - setlocal updatetime=800 +if get(g:, "go_auto_type_info", 0) || get(g:, "go_auto_sameids", 0) + let &l:updatetime= get(g:, "go_updatetime", 800) endif +" NOTE(arslan): experimental, disabled by default, doesn't work well. No +" documentation as well. If anyone feels adventerous, enable the following and +" try to search for Go identifiers ;) +" +" if get(g:, "go_sameid_search_enabled", 0) +" autocmd FileType go nnoremap * :call Sameids_search(0) +" autocmd FileType go nnoremap # :call Sameids_search(1) +" autocmd FileType go nnoremap n :call Sameids_repeat(0) +" autocmd FileType go nnoremap N :call Sameids_repeat(1) +" autocmd FileType go cabbrev nohlsearch =Sameids_nohlsearch() +" endif + +" " mode 0: next 1: prev +" function! Sameids_repeat(mode) +" let matches = getmatches() +" if empty(matches) +" return +" endif +" let cur_offset = go#util#OffsetCursor() + +" " reverse list to make it easy to find the prev occurence +" if a:mode +" call reverse(matches) +" endif + +" for m in matches +" if !has_key(m, "group") +" return +" endif + +" if m.group != "goSameId" +" return +" endif + +" let offset = go#util#Offset(m.pos1[0], m.pos1[1]) + +" if a:mode && cur_offset > offset +" call cursor(m.pos1[0], m.pos1[1]) +" return +" elseif !a:mode && cur_offset < offset +" call cursor(m.pos1[0], m.pos1[1]) +" return +" endif +" endfor + +" " reached start/end, jump to the end/start +" let initial_match = matches[0] +" if !has_key(initial_match, "group") +" return +" endif + +" if initial_match.group != "goSameId" +" return +" endif + +" call cursor(initial_match.pos1[0], initial_match.pos1[1]) +" endfunction + +" function! Sameids_search(mode) +" call go#guru#SameIds() +" call Sameids_repeat(a:mode) +" endfunction + +" function! Sameids_nohlsearch() +" call go#guru#ClearSameIds() +" return "nohlsearch" +" endfunction + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/ftplugin/go/commands.vim b/sources_non_forked/vim-go/ftplugin/go/commands.vim index 31e1f044..d8bff665 100644 --- a/sources_non_forked/vim-go/ftplugin/go/commands.vim +++ b/sources_non_forked/vim-go/ftplugin/go/commands.vim @@ -4,6 +4,7 @@ command! -nargs=? GoRename call go#rename#Rename(0,) " -- guru command! -nargs=* -complete=customlist,go#package#Complete GoGuruScope call go#guru#Scope() command! -range=% GoImplements call go#guru#Implements() +command! -range=% GoWhicherrs call go#guru#Whicherrs() command! -range=% GoCallees call go#guru#Callees() command! -range=% GoDescribe call go#guru#Describe() command! -range=% GoCallers call go#guru#Callers() @@ -12,13 +13,20 @@ command! -range=% GoFreevars call go#guru#Freevars() command! -range=% GoChannelPeers call go#guru#ChannelPeers() command! -range=% GoReferrers call go#guru#Referrers() command! -nargs=? GoGuruTags call go#guru#Tags() -command! -range=% GoSameIds call go#guru#SameIds() + + +command! -nargs=* -range GoAddTags call go#util#AddTags(, , ) + +command! -range=0 GoSameIds call go#guru#SameIds() command! -range=0 GoSameIdsClear call go#guru#ClearSameIds() +command! -range=0 GoSameIdsToggle call go#guru#ToggleSameIds() +command! -range=0 GoSameIdsAutoToggle call go#guru#AutoToogleSameIds() " -- tool command! -nargs=0 GoFiles echo go#tool#Files() command! -nargs=0 GoDeps echo go#tool#Deps() -command! -nargs=* GoInfo call go#complete#Info(0) +command! -nargs=* GoInfo call go#tool#Info(0) +command! -nargs=0 GoAutoTypeInfoToggle call go#complete#ToggleAutoTypeInfo() " -- cmd command! -nargs=* -bang GoBuild call go#cmd#Build(0,) @@ -50,8 +58,12 @@ command! -nargs=* -range -complete=customlist,go#package#Complete GoDocBrowser c " -- fmt command! -nargs=0 GoFmt call go#fmt#Format(-1) +command! -nargs=0 GoFmtAutoSaveToggle call go#fmt#ToggleFmtAutoSave() command! -nargs=0 GoImports call go#fmt#Format(1) +" -- asmfmt +command! -nargs=0 GoAsmFmtAutoSaveToggle call go#asmfmt#ToggleAsmFmtAutoSave() + " -- import command! -nargs=? -complete=customlist,go#package#Complete GoDrop call go#import#SwitchImport(0, '', , '') command! -nargs=1 -bang -complete=customlist,go#package#Complete GoImport call go#import#SwitchImport(1, '', , '') @@ -59,6 +71,7 @@ command! -nargs=* -bang -complete=customlist,go#package#Complete GoImportAs call " -- linters command! -nargs=* GoMetaLinter call go#lint#Gometa(0, ) +command! -nargs=0 GoMetaLinterAutoSaveToggle call go#lint#ToggleMetaLinterAutoSave() command! -nargs=* GoLint call go#lint#Golint() command! -nargs=* -bang GoVet call go#lint#Vet(0, ) command! -nargs=* -complete=customlist,go#package#Complete GoErrCheck call go#lint#Errcheck() @@ -75,4 +88,7 @@ endif " -- impl command! -nargs=* -buffer -complete=customlist,go#impl#Complete GoImpl call go#impl#Impl() +" -- template +command! -nargs=0 GoTemplateAutoCreateToggle call go#template#ToggleAutoCreate() + " vim: sw=2 ts=2 et diff --git a/sources_non_forked/vim-go/ftplugin/go/mappings.vim b/sources_non_forked/vim-go/ftplugin/go/mappings.vim index 7bf8dcf3..e1bbe46e 100644 --- a/sources_non_forked/vim-go/ftplugin/go/mappings.vim +++ b/sources_non_forked/vim-go/ftplugin/go/mappings.vim @@ -31,7 +31,7 @@ nnoremap (go-coverage-browser) :call go#coverage#Browser(!g: nnoremap (go-files) :call go#tool#Files() nnoremap (go-deps) :call go#tool#Deps() -nnoremap (go-info) :call go#complete#Info(0) +nnoremap (go-info) :call go#tool#Info(0) nnoremap (go-import) :call go#import#SwitchImport(1, '', expand(''), '') nnoremap (go-imports) :call go#fmt#Format(1) @@ -43,7 +43,9 @@ nnoremap (go-callstack) :call go#guru#Callstack(-1) xnoremap (go-freevars) :call go#guru#Freevars(0) nnoremap (go-channelpeers) :call go#guru#ChannelPeers(-1) nnoremap (go-referrers) :call go#guru#Referrers(-1) -nnoremap (go-sameids) :call go#guru#SameIds(-1) +nnoremap (go-sameids) :call go#guru#SameIds() +nnoremap (go-whicherrs) :call go#guru#Whicherrs(-1) +nnoremap (go-sameids-toggle) :call go#guru#ToggleSameIds() nnoremap (go-rename) :call go#rename#Rename(!g:go_jump_to_error) @@ -63,6 +65,7 @@ nnoremap (go-doc-split) :call go#doc#Open("new", "split") (go-doc-browser) :call go#doc#OpenBrowser() nnoremap (go-metalinter) :call go#lint#Gometa(0) +nnoremap (go-lint) :call go#lint#Golint() nnoremap (go-vet) :call go#lint#Vet(!g:go_jump_to_error) nnoremap (go-alternate-edit) :call go#alternate#Switch(0, "edit") diff --git a/sources_non_forked/vim-go/ftplugin/go/tagbar.vim b/sources_non_forked/vim-go/ftplugin/go/tagbar.vim index e8982aaa..efdc397b 100644 --- a/sources_non_forked/vim-go/ftplugin/go/tagbar.vim +++ b/sources_non_forked/vim-go/ftplugin/go/tagbar.vim @@ -45,7 +45,7 @@ function! s:SetTagbar() \ 'ctype' : 't', \ 'ntype' : 'n' \ }, - \ 'ctagsbin' : expand(bin_path), + \ 'ctagsbin' : bin_path, \ 'ctagsargs' : '-sort -silent' \ } endif diff --git a/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets b/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets index 15d9b76f..fcb82985 100644 --- a/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets +++ b/sources_non_forked/vim-go/gosnippets/UltiSnips/go.snippets @@ -189,6 +189,11 @@ snippet json "\`json:key\`" \`json:"${1:`!v go#util#snippetcase(matchstr(getline("."), '\w\+'))`}"\` endsnippet +# yaml field tag +snippet yaml "\`yaml:key\`" +\`yaml:"${1:`!v go#util#snippetcase(matchstr(getline("."), '\w\+'))`}"\` +endsnippet + # fallthrough snippet ft "fallthrough" fallthrough diff --git a/sources_non_forked/vim-go/gosnippets/snippets/go.snip b/sources_non_forked/vim-go/gosnippets/snippets/go.snip index 413eb1e1..942a82e0 100644 --- a/sources_non_forked/vim-go/gosnippets/snippets/go.snip +++ b/sources_non_forked/vim-go/gosnippets/snippets/go.snip @@ -162,6 +162,11 @@ snippet json abbr \`json:key\` \`json:"${1:keyName}"\` +# yaml snippet +snippet yaml +abbr \`yaml:key\` + \`yaml:"${1:keyName}"\` + # fallthrough snippet ft abbr fallthrough diff --git a/sources_non_forked/vim-go/indent/gohtmltmpl.vim b/sources_non_forked/vim-go/indent/gohtmltmpl.vim index d95cbc24..864913df 100644 --- a/sources_non_forked/vim-go/indent/gohtmltmpl.vim +++ b/sources_non_forked/vim-go/indent/gohtmltmpl.vim @@ -30,13 +30,13 @@ function! GetGoHTMLTmplIndent(lnum) " If need to indent based on last line let last_line = getline(a:lnum-1) - if last_line =~ '^\s*{{\s*\%(if\|else\|range\|with\|define\|block\).*}}' + if last_line =~ '^\s*{{-\=\s*\%(if\|else\|range\|with\|define\|block\).*}}' let ind += sw endif " End of FuncMap block let current_line = getline(a:lnum) - if current_line =~ '^\s*{{\s*\%(else\|end\).*}}' + if current_line =~ '^\s*{{-\=\s*\%(else\|end\).*}}' let ind -= sw endif diff --git a/sources_non_forked/vim-go/plugin/go.vim b/sources_non_forked/vim-go/plugin/go.vim index 3ba16d7e..3e2f6a1e 100644 --- a/sources_non_forked/vim-go/plugin/go.vim +++ b/sources_non_forked/vim-go/plugin/go.vim @@ -27,7 +27,6 @@ command! GoInstallBinaries call s:GoInstallBinaries(-1) command! GoUpdateBinaries call s:GoInstallBinaries(1) command! -nargs=? -complete=dir GoPath call go#path#GoPath() - " GoInstallBinaries downloads and install all necessary binaries stated in the " packages variable. It uses by default $GOBIN or $GOPATH/bin as the binary " target install directory. GoInstallBinaries doesn't install binaries if they @@ -127,6 +126,10 @@ endfunction " ============================================================================ " function! s:echo_go_info() + if !get(g:, "go_echo_go_info", 1) + return + endif + if !exists('v:completed_item') || empty(v:completed_item) return endif @@ -143,44 +146,68 @@ function! s:echo_go_info() redraws! | echo "vim-go: " | echohl Function | echon item.info | echohl None endfunction +function! s:auto_type_info() + " GoInfo automatic update + if get(g:, "go_auto_type_info", 0) + call go#tool#Info(1) + endif +endfunction + +function! s:auto_sameids() + " GoSameId automatic update + if get(g:, "go_auto_sameids", 0) + call go#guru#SameIds() + endif +endfunction + +function! s:fmt_autosave() + " Go code formatting on save + if get(g:, "go_fmt_autosave", 1) + call go#fmt#Format(-1) + endif +endfunction + +function! s:asmfmt_autosave() + " Go asm formatting on save + if get(g:, "go_asmfmt_autosave", 0) + call go#asmfmt#Format() + endif +endfunction + +function! s:metalinter_autosave() + " run gometalinter on save + if get(g:, "go_metalinter_autosave", 0) + call go#lint#Gometa(1) + endif +endfunction + +function! s:template_autocreate() + " create new template from scratch + if get(g:, "go_template_autocreate", 1) + call go#template#create() + endif +endfunction + augroup vim-go autocmd! - " GoInfo automatic update - if get(g:, "go_auto_type_info", 0) - autocmd CursorHold *.go nested call go#complete#Info(1) - endif - - " GoSameId automatic update - if get(g:, "go_auto_sameids", 0) - autocmd CursorMoved *.go nested call go#guru#SameIds(-1) - endif + autocmd CursorHold *.go call s:auto_type_info() + autocmd CursorHold *.go call s:auto_sameids() " Echo the identifier information when completion is done. Useful to see " the signature of a function, etc... if exists('##CompleteDone') - autocmd CompleteDone *.go nested call s:echo_go_info() + autocmd CompleteDone *.go call s:echo_go_info() endif - " Go code formatting on save - if get(g:, "go_fmt_autosave", 1) - autocmd BufWritePre *.go call go#fmt#Format(-1) - endif - - " Go asm formatting on save - if get(g:, "go_asmfmt_autosave", 1) - autocmd BufWritePre *.s call go#asmfmt#Format() - endif - - " run gometalinter on save - if get(g:, "go_metalinter_autosave", 0) - autocmd BufWritePost *.go call go#lint#Gometa(1) - endif - - " create new template from scratch - if get(g:, "go_template_autocreate", 1) - autocmd BufNewFile *.go call go#template#create() - endif + autocmd BufWritePre *.go call s:fmt_autosave() + 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 diff --git a/sources_non_forked/vim-go/syntax/go.vim b/sources_non_forked/vim-go/syntax/go.vim index 0ead7527..9b23eb6c 100644 --- a/sources_non_forked/vim-go/syntax/go.vim +++ b/sources_non_forked/vim-go/syntax/go.vim @@ -125,12 +125,14 @@ hi def link goComplexes Type " Predefined functions and values -syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/ -syn match goBuiltins /\<\v(make|new|panic|print|println|real|recover)\ze\(/ -syn keyword goBoolean iota true false nil +syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/ +syn match goBuiltins /\<\v(make|new|panic|print|println|real|recover)\ze\(/ +syn keyword goBoolean true false +syn keyword goPredefinedIdentifiers nil iota -hi def link goBuiltins Keyword -hi def link goBoolean Boolean +hi def link goBuiltins Keyword +hi def link goBoolean Boolean +hi def link goPredefinedIdentifiers goBoolean " Comments; their contents syn keyword goTodo contained TODO FIXME XXX BUG @@ -175,7 +177,7 @@ else endif if g:go_highlight_format_strings != 0 - syn match goFormatSpecifier /%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString + syn match goFormatSpecifier /\([^%]\(%%\)*\)\@<=%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString hi def link goFormatSpecifier goSpecialString endif @@ -271,6 +273,7 @@ hi def link goSpaceError Error syn keyword goTodo contained NOTE hi def link goTodo Todo +syn match goVarArgs /\.\.\./ " Operators; if g:go_highlight_operators != 0 @@ -285,9 +288,9 @@ if g:go_highlight_operators != 0 " match remaining two-char operators: := && || <- ++ -- syn match goOperator /:=\|||\|<-\|++\|--/ " match ... - syn match goOperator /\.\.\./ - hi def link goPointerOperator Operator + hi def link goPointerOperator goOperator + hi def link goVarArgs goOperator endif hi def link goOperator Operator @@ -299,21 +302,22 @@ 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\+(/hs=s+1,he=e-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 - syn match goVarArgs /\.\.\.\w\+\>/ - syn match goField /\.\a\+\([\ \n\r\:\)\[]\)\@=/hs=s+1 + syn match goField /\.\w\+\([.\ \n\r\:\)\[,]\)\@=/hs=s+1 endif hi def link goField Identifier @@ -322,7 +326,7 @@ if g:go_highlight_types != 0 syn match goTypeConstructor /\<\w\+{/he=e-1 syn match goTypeDecl /\/ nextgroup=goTypeName skipwhite skipnl syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl - syn match goDeclType /\/ contained skipwhite skipnl + syn match goDeclType /\/ skipwhite skipnl hi def link goReceiverType Type else syn keyword goDeclType struct interface @@ -366,7 +370,22 @@ if g:go_highlight_build_constraints != 0 hi def link goPackageComment Comment endif -hi def link goSameId IncSearch +" :GoCoverage commands +hi def link goCoverageNormalText Comment + +function! s:hi() + hi def link goSameId Search + + " :GoCoverage commands + hi def goCoverageCovered ctermfg=green guifg=#A6E22E + hi def goCoverageUncover ctermfg=red guifg=#F92672 +endfunction + +augroup vim-go-hi + autocmd! + autocmd ColorScheme * call s:hi() +augroup end +call s:hi() " Search backwards for a global declaration to start processing the syntax. "syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/ diff --git a/sources_non_forked/vim-pug/syntax/pug.vim b/sources_non_forked/vim-pug/syntax/pug.vim index ee712dbb..09e6b9b9 100644 --- a/sources_non_forked/vim-pug/syntax/pug.vim +++ b/sources_non_forked/vim-pug/syntax/pug.vim @@ -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="" +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="" 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 diff --git a/sources_non_forked/vim-snipmate/autoload/snipMate.vim b/sources_non_forked/vim-snipmate/autoload/snipMate.vim index 74366fa8..e3b4ca6d 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipMate.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipMate.vim @@ -28,13 +28,9 @@ function! snipMate#expandSnip(snip, version, col) abort let [snippet, b:snip_state.stops] = snipmate#parse#snippet(a:snip) " Build stop/mirror info let b:snip_state.stop_count = s:build_stops(snippet, b:snip_state.stops, lnum, col, indent) - let snipLines = map(copy(snippet), - \ 'snipMate#sniplist_str(v:val, b:snip_state.stops)') else let snippet = snipmate#legacy#process_snippet(a:snip) let [b:snip_state.stops, b:snip_state.stop_count] = snipmate#legacy#build_stops(snippet, lnum, col - indent, indent) - let snipLines = split(substitute(snippet, printf('%s\d\+\|%s{\d\+.\{-}}', - \ g:snipmate#legacy#sigil, g:snipmate#legacy#sigil), '', 'g'), "\n", 1) endif " Abort if the snippet is empty @@ -42,23 +38,7 @@ function! snipMate#expandSnip(snip, version, col) abort return '' endif - " Expand snippet onto current position - let afterCursor = strpart(line, col - 1) - " Keep text after the cursor - if afterCursor != "\t" && afterCursor != ' ' - let line = strpart(line, 0, col - 1) - let snipLines[-1] .= afterCursor - else - let afterCursor = '' - " For some reason the cursor needs to move one right after this - if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore' - let col += 1 - endif - endif - - " Insert snippet with proper indentation - call setline(lnum, line . snipLines[0]) - call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val")) + let col = s:insert_snippet_text(snippet, lnum, col, indent) " Open any folds snippet expands into if &foldenable @@ -77,6 +57,50 @@ function! snipMate#expandSnip(snip, version, col) abort return b:snip_state.set_stop(0) endfunction +function! s:insert_snippet_text(snippet, lnum, col, indent) + let line = getline(a:lnum) + let col = a:col + let snippet = type(a:snippet) == type([]) ? a:snippet : split(a:snippet, "\n", 1) + let lnum = a:lnum + + " Keep text after the cursor + let afterCursor = strpart(line, col - 1) + if afterCursor != "\t" && afterCursor != ' ' + let line = strpart(line, 0, col - 1) + else + let afterCursor = '' + " For some reason the cursor needs to move one right after this + if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore' + let col += 1 + endif + endif + + call setline(lnum, '') + call append(lnum, repeat([''], len(snippet) - 1)) + + for item in snippet + let add = lnum == a:lnum ? line : strpart(line, 0, a:indent - 1) + + if !(empty(item) || (type(item) == type([]) && empty(item[0]))) + if type(item) == type([]) + call setline(lnum, add . + \ snipMate#sniplist_str(item, b:snip_state.stops)) + else + call setline(lnum, add . + \ substitute(item, printf('%s\d\+\|%s{\d\+.\{-}}', + \ g:snipmate#legacy#sigil, g:snipmate#legacy#sigil), + \ '', 'g')) + endif + endif + + let lnum += 1 + endfor + + call setline(lnum - 1, getline(lnum - 1) . afterCursor) + + return col +endfunction + function! snipMate#placeholder_str(num, stops) abort return snipMate#sniplist_str(a:stops[a:num].placeholder, a:stops) endfunction @@ -488,8 +512,18 @@ fun! snipMate#WordBelowCursor() abort endf fun! snipMate#GetSnippetsForWordBelowCursorForComplete(word) abort - let snippets = map(snipMate#GetSnippetsForWordBelowCursor(a:word, 0), 'v:val[0]') - return filter(snippets, 'v:val =~# "\\V\\^' . escape(a:word, '"\') . '"') + let matches = snipMate#GetSnippetsForWordBelowCursor(a:word, 0) + let snippets = [] + for [trigger, dict] in matches + if get(g:snipMate, 'description_in_completion', 0) + call extend(snippets, map(keys(dict), + \ '{ "word" : trigger, "menu" : v:val, "dup" : 1 }')) + else + call add(snippets, { "word" : trigger }) + endif + endfor + return filter(snippets, + \ 'v:val.word =~# "\\V\\^' . escape(a:word, '"\') . '"') endf fun! snipMate#CanBeTriggered() abort diff --git a/sources_non_forked/vim-snipmate/doc/snipMate.txt b/sources_non_forked/vim-snipmate/doc/snipMate.txt index 230fe686..c97205a6 100644 --- a/sources_non_forked/vim-snipmate/doc/snipMate.txt +++ b/sources_non_forked/vim-snipmate/doc/snipMate.txt @@ -160,6 +160,12 @@ g:snipMate.override maps and other settings work. Note: Load order is determined by 'runtimepath'. +g:snipMate.description_in_completion + If set to 1 (default is 0), snippet + descriptions will be included in the popup + menu used for snippet completion, like with + snipMateShow. + g:snipMate['no_match_completion_feedkeys_chars'] A string inserted when no match for a trigger is found. By default a tab is inserted diff --git a/sources_non_forked/vim-snippets/AUTHORS b/sources_non_forked/vim-snippets/AUTHORS new file mode 100644 index 00000000..907daef1 --- /dev/null +++ b/sources_non_forked/vim-snippets/AUTHORS @@ -0,0 +1,383 @@ +Authors +=============================================================================== + +Generated with "git log --oneline --pretty="%an" | sort | uniq > AUTHORS + +Aaron Broder +Adnan Zafar +afolmert +aisensiy +Alexander Ross +Alexandre de Oliveira +Alexey Shevchenko +Alex Tan +Allen.M +Alvin Chan +ALX-Liu-Xiao +Andrea Giardini +Andreas Krennmair +Andreas Steinel +Andrei Cristian Petcu +Andrej Radovic +Andre Walker +Andrey Paskal +Andy Waite +Angel Alonso +Ángel Alonso +Anne Douwe Bouma +Anthony Wilson +Arvind +ashfinal +Audrius Kažukauskas +Austin Wood +Aydar Khabibullin +babybeasimple +Benjamin Nørgaard +Bernhard Graf +Bill Casarin +binaryplease +Björn +Björn-Egil Dahlberg +BlackEagle +Boone Severson +bounceme +Bradlee Speice +Brandon Dulaney +Brandon Hilkert +Brian Hogan +Brian van Burken +Bruno Sutic +Camilo Payan +carme +Cézar Antáres +Chad Paradis +Chen Zhongzheng +Ches Martin +ChickenNuggers +Chipairon +Chris Dueck +Chris Nicola +Chris Sims +Christian +Christian Höltje +Christian Neumüller +Christopher Joslyn +chrisyue +Ciro Santilli +Ciro Santilli 六四事件 法轮功 +Claudio Maradonna +Connor Atherton +Cooper LeBrun +Corentin Peuvrel +Craig Paterson +Craig P Jolicoeur +crazymaster +daa84 +Daeyun Shin +Dale Roberts +Daniel Hahler +Dan Loewenherz +Danny Navarro +daoo +Darrell Hamilton +David Arvelo +David Barnett +David C. Bishop +David Deryl Downey - AKA Deryl R. Doucette +David Rodríguez de Dios +David Sanson +dengyaolong +Derek Morey +dhilipsiva +djdt +Dmitry Dementev +Donny Yang +DSIW +dzikie drożdże +Eduardo Gurgel +Eli Gundry +emzap79 +Enric Lluelles +Enrico Maria De Angelis +Erich Heine +Erik Westrup +Ernest +Eugene Kalinin +Eustaquio Rangel +Eustáquio Rangel +Fatih Arslan +Felix Jung +Filipe Giusti +Florent Lévigne +Florian Sattler +frans +Fuad Saud +Gabriel Chavez +Gaël Chamoulaud +Gea-Suan Lin +George Guimarães +George Lee +Georgios Samaras +Gert +gfixler +Gilad Peleg +gk +goonnow +Gueunet Charles +Gui Lin +guneysus +Gustavo Chain +Gustavo Ferreira +Hans-Guenter +Harald Wartig +Henrik Kjelsberg +HIRAKI Satoru +Holger Rapp +Honza +Honza Pokorny +hulufei +Igor Goldvekht +Ilker Cetinkaya +indi +Indra Susila +Ionică Bizău +Iuri Fernandes +Jack Stalnaker +Jacobo de Vera +Jacques Kvam +jake romer +Jakub Stasiak +James Turley +Jan Mollowitz +Jason S. Jones +Jean Jordaan +Jeffrey Tratner +Jens Hoepken +jiangyc0 +Jim Deville +Jinzhu +Joey Curtin +Johannes Wienke +jonasac +Jonas Bygdén +Jonathan Martin +Jorge García +Jorge López Pérez +Joseph Lin +Josh Bode +Josh Davis +Josh Matthews +Josh Vandergrift +Josh Wainwright +JuanPablo +Julian Bennecker +Julien Deniau +Julien Pivard +Julien Stechele +Julien STECHELE +Kalinin Eugene +kenshin54 +Kentaro Imai +Kevin Koltz +Kevin Lui +Kevin Mees +Kevin Murray +Kevin Schaul +Konstantin +Konstantin Gorodinskiy +Laas Toom +Laurent Georget +laxtiz +Leandro Moreira +Leonardo B +Leonidez Acosta +linduxed +Li Xin +Louis +Louis Pilfold +Lucas Hoffmann +Luis Carlos Cruz +Luis Carlos Cruz Carballo +Luiz Gonzaga dos Santos Filho +majjoha +mangege +Marc Camuzat +Marcelo D Montu +Marcelo Jacobus +Marcin Kulik +Marcus Kammer +Marc Weber +Mario de Frutos +Markus Benning +marocchino +Martin Atukunda +Martin Heuschober +Martxel Lasa +Matěj Cepl +Mathew Attlee +Mathieu Comandon +Matthew Barry +Matthias Viehweger +Mattia Tezzele +Matt Rasband +Matt Stevens +Mauro Porras P +Maximiliano Robaina +Mayeu (Cast) +Meng Zhuo +Michael Gehring +Michael Hinrichs +Michael Rutter +Michael Thessel +Michi Huber +Mickey +midchildan +Mike Foley +Mike Smullin +Miki Tebeka +Minjong Chung +M. Maxwell Watson +mMontu +mockturtl +m-pilia +Muhammad Hallaj Subery +mwcz +Namit +Nan Cloudio Jiang +Nan Zheng +Nate Mara +netei +Ngo The Trung +Nguyen Le +Nick Janetakis +Nicklasos +Nick Papanastasiou +Nicolas G. Querol +Nico Suhl +No Ducks +Norman Messtorff +obaoba +oddlydrawn +Oleg Voronkovich +Ole Hansen +Oliver Andrich +Ondrej Slinták +onemanstartup +opennota +Paco Esteban +Panagiotis Mavrogiorgos +Paolo Cretaro +Pascal +Paulo Romeira +Pawel Jankowski +phcerdan +Philippe Mongeau +Philipp Jovanovic +Piotr Jawniak +Piotr Yordanov +Pirogov Evgenij +Pompeu +Povilas Balzaravicius Pawka +Procras +protream +pydave +r4d2 +Radosław Szymczyszyn +Ralph-Wang +Raül Torralba +raydeal +rcolombo +Rekky +René +Rene Vergara +Renzo Poddighe +Reyes Yang +ricardogcolombo +Ricardo Jesus +Rich Layte +Roberto Miranda +robin +Robin Grindrod +Rok Garbas +Roland Sommer +Rory McNamara +rsw0x +rtorralba +Ruben Vereecken +Ryan Bright +Ryan Pineo +Ryan Wang +Sam Shepherd +Santiago Gallego +sasidhar-d +Sathors +Sebastian Röder +Sebastian Wiesner +Sergey Lebedev +Sergey Zasenko +Serhiy Oplakanets +SevereOverfl0w +Simeon F. Willbanks +Simeon Willbanks +Simon Désaulniers +sirex +skv +Sokovikov +Srijan Choudhary +Steeve +stefan +Stephen Tudor +Stephen Woods +Steve Brown +Steven Humphrey +Steven Oliver +Stuart Grimshaw +Sudar +¨switch87¨ +Tevin Zhang +theocrite +Thiago de Arruda +Thomas Duerr +Thomas Szymanski +tinyladi +Tobias Witt +Tobie Warburton +Tomasz Wisniewski +Tom Vincent +Tony +Tony Narlock +toogley +Torbjørn Vatn +tormaroe +ToruIwashita +Travis Holton +Trevor Sullivan +troydm +tUrG0n +twabiko +Tyler Ball +tyronepost +Tyrone Post +Vadim Khohlov +Vincent Hsu +Vladimir Rybas +Vladislav Khvostov +Vorzard +Vzaa +Waldecir Santos +Wildsky Fann +William Ma +William Travis Holton +X4fyr +xz.zhang +Yamamoto Yuji +Yannick Brehon +yerv000 +Yike Lu +yuhuanbo +Yu Huanbo +Yves Lange +yvhn +zauguin +Zaven Muradyan +ZPH diff --git a/sources_non_forked/vim-snippets/UltiSnips/ada.snippets b/sources_non_forked/vim-snippets/UltiSnips/ada.snippets index cc35c2c2..bea2a6cd 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/ada.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/ada.snippets @@ -5,7 +5,9 @@ global !p def ada_case(word): out = word[0].upper() for i in range(1, len(word)): - if word[i - 1] == '_': + if word[i] == '-': + out = out + '.' + elif word[i - 1] == '_' or word[i - 1] == '-': out = out + word[i].upper() else: out = out + word[i] diff --git a/sources_non_forked/vim-snippets/UltiSnips/all.snippets b/sources_non_forked/vim-snippets/UltiSnips/all.snippets index 0e286e5a..215487ec 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/all.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/all.snippets @@ -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]` @@ -73,4 +73,27 @@ snippet modeline "Vim modeline" vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'` endsnippet +######### +# DATES # +######### +snippet date "YYYY-MM-DD" w +`date +%Y-%m-%d` +endsnippet + +snippet ddate "Month DD, YYYY" w +`date +%B\ %d,\ %Y` +endsnippet + +snippet diso "ISO format datetime" w +`date +%Y-%m-%dT%H:%M:%S%:z` +endsnippet + +snippet time "hh:mm" w +`date +%H:%M` +endsnippet + +snippet datetime "YYYY-MM-DD hh:mm" w +`date +%Y-%m-%d\ %H:%M` +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/cuda.snippets b/sources_non_forked/vim-snippets/UltiSnips/cuda.snippets new file mode 100644 index 00000000..2a9a7e5e --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/cuda.snippets @@ -0,0 +1,5 @@ +priority -50 + +extends cpp + +# vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/html.snippets b/sources_non_forked/vim-snippets/UltiSnips/html.snippets index fd1aca51..026985cb 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/html.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/html.snippets @@ -127,7 +127,6 @@ endsnippet ############# snippet input "Input with Label" w - endsnippet snippet input "XHTML " w @@ -141,9 +140,7 @@ endsnippet snippet select "Select Box" w endsnippet @@ -162,25 +159,25 @@ endsnippet snippet body "" - $0 + ${0:${VISUAL}} endsnippet snippet div "
" w
- $0 + ${0:${VISUAL}}
endsnippet snippet div. "
with class" w - $0 + ${0:${VISUAL}}
endsnippet snippet div# "
with ID & class" w - $0 + ${0:${VISUAL}}
endsnippet @@ -188,33 +185,39 @@ snippet form "XHTML
" w - $0 - -

+ ${0:${VISUAL}}
endsnippet snippet h1 "XHTML

" w -

$0

+

${0:${VISUAL}}

endsnippet snippet h2 "XHTML

" w -

$0

+

${0:${VISUAL}}

endsnippet snippet h3 "XHTML

" w -

$0

+

${0:${VISUAL}}

endsnippet snippet h4 "XHTML

" w -

$0

+

${0:${VISUAL}}

+endsnippet + +snippet h5 "XHTML
" w +
${0:${VISUAL}}
+endsnippet + +snippet h6 "XHTML
" w +
${0:${VISUAL}}
endsnippet snippet head "XHTML " ${1:`!p snip.rv = snip.basename or "Page Title"`} - $0 + ${0:${VISUAL}} endsnippet @@ -232,20 +235,31 @@ endsnippet snippet script "XHTML endsnippet +snippet span "" w + ${0:${VISUAL}} +endsnippet + +snippet span. " with class" w + ${0:${VISUAL}} +endsnippet + +snippet span# " with ID & class" w + ${0:${VISUAL}} +endsnippet + snippet style "XHTML endsnippet snippet table "XHTML " w -
- - +
${5:Header}
${0:Data}
+ ${0:${VISUAL}}
endsnippet @@ -254,29 +268,29 @@ snippet a "Link" w endsnippet snippet p "paragraph" w -

$0

+

${0:${VISUAL}}

endsnippet snippet li "list item" w -
  • $0
  • +
  • ${0:${VISUAL}}
  • endsnippet snippet ul "unordered list" w
      -$0 + ${0:${VISUAL}}
    endsnippet snippet td "table cell" w -$0 +${0:${VISUAL}} endsnippet snippet th "table header" w -$0 +${0:${VISUAL}} endsnippet snippet tr "table row" w -$0 +${0:${VISUAL}} endsnippet snippet title "XHTML " w @@ -286,7 +300,7 @@ endsnippet snippet fieldset "Fieldset" w <fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}> <legend>$1</legend> - $0 + ${0:${VISUAL}} </fieldset> endsnippet @@ -303,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: diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets index 4537baea..8821c5ca 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets @@ -46,7 +46,7 @@ for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) { } endsnippet -snippet fun "function (fun)" +snippet fun "function (fun)" w function ${1:function_name}(${2:argument}) { ${VISUAL}$0 } @@ -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: diff --git a/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets b/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets index 7367a147..de244736 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php-laravel.snippets @@ -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); } } diff --git a/sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets b/sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets index 2b127ee9..9bca168c 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php-symfony2.snippets @@ -61,7 +61,7 @@ snippet sfa "Symfony 2 Controller action" public function $1Action($2) { $3 - return ${4:array();}$0 + return ${4:[];}$0 } endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/python.snippets b/sources_non_forked/vim-snippets/UltiSnips/python.snippets index fa3ff8b9..5d8e2641 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/python.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/python.snippets @@ -486,6 +486,11 @@ def __coerce__(self, other): ${25:pass} endsnippet +snippet deff +def ${1:fname}(`!p snip.rv = vim.eval('indent(".") ? "self" : ""')`$2): + $0 +endsnippet + snippet def "function with docstrings" b def ${1:function}(`!p if snip.indent: diff --git a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets index 4c7e44b4..f43de5ee 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets @@ -10,7 +10,7 @@ endsnippet snippet tab "tabular / array environment" b \begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} -$0${2/((?<=.)c|l|r)|./(?1: & )/g} +$0${2/(?<=.)(c|l|r)|./(?1: & )/g} \end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} endsnippet @@ -20,7 +20,7 @@ snippet table "Table environment" b \caption{${2:caption}} \label{tab:${3:label}} \begin{${4:t}${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${5:c}} - $0${5/((?<=.)c|l|r)|./(?1: & )/g} + $0${5/(?<=.)(c|l|r)|./(?1: & )/g} \end{$4${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} \end{table} endsnippet diff --git a/sources_non_forked/vim-snippets/pythonx/vimsnippets.py b/sources_non_forked/vim-snippets/pythonx/vimsnippets.py index 6a446a2a..d1cee17b 100644 --- a/sources_non_forked/vim-snippets/pythonx/vimsnippets.py +++ b/sources_non_forked/vim-snippets/pythonx/vimsnippets.py @@ -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"] diff --git a/sources_non_forked/vim-snippets/snippets/_.snippets b/sources_non_forked/vim-snippets/snippets/_.snippets index 0153a146..ad0235f1 100644 --- a/sources_non_forked/vim-snippets/snippets/_.snippets +++ b/sources_non_forked/vim-snippets/snippets/_.snippets @@ -279,3 +279,11 @@ snippet AGPL You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. +snippet ISC + ${1:one line to give the program's name and a brief description} + Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")`, ${2:`g:snips_author`} + + Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ${0} diff --git a/sources_non_forked/vim-snippets/snippets/arduino.snippets b/sources_non_forked/vim-snippets/snippets/arduino.snippets index 77ee46fa..6f7f4137 100644 --- a/sources_non_forked/vim-snippets/snippets/arduino.snippets +++ b/sources_non_forked/vim-snippets/snippets/arduino.snippets @@ -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(); diff --git a/sources_non_forked/vim-snippets/snippets/c.snippets b/sources_non_forked/vim-snippets/snippets/c.snippets index f4745c25..524b5b86 100644 --- a/sources_non_forked/vim-snippets/snippets/c.snippets +++ b/sources_non_forked/vim-snippets/snippets/c.snippets @@ -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; diff --git a/sources_non_forked/vim-snippets/snippets/cpp.snippets b/sources_non_forked/vim-snippets/snippets/cpp.snippets index d06b3c90..42c37341 100644 --- a/sources_non_forked/vim-snippets/snippets/cpp.snippets +++ b/sources_non_forked/vim-snippets/snippets/cpp.snippets @@ -3,7 +3,7 @@ extends c ## ## Preprocessor # #include <...> -snippet inc +snippet incc #include <${1:iostream}> snippet binc #include <boost/${1:shared_ptr}.hpp> diff --git a/sources_non_forked/vim-snippets/snippets/cuda.snippets b/sources_non_forked/vim-snippets/snippets/cuda.snippets new file mode 100644 index 00000000..425ca67f --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/cuda.snippets @@ -0,0 +1 @@ +extends cpp diff --git a/sources_non_forked/vim-snippets/snippets/elixir.snippets b/sources_non_forked/vim-snippets/snippets/elixir.snippets index 851dc8be..058f986c 100644 --- a/sources_non_forked/vim-snippets/snippets/elixir.snippets +++ b/sources_non_forked/vim-snippets/snippets/elixir.snippets @@ -48,6 +48,21 @@ snippet fori for ${1:item} <- ${2:items}, into: ${3} do ${0} end +snippet wi + with( + ${1:item} <- ${2:items} + ) do + ${0} + end +snippet wie + with( + ${1:item} <- ${2:items} + ) do + ${3} + else + ${4} -> + ${0} + end snippet df def ${1:name}, do: ${2} snippet def @@ -73,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} @@ -85,6 +102,8 @@ snippet doc @doc """ ${0} """ +snippet docf + @doc false snippet fn fn ${1:args} -> ${0} end snippet mdoc @@ -105,13 +124,17 @@ snippet imp snippet ali alias ${0:module_name} snippet test - test "${1:test_name}" do + test "${1:test name}" do ${0} end snippet testa test "${1:test_name}", %{${2:arg: arg}} do ${0} end +snippet des + describe "${1:test group subject}" do + ${0} + end snippet exunit defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do use ExUnit.Case, async: true diff --git a/sources_non_forked/vim-snippets/snippets/eruby.snippets b/sources_non_forked/vim-snippets/snippets/eruby.snippets index adad8cb0..64f79ef3 100644 --- a/sources_non_forked/vim-snippets/snippets/eruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/eruby.snippets @@ -1,6 +1,7 @@ # .erb and .rhmtl files # Includes html.snippets +extends html # Rails ***************************** snippet rc diff --git a/sources_non_forked/vim-snippets/snippets/fortran.snippets b/sources_non_forked/vim-snippets/snippets/fortran.snippets index c9ab0602..8fecd330 100644 --- a/sources_non_forked/vim-snippets/snippets/fortran.snippets +++ b/sources_non_forked/vim-snippets/snippets/fortran.snippets @@ -26,6 +26,11 @@ snippet doc ! Description: $1 ! """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" $0 +snippet dox + !> @brief ${1} + !> ${2} + !> @author `g:snips_author` + ${0} # Variables definitions # Boolean snippet bool @@ -49,7 +54,7 @@ snippet type snippet const ${1:type}, parameter :: $2 = $0 snippet arr - ${1:type}, allocatable, dimension(${2::}) :: $0 + ${1:type}, ${2:allocatable, }dimension(${3::}) :: $0 snippet intent ${1:type}, intent(inout) :: $0 # Array @@ -57,7 +62,7 @@ snippet / (/ $1 /) ${2:,&} $0 snippet if if (${1:condition}) then - $2 + $0 end if snippet case select case (${1:expr}) @@ -66,8 +71,8 @@ snippet case $3 end select $0 snippet do - do ${1:i} = ${2:start},${3:end}, ${4:incr} - $4 + do ${1:i} = ${2:start}, ${3:end}, ${4:incr} + $0 end do snippet dow do while (${1:condition}) @@ -84,10 +89,10 @@ snippet func snippet pr write(*,*) $0 snippet read - read( unit = ${1:fp}, file = ${2:filename}${3:, iostat = IERR }) $0 + read(unit = ${1:fp}, file = ${2:filename}, iostat = ${3:ierr}) $0 snippet write - write( unit = ${1:fp}, file = ${2:filename}${3:, iostat = IERR }) $0 + write(unit = ${1:fp}, file = ${2:filename}, iostat = ${3:ierr}) $0 snippet open - open (unit = ${1:fp}, file = ${2:filename}, status = unknown${3:, iostat = IERR }) $0 + open(unit = ${1:fp}, file = ${2:filename}, status = ${3:unknown}, iostat = ${4:ierr}) $0 snippet close - close ( unit = ${1:fp} ) $0 + close(unit = ${1:fp}) $0 diff --git a/sources_non_forked/vim-snippets/snippets/go.snippets b/sources_non_forked/vim-snippets/snippets/go.snippets index b3acac1a..b2bdc9e0 100644 --- a/sources_non_forked/vim-snippets/snippets/go.snippets +++ b/sources_non_forked/vim-snippets/snippets/go.snippets @@ -171,6 +171,9 @@ snippet pn # print snippet pr fmt.Printf("%${1:s}\n", ${2:var}) +# println +snippet pl + fmt.Println("${1:s}") # range snippet rn range ${0} diff --git a/sources_non_forked/vim-snippets/snippets/handlebars.snippets b/sources_non_forked/vim-snippets/snippets/handlebars.snippets new file mode 100644 index 00000000..d1ab0f03 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/handlebars.snippets @@ -0,0 +1,14 @@ +snippet if # {{#if value}} ... {{/if}} + {{#if ${1:value}}} + ${0} + {{/if}} +snippet ifn # {{#unless value}} ... {{/unless}} + {{#unless ${1:value}}} + ${0} + {{/unless}} +snippet ife # {{#if value}} ... {{else}} .. {{/if}} + {{#if ${1:value}}} + ${2} + {{else}} + ${3} + {{/if}} diff --git a/sources_non_forked/vim-snippets/snippets/html.snippets b/sources_non_forked/vim-snippets/snippets/html.snippets index 5ae8e749..85d0e526 100644 --- a/sources_non_forked/vim-snippets/snippets/html.snippets +++ b/sources_non_forked/vim-snippets/snippets/html.snippets @@ -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"> diff --git a/sources_non_forked/vim-snippets/snippets/java.snippets b/sources_non_forked/vim-snippets/snippets/java.snippets index e40bbf52..39cc850a 100644 --- a/sources_non_forked/vim-snippets/snippets/java.snippets +++ b/sources_non_forked/vim-snippets/snippets/java.snippets @@ -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 diff --git a/sources_non_forked/vim-snippets/snippets/javascript-bemjson.snippets b/sources_non_forked/vim-snippets/snippets/javascript-bemjson.snippets new file mode 100644 index 00000000..7899c22d --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/javascript-bemjson.snippets @@ -0,0 +1,52 @@ +# Snippet for bemjson. https://en.bem.info/platform/bemjson/ + +# Blocks +snippet b + { + block : '${1:name}', + content : [ + '${2:content}' + ] + } + +# btc - BEM block with text content +snippet btc + { + block : '${1:name}', + content: '${2:content}' + } + +# bwm - BEM block with modifier. +snippet bwm + { + block : '${1:name}', + mods: { ${2:modName}: '${3:modVal}' }, + content : [ + '${4:content}' + ] + } + +# Elems + +# e - BEM elem +snippet e + { + elem : '${1:name}', + content : [ + '${2:content}' + ] + } + + +# mo - Mods +snippet mo + mods : { ${1:modName} : '${2:modVal}' }, + +# mi - BEM mix mod +snippet mi + mix : [ { ${1:block} : '${2:block}' } ], + +# a - BEM attrs mod +snippet a + attrs : { ${1:attr} : '${2:val}' }, + diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.d3.snippets b/sources_non_forked/vim-snippets/snippets/javascript-d3.snippets similarity index 100% rename from sources_non_forked/vim-snippets/snippets/javascript/javascript.d3.snippets rename to sources_non_forked/vim-snippets/snippets/javascript-d3.snippets diff --git a/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets b/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets index f08bf849..cabfd401 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript-mocha.snippets @@ -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 diff --git a/sources_non_forked/vim-snippets/snippets/javascript.es6.react.snippets b/sources_non_forked/vim-snippets/snippets/javascript.es6.react.snippets new file mode 100644 index 00000000..0762eb6b --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/javascript.es6.react.snippets @@ -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} diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets new file mode 100644 index 00000000..9deae796 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets @@ -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} diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets index df059a15..a1adedef 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.es6.snippets @@ -2,8 +2,12 @@ snippet const const ${1} = ${0}; snippet let let ${1} = ${0}; -snippet im - import ${1} from '${0}'; +snippet im "import xyz from 'xyz'" + import ${1} from '${2:$1}'; +snippet imas "import * as xyz from 'xyz'" + import * as ${1} from '${2:$1}'; +snippet imm "import { member } from 'xyz'" + import { ${1} } from '${2}'; snippet cla class ${1} { ${0} @@ -12,6 +16,29 @@ snippet clax class ${1} extends ${2} { ${0} } +snippet clac + class ${1} { + constructor(${2}) { + ${0} + } + } +snippet foro "for (const prop of object}) { ... }" + for (const ${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} diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets index 2b5aefb4..489e0abb 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.node.snippets @@ -5,7 +5,7 @@ snippet ex module.exports = ${1}; # require snippet re - ${1:var} ${2} = require('${3:module_name}'); + ${1:const} ${2} = require('${3:module_name}'); # EventEmitter snippet on on('${1:event_name}', function(${2:stream}) { diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets index 0d054f4e..0ac0bfb4 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets @@ -1,5 +1,4 @@ # Functions - # prototype snippet proto ${1:class_name}.prototype.${2:method_name} = function(${3}) { @@ -30,6 +29,11 @@ snippet (f (function(${1}) { ${0} }(${2})); +# Minify safe iife +snippet ;fe + ;(function(${1}) { + ${0} + }(${2})) # self-defining function snippet sdf var ${1:function_name} = function (${2:argument}) { @@ -39,9 +43,7 @@ snippet sdf ${0} }; }; - # Flow control - # if snippet if if (${1:true}) { @@ -95,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++) { @@ -123,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}) { @@ -202,9 +199,7 @@ snippet prop configurable : ${0:boolean} } ); - # Documentation - # docstring snippet /** /** @@ -223,9 +218,7 @@ snippet jsonp # JSON.stringify snippet jsons JSON.stringify(${0:object}); - # DOM selectors - # Get elements snippet get getElementsBy${1:TagName}('${0}') @@ -244,7 +237,6 @@ snippet qs # Query selector all snippet qsa ${1:document}.querySelectorAll('${0:CSS selector}') - # Debugging snippet de debugger; @@ -257,6 +249,12 @@ snippet cd # console.error snippet ce console.error(${0}); +# console.warn +snippet cw + console.warn(${0}); +# console.info +snippet ci + console.info(${0}); # console.trace snippet ct console.trace(${0:label}); @@ -269,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}); diff --git a/sources_non_forked/vim-snippets/snippets/lfe.snippets b/sources_non_forked/vim-snippets/snippets/lfe.snippets new file mode 100644 index 00000000..b716e6ef --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/lfe.snippets @@ -0,0 +1,18 @@ +snippet defmo + (defmodule ${1:`vim_snippets#Filename()`} + (export ${2:all})) + $0 +snippet def + (defun $1 ($2) + $0) +snippet ltest + (defmodule ${1:`vim_snippets#Filename()`} + (behaviour ltest-unit) + (export all)) + + (include-lib "ltest/include/ltest-macros.lfe") + + $0 +snippet test + (deftest $1 + $0) diff --git a/sources_non_forked/vim-snippets/snippets/mustache.snippets b/sources_non_forked/vim-snippets/snippets/mustache.snippets index 8296afcb..ad8723ed 100644 --- a/sources_non_forked/vim-snippets/snippets/mustache.snippets +++ b/sources_non_forked/vim-snippets/snippets/mustache.snippets @@ -1,15 +1,12 @@ -# if {{#value}} ... {{/value}} -snippet if +snippet if # {{#value}} ... {{/value}} {{#${1:value}}} ${0} {{/$1}} -# if not {{^value}} ... {{/value}} -snippet ifn +snippet ifn # {{^value}} ... {{/value}} {{^${1:value}}} ${0} {{/$1}} -# if else {{#value}} ... {{/value}} {{^value}} ... {{/value}} -snippet ife +snippet ife # {{#value}} ... {{/value}} {{^value}} ... {{/value}} {{#${1:value}}} ${2} {{/$1}} diff --git a/sources_non_forked/vim-snippets/snippets/perl.snippets b/sources_non_forked/vim-snippets/snippets/perl.snippets index 65120a25..2ed2932a 100644 --- a/sources_non_forked/vim-snippets/snippets/perl.snippets +++ b/sources_non_forked/vim-snippets/snippets/perl.snippets @@ -84,7 +84,9 @@ snippet fore ${1:expression} foreach @${2:array}; # Package snippet package - package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}; + package ${1:`expand('%:p:s?.*lib/??:r:gs?/?::?')`}; + use strict; + use warnings; ${0} @@ -93,7 +95,9 @@ snippet package __END__ # Package syntax perl >= 5.14 snippet packagev514 - package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99}; + package ${1:`expand('%:p:s?.*lib/??:r:gs?/?::?')`} ${2:0.99}; + use v5.14; + use warnings; ${0} diff --git a/sources_non_forked/vim-snippets/snippets/php.snippets b/sources_non_forked/vim-snippets/snippets/php.snippets index 06448590..2d9f5152 100644 --- a/sources_non_forked/vim-snippets/snippets/php.snippets +++ b/sources_non_forked/vim-snippets/snippets/php.snippets @@ -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(); } diff --git a/sources_non_forked/vim-snippets/snippets/ps1.snippets b/sources_non_forked/vim-snippets/snippets/ps1.snippets new file mode 100644 index 00000000..acab10cc --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/ps1.snippets @@ -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} diff --git a/sources_non_forked/vim-snippets/snippets/purescript.snippets b/sources_non_forked/vim-snippets/snippets/purescript.snippets new file mode 100644 index 00000000..06d6b34a --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/purescript.snippets @@ -0,0 +1,52 @@ +snippet mod + module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` + ( + ) where + + import Prelude + + ${0} +snippet imp + import ${0:Data.List} +snippet impq + import ${1:Data.List} as ${0:List} +snippet fn0 + ${1:name} :: ${2:a} + $1 = ${0:undefined} +snippet fn + ${1:fn} :: ${2:a} -> ${3:a} + $1 ${4}= ${0} +snippet fn1 + ${1:fn} :: ${2:a} -> ${3:a} + $1 ${4}= ${0} +snippet fn2 + ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} + $1 ${5}= ${0} +snippet fn3 + ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} -> ${5:a} + $1 ${6}= ${0} +snippet case + case ${1} of + ${2} -> ${0} +snippet let + let + ${1} = ${2} + in + ${3} +snippet where + where + ${1} = ${0} +snippet testunit + module Test.Main where + + import Prelude + import Test.Unit (suite, test) + import Test.Unit.Main (runTest) + import Test.Unit.Assert as Assert + + main = runTest do + suite "${1}" do + test "${2:the tests run}" do + Assert.equal + "Hello, world!" + "Hello, sailor!" diff --git a/sources_non_forked/vim-snippets/snippets/rails.snippets b/sources_non_forked/vim-snippets/snippets/rails.snippets index e8342222..6a5c5ff0 100644 --- a/sources_non_forked/vim-snippets/snippets/rails.snippets +++ b/sources_non_forked/vim-snippets/snippets/rails.snippets @@ -325,7 +325,7 @@ snippet xpost snippet xput xhr :put, :${1:update}, id: ${2:1}, ${3:object}: ${4:object} snippet test - test 'should ${1:do something}' do + test '${1:should do something}' do ${0} end ########################### diff --git a/sources_non_forked/vim-snippets/snippets/stylus.snippets b/sources_non_forked/vim-snippets/snippets/stylus.snippets index 205f8479..3ce35c26 100644 --- a/sources_non_forked/vim-snippets/snippets/stylus.snippets +++ b/sources_non_forked/vim-snippets/snippets/stylus.snippets @@ -379,6 +379,8 @@ snippet d:mis display -moz-inline-stack snippet d:b display block +snippet d:f + display flex snippet d:cp display compact snippet d:ib @@ -991,3 +993,7 @@ snippet for for ${1:i} in ${0} snippet keyf @keyframes ${0} +snippet jc:c + justify-content center +snippet jc + justify-content diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index 68ac5d05..05ec852c 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -1,317 +1,327 @@ +#version 1 #PREAMBLE #newcommand snippet nc \newcommand - \newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} + \\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} #usepackage snippet up \usepackage - \usepackage[${1:options}]{${2:package}} ${0} + \\usepackage[${1:options}]{${2:package}} ${0} #newunicodechar snippet nuc \newunicodechar - \newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${0} + \\newunicodechar{${1}}{${2:\\ensuremath}${3:tex-substitute}}} ${0} #DeclareMathOperator snippet dmo \DeclareMathOperator - \DeclareMathOperator{${1}}{${2}} ${0} + \\DeclareMathOperator{${1}}{${2}} ${0} #DOCUMENT # \begin{}...\end{} snippet begin \begin{} ... \end{} block - \begin{${1:env}} + \\begin{${1:env}} ${0:${VISUAL}} - \end{$1} + \\end{$1} # Tabular snippet tab tabular (or arbitrary) environment - \begin{${1:tabular}}{${2:c}} + \\begin{${1:tabular}}{${2:c}} ${0:${VISUAL}} - \end{$1} + \\end{$1} snippet thm thm (or arbitrary) environment with optional argument - \begin[${1:author}]{${2:thm}} + \\begin[${1:author}]{${2:thm}} ${0:${VISUAL}} - \end{$2} + \\end{$2} snippet center center environment - \begin{center} + \\begin{center} ${0:${VISUAL}} - \end{center} + \\end{center} # Align(ed) snippet ali align(ed) environment - \begin{align${1:ed}} - \label{eq:${2}} + \\begin{align${1:ed}} + \\label{eq:${2}} ${0:${VISUAL}} - \end{align$1} + \\end{align$1} # Gather(ed) snippet gat gather(ed) environment - \begin{gather${1:ed}} + \\begin{gather${1:ed}} ${0:${VISUAL}} - \end{gather$1} + \\end{gather$1} # Equation snippet eq equation environment - \begin{equation} + \\begin{equation} ${0:${VISUAL}} - \end{equation} + \\end{equation} # Equation snippet eql Labeled equation environment - \begin{equation} - \label{eq:${2}} + \\begin{equation} + \\label{eq:${2}} ${0:${VISUAL}} - \end{equation} + \\end{equation} # Equation snippet eq* unnumbered equation environment - \begin{equation*} + \\begin{equation*} ${0:${VISUAL}} - \end{equation*} + \\end{equation*} # Unnumbered Equation snippet \ unnumbered equation: \[ ... \] - \[ + \\[ ${0:${VISUAL}} - \] + \\] # Equation array snippet eqnarray eqnarray environment - \begin{eqnarray} + \\begin{eqnarray} ${0:${VISUAL}} - \end{eqnarray} + \\end{eqnarray} # Label snippet lab \label - \label{${1:eq:}${2:fig:}${3:tab:}${0}} + \\label{${1:eq:}${2:fig:}${3:tab:}${0}} # Enumerate snippet enum enumerate environment - \begin{enumerate} - \item ${0} - \end{enumerate} + \\begin{enumerate} + \\item ${0} + \\end{enumerate} snippet enuma enumerate environment - \begin{enumerate}[(a)] - \item ${0} - \end{enumerate} + \\begin{enumerate}[(a)] + \\item ${0} + \\end{enumerate} snippet enumi enumerate environment - \begin{enumerate}[(i)] - \item ${0} - \end{enumerate} + \\begin{enumerate}[(i)] + \\item ${0} + \\end{enumerate} # Itemize snippet itemize itemize environment - \begin{itemize} - \item ${0} - \end{itemize} + \\begin{itemize} + \\item ${0} + \\end{itemize} snippet item \item - \item ${1:${VISUAL}} + \\item ${1:${VISUAL}} # Description snippet desc description environment - \begin{description} - \item[${1}] ${0} - \end{description} + \\begin{description} + \\item[${1}] ${0} + \\end{description} # Endless new item snippet ]i \item (recursive) - \item ${1} + \\item ${1} ${0:]i} # Matrix snippet mat smart matrix environment - \begin{${1:p/b/v/V/B/small}matrix} + \\begin{${1:p/b/v/V/B/small}matrix} ${0:${VISUAL}} - \end{$1matrix} + \\end{$1matrix} # Cases snippet cas cases environment - \begin{cases} - ${1:equation}, &\text{ if }${2:case}\\ + \\begin{cases} + ${1:equation}, &\\text{ if }${2:case}\\ ${0:${VISUAL}} - \end{cases} + \\end{cases} # Split snippet spl split environment - \begin{split} + \\begin{split} ${0:${VISUAL}} - \end{split} + \\end{split} # Part snippet part document \part - \part{${1:part name}} % (fold) - \label{prt:${2:$1}} + \\part{${1:part name}} % (fold) + \\label{prt:${2:$1}} ${0} % part $2 (end) # Chapter snippet cha \chapter - \chapter{${1:chapter name}} - \label{cha:${2:$1}} + \\chapter{${1:chapter name}} + \\label{cha:${2:$1}} ${0} # Section snippet sec \section - \section{${1:section name}} - \label{sec:${2:$1}} + \\section{${1:section name}} + \\label{sec:${2:$1}} ${0} # Section without number snippet sec* \section* - \section*{${1:section name}} - \label{sec:${2:$1}} + \\section*{${1:section name}} + \\label{sec:${2:$1}} ${0} # Sub Section snippet sub \subsection - \subsection{${1:subsection name}} - \label{sub:${2:$1}} + \\subsection{${1:subsection name}} + \\label{sub:${2:$1}} ${0} # Sub Section without number snippet sub* \subsection* - \subsection*{${1:subsection name}} - \label{sub:${2:$1}} + \\subsection*{${1:subsection name}} + \\label{sub:${2:$1}} ${0} # Sub Sub Section snippet subs \subsubsection - \subsubsection{${1:subsubsection name}} - \label{ssub:${2:$1}} + \\subsubsection{${1:subsubsection name}} + \\label{ssub:${2:$1}} ${0} # Sub Sub Section without number snippet subs* \subsubsection* - \subsubsection*{${1:subsubsection name}} - \label{ssub:${2:$1}} + \\subsubsection*{${1:subsubsection name}} + \\label{ssub:${2:$1}} ${0} # Paragraph snippet par \paragraph - \paragraph{${1:paragraph name}} - \label{par:${2:$1}} + \\paragraph{${1:paragraph name}} + \\label{par:${2:$1}} ${0} # Sub Paragraph snippet subp \subparagraph - \subparagraph{${1:subparagraph name}} - \label{subp:${2:$1}} + \\subparagraph{${1:subparagraph name}} + \\label{subp:${2:$1}} ${0} snippet ni \noindent - \noindent + \\noindent ${0} #References snippet itd description \item - \item[${1:description}] ${0:item} + \\item[${1:description}] ${0:item} snippet figure reference to a figure - ${1:Figure}~\ref{${2:fig:}} + ${1:Figure}~\\ref{${2:fig:}} snippet table reference to a table - ${1:Table}~\ref{${2:tab:}} + ${1:Table}~\\ref{${2:tab:}} snippet listing reference to a listing - ${1:Listing}~\ref{${2:list}} + ${1:Listing}~\\ref{${2:list}} snippet section reference to a section - ${1:Section}~\ref{sec:${2}} ${0} + ${1:Section}~\\ref{sec:${2}} ${0} snippet page reference to a page - ${1:page}~\pageref{${2}} ${0} + ${1:page}~\\pageref{${2}} ${0} snippet index \index - \index{${1:index}} ${0} + \\index{${1:index}} ${0} #Citations snippet citen \citen - \citen{${1}} ${0} + \\citen{${1}} ${0} # natbib citations snippet citep \citep - \citep{${1}} ${0} + \\citep{${1}} ${0} snippet citet \citet - \citet{${1}} ${0} + \\citet{${1}} ${0} snippet cite \cite[]{} - \cite[${1}]{${2}} ${0} + \\cite[${1}]{${2}} ${0} snippet citea \citeauthor - \citeauthor{${1}} ${0} + \\citeauthor{${1}} ${0} snippet citey \citeyear - \citeyear{${1}} ${0} + \\citeyear{${1}} ${0} snippet fcite \footcite[]{} - \footcite[${1}]{${2}}${0} + \\footcite[${1}]{${2}}${0} #Formating text: italic, bold, underline, small capital, emphase .. snippet it italic text - \textit{${0:${VISUAL:text}}} + \\textit{${0:${VISUAL:text}}} snippet bf bold face text - \textbf{${0:${VISUAL:text}}} + \\textbf{${0:${VISUAL:text}}} snippet under underline text - \underline{${0:${VISUAL:text}}} + \\underline{${0:${VISUAL:text}}} snippet emp emphasize text - \emph{${0:${VISUAL:text}}} + \\emph{${0:${VISUAL:text}}} snippet sc small caps text - \textsc{${0:${VISUAL:text}}} + \\textsc{${0:${VISUAL:text}}} #Choosing font snippet sf sans serife text - \textsf{${0:${VISUAL:text}}} + \\textsf{${0:${VISUAL:text}}} snippet rm roman font text - \textrm{${0:${VISUAL:text}}} + \\textrm{${0:${VISUAL:text}}} snippet tt typewriter (monospace) text - \texttt{${0:${VISUAL:text}}} + \\texttt{${0:${VISUAL:text}}} #Math font snippet mf mathfrak - \mathfrak{${0:${VISUAL:text}}} + \\mathfrak{${0:${VISUAL:text}}} snippet mc mathcal - \mathcal{${0:${VISUAL:text}}} + \\mathcal{${0:${VISUAL:text}}} snippet ms mathscr - \mathscr{${0:${VISUAL:text}}} + \\mathscr{${0:${VISUAL:text}}} #misc snippet ft \footnote - \footnote{${0:${VISUAL:text}}} + \\footnote{${0:${VISUAL:text}}} snippet fig figure environment (includegraphics) - \begin{figure} - \begin{center} - \includegraphics[scale=${1}]{Figures/${2}} - \end{center} - \caption{${3}} - \label{fig:${4}} - \end{figure} + \\begin{figure} + \\begin{center} + \\includegraphics[scale=${1}]{Figures/${2}} + \\end{center} + \\caption{${3}} + \\label{fig:${4}} + \\end{figure} ${0} snippet tikz figure environment (tikzpicture) - \begin{figure} - \begin{center} - \begin{tikzpicture}[scale=${1:1}] + \\begin{figure}[htpb] + \\begin{center} + \\begin{tikzpicture}[scale=${1:1}, transform shape] ${2} - \end{tikzpicture} - \end{center} - \caption{${3}} - \label{fig:${4}} - \end{figure} + \\end{tikzpicture} + \\end{center} + \\caption{${3}} + \\label{fig:${4}} + \\end{figure} + ${0} +snippet subfig subfigure environment + \\begin{subfigure}[${1}]{${2:\\textwidth}} + \\begin{center} + ${3} + \\end{center} + \\caption{${4}} + \\label{fig:${5}} + \\end{subfigure} ${0} #math snippet stackrel \stackrel{}{} - \stackrel{${1:above}}{${2:below}} ${0} + \\stackrel{${1:above}}{${2:below}} ${0} snippet frac \frac{}{} - \frac{${1:num}}{${2:denom}} ${0} + \\frac{${1:num}}{${2:denom}} ${0} snippet sum \sum^{}_{} - \sum^{${1:n}}_{${2:i=1}} ${0} + \\sum^{${1:n}}_{${2:i=1}} ${0} snippet lim \lim_{} - \lim_{${1:n \to \infty}} ${0} + \\lim_{${1:n \\to \\infty}} ${0} snippet frame frame environment - \begin{frame}[${1:t}]{${2:title}} + \\begin{frame}[${1:t}]{${2:title}} ${0:${VISUAL}} - \end{frame} + \\end{frame} snippet block block environment - \begin{block}{${1:title}} - ${0:${VISUAL}} - \end{block} + \\begin{block}{${1:title}} + ${0:${VISUAL}} + \\end{block} snippet alert alertblock environment - \begin{alertblock}{${1:title}} - ${0:${VISUAL}} - \end{alertblock} + \\begin{alertblock}{${1:title}} + ${0:${VISUAL}} + \\end{alertblock} snippet example exampleblock environment - \begin{exampleblock}{${1:title}} - ${0:${VISUAL}} - \end{exampleblock} + \\begin{exampleblock}{${1:title}} + ${0:${VISUAL}} + \\end{exampleblock} snippet col2 two-column environment - \begin{columns} - \begin{column}{0.5\textwidth} + \\begin{columns} + \\begin{column}{0.5\\textwidth} ${1} - \end{column} - \begin{column}{0.5\textwidth} + \\end{column} + \\begin{column}{0.5\\textwidth} ${0} - \end{column} - \end{columns} + \\end{column} + \\end{columns} snippet \{ \{ \} \\{ ${0} \\} #delimiter snippet lr left right - \left${1} ${0} \right$1 -snippet lr( left( right) - \left( ${0} \right) -snippet lr| left| right| - \left| ${0} \right| -snippet lr{ left\{ right\} - \left\\{ ${0} \right\\} -snippet lr[ left[ right] - \left[ ${0} \right] -snippet lra langle rangle - \langle ${0} \rangle + \\left${1} ${0} \\right$1 +snippet lr( left( right) + \\left( ${0} \\right) +snippet lr| left| right| + \\left| ${0} \\right| +snippet lr{ left\{ right\} + \\left\\{ ${0} \\right\\} +snippet lr[ left[ right] + \\left[ ${0} \\right] +snippet lra langle rangle + \\langle ${0} \\rangle # Code listings snippet lst - \begin{listing}[language=${1:language}] + \\begin{listing}[language=${1:language}] ${0:${VISUAL}} - \end{listing} + \\end{listing} snippet lsi - \lstinline|${1}| ${0} + \\lstinline|${1}| ${0} # Hyperlinks snippet url - \url{${1}} ${0} + \\url{${1}} ${0} snippet href - \href{${1}}{${2}} ${0} + \\href{${1}}{${2}} ${0} # URL from Clipboard. snippet urlc - \url{`@+`} ${0} + \\url{`@+`} ${0} snippet hrefc - \href{`@+`}{${1}} ${0} + \\href{`@+`}{${1}} ${0} diff --git a/sources_non_forked/vim-snippets/snippets/vhdl.snippets b/sources_non_forked/vim-snippets/snippets/vhdl.snippets new file mode 100644 index 00000000..f13f5bf9 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/vhdl.snippets @@ -0,0 +1,127 @@ +# +## Libraries + +snippet lib + library ${1} + use ${1}.${2} + +# Standard Libraries +snippet libs + library IEEE; + use IEEE.std_logic_1164.ALL; + use IEEE.numeric_std.ALL; + +# Xilinx Library +snippet libx + library UNISIM; + use UNISIM.VCOMPONENTS.ALL; + +## Entity Declaration +snippet ent + entity ${1:`vim_snippets#Filename()`} is + generic ( + ${2} + ); + port ( + ${3} + ); + end entity $1; + +## Architecture +snippet arc + architecture ${1:behav} of ${2:`vim_snippets#Filename()`} is + + ${3} + + begin + + + end $1; + +## Declarations +# std_logic +snippet st + signal ${1} : std_logic; +# std_logic_vector +snippet sv + signal ${1} : std_logic_vector (${2} downto 0); +# std_logic in +snippet ist + ${1} : in std_logic; +# std_logic_vector in +snippet isv + ${1} : in std_logic_vector (${2} downto 0); +# std_logic out +snippet ost + ${1} : out std_logic; +# std_logic_vector out +snippet osv + ${1} : out std_logic_vector (${2} downto 0); +# unsigned +snippet un + signal ${1} : unsigned (${2} downto 0); +## Process Statements +# process +snippet pr + process (${1}) + begin + ${2} + end process; +# process with clock +snippet prc + process (${1:clk}) + begin + if rising_edge ($1) then + ${2} + end if; + end process; +# process all +snippet pra + process (${1:all}) + begin + ${2} + end process; +## Control Statements +# if +snippet if + if ${1} then + ${2} + end if; +# if +snippet ife + if ${1} then + ${2} + else + ${3} + end if; +# else +snippet el + else + ${1} +# if +snippet eif + elsif ${1} then + ${2} +# case +snippet ca + case ${1} is + ${2} + end case; +# when +snippet wh + when ${1} => + ${2} +# for +snippet for + for ${1:i} in ${2} ${3:to} ${4} loop + ${5} + end loop; +# while +snippet wh + while ${1} loop + ${2} + end loop; +## Misc +# others +snippet oth + (others => '${1:0}'); diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index 837469f7..6c1d423c 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -131,6 +131,12 @@ set novisualbell set t_vb= set tm=500 +" Properly disable sound on errors on MacVim +if has("gui_macvim") + autocmd GUIEnter * set vb t_vb= +endif + + " Add a bit extra margin to the left set foldcolumn=1 @@ -141,6 +147,11 @@ set foldcolumn=1 " Enable syntax highlighting syntax enable +" Enable 256 colors palette in Gnome Terminal +if $COLORTERM == 'gnome-terminal' + set t_Co=256 +endif + try colorscheme desert catch @@ -372,11 +383,11 @@ function! VisualSelection(direction, extra_filter) range let l:saved_reg = @" execute "normal! vgvy" - let l:pattern = escape(@", '\\/.*$^~[]') + let l:pattern = escape(@", "\\/.*'$^~[]") let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'gv' - call CmdLine("Ag \"" . l:pattern . "\" " ) + call CmdLine("Ag '" . l:pattern . "' " ) elseif a:direction == 'replace' call CmdLine("%s" . '/'. l:pattern . '/') endif diff --git a/vimrcs/extended.vim b/vimrcs/extended.vim index 649ed083..499959a2 100644 --- a/vimrcs/extended.vim +++ b/vimrcs/extended.vim @@ -21,12 +21,6 @@ elseif has("unix") set gfn=Monospace\ 11 endif -" Open MacVim in fullscreen mode -if has("gui_macvim") - set fuoptions=maxvert,maxhorz - au GUIEnter * set fullscreen -endif - " Disable scrollbars (real hackers don't use scrollbars for navigation!) set guioptions-=r set guioptions-=R diff --git a/vimrcs/filetypes.vim b/vimrcs/filetypes.vim index 164454eb..8c4eb9db 100644 --- a/vimrcs/filetypes.vim +++ b/vimrcs/filetypes.vim @@ -17,6 +17,9 @@ au FileType python map <buffer> <leader>1 /class au FileType python map <buffer> <leader>2 /def au FileType python map <buffer> <leader>C ?class au FileType python map <buffer> <leader>D ?def +au FileType python set cindent +au FileType python set cinkeys-=0# +au FileType python set indentkeys-=0# """""""""""""""""""""""""""""" @@ -54,3 +57,11 @@ endfunction au FileType coffee call CoffeeScriptFold() au FileType gitcommit call setpos('.', [0, 1, 1, 0]) + + +"""""""""""""""""""""""""""""" +" => Shell section +"""""""""""""""""""""""""""""" +if exists('$TMUX') + set term=screen-256color +endif