Updated plugins

This commit is contained in:
amix 2017-02-11 14:01:38 +01:00
parent a6de243fca
commit fe46dfbbe6
141 changed files with 2790 additions and 1630 deletions

View file

@ -303,7 +303,6 @@ fu! s:match_window_opts()
let s:mw_res = let s:mw_res =
\ s:mw =~ 'results:[^,]\+' ? str2nr(matchstr(s:mw, 'results:\zs\d\+')) \ s:mw =~ 'results:[^,]\+' ? str2nr(matchstr(s:mw, 'results:\zs\d\+'))
\ : min([s:mw_max, &lines]) \ : min([s:mw_max, &lines])
let s:mw_res = max([s:mw_res, 1])
endf endf
"}}}1 "}}}1
" * Open & Close {{{1 " * Open & Close {{{1
@ -1995,9 +1994,14 @@ fu! s:bufnrfilpath(line)
en en
let filpath = fnamemodify(filpath, ':p') let filpath = fnamemodify(filpath, ':p')
let bufnr = bufnr('^'.filpath.'$') let bufnr = bufnr('^'.filpath.'$')
if (a:line =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(filpath) && bufnr < 1) if (!filereadable(filpath) && bufnr < 1)
let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$')) if (a:line =~ '[\/]\?\[\d\+\*No Name\]$')
let filpath = bufnr let bufnr = str2nr(matchstr(a:line, '[\/]\?\[\zs\d\+\ze\*No Name\]$'))
let filpath = bufnr
else
let bufnr = bufnr(a:line)
retu [bufnr, a:line]
en
en en
retu [bufnr, filpath] retu [bufnr, filpath]
endf endf

View file

@ -137,8 +137,8 @@ fu! ctrlp#tag#id()
endf endf
fu! ctrlp#tag#enter() fu! ctrlp#tag#enter()
let tfs = tagfiles() let tfs = get(g:, 'ctrlp_custom_tag_files', tagfiles())
let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'), let s:tagfiles = type(tfs) == 3 && tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
\ 'filereadable(v:val)') : [] \ 'filereadable(v:val)') : []
endf endf
"}}} "}}}

View file

@ -148,6 +148,7 @@ The minimum and maximum heights:
The maximum number of results: The maximum number of results:
results:{n} - list maximum {n} results (default: sync with max height). results:{n} - list maximum {n} results (default: sync with max height).
0 mean no-limit.
Note: When a setting isn't set, its default value will be used. Note: When a setting isn't set, its default value will be used.
@ -1497,6 +1498,9 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
* New option |g:ctrlp_custom_tag_files| to specify custom tag files.
* Accept 0 for g:ctrlp_match_window no-limited window size.
Before 2016/11/28~ Before 2016/11/28~
+ New command: |YankLine()| to yank current line. + New command: |YankLine()| to yank current line.

View file

@ -122,7 +122,7 @@ function! s:tranquilize()
endfunction endfunction
function! s:hide_statusline() function! s:hide_statusline()
let &l:statusline = repeat(' ', winwidth(0)) setlocal statusline=\
endfunction endfunction
function! s:hide_linenr() function! s:hide_linenr()
@ -239,7 +239,7 @@ function! s:goyo_on(dim)
set showtabline=0 set showtabline=0
set noruler set noruler
set fillchars+=vert:\ set fillchars+=vert:\
set fillchars+=stl:. set fillchars+=stl:\
set fillchars+=stlnc:\ set fillchars+=stlnc:\
set sidescroll=1 set sidescroll=1
set sidescrolloff=0 set sidescrolloff=0

View file

@ -301,10 +301,10 @@ endfunction
"FUNCTION: Path._escChars() {{{1 "FUNCTION: Path._escChars() {{{1
function! s:Path._escChars() function! s:Path._escChars()
if nerdtree#runningWindows() if nerdtree#runningWindows()
return " `\|\"#%&,?()\*^<>" return " `\|\"#%&,?()\*^<>$"
endif endif
return " \\`\|\"#%&,?()\*^<>[]" return " \\`\|\"#%&,?()\*^<>[]$"
endfunction endfunction
"FUNCTION: Path.getDir() {{{1 "FUNCTION: Path.getDir() {{{1

View file

@ -3226,7 +3226,7 @@ accepts the standard options described at |syntastic-config-makeprg|.
Notes~ Notes~
Syntastic requires "Flow" version 0.18.1 or later. Syntastic requires "Flow" version 0.34.0 or later.
To use "Flow" with your projects, you must: To use "Flow" with your projects, you must:

View file

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START lockvar! g:_SYNTASTIC_START
endif endif
let g:_SYNTASTIC_VERSION = '3.8.0-10' let g:_SYNTASTIC_VERSION = '3.8.0-21'
lockvar g:_SYNTASTIC_VERSION lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1 " Sanity checks {{{1
@ -67,6 +67,15 @@ else
endif endif
lockvar g:_SYNTASTIC_UNAME lockvar g:_SYNTASTIC_UNAME
" XXX Ugly hack to make g:_SYNTASTIC_UNAME available to :SyntasticInfo without
" polluting session namespaces
let g:syntastic_version =
\ g:_SYNTASTIC_VERSION .
\ ' (Vim ' . v:version . (has('nvim') ? ', Neovim' : '') . ', ' .
\ g:_SYNTASTIC_UNAME .
\ (has('gui') ? ', GUI' : '') . ')'
lockvar g:syntastic_version
" }}}1 " }}}1
" Defaults {{{1 " Defaults {{{1
@ -344,13 +353,6 @@ function! s:BufWinEnterHook(fname) abort " {{{2
endfunction " }}}2 endfunction " }}}2
function! s:VimEnterHook() abort " {{{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('') let buf = bufnr('')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: VimEnter, buffer ' . buf . ' = ' . string(bufname(buf)) . ', &buftype = ' . string(&buftype)) \ 'autocmd: VimEnter, buffer ' . buf . ' = ' . string(bufname(buf)) . ', &buftype = ' . string(&buftype))

View file

@ -13,28 +13,58 @@ main([File]) ->
%% `rebar.config` is looked for, %% `rebar.config` is looked for,
%% but it is not necessarily the one in the project root. %% but it is not necessarily the one in the project root.
%% I.e. it may be one deeper in the project file hierarchy. %% I.e. it may be one deeper in the project file hierarchy.
RebarFile = rebar_file(Dir), Profile = which_compile_opts_profile(filename:absname(File)),
%% `rebar.config` might contain relative paths. CompileOpts = case which_build_tool(Dir, Profile) of
%% They are relative to the file! Not to the project root. {rebar, RebarFile} ->
RebarOpts = rebar_opts(Dir ++ "/" ++ RebarFile), %% `rebar.config` might contain relative paths.
%% They are relative to the file! Not to the project root.
%% rebar specific begin
rebar_opts(RebarFile);
%% rebar specific end
{erlangmk, ErlangMkDir} ->
%% Erlang.mk specific begin
erlangmk_opts(ErlangMkDir, Profile);
%% Erlang.mk specific end
undefined ->
fallback_opts()
end,
code:add_patha(filename:absname("ebin")), code:add_patha(filename:absname("ebin")),
%% `compile:file/2` requires the `{i, Path}` to be relative %% `compile:file/2` requires the `{i, Path}` to be relative
%% to CWD - no surprise here. %% to CWD - no surprise here.
compile:file(File, Defs ++ translate_paths(Dir, RebarOpts)); compile:file(File, Defs ++ translate_paths(Dir, CompileOpts));
main(_) -> main(_) ->
io:format("Usage: ~s <file>~n", [escript:script_name()]), io:format("Usage: ~s <file>~n", [escript:script_name()]),
halt(1). halt(1).
rebar_file(Dir) -> which_compile_opts_profile(File) ->
DirList = filename:split(Dir), case filename:basename(filename:dirname(File)) of
case lists:last(DirList) of "test" -> test;
"test" -> _ -> normal
"rebar.test.config";
_ ->
"rebar.config"
end. end.
which_build_tool(Dir, Profile) ->
%% rebar specific begin
RebarFile = rebar_file(Dir, Profile),
%% rebar specific end
case filelib:is_file(RebarFile) of
true ->
{rebar, RebarFile};
false ->
%% Erlang.mk specific begin
ErlangMk = erlangmk_file(Dir),
%% Erlang.mk specific end
case filelib:is_file(ErlangMk) of
true -> {erlangmk, Dir};
false -> undefined
end
end.
rebar_file(Dir, normal) -> filename:join(Dir, "rebar.config");
rebar_file(Dir, test) -> filename:join(Dir, "rebar.test.config").
erlangmk_file(Dir) -> filename:join(Dir, "erlang.mk").
rebar_opts(RebarFile) -> rebar_opts(RebarFile) ->
Dir = get_root(filename:dirname(RebarFile)), Dir = get_root(filename:dirname(RebarFile)),
case file:consult(RebarFile) of case file:consult(RebarFile) of
@ -54,6 +84,165 @@ rebar_opts(RebarFile) ->
rebar_opts("rebar.config") rebar_opts("rebar.config")
end. end.
erlangmk_opts(BaseDir, Profile) ->
Make =
case os:getenv("MAKE") of
false ->
case os:find_executable("gmake") of
false -> "make";
Path -> Path
end;
Cmd ->
case (lists:member($/, Cmd) orelse lists:member($\\, Cmd)) of
true -> Cmd;
false -> os:find_executable(Cmd)
end
end,
ERLC_OPTS_Target =
case Profile of
normal -> "show-ERLC_OPTS";
test -> "show-TEST_ERLC_OPTS"
end,
Args = [
"--no-print-directory",
"-C", BaseDir,
"show-ERL_LIBS",
ERLC_OPTS_Target
],
try
Port = erlang:open_port({spawn_executable, Make}, [
{args, Args},
exit_status, use_stdio, stderr_to_stdout]),
case erlangmk_port_receive_loop(Port, "", BaseDir) of
{error, _} ->
fallback_opts();
{ok, {ErlLibs, ErlcOpts}} ->
[code:add_pathsa(filelib:wildcard(
filename:join([ErlLib, "*", "ebin"])))
|| ErlLib <- ErlLibs],
ErlcOpts
end
catch
error:_ ->
fallback_opts()
end.
erlangmk_port_receive_loop(Port, Stdout, BaseDir) ->
receive
{Port, {exit_status, 0}} ->
erlangmk_format_opts(Stdout, BaseDir);
{Port, {exit_status, _}} ->
{error, {erlangmk, make_target_failure}};
{Port, {data, Out}} ->
erlangmk_port_receive_loop(Port, Stdout ++ Out, BaseDir)
end.
erlangmk_format_opts(Stdout, BaseDir) ->
case string:tokens(Stdout, "\n") of
[ErlLibsLine | ErlcOptsLines] ->
ErlLibs = erlangmk_format_erl_libs(ErlLibsLine),
ErlcOpts = erlangmk_format_erlc_opts(ErlcOptsLines, BaseDir),
{ok, {ErlLibs, ErlcOpts}};
_ ->
{error, {erlangmk, incorrect_output}}
end.
erlangmk_format_erl_libs(ErlLibsLine) ->
case os:type() of
{win32, _} -> string:tokens(ErlLibsLine, ";");
_ -> string:tokens(ErlLibsLine, ":")
end.
erlangmk_format_erlc_opts(ErlcOptsLines, BaseDir) ->
erlangmk_format_erlc_opts(ErlcOptsLines, [], BaseDir).
erlangmk_format_erlc_opts(["+" ++ Option | Rest], Opts, BaseDir) ->
case make_term(Option) of
{error, _} -> erlangmk_format_erlc_opts(Rest, Opts, BaseDir);
Opt -> erlangmk_format_erlc_opts(Rest, [Opt | Opts], BaseDir)
end;
erlangmk_format_erlc_opts(["-I" ++ Opt | Rest], Opts, BaseDir)
when Opt =/= "" ->
erlangmk_format_erlc_opts(["-I", Opt | Rest], Opts, BaseDir);
erlangmk_format_erlc_opts(["-I", [C | _] = Dir | Rest], Opts, BaseDir)
when C =/= $- andalso C =/= $+ ->
AbsDir = filename:absname(Dir, BaseDir),
erlangmk_format_erlc_opts(Rest, [{i, AbsDir} | Opts], BaseDir);
erlangmk_format_erlc_opts(["-W" ++ Warn | Rest], Opts, BaseDir)
when Warn =/= "" ->
erlangmk_format_erlc_opts(["-W", Warn | Rest], Opts, BaseDir);
erlangmk_format_erlc_opts(["-W", Warn | Rest], Opts, BaseDir) ->
case Warn of
"all" ->
erlangmk_format_erlc_opts(Rest, [{warn_format, 999} | Opts],
BaseDir);
"error" ->
erlangmk_format_erlc_opts(Rest, [warnings_as_errors | Opts],
BaseDir);
"" ->
erlangmk_format_erlc_opts(Rest, [{warn_format, 1} | Opts],
BaseDir);
_ ->
try list_to_integer(Warn) of
Level ->
erlangmk_format_erlc_opts(Rest,
[{warn_format, Level} | Opts], BaseDir)
catch
error:badarg ->
erlangmk_format_erlc_opts(Rest, Opts, BaseDir)
end
end;
erlangmk_format_erlc_opts(["-D" ++ Opt | Rest], Opts, BaseDir)
when Opt =/= "" ->
erlangmk_format_erlc_opts(["-D", Opt | Rest], Opts, BaseDir);
erlangmk_format_erlc_opts(["-D", [C | _] = Val0 | Rest], Opts, BaseDir)
when C =/= $- andalso C =/= $+ ->
{Key0, Val1} = split_at_equals(Val0, []),
Key = list_to_atom(Key0),
case Val1 of
[] ->
erlangmk_format_erlc_opts(Rest, [{d, Key} | Opts], BaseDir);
Val2 ->
case make_term(Val2) of
{error, _} ->
erlangmk_format_erlc_opts(Rest, Opts, BaseDir);
Val ->
erlangmk_format_erlc_opts(Rest, [{d, Key, Val} | Opts], BaseDir)
end
end;
erlangmk_format_erlc_opts([PathFlag, [_ | _] = Dir | Rest], Opts, BaseDir)
when PathFlag =:= "-pa" orelse PathFlag =:= "-pz" ->
AbsDir = filename:absname(Dir, BaseDir),
case PathFlag of
"-pa" -> code:add_patha(AbsDir);
"-pz" -> code:add_pathz(AbsDir)
end,
erlangmk_format_erlc_opts(Rest, Opts, BaseDir);
erlangmk_format_erlc_opts([_ | Rest], Opts, BaseDir) ->
erlangmk_format_erlc_opts(Rest, Opts, BaseDir);
erlangmk_format_erlc_opts([], Opts, _) ->
lists:reverse(Opts).
%% Function imported from erl_compile.erl from Erlang 19.1.
make_term(Str) ->
case erl_scan:string(Str) of
{ok, Tokens, _} ->
case erl_parse:parse_term(Tokens ++ [{dot, 1}]) of
{ok, Term} -> Term;
{error, Reason} -> {error, Reason}
end;
{error, Reason, _} ->
{error, Reason}
end.
%% Function imported from erl_compile.erl from Erlang 19.1.
split_at_equals([$=|T], Acc) ->
{lists:reverse(Acc),T};
split_at_equals([H|T], Acc) ->
split_at_equals(T, [H|Acc]);
split_at_equals([], Acc) ->
{lists:reverse(Acc),[]}.
fallback_opts() -> fallback_opts() ->
code:add_pathsa(filelib:wildcard("deps/*/ebin")), code:add_pathsa(filelib:wildcard("deps/*/ebin")),
code:add_pathsa(nested_app_ebins()), code:add_pathsa(nested_app_ebins()),

View file

@ -32,9 +32,12 @@ function! SyntaxCheckers_haxe_haxe_GetLocList() dict
if hxml !=# '' if hxml !=# ''
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'fname': syntastic#util#shescape(fnamemodify(hxml, ':t')) }) \ 'fname': syntastic#util#shescape(fnamemodify(hxml, ':t')),
\ 'args_after' : ['--no-output'] })
let errorformat = '%E%f:%l: characters %c-%n : %m' let errorformat =
\ '%W%f:%l: characters %c-%n : Warning : %m,' .
\ '%E%f:%l: characters %c-%n : %m'
let loclist = SyntasticMake({ let loclist = SyntasticMake({
\ 'makeprg': makeprg, \ 'makeprg': makeprg,

View file

@ -25,7 +25,7 @@ function! SyntaxCheckers_javascript_flow_IsAvailable() dict
if !executable(self.getExec()) if !executable(self.getExec())
return 0 return 0
endif endif
return syntastic#util#versionIsAtLeast(self.getVersion(self.getExecEscaped() . ' version'), [0, 18, 1]) return syntastic#util#versionIsAtLeast(self.getVersion(self.getExecEscaped() . ' version'), [0, 34])
endfunction endfunction
function! SyntaxCheckers_javascript_flow_GetLocList() dict function! SyntaxCheckers_javascript_flow_GetLocList() dict
@ -34,8 +34,8 @@ function! SyntaxCheckers_javascript_flow_GetLocList() dict
endif endif
let makeprg = self.makeprgBuild({ let makeprg = self.makeprgBuild({
\ 'exe': self.getExecEscaped() . ' check', \ 'exe': self.getExecEscaped() . ' status',
\ 'args_after': '--show-all-errors --json' }) \ 'args_after': '--quiet --show-all-errors --json' })
let errorformat = let errorformat =
\ '%f:%l:%c:%n: %m,' . \ '%f:%l:%c:%n: %m,' .

View file

@ -24,9 +24,12 @@ function! SyntaxCheckers_vala_valac_GetHighlightRegex(pos) " {{{1
endfunction " }}}1 endfunction " }}}1
function! SyntaxCheckers_vala_valac_GetLocList() dict " {{{1 function! SyntaxCheckers_vala_valac_GetLocList() dict " {{{1
let vala_pkg_args = join(map(s:GetValaModules(), '"--pkg ".v:val'), ' ') let buf = bufnr('')
let vala_vapi_args = join(map(s:GetValaVapiDirs(), '"--vapidir ".v:val'), ' ') let makeprg = self.makeprgBuild({
let makeprg = self.makeprgBuild({ 'args': '-C ' . vala_pkg_args . ' ' . vala_vapi_args }) \ 'args': '-C ' .
\ s:GetValaOpts(buf, 'modules', 'modules', '--pkg') . ' ' .
\ s:GetValaOpts(buf, 'vapi_dirs', 'vapidirs', '--vapidir'),
\ })
let errorformat = let errorformat =
\ '%A%f:%l.%c-%\d%\+.%\d%\+: %t%[a-z]%\+: %m,'. \ '%A%f:%l.%c-%\d%\+.%\d%\+: %t%[a-z]%\+: %m,'.
@ -40,38 +43,27 @@ endfunction " }}}1
" Utilities {{{1 " Utilities {{{1
function! s:GetValaModules() " {{{2 function! s:GetValaOpts(buf, name, comment, cmd) " {{{2
if exists('g:syntastic_vala_modules') || exists('b:syntastic_vala_modules') let var = syntastic#util#var('vala_' . a:name)
let modules = syntastic#util#var('vala_modules') if type(var) == type([])
if type(modules) == type('') let opts = map(copy(var), 'syntastic#util#shescape(v:val)')
return split(modules, '\m\s\+') elseif type(var) == type('')
elseif type(modules) == type([]) if var !=# ''
return copy(modules) let opts = split(var, '\s\+')
else else
echoerr 'syntastic_vala_modules must be either list or string: fallback to in file modules string' let opts = []
for line in filter(getbufline(a:buf, 1, 100), 'v:val =~# ' . string('\m^//\s\+' . a:comment . ':\s*'))
call extend(opts, split( matchstr(line, '\m^//\s\+' . a:comment . ':\s*\zs.*'), '\s\+' ))
endfor
call map( filter(opts, 'v:val !=# ""'), 'syntastic#util#shescape(v:val)' )
endif endif
else
call syntastic#log#error('syntastic_vala_' . a:name . ' must be either a list, or a string')
return ''
endif endif
let modules_line = search('^// modules: ', 'n') return join(map(opts, string(a:cmd . ' ') . ' . v:val'))
let modules_str = getline(modules_line)
return split(strpart(modules_str, 12), '\m\s\+')
endfunction " }}}2
function! s:GetValaVapiDirs() " {{{2
if exists('g:syntastic_vala_vapi_dirs') || exists('b:syntastic_vala_vapi_dirs')
let vapi_dirs = syntastic#util#var('vala_vapi_dirs')
if type(vapi_dirs) == type('')
return split(vapi_dirs, '\m\s\+')
elseif type(vapi_dirs) == type([])
return copy(vapi_dirs)
else
echoerr 'syntastic_vala_vapi_dirs must be either a list, or a string: fallback to in-file modules string'
endif
endif
let vapi_line = search('^//\s*vapidirs:\s*','n')
let vapi_str = getline(vapi_line)
return split( substitute( vapi_str, '\m^//\s*vapidirs:\s*', '', 'g' ), '\m\s\+' )
endfunction " }}}2 endfunction " }}}2
" }}}1 " }}}1

View file

@ -18,7 +18,7 @@ setlocal indentexpr=GetCoffeeHtmlIndent(v:lnum)
function! GetCoffeeHtmlIndent(curlinenum) function! GetCoffeeHtmlIndent(curlinenum)
" See if we're inside a coffeescript block. " See if we're inside a coffeescript block.
let scriptlnum = searchpair('<script [^>]*type="text/coffeescript"[^>]*>', '', let scriptlnum = searchpair('<script [^>]*type=[''"]\?text/coffeescript[''"]\?[^>]*>', '',
\ '</script>', 'bWn') \ '</script>', 'bWn')
let prevlnum = prevnonblank(a:curlinenum) let prevlnum = prevnonblank(a:curlinenum)

View file

@ -9,7 +9,7 @@ endif
" Syntax highlighting for text/coffeescript script tags " Syntax highlighting for text/coffeescript script tags
syn include @htmlCoffeeScript syntax/coffee.vim syn include @htmlCoffeeScript syntax/coffee.vim
syn region coffeeScript start=#<script [^>]*type="text/coffeescript"[^>]*># syn region coffeeScript start=#<script [^>]*type=['"]\?text/coffeescript['"]\?[^>]*>#
\ end=#</script>#me=s-1 keepend \ end=#</script>#me=s-1 keepend
\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc \ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc
\ containedin=htmlHead \ containedin=htmlHead

View file

@ -4,4 +4,14 @@
def: 42 def: 42
} }
</script> </script>
<script type='text/coffeescript'>
abc = {
def: 42
}
</script>
<script type=text/coffeescript>
abc = {
def: 42
}
</script>
</head> </head>

View file

@ -195,7 +195,7 @@ function! fugitive#detect(path) abort
nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR> nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR>
endif endif
let buffer = fugitive#buffer() let buffer = fugitive#buffer()
if expand('%:p') =~# '//' if expand('%:p') =~# '://'
call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', '')) call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', ''))
endif endif
if stridx(buffer.getvar('&tags'), escape(b:git_dir, ', ')) == -1 if stridx(buffer.getvar('&tags'), escape(b:git_dir, ', ')) == -1
@ -700,7 +700,11 @@ function! s:Git(bang, args) abort
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=') let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
if exists(':terminal') if exists(':terminal')
let dir = s:repo().tree() let dir = s:repo().tree()
-tabedit % if expand('%') != ''
-tabedit %
else
-tabnew
endif
execute 'lcd' fnameescape(dir) execute 'lcd' fnameescape(dir)
execute 'terminal' git args execute 'terminal' git args
else else
@ -2295,9 +2299,9 @@ function! s:Browse(bang,line1,count,...) abort
if empty(remote) if empty(remote)
let remote = '.' let remote = '.'
let raw = s:repo().git_chomp('config','remote.origin.url') let raw = s:repo().git_chomp('remote','get-url','origin')
else else
let raw = s:repo().git_chomp('config','remote.'.remote.'.url') let raw = s:repo().git_chomp('remote','get-url',remote)
endif endif
if raw ==# '' if raw ==# ''
let raw = remote let raw = remote

View file

@ -1,2 +1,6 @@
doc/tags doc/tags
.DS_Store .DS_Store
# Test specific files
FAILED
test.log

View file

@ -0,0 +1,22 @@
language: go
env:
global:
- DEPS=$HOME/deps
- PATH=$DEPS/bin:$PATH
- PATCH="v8.0.0134"
install: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
# check out if we can pre-compiled Vim releases somehow,
git clone --branch $PATCH --depth 1 https://github.com/vim/vim
cd vim
./configure --prefix=$DEPS --with-features=huge --disable-gui
make
make install
cd -
script: ./scripts/test.sh

View file

@ -1,7 +1,33 @@
## 1.11 - Unplanned ## unplanned
FEATURES: FEATURES:
* Add new `errl` snippet that expands to [gh-1185]:
```
if err != nil {
log.Fatal(err)
}
```
IMPROVEMENTS:
* Lowercase `<Leader>` in mappings examples for consisten documentation across the README [gh-1192]
* All of files should be written in utf-8 if the file will be passed to external command. [gh-1184]
BUG FIXES:
* Honor `g:go_echo_command_info` when dispatching builds in neovim [gh-1176]
* Fix `:GoBuild` error in neovim due to invalid jobcontrol handler function signatures (`s:on_stdout`, `s:on_stderr`)[gh-1176]
* Update statusline before and after `go#jobcontrol#Spawn` command is executed [gh-1176]
* Correctly report the value of the 'g:go_guru_tags' variable [gh-1177]
* Ensure no trailing `:` exist in GOPATH detection if initial GOPATH is not set [gh-1194]
## 1.11 - (January 9, 2017)
FEATURES:
* Travis test integration has been added. Now any file that is added as `<name>_test.vim` will be automatically tested in for every Pull Request (just like how we add tests to Go with `_test.go`). Going forward this will tremendously increase the stability and decrease the maintaince burden of vim-go. [gh-1157]
* Add new `g:go_updatetime` setting to change the default updatetime (which was hardcoded previously) [gh-1055] * 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] * Add new `g:go_template_use_pkg` setting to enable to use cwd as package name instead of basic template file [gh-1124]
@ -9,6 +35,8 @@ IMPROVEMENTS:
* Add `statusline` support for `:GoMetaLinter` [gh-1120] * 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] * Quickfix and Location lists contain now a descriptive title (requires at least Vim `7.4.2200`)[gh-1004]
* Check `go env GOPATH` as well for `:GoInstallBinaries` as Go has now a default path for GOPATH ("~/go")starting with 1.8 [gh-1152]
* `:GoDocBrowser` now also works on import paths [gh-1174]
BUG FIXES: BUG FIXES:
@ -24,6 +52,22 @@ BUG FIXES:
* Fix referencing a non defined variable for async commands when bang (!) was used * 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 `: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] * Fix `:GoDefStack` to allow popping from jump list when buffer is modified [gh-1133]
* Improve internal defining of functions and referencing them for async operations [gh-1155]
* Fix `:GoMetaLinter` failing if `go_metalinter_command` is set. [gh-1160]
* Fix `:GoMetaLinter`'s `go_metalinter_deadline` setting for async mode [gh-1146]
BACKWARDS INCOMPATIBILITIES:
* The following syntax options are now disabled by default. If you're using them be sure to set them in your .vimrc [gh-1167]
```viml
g:go_highlight_array_whitespace_error
g:go_highlight_chan_whitespace_error
g:go_highlight_extra_types
g:go_highlight_space_tab_error
g:go_highlight_trailing_whitespace_error
```
## 1.10 (November 24, 2016) ## 1.10 (November 24, 2016)

View file

@ -0,0 +1,7 @@
all: test
test:
@echo "==> Running tests"
@./scripts/test.sh
.PHONY: all test

View file

@ -1,4 +1,4 @@
# vim-go # vim-go [![Build Status](http://img.shields.io/travis/fatih/vim-go.svg?style=flat-square)](https://travis-ci.org/fatih/vim-go)
<p align="center"> <p align="center">
<img style="float: right;" src="assets/vim-go.png" alt="Vim-go logo"/> <img style="float: right;" src="assets/vim-go.png" alt="Vim-go logo"/>
@ -137,43 +137,43 @@ current buffer. You can also open the definition/declaration, in a new vertical,
horizontal, or tab, for the word under your cursor: horizontal, or tab, for the word under your cursor:
```vim ```vim
au FileType go nmap <Leader>ds <Plug>(go-def-split) au FileType go nmap <leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical) au FileType go nmap <leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab) au FileType go nmap <leader>dt <Plug>(go-def-tab)
``` ```
Open the relevant Godoc for the word under the cursor with `<leader>gd` or open Open the relevant Godoc for the word under the cursor with `<leader>gd` or open
it vertically with `<leader>gv` it vertically with `<leader>gv`
```vim ```vim
au FileType go nmap <Leader>gd <Plug>(go-doc) au FileType go nmap <leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical) au FileType go nmap <leader>gv <Plug>(go-doc-vertical)
``` ```
Or open the Godoc in browser Or open the Godoc in browser
```vim ```vim
au FileType go nmap <Leader>gb <Plug>(go-doc-browser) au FileType go nmap <leader>gb <Plug>(go-doc-browser)
``` ```
Show a list of interfaces which is implemented by the type under your cursor Show a list of interfaces which is implemented by the type under your cursor
with `<leader>s` with `<leader>s`
```vim ```vim
au FileType go nmap <Leader>s <Plug>(go-implements) au FileType go nmap <leader>s <Plug>(go-implements)
``` ```
Show type info for the word under your cursor with `<leader>i` (useful if you Show type info for the word under your cursor with `<leader>i` (useful if you
have disabled auto showing type info via `g:go_auto_type_info`) have disabled auto showing type info via `g:go_auto_type_info`)
```vim ```vim
au FileType go nmap <Leader>i <Plug>(go-info) au FileType go nmap <leader>i <Plug>(go-info)
``` ```
Rename the identifier under the cursor to a new name Rename the identifier under the cursor to a new name
```vim ```vim
au FileType go nmap <Leader>e <Plug>(go-rename) au FileType go nmap <leader>e <Plug>(go-rename)
``` ```
More `<Plug>` mappings can be seen with `:he go-mappings`. Also these are just More `<Plug>` mappings can be seen with `:he go-mappings`. Also these are just
@ -245,8 +245,8 @@ Run `:GoRun` in a new tab, horizontal split or vertical split terminal
```vim ```vim
au FileType go nmap <leader>rt <Plug>(go-run-tab) au FileType go nmap <leader>rt <Plug>(go-run-tab)
au FileType go nmap <Leader>rs <Plug>(go-run-split) au FileType go nmap <leader>rs <Plug>(go-run-split)
au FileType go nmap <Leader>rv <Plug>(go-run-vertical) au FileType go nmap <leader>rv <Plug>(go-run-vertical)
``` ```
By default new terminals are opened in a vertical split. To change it By default new terminals are opened in a vertical split. To change it
@ -288,6 +288,31 @@ information. It includes
section](https://github.com/fatih/vim-go/wiki/FAQ-Troubleshooting), and many section](https://github.com/fatih/vim-go/wiki/FAQ-Troubleshooting), and many
other [various pieces](https://github.com/fatih/vim-go/wiki) of information. other [various pieces](https://github.com/fatih/vim-go/wiki) of information.
## Development & Testing
vim-go supports now test files. Please check `autoload` folder for examples. If
you add a new feature be sure you also include the `_test.vim` file next to the
script. Test functions should be starting with `Test_`, example:
```viml
function Test_run_fmt()
call assert_equal(expected, actual)
...
endfunction
```
You can locally test it by running:
```
make
```
This will run all tests and print either `PASS` or `FAIL` to indicate the final
status of all tests.
Additionally, each new pull request will trigger a new Travis-ci job.
## Donation ## Donation
People have asked for this for a long time, now you can be a fully supporter by People have asked for this for a long time, now you can be a fully supporter by

View file

@ -1,13 +0,0 @@
#!/usr/bin/env rake
task :ci => [:dump, :test]
task :dump do
sh 'vim --version'
end
# Firstly, `bundle install; bundle install --deployment`
# Then, `rake test`
task :test do
sh 'bundle exec vim-flavor test'
end

View file

@ -25,7 +25,7 @@ function! go#asmfmt#Format() abort
" Write the current buffer to a tempfile. " Write the current buffer to a tempfile.
let l:tmpname = tempname() let l:tmpname = tempname()
call writefile(getline(1, '$'), l:tmpname) call writefile(go#util#GetLines(), l:tmpname)
" Run asmfmt. " Run asmfmt.
let path = go#path#CheckBinPath("asmfmt") let path = go#path#CheckBinPath("asmfmt")

View file

@ -32,8 +32,11 @@ function! go#cmd#Build(bang, ...) abort
\}) \})
return return
elseif has('nvim') elseif has('nvim')
if get(g:, 'go_echo_command_info', 1)
call go#util#EchoProgress("building dispatched ...")
endif
" if we have nvim, call it asynchronously and return early ;) " if we have nvim, call it asynchronously and return early ;)
call go#util#EchoProgress("building dispatched ...")
call go#jobcontrol#Spawn(a:bang, "build", args) call go#jobcontrol#Spawn(a:bang, "build", args)
return return
endif endif
@ -419,7 +422,7 @@ function s:cmd_job(args) abort
call go#statusline#Update(status_dir, status) call go#statusline#Update(status_dir, status)
endfunction endfunction
let a:args.error_info_cb = function('s:error_info_cb') let a:args.error_info_cb = funcref('s:error_info_cb')
let callbacks = go#job#Spawn(a:args) let callbacks = go#job#Spawn(a:args)
let start_options = { let start_options = {

View file

@ -1,18 +1,8 @@
let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix' let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix'
function! s:gocodeCurrentBuffer() abort function! s:gocodeCurrentBuffer() abort
let buf = getline(1, '$')
if &encoding != 'utf-8'
let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")')
endif
if &l:fileformat == 'dos'
" XXX: line2byte() depend on 'fileformat' option.
" so if fileformat is 'dos', 'buf' must include '\r'.
let buf = map(buf, 'v:val."\r"')
endif
let file = tempname() let file = tempname()
call writefile(buf, file) call writefile(go#util#GetLines(), file)
return file return file
endfunction endfunction

View file

@ -283,7 +283,7 @@ function s:coverage_job(args)
call go#statusline#Update(status_dir, status) call go#statusline#Update(status_dir, status)
endfunction endfunction
let a:args.error_info_cb = function('s:error_info_cb') let a:args.error_info_cb = funcref('s:error_info_cb')
let callbacks = go#job#Spawn(a:args) let callbacks = go#job#Spawn(a:args)
let start_options = { let start_options = {

View file

@ -16,7 +16,7 @@ function! go#def#Jump(mode) abort
if &modified if &modified
" Write current unsaved buffer to a temp file and use the modified content " Write current unsaved buffer to a temp file and use the modified content
let l:tmpname = tempname() let l:tmpname = tempname()
call writefile(getline(1, '$'), l:tmpname) call writefile(go#util#GetLines(), l:tmpname)
let fname = l:tmpname let fname = l:tmpname
endif endif
@ -41,8 +41,7 @@ function! go#def#Jump(mode) abort
let stdin_content = "" let stdin_content = ""
if &modified if &modified
let sep = go#util#LineEnding() let content = join(go#util#GetLines(), "\n")
let content = join(getline(1, '$'), sep)
let stdin_content = fname . "\n" . strlen(content) . "\n" . content let stdin_content = fname . "\n" . strlen(content) . "\n" . content
call add(cmd, "-modified") call add(cmd, "-modified")
endif endif
@ -87,7 +86,7 @@ function! go#def#Jump(mode) abort
return return
endif endif
call s:jump_to_declaration(out, a:mode, bin_name) call go#def#jump_to_declaration(out, a:mode, bin_name)
let $GOPATH = old_gopath let $GOPATH = old_gopath
endfunction endfunction
@ -96,10 +95,10 @@ function! s:jump_to_declaration_cb(mode, bin_name, job, exit_status, data) abort
return return
endif endif
call s:jump_to_declaration(a:data[0], a:mode, a:bin_name) call go#def#jump_to_declaration(a:data[0], a:mode, a:bin_name)
endfunction endfunction
function! s:jump_to_declaration(out, mode, bin_name) abort function! go#def#jump_to_declaration(out, mode, bin_name) abort
let final_out = a:out let final_out = a:out
if a:bin_name == "godef" if a:bin_name == "godef"
" append the type information to the same line so our we can parse it. " append the type information to the same line so our we can parse it.
@ -299,7 +298,7 @@ function s:def_job(args) abort
" do not print anything during async definition search&jump " do not print anything during async definition search&jump
endfunction endfunction
let a:args.error_info_cb = function('s:error_info_cb') let a:args.error_info_cb = funcref('s:error_info_cb')
let callbacks = go#job#Spawn(a:args) let callbacks = go#job#Spawn(a:args)
let start_options = { let start_options = {

View file

@ -0,0 +1,32 @@
func Test_jump_to_declaration_guru()
let file_name = "test-fixtures/def/jump.go"
let lnum = 5
let col = 6
let out = printf("%s:%d:%d: defined here as func main", file_name, lnum, col)
let bin_name = "guru"
call go#def#jump_to_declaration(out, "", bin_name)
call assert_equal(file_name, bufname("%"))
call assert_equal(lnum, getcurpos()[1])
call assert_equal(col, getcurpos()[2])
endfunc
func Test_jump_to_declaration_godef()
let file_name = "test-fixtures/def/jump.go"
let lnum = 5
let col = 6
" note that the output of godef has two lines
let out = printf("%s:%d:%d\ndefined here as func main", file_name, lnum, col)
let bin_name = "godef"
call go#def#jump_to_declaration(out, "", bin_name)
call assert_equal(file_name, bufname("%"))
call assert_equal(lnum, getcurpos()[1])
call assert_equal(col, getcurpos()[2])
endfunc
" vim: sw=2 ts=2 et

View file

@ -31,12 +31,11 @@ function! go#doc#OpenBrowser(...) abort
let import = out["import"] let import = out["import"]
let name = out["name"] let name = out["name"]
let decl = out["decl"]
" if import is empty, it means we selected a package name
if import ==# "" let godoc_url = "https://godoc.org/" . import
let godoc_url = "https://godoc.org/" . name if decl !~ "^package"
else let godoc_url .= "#" . name
let godoc_url = "https://godoc.org/" . import . "#" . name
endif endif
echo godoc_url echo godoc_url
@ -153,8 +152,7 @@ function! s:gogetdoc(json) abort
" file size followed by newline " file size followed by newline
" file contents " file contents
let in = "" let in = ""
let sep = go#util#LineEnding() let content = join(go#util#GetLines(), "\n")
let content = join(getline(1, '$'), sep)
let in = fname . "\n" . strlen(content) . "\n" . content let in = fname . "\n" . strlen(content) . "\n" . content
let command .= " -modified" let command .= " -modified"
let out = go#util#System(command, in) let out = go#util#System(command, in)

View file

@ -2,26 +2,8 @@
" Use of this source code is governed by a BSD-style " Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file. " license that can be found in the LICENSE file.
" "
" fmt.vim: Vim command to format Go files with gofmt. " fmt.vim: Vim command to format Go files with gofmt (and gofmt compatible
" " toorls, such as goimports).
" This filetype plugin add a new commands for go buffers:
"
" :Fmt
"
" Filter the current Go buffer through gofmt.
" It tries to preserve cursor position and avoids
" replacing the buffer with stderr output.
"
" Options:
"
" g:go_fmt_command [default="gofmt"]
"
" Flag naming the gofmt executable to use.
"
" g:go_fmt_autosave [default=1]
"
" Flag to auto call :Fmt when saved file
"
if !exists("g:go_fmt_command") if !exists("g:go_fmt_command")
let g:go_fmt_command = "gofmt" let g:go_fmt_command = "gofmt"
@ -67,6 +49,13 @@ function! go#fmt#Format(withGoimport) abort
catch catch
let l:curw = winsaveview() let l:curw = winsaveview()
endtry endtry
" save our undo file to be restored after we are done. This is needed to
" prevent an additional undo jump due to BufWritePre auto command and also
" restore 'redo' history because it's getting being destroyed every
" BufWritePre
let tmpundofile = tempname()
exe 'wundo! ' . tmpundofile
else else
" Save cursor position and many other things. " Save cursor position and many other things.
let l:curw = winsaveview() let l:curw = winsaveview()
@ -74,135 +63,32 @@ function! go#fmt#Format(withGoimport) abort
" Write current unsaved buffer to a temp file " Write current unsaved buffer to a temp file
let l:tmpname = tempname() let l:tmpname = tempname()
call writefile(getline(1, '$'), l:tmpname) call writefile(go#util#GetLines(), l:tmpname)
if g:go_fmt_experimental == 1
" save our undo file to be restored after we are done. This is needed to
" prevent an additional undo jump due to BufWritePre auto command and also
" restore 'redo' history because it's getting being destroyed every
" BufWritePre
let tmpundofile = tempname()
exe 'wundo! ' . tmpundofile
endif
" get the command first so we can test it
let bin_name = g:go_fmt_command
if a:withGoimport == 1
let bin_name = g:go_goimports_bin
endif
" check if the user has installed command binary.
" For example if it's goimports, let us check if it's installed,
" if not the user get's a warning via go#path#CheckBinPath()
let bin_path = go#path#CheckBinPath(bin_name)
if empty(bin_path)
return
endif
if bin_name != "gofmt"
" change GOPATH too, so goimports can pick up the correct library
let old_gopath = $GOPATH
let $GOPATH = go#path#Detect()
endif
" populate the final command with user based fmt options
let command = bin_path . ' -w '
if a:withGoimport != 1
let command = command . g:go_fmt_options
endif
if bin_name == "goimports"
if !exists('b:goimports_vendor_compatible')
let out = go#util#System(bin_path . " --help")
if out !~ "-srcdir"
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
endif
if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible
let ssl_save = &shellslash
set noshellslash
let command = command . '-srcdir ' . shellescape(expand("%:p"))
let &shellslash = ssl_save
endif
endif
" execute our command...
if go#util#IsWin() if go#util#IsWin()
let l:tmpname = tr(l:tmpname, '\', '/') let l:tmpname = tr(l:tmpname, '\', '/')
endif endif
let out = go#util#System(command . " " . l:tmpname)
if bin_name != "gofmt" let bin_name = g:go_fmt_command
let $GOPATH = old_gopath if a:withGoimport == 1
let bin_name = g:go_goimports_bin
endif endif
let l:listtype = "locationlist" let out = go#fmt#run(bin_name, l:tmpname, expand('%'))
"if there is no error on the temp file replace the output with the current
"file (if this fails, we can always check the outputs first line with:
"splitted =~ 'package \w\+')
if go#util#ShellError() == 0 if go#util#ShellError() == 0
" remove undo point caused via BufWritePre call go#fmt#update_file(l:tmpname, expand('%'))
try | silent undojoin | catch | endtry
" 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
" clean up previous location list, but only if it's due to fmt
if exists('b:got_fmt_error') && b:got_fmt_error
let b:got_fmt_error = 0
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
endif
elseif g:go_fmt_fail_silently == 0 elseif g:go_fmt_fail_silently == 0
let splitted = split(out, '\n') let errors = s:parse_errors(out)
"otherwise get the errors and put them to location list call s:show_errors(errors)
let errors = []
for line in splitted
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
if !empty(tokens)
call add(errors, {"filename": @%,
\"lnum": tokens[2],
\"col": tokens[3],
\"text": tokens[4]})
endif
endfor
if empty(errors)
% | " Couldn't detect gofmt error format, output errors
endif
if !empty(errors)
call go#list#Populate(l:listtype, errors, 'Format')
echohl Error | echomsg "Gofmt returned error" | echohl None
endif
let b:got_fmt_error = 1
call go#list#Window(l:listtype, len(errors))
" We didn't use the temp file, so clean up
call delete(l:tmpname)
endif endif
" We didn't use the temp file, so clean up
call delete(l:tmpname)
if g:go_fmt_experimental == 1 if g:go_fmt_experimental == 1
" restore our undo history " restore our undo history
silent! exe 'rundo ' . tmpundofile silent! exe 'rundo ' . tmpundofile
call delete(tmpundofile) call delete(tmpundofile)
endif
if g:go_fmt_experimental == 1
" Restore our cursor/windows positions, folds, etc. " Restore our cursor/windows positions, folds, etc.
if empty(l:curw) if empty(l:curw)
silent! loadview silent! loadview
@ -215,6 +101,134 @@ function! go#fmt#Format(withGoimport) abort
endif endif
endfunction endfunction
" update_file updates the target file with the given formatted source
function! go#fmt#update_file(source, target)
" remove undo point caused via BufWritePre
try | silent undojoin | catch | endtry
let old_fileformat = &fileformat
if exists("*getfperm")
" save file permissions
let original_fperm = getfperm(a:target)
endif
call rename(a:source, a:target)
" restore file permissions
if exists("*setfperm") && original_fperm != ''
call setfperm(a:target , original_fperm)
endif
" reload buffer to reflect latest changes
silent! edit!
let &fileformat = old_fileformat
let &syntax = &syntax
" clean up previous location list
let l:listtype = "locationlist"
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
endfunction
" run runs the gofmt/goimport command for the given source file and returns
" the the output of the executed command. Target is the real file to be
" formated.
function! go#fmt#run(bin_name, source, target)
let cmd = s:fmt_cmd(a:bin_name, a:source, a:target)
if cmd[0] == "goimports"
" change GOPATH too, so goimports can pick up the correct library
let old_gopath = $GOPATH
let $GOPATH = go#path#Detect()
endif
let command = join(cmd, " ")
" execute our command...
let out = go#util#System(command)
if cmd[0] == "goimports"
let $GOPATH = old_gopath
endif
return out
endfunction
" fmt_cmd returns a dict that contains the command to execute gofmt (or
" goimports). args is dict with
function! s:fmt_cmd(bin_name, source, target)
" check if the user has installed command binary.
" For example if it's goimports, let us check if it's installed,
" if not the user get's a warning via go#path#CheckBinPath()
let bin_path = go#path#CheckBinPath(a:bin_name)
if empty(bin_path)
return
endif
" start constructing the command
let cmd = [bin_path]
call add(cmd, "-w")
if a:bin_name != "goimports"
call extend(cmd, split(g:go_fmt_options, " "))
else
" lazy check if goimports support `-srcdir`. We should eventually remove
" this in the future
if !exists('b:goimports_vendor_compatible')
let out = go#util#System(bin_path . " --help")
if out !~ "-srcdir"
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
endif
if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible
let ssl_save = &shellslash
set noshellslash
call extend(cmd, ["-srcdir", shellescape(fnamemodify(a:target, ":p"))])
let &shellslash = ssl_save
endif
endif
call add(cmd, a:source)
return cmd
endfunction
" parse_errors parses the given errors and returns a list of parsed errors
function! s:parse_errors(content) abort
let splitted = split(a:content, '\n')
" list of errors to be put into location list
let errors = []
for line in splitted
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
if !empty(tokens)
call add(errors,{
\"lnum": tokens[2],
\"col": tokens[3],
\"text": tokens[4],
\ })
endif
endfor
return errors
endfunction
" show_errors opens a location list and shows the given errors. If the given
" errors is empty, it closes the the location list
function! s:show_errors(errors) abort
let l:listtype = "locationlist"
if !empty(a:errors)
call go#list#Populate(l:listtype, a:errors, 'Format')
echohl Error | echomsg "Gofmt returned error" | echohl None
endif
" this closes the window if there are no errors or it opens
" it if there is any
call go#list#Window(l:listtype, len(a:errors))
endfunction
function! go#fmt#ToggleFmtAutoSave() abort function! go#fmt#ToggleFmtAutoSave() abort
if get(g:, "go_fmt_autosave", 1) if get(g:, "go_fmt_autosave", 1)
let g:go_fmt_autosave = 0 let g:go_fmt_autosave = 0
@ -225,4 +239,5 @@ function! go#fmt#ToggleFmtAutoSave() abort
let g:go_fmt_autosave = 1 let g:go_fmt_autosave = 1
call go#util#EchoProgress("auto fmt enabled") call go#util#EchoProgress("auto fmt enabled")
endfunction endfunction
" vim: sw=2 ts=2 et " vim: sw=2 ts=2 et

View file

@ -0,0 +1,31 @@
func Test_run_fmt()
let actual_file = tempname()
call writefile(readfile("test-fixtures/fmt/hello.go"), actual_file)
let expected = join(readfile("test-fixtures/fmt/hello_golden.go"), "\n")
" run our code
call go#fmt#run("gofmt", actual_file, "test-fixtures/fmt/hello.go")
" this should now contain the formatted code
let actual = join(readfile(actual_file), "\n")
call assert_equal(expected, actual)
endfunc
func Test_update_file()
let expected = join(readfile("test-fixtures/fmt/hello_golden.go"), "\n")
let source_file = tempname()
call writefile(readfile("test-fixtures/fmt/hello_golden.go"), source_file)
let target_file = tempname()
call writefile([""], target_file)
" update_file now
call go#fmt#update_file(source_file, target_file)
" this should now contain the formatted code
let actual = join(readfile(target_file), "\n")
call assert_equal(expected, actual)
endfunc

View file

@ -1,6 +1,6 @@
" guru.vim -- Vim integration for the Go guru. " guru.vim -- Vim integration for the Go guru.
" guru_cmd returns a dict that contains the command to execute guru. option " guru_cmd returns a dict that contains the command to execute guru. args
" is dict with following options: " is dict with following options:
" mode : guru mode, such as 'implements' " mode : guru mode, such as 'implements'
" format : output format, either 'plain' or 'json' " format : output format, either 'plain' or 'json'
@ -34,10 +34,8 @@ function! s:guru_cmd(args) range abort
let cmd = [bin_path] let cmd = [bin_path]
let filename = fnamemodify(expand("%"), ':p:gs?\\?/?') let filename = fnamemodify(expand("%"), ':p:gs?\\?/?')
let stdin_content = ""
if &modified if &modified
let sep = go#util#LineEnding() let content = join(go#util#GetLines(), "\n")
let content = join(getline(1, '$'), sep )
let result.stdin_content = filename . "\n" . strlen(content) . "\n" . content let result.stdin_content = filename . "\n" . strlen(content) . "\n" . content
call add(cmd, "-modified") call add(cmd, "-modified")
endif endif
@ -127,7 +125,7 @@ function! s:sync_guru(args) abort
" run, forrest run!!! " run, forrest run!!!
let command = join(result.cmd, " ") let command = join(result.cmd, " ")
if &modified if has_key(result, 'stdin_content')
let out = go#util#System(command, result.stdin_content) let out = go#util#System(command, result.stdin_content)
else else
let out = go#util#System(command) let out = go#util#System(command)
@ -198,10 +196,10 @@ function! s:async_guru(args) abort
endfunction endfunction
let start_options = { let start_options = {
\ 'close_cb': function("s:close_cb"), \ 'close_cb': funcref("s:close_cb"),
\ } \ }
if &modified if has_key(result, 'stdin_content')
let l:tmpname = tempname() let l:tmpname = tempname()
call writefile(split(result.stdin_content, "\n"), l:tmpname, "b") call writefile(split(result.stdin_content, "\n"), l:tmpname, "b")
let l:start_options.in_io = "file" let l:start_options.in_io = "file"
@ -543,7 +541,7 @@ function! go#guru#ClearSameIds() abort
endfor endfor
" remove the autocmds we defined " remove the autocmds we defined
if exists("#BufWinEnter<buffer>") if exists("#BufWinEnter#<buffer>")
autocmd! BufWinEnter <buffer> autocmd! BufWinEnter <buffer>
endif endif
endfunction endfunction
@ -635,7 +633,7 @@ function! go#guru#Tags(...) abort
if !exists('g:go_guru_tags') if !exists('g:go_guru_tags')
call go#util#EchoSuccess("guru tags is not set") call go#util#EchoSuccess("guru tags is not set")
else else
call go#util#EchoSuccess("current guru tags: ". a:1) call go#util#EchoSuccess("current guru tags: ". g:go_guru_tags)
endif endif
endfunction endfunction

View file

@ -38,6 +38,16 @@ endfunction
" GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the " GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the
" current files folder. " current files folder.
function! s:spawn(bang, desc, args) abort function! s:spawn(bang, desc, args) abort
let status_type = a:args[0]
let status_dir = expand('%:p:h')
let started_at = reltime()
call go#statusline#Update(status_dir, {
\ 'desc': "current status",
\ 'type': status_type,
\ 'state': "started",
\})
let job = { let job = {
\ 'desc': a:desc, \ 'desc': a:desc,
\ 'bang': a:bang, \ 'bang': a:bang,
@ -49,6 +59,9 @@ function! s:spawn(bang, desc, args) abort
\ 'on_stdout': function('s:on_stdout'), \ 'on_stdout': function('s:on_stdout'),
\ 'on_stderr': function('s:on_stderr'), \ 'on_stderr': function('s:on_stderr'),
\ 'on_exit' : function('s:on_exit'), \ 'on_exit' : function('s:on_exit'),
\ 'status_type' : status_type,
\ 'status_dir' : status_dir,
\ 'started_at' : started_at,
\ } \ }
" modify GOPATH if needed " modify GOPATH if needed
@ -91,6 +104,23 @@ endfunction
" on_stderr handler. If there are no errors and a quickfix window is open, " on_stderr handler. If there are no errors and a quickfix window is open,
" it'll be closed. " it'll be closed.
function! s:on_exit(job_id, exit_status, event) dict abort function! s:on_exit(job_id, exit_status, event) dict abort
let status = {
\ 'desc': 'last status',
\ 'type': self.status_type,
\ 'state': "success",
\ }
if a:exit_status
let status.state = "failed"
endif
let elapsed_time = reltimestr(reltime(self.started_at))
" strip whitespace
let elapsed_time = substitute(elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '')
let status.state .= printf(" (%ss)", elapsed_time)
call go#statusline#Update(self.status_dir, status)
let std_combined = self.stderr + self.stdout let std_combined = self.stderr + self.stdout
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
@ -105,14 +135,20 @@ function! s:on_exit(job_id, exit_status, event) dict abort
call go#list#Window(l:listtype) call go#list#Window(l:listtype)
let self.state = "SUCCESS" let self.state = "SUCCESS"
call go#util#EchoSuccess("SUCCESS")
if get(g:, 'go_echo_command_info', 1)
call go#util#EchoSuccess("[" . self.status_type . "] SUCCESS")
endif
execute cd . fnameescape(dir) execute cd . fnameescape(dir)
return return
endif endif
let self.state = "FAILED" let self.state = "FAILED"
call go#util#EchoError("FAILED")
if get(g:, 'go_echo_command_info', 1)
call go#util#EchoError("[" . self.status_type . "] FAILED")
endif
let errors = go#tool#ParseErrors(std_combined) let errors = go#tool#ParseErrors(std_combined)
let errors = go#tool#FilterValids(errors) let errors = go#tool#FilterValids(errors)
@ -148,13 +184,13 @@ endfunction
" on_stdout is the stdout handler for jobstart(). It collects the output of " on_stdout is the stdout handler for jobstart(). It collects the output of
" stderr and stores them to the jobs internal stdout list. " stderr and stores them to the jobs internal stdout list.
function! s:on_stdout(job_id, data) dict abort function! s:on_stdout(job_id, data, event) dict abort
call extend(self.stdout, a:data) call extend(self.stdout, a:data)
endfunction endfunction
" on_stderr is the stderr handler for jobstart(). It collects the output of " on_stderr is the stderr handler for jobstart(). It collects the output of
" stderr and stores them to the jobs internal stderr list. " stderr and stores them to the jobs internal stderr list.
function! s:on_stderr(job_id, data) dict abort function! s:on_stderr(job_id, data, event) dict abort
call extend(self.stderr, a:data) call extend(self.stderr, a:data)
endfunction endfunction

View file

@ -10,10 +10,6 @@ if !exists("g:go_metalinter_enabled")
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck'] let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
endif endif
if !exists("g:go_metalinter_deadline")
let g:go_metalinter_deadline = "5s"
endif
if !exists("g:go_golint_bin") if !exists("g:go_golint_bin")
let g:go_golint_bin = "golint" let g:go_golint_bin = "golint"
endif endif
@ -48,16 +44,33 @@ function! go#lint#Gometa(autosave, ...) abort
let cmd += [expand('%:p:h')] let cmd += [expand('%:p:h')]
else else
" the user wants something else, let us use it. " the user wants something else, let us use it.
let cmd += [split(g:go_metalinter_command, " ")] let cmd += split(g:go_metalinter_command, " ")
endif endif
" gometalinter has a default deadline of 5 seconds.
"
" For async mode (s:lint_job), we want to override the default deadline only
" if we have a deadline configured.
"
" For sync mode (go#tool#ExecuteInDir), always explicitly pass the 5 seconds
" deadline if there is no other deadline configured. If a deadline is
" configured, then use it.
" Call gometalinter asynchronously.
if go#util#has_job() && has('lambda') if go#util#has_job() && has('lambda')
let deadline = get(g:, 'go_metalinter_deadline', 0)
if deadline != 0
let cmd += ["--deadline=" . deadline]
endif
call s:lint_job({'cmd': cmd}) call s:lint_job({'cmd': cmd})
return return
endif endif
" we add deadline only for sync mode " We're calling gometalinter synchronously.
let cmd += ["--deadline=" . g:go_metalinter_deadline]
let cmd += ["--deadline=" . get(g:, 'go_metalinter_deadline', "5s")]
if a:autosave if a:autosave
" include only messages for the active buffer " include only messages for the active buffer
let cmd += ["--include='^" . expand('%:p') . ".*$'"] let cmd += ["--include='^" . expand('%:p') . ".*$'"]
@ -283,8 +296,8 @@ function s:lint_job(args)
endfunction endfunction
let start_options = { let start_options = {
\ 'callback': function("s:callback"), \ 'callback': funcref("s:callback"),
\ 'close_cb': function("s:close_cb"), \ 'close_cb': funcref("s:close_cb"),
\ } \ }
call job_start(a:args.cmd, start_options) call job_start(a:args.cmd, start_options)

View file

@ -110,6 +110,9 @@ function! go#path#Detect() abort
endif endif
endif endif
" Fix up the case where initial $GOPATH is empty,
" and we end up with a trailing :
let gopath = substitute(gopath, ":$", "", "")
return gopath return gopath
endfunction endfunction

View file

@ -85,8 +85,8 @@ function s:rename_job(args)
endfunction endfunction
let start_options = { let start_options = {
\ 'callback': function("s:callback"), \ 'callback': funcref("s:callback"),
\ 'close_cb': function("s:close_cb"), \ 'close_cb': funcref("s:close_cb"),
\ } \ }
" modify GOPATH if needed " modify GOPATH if needed

View file

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}

View file

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}

View file

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}

View file

@ -20,7 +20,7 @@ function! go#textobj#Function(mode) abort
if &modified if &modified
" Write current unsaved buffer to a temp file and use the modified content " Write current unsaved buffer to a temp file and use the modified content
let l:tmpname = tempname() let l:tmpname = tempname()
call writefile(getline(1, '$'), l:tmpname) call writefile(go#util#GetLines(), l:tmpname)
let fname = l:tmpname let fname = l:tmpname
endif endif
@ -107,7 +107,7 @@ function! go#textobj#FunctionJump(mode, direction) abort
if &modified if &modified
" Write current unsaved buffer to a temp file and use the modified content " Write current unsaved buffer to a temp file and use the modified content
let l:tmpname = tempname() let l:tmpname = tempname()
call writefile(getline(1, '$'), l:tmpname) call writefile(go#util#GetLines(), l:tmpname)
let fname = l:tmpname let fname = l:tmpname
endif endif

View file

@ -305,4 +305,17 @@ function! go#util#EchoInfo(msg)
redraw | echohl Debug | echom "vim-go: " . a:msg | echohl None redraw | echohl Debug | echom "vim-go: " . a:msg | echohl None
endfunction endfunction
function! go#util#GetLines()
let buf = getline(1, '$')
if &encoding != 'utf-8'
let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")')
endif
if &l:fileformat == 'dos'
" XXX: line2byte() depend on 'fileformat' option.
" so if fileformat is 'dos', 'buf' must include '\r'.
let buf = map(buf, 'v:val."\r"')
endif
return buf
endfunction
" vim: sw=2 ts=2 et " vim: sw=2 ts=2 et

View file

@ -1382,8 +1382,7 @@ For example here is how to set each to 30.
This option is Neovim only. Use it to change the behavior of the test 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 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 according to |'g:go_term_mode'|, otherwise it will run them in the background
just like `:GoBuild` and then display the status with just like `:GoBuild`. By default it is disabled.
|go#jobcontrol#Statusline()|. By default it is disabled.
> >
let g:go_term_enabled = 0 let g:go_term_enabled = 0
< <

View file

@ -151,6 +151,14 @@ if err != nil {
${0} ${0}
endsnippet endsnippet
# error log snippet
snippet errl "Error with log.Fatal(err)" !b
if err != nil {
log.Fatal(err)
}
${0}
endsnippet
# error multiple return # error multiple return
snippet errn, "Error return with two return values" !b snippet errn, "Error return with two return values" !b
if err != nil { if err != nil {

View file

@ -132,6 +132,13 @@ abbr if err != nil { ... }
t.Fatal(err) t.Fatal(err)
} }
# error snippet in log.Fatal
snippet errl
abbr if err != nil { ... }
if err != nil {
log.Fatal(err)
}
# error snippet with two return values # error snippet with two return values
snippet errn, snippet errn,
abbr if err != nil { return [...], err } abbr if err != nil { return [...], err }

View file

@ -32,7 +32,7 @@ command! -nargs=? -complete=dir GoPath call go#path#GoPath(<f-args>)
" target install directory. GoInstallBinaries doesn't install binaries if they " target install directory. GoInstallBinaries doesn't install binaries if they
" exist, to update current binaries pass 1 to the argument. " exist, to update current binaries pass 1 to the argument.
function! s:GoInstallBinaries(updateBinaries) function! s:GoInstallBinaries(updateBinaries)
if $GOPATH == "" if $GOPATH == "" && go#util#gopath() == ""
echohl Error echohl Error
echomsg "vim.go: $GOPATH is not set" echomsg "vim.go: $GOPATH is not set"
echohl None echohl None

View file

@ -0,0 +1,81 @@
let total_started = reltime()
" add vim-go the only plugin inside the runtimepath
let git_root_path = system("git rev-parse --show-toplevel | tr -d '\\n'")
exe 'set rtp=' . git_root_path
" source the passed test file
source %
" cd into the folder of the test file
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
execute cd . expand('%:p:h')
" initialize variables
let g:testname = expand('%')
let s:fail = 0
let s:done = 0
let s:logs = []
" get a list of all Test_ functions for the given file
set nomore
redir @q
silent function /^Test_
redir END
let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
" Iterate over all tests and execute them
for s:test in sort(s:tests)
let started = reltime()
call add(s:logs, printf("=== RUN %s", s:test[:-3]))
exe 'call ' . s:test
let elapsed_time = reltimestr(reltime(started))
let elapsed_time = substitute(elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '')
let s:done += 1
if len(v:errors) > 0
let s:fail += 1
call add(s:logs, printf("--- FAIL: %s (%ss)", s:test[:-3], elapsed_time))
call extend(s:logs, map(v:errors, '" ". v:val'))
" reset so we can capture failures of next test
let v:errors = []
else
call add(s:logs, printf("--- PASS: %s (%ss)", s:test[:-3], elapsed_time))
endif
endfor
" pop out into the scripts folder
execute cd . fnameescape(dir)
" create an empty fail to indicate that the test failed
if s:fail > 0
split FAILED
write
endif
let total_elapsed_time = reltimestr(reltime(total_started))
let total_elapsed_time = substitute(total_elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '')
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test') . '. Total test time: '. total_elapsed_time .'s'
call add(s:logs, "")
call add(s:logs, message)
" store all error messages from within vim into test.log
redir > test.log
silent messages
redir END
" also store all internal messages from s:logs: as well
split test.log
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
call append(line('$'), s:logs)
write
" bye, bye!
qall!

View file

@ -1,77 +1,29 @@
#!/bin/bash -e #!/bin/bash
#
# Copyright 2012 The Go Authors. All rights reserved. set -e
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# Tests for import.vim.
cd $(dirname $0) cd $(dirname $0)
cat > base.go <<EOF # cleanup test.log
package test if [ -f "test.log" ]; then
rm test.log
fi
import ( if [ -f "FAILED" ]; then
"bytes" rm FAILED
"io" fi
"net"
"mycorp/foo" for test_file in ../autoload/go/*_test.vim
) do
EOF vim -u NONE -S runtest.vim $test_file
done
fail=0 if [ -f "test.log" ]; then
cat test.log
fi
# usage: test_one command pattern # if Failed exists, test failed
# Pattern is a PCRE expression that will match across lines. if [ -f "FAILED" ]; then
test_one() {
echo 2>&1 -n "$1: "
vim -e -s -u /dev/null -U /dev/null --noplugin -c "source import.vim" \
-c "$1" -c 'wq! test.go' base.go
# ensure blank lines are treated correctly
if ! gofmt test.go | cmp test.go -; then
echo 2>&1 "gofmt conflict"
gofmt test.go | diff -u test.go - | sed "s/^/ /" 2>&1
fail=1
return
fi
if ! [[ $(cat test.go) =~ $2 ]]; then
echo 2>&1 "$2 did not match"
cat test.go | sed "s/^/ /" 2>&1
fail=1
return
fi
echo 2>&1 "ok"
}
# Tests for Import
test_one "Import baz" '"baz".*"bytes"'
test_one "Import io/ioutil" '"io".*"io/ioutil".*"net"'
test_one "Import myc" '"io".*"myc".*"net"' # prefix of a site prefix
test_one "Import nat" '"io".*"nat".*"net"'
test_one "Import net/http" '"net".*"net/http".*"mycorp/foo"'
test_one "Import zoo" '"net".*"zoo".*"mycorp/foo"'
test_one "Import mycorp/bar" '"net".*"mycorp/bar".*"mycorp/foo"'
test_one "Import mycorp/goo" '"net".*"mycorp/foo".*"mycorp/goo"'
# Tests for Drop
cat > base.go <<EOF
package test
import (
"foo"
"something"
"zoo"
)
EOF
test_one "Drop something" '\([^"]*"foo"[^"]*"zoo"[^"]*\)'
rm -f base.go test.go
if [ $fail -gt 0 ]; then
echo 2>&1 "FAIL" echo 2>&1 "FAIL"
exit 1 exit 1
fi fi

View file

@ -10,9 +10,7 @@
" let OPTION_NAME = 0 " let OPTION_NAME = 0
" in your ~/.vimrc file to disable particular options. You can also write: " in your ~/.vimrc file to disable particular options. You can also write:
" let OPTION_NAME = 1 " let OPTION_NAME = 1
" to enable particular options. " to enable particular options. At present, all options default to off:
" At present, all options default to on, except highlight of:
" functions, methods, structs, operators, build constraints and interfaces.
" "
" - go_highlight_array_whitespace_error " - go_highlight_array_whitespace_error
" Highlights white space after "[]". " Highlights white space after "[]".
@ -36,23 +34,23 @@ if exists("b:current_syntax")
endif endif
if !exists("g:go_highlight_array_whitespace_error") if !exists("g:go_highlight_array_whitespace_error")
let g:go_highlight_array_whitespace_error = 1 let g:go_highlight_array_whitespace_error = 0
endif endif
if !exists("g:go_highlight_chan_whitespace_error") if !exists("g:go_highlight_chan_whitespace_error")
let g:go_highlight_chan_whitespace_error = 1 let g:go_highlight_chan_whitespace_error = 0
endif endif
if !exists("g:go_highlight_extra_types") if !exists("g:go_highlight_extra_types")
let g:go_highlight_extra_types = 1 let g:go_highlight_extra_types = 0
endif endif
if !exists("g:go_highlight_space_tab_error") if !exists("g:go_highlight_space_tab_error")
let g:go_highlight_space_tab_error = 1 let g:go_highlight_space_tab_error = 0
endif endif
if !exists("g:go_highlight_trailing_whitespace_error") if !exists("g:go_highlight_trailing_whitespace_error")
let g:go_highlight_trailing_whitespace_error = 1 let g:go_highlight_trailing_whitespace_error = 0
endif endif
if !exists("g:go_highlight_operators") if !exists("g:go_highlight_operators")

View file

@ -1,191 +0,0 @@
" to execute, `rake test` on parent dir
describe 'go#coverage#Buffer'
before
new
let g:curdir = expand('<sfile>:p:h') . '/'
let g:srcpath = 't/fixtures/src/'
let g:sample = 'pkg1/sample.go'
let g:sampleabs = g:curdir . g:srcpath . 'pkg1/sample.go'
let g:samplecover = g:curdir . g:srcpath . 'pkg1/sample.out'
let g:go_gopath = g:curdir . 't/fixtures'
execute "badd " . g:srcpath . g:sample
execute "buffer " . bufnr("$")
end
after
execute "bprev"
execute "bdelete " . g:srcpath . g:sample
close!
end
it 'puts match to the list'
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 5
call go#coverlay#Clearlay()
Expect len(go#coverlay#matches()) == 0
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 5
call go#coverlay#Clearlay()
Expect len(go#coverlay#matches()) == 0
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 5
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 5
call go#coverlay#Clearlay()
Expect len(go#coverlay#matches()) == 0
end
end
describe 'go#coverage#Buffer fail'
before
new
let g:curdir = expand('<sfile>:p:h') . '/'
let g:srcpath = 't/fixtures/src/'
let g:sample = 'failtest/sample.go'
let g:sampletest = 'failtest/sample_test.go'
let g:sampleabs = g:curdir . g:srcpath . 'failtest/sample.go'
let g:go_gopath = g:curdir . 't/fixtures'
execute "badd " . g:srcpath . g:sample
execute "buffer " . bufnr("$")
end
after
execute "bprev"
execute "bdelete " . g:srcpath . g:sampletest
execute "bdelete " . g:srcpath . g:sample
end
it 'does nothing if test fail'
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 0
Expect len(getqflist()) == 1
end
end
describe 'go#coverage#Buffer build fail'
before
new
let g:curdir = expand('<sfile>:p:h') . '/'
let g:srcpath = 't/fixtures/src/'
let g:sample = 'buildfail/sample.go'
let g:sampleabs = g:curdir . g:srcpath . 'buildfail/sample.go'
let g:go_gopath = g:curdir . 't/fixtures'
execute "badd " . g:srcpath . g:sample
execute "buffer " . bufnr("$")
end
after
execute "bprev"
execute "bdelete " . g:srcpath . g:sample
end
it 'does nothing if test fail'
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 0
end
end
describe 'go#coverage#Buffer build test fail'
before
new
let g:curdir = expand('<sfile>:p:h') . '/'
let g:srcpath = 't/fixtures/src/'
let g:sample = 'buildtestfail/sample.go'
let g:sampleabs = g:curdir . g:srcpath . 'buildtestfail/sample.go'
let g:go_gopath = g:curdir . 't/fixtures'
execute "badd " . g:srcpath . g:sample
execute "buffer " . bufnr("$")
end
after
execute "bprev"
execute "bdelete " . g:srcpath . g:sample
end
it 'does nothing if test fail'
call go#coverage#Buffer(0)
Expect len(go#coverlay#matches()) == 0
end
end
describe 'go#coverlay#findbufnr'
before
new
let g:curdir = expand('<sfile>:p:h') . '/'
let g:srcpath = 't/fixtures/src/'
let g:sample = 'pkg1/sample.go'
let g:sample2 = 'pkg2/sample.go'
let g:sampleabs = g:curdir . g:srcpath . 'pkg1/sample.go'
let g:sampleabs2 = g:curdir . g:srcpath . 'pkg2/sample.go'
let g:go_gopath = g:curdir . 't/fixtures'
execute "badd " . g:srcpath . g:sample
execute "badd " . g:srcpath . g:sample2
end
after
execute "bdelete " . g:srcpath . g:sample2
execute "bdelete " . g:srcpath . g:sample
close!
end
it 'returns BUFNR if FILE is opened at BUFNR'
Expect go#coverlay#findbufnr('_' . g:sampleabs) == bufnr(g:sampleabs)
Expect go#coverlay#findbufnr(g:sample) == bufnr(g:sampleabs)
Expect go#coverlay#findbufnr('_' . g:sampleabs2) == bufnr(g:sampleabs2)
Expect go#coverlay#findbufnr(g:sample2) == bufnr(g:sampleabs2)
end
it 'returns -1 if FILE is not exists'
Expect go#coverlay#findbufnr('pkg1/NOTEXISTS.go') == -1
Expect go#coverlay#findbufnr('_' . g:curdir . g:srcpath . 'pkg1/NOTEXISTS.go') == -1
end
end
describe 'go#coverlay#isopenedon'
before
new
let g:curdir = expand('<sfile>:p:h') . '/'
let g:srcpath = 't/fixtures/src/'
let g:sample = 'pkg1/sample.go'
let g:sampleabs = g:curdir . g:srcpath . 'pkg1/sample.go'
let g:go_gopath = g:curdir . 't/fixtures'
execute "badd " . g:srcpath . g:sample
end
after
execute "bdelete " . g:srcpath . g:sample
close!
end
it 'returns 1 if FILE is opened at BUFNR'
Expect go#coverlay#isopenedon('_' . g:sampleabs, bufnr(g:sampleabs)) == 1
Expect go#coverlay#isopenedon(g:sample, bufnr(g:sampleabs)) == 1
end
it 'returns 0 if FILE is not opened at BUFNR'
Expect go#coverlay#isopenedon('_' . g:sampleabs, 42) == 0
Expect go#coverlay#isopenedon(g:sample, 42) == 0
end
it 'returns 0 if FILE is not exists'
Expect go#coverlay#isopenedon('_' . g:curdir . g:srcpath . 'pkg1/NOTEXISTS', bufnr(g:sampleabs)) == 0
Expect go#coverlay#isopenedon('pkg1/NOTEXISTS.go', bufnr(g:sampleabs)) == 0
end
end
describe 'go#coverlay#parsegocoverline'
it 'parses a go cover output line and returns as dict'
let d = {'file': 'f',"startline": "1", "startcol": "2", "endline": "3", "endcol": "4", "numstmt": "5", "cnt": "6"}
" file:startline.col,endline.col numstmt count
Expect go#coverlay#parsegocoverline("f:1.2,3.4 5 6") == d
end
end
describe 'go#coverlay#genmatch'
it 'generate mark pattern from cover data'
let d = {'file': 'f',"startline": "1", "startcol": "2", "endline": "3", "endcol": "4", "numstmt": "5", "cnt": "6"}
Expect go#coverlay#genmatch(d) == {'group': 'covered', "pattern": '\%>1l\_^\s\+\%<3l\|\%1l\_^\s\+\|\%3l\_^\s\+\(\}$\)\@!', "priority": 6}
let d = {'file': 'f',"startline": "1", "startcol": "2", "endline": "3", "endcol": "4", "numstmt": "5", "cnt": "0"}
Expect go#coverlay#genmatch(d) == {'group': 'uncover', "pattern": '\%>1l\_^\s\+\%<3l\|\%1l\_^\s\+\|\%3l\_^\s\+\(\}$\)\@!', "priority": 5}
end
end

View file

@ -1,13 +0,0 @@
// set gopath before
//go:generate go test --coverprofile=sample.out
// go1.5.3 example output:
// GOPATH=`pwd`/fixtures go test --coverprofile=log.out buildfail
// # buildfail
// /tmp/go-build264733986/buildfail/_test/_obj_test/sample.go:7: undefined: IT_SHOULD_BE_BUILD_FAILED
// /tmp/go-build264733986/buildfail/_test/_obj_test/sample.go:8: missing return at end of function
// FAIL buildfail [build failed]
package pkg
func Sample() int {
IT_SHOULD_BE_BUILD_FAILED
}

View file

@ -1,7 +0,0 @@
package pkg
import "testing"
func TestSample(t *testing.T) {
Sample()
}

View file

@ -1,7 +0,0 @@
// set gopath before
//go:generate go test --coverprofile=sample.out
package pkg
func Sample() int {
return 1
}

View file

@ -1,15 +0,0 @@
// go1.5.3 example output:
// GOPATH=`pwd`/fixtures go test --coverprofile=log.out buildtestfail
// # buildtestfail
// fixtures/src/buildtestfail/sample_test.go:14: undefined: IT_SHOULD_BE_BUILD_FAILED
// FAIL buildtestfail [build failed]
// echo $?
// 2
package pkg
import "testing"
func TestSample(t *testing.T) {
IT_SHOULD_BE_BUILD_FAILED
}

View file

@ -1,12 +0,0 @@
// set gopath before
//go:generate go test --coverprofile=sample.out
package pkg
func Sample() int {
if false {
return 0
} else if false {
return 0
}
return 1
}

View file

@ -1,8 +0,0 @@
package pkg
import "testing"
func TestSample(t *testing.T) {
Sample()
t.Fatal("itwillfail")
}

View file

@ -1,14 +0,0 @@
// set gopath before
//go:generate go test --coverprofile=sample.out
// go1.5.3 example output:
// GOPATH=`pwd`/fixtures go test --coverprofile=log.out parsefail
// # cover parsefail
// 2016/01/17 23:59:08 cover: /home/sey/vimfiles/_vim/bundle/vim-go-coverlay/t/fixtures/src/parsefail/sample.go: /home/sey/vimfiles/_vim/bundle/vim-go-coverlay/t/fixtures/src/parsefail/sample.go:10:1: expected declaration, found 'IDENT' PARSEFAIL
// FAIL parsefail [build failed]
// echo $?
// 2
package pkg
PARSEFAIL Sample() int {
return 0
}

View file

@ -1,7 +0,0 @@
package pkg
import "testing"
func TestSample(t *testing.T) {
Sample()
}

View file

@ -1,12 +0,0 @@
// set gopath before
//go:generate go test --coverprofile=sample.out
package pkg1
func Sample() int {
if false {
return 0
} else if false {
return 0
}
return 1
}

View file

@ -1,6 +0,0 @@
mode: set
pkg1/sample.go:5.19,6.11 1 1
pkg1/sample.go:11.2,11.10 1 1
pkg1/sample.go:6.11,8.3 1 0
pkg1/sample.go:8.3,8.18 1 1
pkg1/sample.go:8.18,10.3 1 0

View file

@ -1,7 +0,0 @@
package pkg1
import "testing"
func TestSample(t *testing.T) {
Sample()
}

View file

@ -2,6 +2,8 @@
Vim syntax highlighting for Pug (formerly Jade) templates. Vim syntax highlighting for Pug (formerly Jade) templates.
For best results consider using this with an (improved) HTML5 syntax plugin.
Installation Installation
------------ ------------

View file

@ -36,8 +36,9 @@ syntax keyword pugCommentTodo contained TODO FIXME XXX TBD
syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo
syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo keepend syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo keepend
syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->" contains=pugCommentTodo syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->" contains=pugCommentTodo
syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,pugHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent syn region pugAngular2 start="(" end=")" contains=htmlEvent
syn match pugClassChar "\." contained nextgroup=pugClass syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent
syn match pugClassChar "\." containedin=htmlTagName nextgroup=pugClass
syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar
syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId
syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent

View file

@ -131,14 +131,14 @@ Don't add useless placeholder default texts like:
``` ```
if (${1:condition}){ if (${1:condition}){
${2:some code here} ${0:some code here}
} }
``` ```
instead use: instead use:
``` ```
if (${1}){ if (${1}){
${2} ${0:${VISUAL}}
} }
``` ```
@ -148,6 +148,8 @@ get vim-dev plugin which has function completion
Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks
When the snippet can be used to wrap existing code leverage `${VISUAL}`
Open questions: Open questions:
What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ? What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ?
Which additional policies to add? Which additional policies to add?

View file

@ -77,23 +77,23 @@ endsnippet
# DATES # # DATES #
######### #########
snippet date "YYYY-MM-DD" w snippet date "YYYY-MM-DD" w
`date +%Y-%m-%d` `!v strftime("%F")`
endsnippet endsnippet
snippet ddate "Month DD, YYYY" w snippet ddate "Month DD, YYYY" w
`date +%B\ %d,\ %Y` `!v strftime("%b %d, %Y")`
endsnippet endsnippet
snippet diso "ISO format datetime" w snippet diso "ISO format datetime" w
`date +%Y-%m-%dT%H:%M:%S%:z` `!v strftime("%F %H:%M:%S%z")`
endsnippet endsnippet
snippet time "hh:mm" w snippet time "hh:mm" w
`date +%H:%M` `!v strftime("%H:%M")`
endsnippet endsnippet
snippet datetime "YYYY-MM-DD hh:mm" w snippet datetime "YYYY-MM-DD hh:mm" w
`date +%Y-%m-%d\ %H:%M` `!v strftime("%Y-%m-%d %H:%M")`
endsnippet endsnippet
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -5,7 +5,7 @@
priority -50 priority -50
snippet def "#define ..." snippet def "#define ..."
#define ${1} #define $1
endsnippet endsnippet
snippet #ifndef "#ifndef ... #define ... #endif" snippet #ifndef "#ifndef ... #define ... #endif"
@ -16,7 +16,7 @@ endsnippet
snippet #if "#if #endif" b snippet #if "#if #endif" b
#if ${1:0} #if ${1:0}
${VISUAL}${0} ${VISUAL}$0
#endif #endif
endsnippet endsnippet
@ -32,20 +32,20 @@ endsnippet
snippet main "main() (main)" snippet main "main() (main)"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
${VISUAL}${0} ${VISUAL}$0
return 0; return 0;
} }
endsnippet endsnippet
snippet for "for loop (for)" snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet fori "for int loop (fori)" snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
@ -60,7 +60,7 @@ else:
snip.rv = snip.c`} snip.rv = snip.c`}
#define $1 #define $1
${VISUAL}${0} ${VISUAL}$0
#endif /* end of include guard: $1 */ #endif /* end of include guard: $1 */
endsnippet endsnippet
@ -71,7 +71,7 @@ endsnippet
snippet eli "else if .. (eli)" snippet eli "else if .. (eli)"
else if (${1:/* condition */}) { else if (${1:/* condition */}) {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
@ -86,14 +86,14 @@ struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} {
endsnippet endsnippet
snippet fun "function" b snippet fun "function" b
${1:void} ${2:function_name}(${3}) ${1:void} ${2:function_name}($3)
{ {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet fund "function declaration" b snippet fund "function declaration" b
${1:void} ${2:function_name}(${3}); ${1:void} ${2:function_name}($3);
endsnippet endsnippet
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -12,7 +12,7 @@ snippet createClass "React define Class" b
${1:classname}Class = React.createClass ${1:classname}Class = React.createClass
displayName: "$1" displayName: "$1"
render: -> render: ->
${2} $2
$1 = React.createFactory($1) $1 = React.createFactory($1)
endsnippet endsnippet
@ -23,58 +23,58 @@ endsnippet
snippet propType "React propType (key/value)" b snippet propType "React propType (key/value)" b
${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} ${1:myVar}: React.PropTypes.${2:type}${3:.isRequired}
${4} $4
endsnippet endsnippet
snippet setState "React setState" b snippet setState "React setState" b
@setState @setState
${1:myvar}: ${2:myvalue} ${1:myvar}: ${2:myvalue}
${3} $3
endsnippet endsnippet
snippet getInitialState "React define getInitialState" b snippet getInitialState "React define getInitialState" b
getInitialState: -> getInitialState: ->
${1:myvar}: ${2:myvalue} ${1:myvar}: ${2:myvalue}
${3} $3
endsnippet endsnippet
snippet getDefaultProps "React define getDefaultProps" b snippet getDefaultProps "React define getDefaultProps" b
getDefaultProps: -> getDefaultProps: ->
${1:myvar}: ${2:myvalue} ${1:myvar}: ${2:myvalue}
${3} $3
endsnippet endsnippet
snippet componentWillMount "React define componentWillMount" b snippet componentWillMount "React define componentWillMount" b
componentWillMount: -> componentWillMount: ->
${1} $1
endsnippet endsnippet
snippet componentDidMount "React define componentDidMount" b snippet componentDidMount "React define componentDidMount" b
componentDidMount: -> componentDidMount: ->
${1} $1
endsnippet endsnippet
snippet componentWillReceiveProps "React define componentWillReceiveProps" b snippet componentWillReceiveProps "React define componentWillReceiveProps" b
componentWillReceiveProps: (nextProps) -> componentWillReceiveProps: (nextProps) ->
${1} $1
endsnippet endsnippet
snippet shouldComponentUpdate "React define shouldComponentUpdate" b snippet shouldComponentUpdate "React define shouldComponentUpdate" b
shouldComponentUpdate: (nextProps, nextState) -> shouldComponentUpdate: (nextProps, nextState) ->
${1} $1
endsnippet endsnippet
snippet componentWillUpdate "React define componentWillUpdate" b snippet componentWillUpdate "React define componentWillUpdate" b
componentWillUpdate: (nextProps, nextState) -> componentWillUpdate: (nextProps, nextState) ->
${1} $1
endsnippet endsnippet
snippet componentDidUpdate "React define componentDidUpdate" b snippet componentDidUpdate "React define componentDidUpdate" b
componentDidUpdate: (prevProps, prevState) -> componentDidUpdate: (prevProps, prevState) ->
${1} $1
endsnippet endsnippet
snippet componentWillUnmount "React define componentWillUnmount" b snippet componentWillUnmount "React define componentWillUnmount" b
componentWillUnmount: -> componentWillUnmount: ->
${1} $1
endsnippet endsnippet

View file

@ -27,7 +27,7 @@ endsnippet
snippet ns "namespace .. (namespace)" snippet ns "namespace .. (namespace)"
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
{ {
${VISUAL}${0} ${VISUAL}$0
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m} }${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
endsnippet endsnippet
@ -61,7 +61,7 @@ snippet cla "An entire .h generator" b
class ${1:`!v substitute(substitute(vim_snippets#Filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`} class ${1:`!v substitute(substitute(vim_snippets#Filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`}
{ {
private: private:
${3} $3
public: public:
$1(); $1();

View file

@ -0,0 +1,13 @@
priority -50
snippet "\b(de)?f" "def <name>..." r
def ${1:method_name}${2:(${3:*args})}
$0
end
endsnippet
snippet "\b(pde)?f" "private def <name>..." r
private def ${1:method_name}${2:(${3:*args})}
$0
end
endsnippet

View file

@ -259,7 +259,7 @@ finally
endsnippet endsnippet
snippet throw "throw" snippet throw "throw"
throw new ${1}Exception("${2}"); throw new $1Exception("$2");
endsnippet endsnippet

View file

@ -1,11 +1,5 @@
priority -50 priority -50
snippet . "selector { }"
$1 {
$0
}
endsnippet
snippet p "padding" snippet p "padding"
padding: ${1:0};$0 padding: ${1:0};$0
endsnippet endsnippet

View file

@ -23,7 +23,7 @@ mixin ${1:/*mixed_in*/} ${2:/*name*/};
endsnippet endsnippet
snippet new "new (new)" snippet new "new (new)"
new ${1}(${2}); new $1($2);
endsnippet endsnippet
snippet scpn "@safe const pure nothrow (scpn)" snippet scpn "@safe const pure nothrow (scpn)"
@ -98,7 +98,7 @@ endsnippet
snippet enf "enforce (enf)" b snippet enf "enforce (enf)" b
enforce(${1:/*condition*/}, enforce(${1:/*condition*/},
new ${2}Exception(${3:/*args*/})); new $2Exception(${3:/*args*/}));
endsnippet endsnippet
# Branches # Branches
@ -106,14 +106,14 @@ endsnippet
snippet if "if .. (if)" snippet if "if .. (if)"
if(${1:/*condition*/}) if(${1:/*condition*/})
{ {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet ife "if .. else (ife)" b snippet ife "if .. else (ife)" b
if(${1:/*condition*/}) if(${1:/*condition*/})
{ {
${2} $2
} }
else else
{ {
@ -124,14 +124,14 @@ endsnippet
snippet el "else (el)" b snippet el "else (el)" b
else else
{ {
${VISUAL}${1} ${VISUAL}$1
} }
endsnippet endsnippet
snippet elif "else if (elif)" b snippet elif "else if (elif)" b
else if(${1:/*condition*/}) else if(${1:/*condition*/})
{ {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
@ -139,10 +139,10 @@ snippet sw "switch (sw)"
switch(${1:/*var*/}) switch(${1:/*var*/})
{ {
case ${2:/*value*/}: case ${2:/*value*/}:
${3} $3
break; break;
case ${4:/*value*/}: case ${4:/*value*/}:
${5} $5
break; break;
${7:/*more cases*/} ${7:/*more cases*/}
default: default:
@ -154,10 +154,10 @@ snippet fsw "final switch (fsw)"
final switch(${1:/*var*/}) final switch(${1:/*var*/})
{ {
case ${2:/*value*/}: case ${2:/*value*/}:
${3} $3
break; break;
case ${4:/*value*/}: case ${4:/*value*/}:
${5} $5
break; break;
${7:/*more cases*/} ${7:/*more cases*/}
} }
@ -165,7 +165,7 @@ endsnippet
snippet case "case (case)" b snippet case "case (case)" b
case ${1:/*value*/}: case ${1:/*value*/}:
${2} $2
break; break;
endsnippet endsnippet
@ -178,42 +178,42 @@ endsnippet
snippet do "do while (do)" b snippet do "do while (do)" b
do do
{ {
${VISUAL}${2} ${VISUAL}$2
} while(${1:/*condition*/}); } while(${1:/*condition*/});
endsnippet endsnippet
snippet wh "while (wh)" b snippet wh "while (wh)" b
while(${1:/*condition*/}) while(${1:/*condition*/})
{ {
${VISUAL}${2} ${VISUAL}$2
} }
endsnippet endsnippet
snippet for "for (for)" b snippet for "for (for)" b
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{ {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet forever "forever (forever)" b snippet forever "forever (forever)" b
for(;;) for(;;)
{ {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet fore "foreach (fore)" snippet fore "foreach (fore)"
foreach(${1:/*elem*/}; ${2:/*range*/}) foreach(${1:/*elem*/}; ${2:/*range*/})
{ {
${VISUAL}${3} ${VISUAL}$3
} }
endsnippet endsnippet
snippet forif "foreach if (forif)" b snippet forif "foreach if (forif)" b
foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/}) foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/})
{ {
${VISUAL}${4} ${VISUAL}$4
} }
endsnippet endsnippet
@ -222,7 +222,7 @@ snippet in "in contract (in)" b
in in
{ {
assert(${1:/*condition*/}, "${2:error message}"); assert(${1:/*condition*/}, "${2:error message}");
${3} $3
} }
body body
endsnippet endsnippet
@ -231,7 +231,7 @@ snippet out "out contract (out)" b
out${1:(result)} out${1:(result)}
{ {
assert(${2:/*condition*/}, "${3:error message}"); assert(${2:/*condition*/}, "${3:error message}");
${4} $4
} }
body body
endsnippet endsnippet
@ -240,7 +240,7 @@ snippet inv "invariant (inv)" b
invariant() invariant()
{ {
assert(${1:/*condition*/}, "${2:error message}"); assert(${1:/*condition*/}, "${2:error message}");
${3} $3
} }
endsnippet endsnippet
@ -249,21 +249,21 @@ endsnippet
snippet fun "function definition (fun)" snippet fun "function definition (fun)"
${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow} ${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow}
{ {
${VISUAL}${5} ${VISUAL}$5
} }
endsnippet endsnippet
snippet void "void function definition (void)" snippet void "void function definition (void)"
void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow} void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow}
{ {
${VISUAL}${4} ${VISUAL}$4
} }
endsnippet endsnippet
snippet this "ctor (this)" w snippet this "ctor (this)" w
this(${1:/*args*/}) this(${1:/*args*/})
{ {
${VISUAL}${2} ${VISUAL}$2
} }
endsnippet endsnippet
@ -295,16 +295,16 @@ endsnippet
snippet scope "scope (scope)" b snippet scope "scope (scope)" b
scope(${1:exit}) scope(${1:exit})
{ {
${VISUAL}${2} ${VISUAL}$2
} }
endsnippet endsnippet
# With # With
snippet with "with (with)" snippet with "with (with)"
with(${1}) with($1)
{ {
${VISUAL}${2} ${VISUAL}$2
} }
endsnippet endsnippet
@ -315,7 +315,7 @@ try
{ {
${VISUAL}${1:/*code to try*/} ${VISUAL}${1:/*code to try*/}
} }
catch(${2}Exception e) catch($2Exception e)
{ {
${3:/*handle exception*/} ${3:/*handle exception*/}
} }
@ -326,7 +326,7 @@ try
{ {
${VISUAL}${1:/*code to try*/} ${VISUAL}${1:/*code to try*/}
} }
catch(${2}Exception e) catch($2Exception e)
{ {
${3:/*handle exception*/} ${3:/*handle exception*/}
} }
@ -337,14 +337,14 @@ finally
endsnippet endsnippet
snippet catch "catch (catch)" b snippet catch "catch (catch)" b
catch(${1}Exception e) catch($1Exception e)
{ {
${2:/*handle exception*/} ${2:/*handle exception*/}
} }
endsnippet endsnippet
snippet thr "throw (thr)" snippet thr "throw (thr)"
throw new ${1}Exception("${2}"); throw new $1Exception("$2");
endsnippet endsnippet
@ -353,35 +353,35 @@ endsnippet
snippet struct "struct (struct)" snippet struct "struct (struct)"
struct ${1:`!p snip.rv = (snip.basename or "name")`} struct ${1:`!p snip.rv = (snip.basename or "name")`}
{ {
${2} $2
} }
endsnippet endsnippet
snippet union "union (union)" snippet union "union (union)"
union ${1:`!p snip.rv = (snip.basename or "name")`} union ${1:`!p snip.rv = (snip.basename or "name")`}
{ {
${2} $2
} }
endsnippet endsnippet
snippet class "class (class)" snippet class "class (class)"
class ${1:`!p snip.rv = (snip.basename or "name")`} class ${1:`!p snip.rv = (snip.basename or "name")`}
{ {
${2} $2
} }
endsnippet endsnippet
snippet inter "interface (inter)" snippet inter "interface (inter)"
interface ${1:`!p snip.rv = (snip.basename or "name")`} interface ${1:`!p snip.rv = (snip.basename or "name")`}
{ {
${2} $2
} }
endsnippet endsnippet
snippet enum "enum (enum)" snippet enum "enum (enum)"
enum ${1:`!p snip.rv = (snip.basename or "name")`} enum ${1:`!p snip.rv = (snip.basename or "name")`}
{ {
${2} $2
} }
endsnippet endsnippet
@ -390,7 +390,7 @@ endsnippet
snippet exc "exception declaration (exc)" b snippet exc "exception declaration (exc)" b
/// ${3:/*documentation*/} /// ${3:/*documentation*/}
class ${1}Exception : ${2}Exception class $1Exception : $2Exception
{ {
public this(string msg, string file = __FILE__, int line = __LINE__) public this(string msg, string file = __FILE__, int line = __LINE__)
{ {
@ -405,14 +405,14 @@ endsnippet
snippet version "version (version)" b snippet version "version (version)" b
version(${1:/*version name*/}) version(${1:/*version name*/})
{ {
${VISUAL}${2} ${VISUAL}$2
} }
endsnippet endsnippet
snippet debug "debug" b snippet debug "debug" b
debug debug
{ {
${VISUAL}${1} ${VISUAL}$1
} }
endsnippet endsnippet
@ -422,7 +422,7 @@ endsnippet
snippet temp "template (temp)" b snippet temp "template (temp)" b
template ${2:/*name*/}(${1:/*args*/}) template ${2:/*name*/}(${1:/*args*/})
{ {
${3} $3
} }
endsnippet endsnippet
@ -440,7 +440,7 @@ endsnippet
snippet unittest "unittest (unittest)" b snippet unittest "unittest (unittest)" b
unittest unittest
{ {
${1} $1
} }
endsnippet endsnippet
@ -450,21 +450,21 @@ endsnippet
snippet opDis "opDispatch (opDis)" b snippet opDis "opDispatch (opDis)" b
${1:/*return type*/} opDispatch(string s)() ${1:/*return type*/} opDispatch(string s)()
{ {
${2}; $2;
} }
endsnippet endsnippet
snippet op= "opAssign (op=)" b snippet op= "opAssign (op=)" b
void opAssign(${1} rhs) ${2:@safe pure nothrow} void opAssign($1 rhs) ${2:@safe pure nothrow}
{ {
${2} $2
} }
endsnippet endsnippet
snippet opCmp "opCmp (opCmp)" b snippet opCmp "opCmp (opCmp)" b
int opCmp(${1} rhs) @safe const pure nothrow int opCmp($1 rhs) @safe const pure nothrow
{ {
${2} $2
} }
endsnippet endsnippet
@ -484,7 +484,7 @@ endsnippet
snippet toString "toString (toString)" b snippet toString "toString (toString)" b
string toString() @safe const pure nothrow string toString() @safe const pure nothrow
{ {
${1} $1
} }
endsnippet endsnippet
@ -493,7 +493,7 @@ endsnippet
snippet todo "TODO (todo)" snippet todo "TODO (todo)"
// TODO: ${1} // TODO: $1
endsnippet endsnippet
@ -509,16 +509,16 @@ snippet fdoc "function ddoc block (fdoc)" b
/// ${1:description} /// ${1:description}
/// ///
/// ${2:Params: ${3:param} = ${4:param description} /// ${2:Params: ${3:param} = ${4:param description}
/// ${5}} /// $5}
/// ///
/// ${6:Returns: ${7:return value}} /// ${6:Returns: ${7:return value}}
/// ///
/// ${8:Throws: ${9}Exception ${10}} /// ${8:Throws: $9Exception $10}
endsnippet endsnippet
snippet Par "Params (Par)" snippet Par "Params (Par)"
Params: ${1:param} = ${2:param description} Params: ${1:param} = ${2:param description}
/// ${3} /// $3
endsnippet endsnippet
snippet Ret "Returns (Ret)" snippet Ret "Returns (Ret)"
@ -526,7 +526,7 @@ Returns: ${1:return value/s}
endsnippet endsnippet
snippet Thr "Throws (Thr)" snippet Thr "Throws (Thr)"
Throws: ${1}Exception ${2} Throws: $1Exception $2
endsnippet endsnippet
snippet Example "Examples (Example)" snippet Example "Examples (Example)"
@ -556,7 +556,7 @@ snippet gpl "GPL (gpl)" b
// //
// Copyright (C) ${1:Author}, `!v strftime("%Y")` // Copyright (C) ${1:Author}, `!v strftime("%Y")`
${2} $2
endsnippet endsnippet
snippet boost "Boost (boost)" b snippet boost "Boost (boost)" b
@ -565,7 +565,7 @@ snippet boost "Boost (boost)" b
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
${2} $2
endsnippet endsnippet
@ -577,8 +577,8 @@ snippet module "New module (module)" b
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
module ${2}.`!v vim_snippets#Filename('$1', 'name')`; module $2.`!v vim_snippets#Filename('$1', 'name')`;
${3} $3
endsnippet endsnippet

View file

@ -124,7 +124,7 @@ endsnippet
snippet model "Model" b snippet model "Model" b
class ${1:MODELNAME}(models.Model): class ${1:MODELNAME}(models.Model):
${0} $0
class Meta: class Meta:
verbose_name = "$1" verbose_name = "$1"
verbose_name_plural = "$1s" verbose_name_plural = "$1s"
@ -275,19 +275,19 @@ endsnippet
# VIEWS SNIPPETS # VIEWS SNIPPETS
snippet adminview "Model Admin View" b snippet adminview "Model Admin View" b
class ${1}Admin(admin.ModelAdmin): class $1Admin(admin.ModelAdmin):
''' '''
Admin View for ${1} Admin View for $1
''' '''
list_display = ('${2}',) list_display = ('$2',)
list_filter = ('${3}',) list_filter = ('$3',)
inlines = [ inlines = [
${4}Inline, $4Inline,
] ]
raw_id_fields = ('${5}',) raw_id_fields = ('$5',)
readonly_fields = ('${6}',) readonly_fields = ('$6',)
search_fields = ['${7}'] search_fields = ['$7']
admin.site.register(${1}, ${1}Admin) admin.site.register($1, $1Admin)
endsnippet endsnippet
snippet createview "Generic Create View" b snippet createview "Generic Create View" b
@ -315,27 +315,27 @@ class ${1:MODEL_NAME}ListView(ListView):
endsnippet endsnippet
snippet stackedinline "Stacked Inline" b snippet stackedinline "Stacked Inline" b
class ${1}Inline(admin.StackedInline): class $1Inline(admin.StackedInline):
''' '''
Stacked Inline View for ${1} Stacked Inline View for $1
''' '''
model = ${2:${1}} model = ${2:$1}
min_num = ${3:3} min_num = ${3:3}
max_num = ${4:20} max_num = ${4:20}
extra = ${5:1} extra = ${5:1}
raw_id_fields = (${6},) raw_id_fields = ($6,)
endsnippet endsnippet
snippet tabularinline "Tabular Inline" b snippet tabularinline "Tabular Inline" b
class ${1}Inline(admin.TabularInline): class $1Inline(admin.TabularInline):
''' '''
Tabular Inline View for ${1} Tabular Inline View for $1
''' '''
model = ${2:${1}} model = ${2:$1}
min_num = ${3:3} min_num = ${3:3}
max_num = ${4:20} max_num = ${4:20}
extra = ${5:1} extra = ${5:1}
raw_id_fields = (${6},) raw_id_fields = ($6,)
endsnippet endsnippet
snippet templateview "Generic Template View" b snippet templateview "Generic Template View" b

View file

@ -27,12 +27,12 @@ def textmate_var(var, snip):
endglobal endglobal
snippet % "<% ${0} %>" i snippet % "<% $0 %>" i
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`$0`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
endsnippet endsnippet
snippet = "<%= ${0} %>" i snippet = "<%= $0 %>" i
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`$0`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet endsnippet
########################################################################### ###########################################################################
@ -150,11 +150,11 @@ snippet licai "link_to (controller, action, id)" w
endsnippet endsnippet
snippet linpp "link_to (nested path plural)" w snippet linpp "link_to (nested path plural)" w
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${10:parent}_${11:child}_path(${12:@}${13:${10}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${10:parent}_${11:child}_path(${12:@}${13:$10})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet endsnippet
snippet linp "link_to (nested path)" w snippet linp "link_to (nested path)" w
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:parent}_${13:child}_path(${14:@}${15:$12}, ${16:@}${17:$13})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet endsnippet
snippet lipp "link_to (path plural)" w snippet lipp "link_to (path plural)" w
@ -162,7 +162,7 @@ snippet lipp "link_to (path plural)" w
endsnippet endsnippet
snippet lip "link_to (path)" w snippet lip "link_to (path)" w
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:model}_path(${13:@}${14:${12}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:model}_path(${13:@}${14:$12})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet endsnippet
snippet lim "link_to model" w snippet lim "link_to model" w

View file

@ -53,7 +53,7 @@ endsnippet
snippet switch "Switch statement" b snippet switch "Switch statement" b
switch ${1:expression}${1/(.+)/ /}{ switch ${1:expression}${1/(.+)/ /}{
case${0} case$0
} }
endsnippet endsnippet

View file

@ -12,33 +12,6 @@ def x(snip):
snip.rv = "" snip.rv = ""
endglobal endglobal
############
# Doctypes #
############
snippet doctype "DocType XHTML 1.0 Strict" b
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
endsnippet
snippet doctype "DocType XHTML 1.0 Transitional" b
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
endsnippet
snippet doctype "DocType XHTML 1.1" b
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
endsnippet
snippet doctype "HTML - 4.0 Transitional (doctype)" b
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
endsnippet
snippet doctype "HTML - 5.0 (doctype)" b snippet doctype "HTML - 5.0 (doctype)" b
<!DOCTYPE html> <!DOCTYPE html>
@ -83,45 +56,6 @@ snippet left "Left (left)"
&#x2190; &#x2190;
endsnippet endsnippet
snippet option "Option (option)"
&#x2325;
endsnippet
#######################
# Conditional inserts #
#######################
snippet ! "IE Conditional Comment: Internet Explorer 5_0 only"
<!--[if IE 5.0]>${1:IE Conditional Comment: Internet Explorer 5.0 only }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 5_5 only"
<!--[if IE 5.5000]>${1:IE Conditional Comment: Internet Explorer 5.5 only }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 5_x"
<!--[if lt IE 6]>${1:IE Conditional Comment: Internet Explorer 5.x }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 6 and below"
<!--[if lte IE 6]>${1:IE Conditional Comment: Internet Explorer 6 and below }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 6 only"
<!--[if IE 6]>${1:IE Conditional Comment: Internet Explorer 6 only }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer 7+"
<!--[if gte IE 7]>${1:IE Conditional Comment: Internet Explorer 7 and above }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: Internet Explorer"
<!--[if IE]>${1: IE Conditional Comment: Internet Explorer }<![endif]-->$0
endsnippet
snippet ! "IE Conditional Comment: NOT Internet Explorer"
<!--[if !IE]><!-->${1: IE Conditional Comment: NOT Internet Explorer }<!-- <![endif]-->$0
endsnippet
############# #############
# HTML TAGS # # HTML TAGS #
############# #############
@ -129,12 +63,12 @@ snippet input "Input with Label" w
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`> <label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`>
endsnippet endsnippet
snippet input "XHTML <input>" w snippet input "HTML <input>" w
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`> <input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`>
endsnippet endsnippet
snippet opt "Option" w snippet option "Option" w
<option${1: value="${2:option}"}>${3:$2}</option> <option${1: value="${2:option}"}>${3:$2}</option>
endsnippet endsnippet
@ -145,15 +79,15 @@ snippet select "Select Box" w
endsnippet endsnippet
snippet textarea "XHTML <textarea>" w snippet textarea "HTML <textarea>" w
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea> <textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
endsnippet endsnippet
snippet mailto "XHTML <a mailto: >" w snippet mailto "HTML <a mailto: >" w
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a> <a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
endsnippet endsnippet
snippet base "XHTML <base>" w snippet base "HTML <base>" w
<base href="$1"${2: target="$3"}`!p x(snip)`> <base href="$1"${2: target="$3"}`!p x(snip)`>
endsnippet endsnippet
@ -229,12 +163,12 @@ snippet meta "XHTML <meta>" w
<meta name="${1:name}" content="${2:content}"`!p x(snip)`> <meta name="${1:name}" content="${2:content}"`!p x(snip)`>
endsnippet endsnippet
snippet scriptsrc "XHTML <script src...>" w snippet scriptsrc "HTML <script src...>" w
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script> <script src="$1" charset="${3:utf-8}"></script>
endsnippet endsnippet
snippet script "XHTML <script>" w snippet script "HTML <script>" w
<script type="text/javascript" charset="utf-8"> <script charset="utf-8">
${0:${VISUAL}} ${0:${VISUAL}}
</script> </script>
endsnippet endsnippet
@ -304,20 +238,6 @@ snippet fieldset "Fieldset" w
</fieldset> </fieldset>
endsnippet endsnippet
snippet movie "Embed QT movie (movie)" b
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="$1"`!p x(snip)`>
<param name="controller" value="$4"`!p x(snip)`>
<param name="autoplay" value="$5"`!p x(snip)`>
<embed src="${1:movie.mov}"
width="${2:320}" height="${3:240}"
controller="${4:true}" autoplay="${5:true}"
scale="tofit" cache="true"
pluginspage="http://www.apple.com/quicktime/download/"
`!p x(snip)`>
</object>
endsnippet
snippet viewport "Responsive viewport meta" w snippet viewport "Responsive viewport meta" w
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
endsnippet endsnippet

View file

@ -4,24 +4,24 @@
priority -50 priority -50
snippet id snippet id
id="${1}"${2} id="$1"$2
endsnippet endsnippet
snippet idn snippet idn
id="${1}" name="${2:$1}" id="$1" name="${2:$1}"
endsnippet endsnippet
snippet label_and_input snippet label_and_input
<label for="${2:$1}">${1}</label> <label for="${2:$1}">$1</label>
<input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="${7}" />${8} <input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="$7" />$8
endsnippet endsnippet
snippet input snippet input
<input type="${1:text}" value="${2}" name="${3}"${4: id="${5:$3}"}/>${7} <input type="${1:text}" value="$2" name="$3"${4: id="${5:$3}"}/>$7
endsnippet endsnippet
snippet submit snippet submit
<input type="submit" value="${2}" ${3}/>${7} <input type="submit" value="$2" $3/>$7
endsnippet endsnippet
snippet textarea snippet textarea

View file

@ -4,30 +4,30 @@ extends html
# Generic Tags # Generic Tags
snippet % "" bi snippet % "" bi
{% ${1} %}${2} {% $1 %}$2
endsnippet endsnippet
snippet %% "" bi snippet %% "" bi
{% ${1:tag_name} %} {% ${1:tag_name} %}
${2} $2
{% end$1 %} {% end$1 %}
endsnippet endsnippet
snippet { "" bi snippet { "" bi
{{ ${1} }}${2} {{ $1 }}$2
endsnippet endsnippet
# Template Tags # Template Tags
snippet autoescape "" bi snippet autoescape "" bi
{% autoescape ${1:off} %} {% autoescape ${1:off} %}
${2} $2
{% endautoescape %} {% endautoescape %}
endsnippet endsnippet
snippet block "" bi snippet block "" bi
{% block ${1} %} {% block $1 %}
${2} $2
{% endblock $1 %} {% endblock $1 %}
endsnippet endsnippet
@ -37,12 +37,12 @@ endsnippet
snippet comment "" bi snippet comment "" bi
{% comment %} {% comment %}
${1} $1
{% endcomment %} {% endcomment %}
endsnippet endsnippet
snippet cycle "" bi snippet cycle "" bi
{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} {% cycle ${1:val1} ${2:val2} ${3:as $4} %}
endsnippet endsnippet
snippet debug "" bi snippet debug "" bi
@ -54,76 +54,76 @@ snippet extends "" bi
endsnippet endsnippet
snippet filter "" bi snippet filter "" bi
{% filter ${1} %} {% filter $1 %}
${2} $2
{% endfilter %} {% endfilter %}
endsnippet endsnippet
snippet firstof "" bi snippet firstof "" bi
{% firstof ${1} %} {% firstof $1 %}
endsnippet endsnippet
snippet for "" bi snippet for "" bi
{% for ${1} in ${2} %} {% for $1 in $2 %}
${3} $3
{% endfor %} {% endfor %}
endsnippet endsnippet
snippet empty "" bi snippet empty "" bi
{% empty %} {% empty %}
${1} $1
endsnippet endsnippet
snippet if "" bi snippet if "" bi
{% if ${1} %} {% if $1 %}
${2} $2
{% endif %} {% endif %}
endsnippet endsnippet
snippet iif "" bi snippet iif "" bi
{% if ${1} %}${2}{% endif %} {% if $1 %}$2{% endif %}
endsnippet endsnippet
snippet ielse "" bi snippet ielse "" bi
{% else %}${1} {% else %}$1
endsnippet endsnippet
snippet else "" bi snippet else "" bi
{% else %} {% else %}
${1} $1
endsnippet endsnippet
snippet ielif "" bi snippet ielif "" bi
{% elif %}${1} {% elif %}$1
endsnippet endsnippet
snippet elif "" bi snippet elif "" bi
{% elif %} {% elif %}
${1} $1
endsnippet endsnippet
snippet ifchanged "" bi snippet ifchanged "" bi
{% ifchanged %}${1}{% endifchanged %} {% ifchanged %}$1{% endifchanged %}
endsnippet endsnippet
snippet ifequal "" bi snippet ifequal "" bi
{% ifequal ${1} ${2} %} {% ifequal $1 $2 %}
${3} $3
{% endifequal %} {% endifequal %}
endsnippet endsnippet
snippet ifnotequal "" bi snippet ifnotequal "" bi
{% ifnotequal ${1} ${2} %} {% ifnotequal $1 $2 %}
${3} $3
{% endifnotequal %} {% endifnotequal %}
endsnippet endsnippet
snippet include "" bi snippet include "" bi
{% include "${1}" %} {% include "$1" %}
endsnippet endsnippet
snippet load "" bi snippet load "" bi
{% load ${1} %} {% load $1 %}
endsnippet endsnippet
snippet now "" bi snippet now "" bi
@ -131,15 +131,15 @@ snippet now "" bi
endsnippet endsnippet
snippet regroup "" bi snippet regroup "" bi
{% regroup ${1} by ${2} as ${3} %} {% regroup $1 by $2 as $3 %}
endsnippet endsnippet
snippet spaceless "" bi snippet spaceless "" bi
{% spaceless %}${1}{% endspaceless %} {% spaceless %}$1{% endspaceless %}
endsnippet endsnippet
snippet ssi "" bi snippet ssi "" bi
{% ssi ${1} %} {% ssi $1 %}
endsnippet endsnippet
snippet trans "" bi snippet trans "" bi
@ -147,7 +147,7 @@ snippet trans "" bi
endsnippet endsnippet
snippet url "" bi snippet url "" bi
{% url ${1} as ${2} %} {% url $1 as $2 %}
endsnippet endsnippet
snippet widthratio "" bi snippet widthratio "" bi
@ -155,7 +155,7 @@ snippet widthratio "" bi
endsnippet endsnippet
snippet with "" bi snippet with "" bi
{% with ${1} as ${2} %} {% with $1 as $2 %}
${VISUAL} ${VISUAL}
{% endwith %} {% endwith %}
endsnippet endsnippet
@ -197,7 +197,7 @@ snippet blocktrans "" bi
endsnippet endsnippet
snippet lorem "" bi snippet lorem "" bi
{% lorem ${1} %} {% lorem $1 %}
endsnippet endsnippet
# Template Filters # Template Filters
@ -209,91 +209,91 @@ endsnippet
# Note: Template tags that take no arguments are not implemented. # Note: Template tags that take no arguments are not implemented.
snippet add "" bi snippet add "" bi
add:"${1}" add:"$1"
endsnippet endsnippet
snippet center "" bi snippet center "" bi
center:"${1}" center:"$1"
endsnippet endsnippet
snippet cut "" bi snippet cut "" bi
cut:"${1}" cut:"$1"
endsnippet endsnippet
snippet date "" bi snippet date "" bi
date:"${1}" date:"$1"
endsnippet endsnippet
snippet default "" bi snippet default "" bi
default:"${1}" default:"$1"
endsnippet endsnippet
snippet defaultifnone "" bi snippet defaultifnone "" bi
default_if_none:"${1}" default_if_none:"$1"
endsnippet endsnippet
snippet dictsort "" bi snippet dictsort "" bi
dictsort:"${1}" dictsort:"$1"
endsnippet endsnippet
snippet dictsortrev "" bi snippet dictsortrev "" bi
dictsortreversed:"${1}" dictsortreversed:"$1"
endsnippet endsnippet
snippet divisibleby "" bi snippet divisibleby "" bi
divisibleby:"${1}" divisibleby:"$1"
endsnippet endsnippet
snippet floatformat "" bi snippet floatformat "" bi
floatformat:"${1}" floatformat:"$1"
endsnippet endsnippet
snippet getdigit "" bi snippet getdigit "" bi
get_digit:"${1}" get_digit:"$1"
endsnippet endsnippet
snippet join "" bi snippet join "" bi
join:"${1}" join:"$1"
endsnippet endsnippet
snippet lengthis "" bi snippet lengthis "" bi
length_is:"${1}" length_is:"$1"
endsnippet endsnippet
snippet pluralize "" bi snippet pluralize "" bi
pluralize:"${1}" pluralize:"$1"
endsnippet endsnippet
snippet removetags "" bi snippet removetags "" bi
removetags:"${1}" removetags:"$1"
endsnippet endsnippet
snippet slice "" bi snippet slice "" bi
slice:"${1}" slice:"$1"
endsnippet endsnippet
snippet stringformat "" bi snippet stringformat "" bi
stringformat:"${1}" stringformat:"$1"
endsnippet endsnippet
snippet time "" bi snippet time "" bi
time:"${1}" time:"$1"
endsnippet endsnippet
snippet truncatewords "" bi snippet truncatewords "" bi
truncatewords:${1} truncatewords:$1
endsnippet endsnippet
snippet truncatewordshtml "" bi snippet truncatewordshtml "" bi
truncatewords_html:${1} truncatewords_html:$1
endsnippet endsnippet
snippet urlizetrunc "" bi snippet urlizetrunc "" bi
urlizetrunc:${1} urlizetrunc:$1
endsnippet endsnippet
snippet wordwrap "" bi snippet wordwrap "" bi
wordwrap:${1} wordwrap:$1
endsnippet endsnippet
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -48,7 +48,7 @@ $0
endsnippet endsnippet
snippet /o|v/ "new Object or variable" br snippet /o|v/ "new Object or variable" br
${1:Object} ${2:var} = new $1(${3}); ${1:Object} ${2:var} = new $1($3);
endsnippet endsnippet
snippet f "field" b snippet f "field" b
@ -310,13 +310,13 @@ try {
endsnippet endsnippet
snippet mt "method throws" b snippet mt "method throws" b
${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{ ${1:private} ${2:void} ${3:method}($4) ${5:throws $6 }{
$0 $0
} }
endsnippet endsnippet
snippet m "method" b snippet m "method" b
${1:private} ${2:void} ${3:method}(${4}) { ${1:private} ${2:void} ${3:method}($4) {
$0 $0
} }
endsnippet endsnippet

View file

@ -19,7 +19,7 @@ config(function($1) {
endsnippet endsnippet
snippet acont "angular controller" i snippet acont "angular controller" i
controller('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { controller('${1:name}', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0 $0
}]); }]);
endsnippet endsnippet
@ -31,29 +31,29 @@ controller('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)
endsnippet endsnippet
snippet adir "angular directive" i snippet adir "angular directive" i
directive('${1}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { directive('$1', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
return { return {
restrict: '${3:EA}', restrict: '${3:EA}',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
${0} $0
} }
}; };
}]); }]);
endsnippet endsnippet
snippet adirs "angular directive with scope" i snippet adirs "angular directive with scope" i
directive('${1}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { directive('$1', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
return { return {
restrict: '${3:EA}', restrict: '${3:EA}',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
${0} $0
} }
}; };
}]); }]);
endsnippet endsnippet
snippet afact "angular factory" i snippet afact "angular factory" i
factory('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { factory('${1:name}', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0 $0
}]); }]);
endsnippet endsnippet
@ -65,7 +65,7 @@ factory('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$
endsnippet endsnippet
snippet aserv "angular service" i snippet aserv "angular service" i
service('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { service('${1:name}', [$2function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) {
$0 $0
}]); }]);
endsnippet endsnippet

View file

@ -5,48 +5,48 @@ snippet #! "shebang"
endsnippet endsnippet
snippet vreq "assign a CommonJS-style module to a var" snippet vreq "assign a CommonJS-style module to a var"
var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('${1}'); var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('$1');
endsnippet endsnippet
snippet ex "module.exports" snippet ex "module.exports"
module.exports = ${1}; module.exports = $1;
endsnippet endsnippet
snippet hcs "http.createServer" snippet hcs "http.createServer"
http.createServer(${1}).listen(${2}); http.createServer($1).listen($2);
endsnippet endsnippet
snippet ncs "net.createServer" snippet ncs "net.createServer"
net.createServer(function(${1:socket}){ net.createServer(function(${1:socket}){
${1}.on('data', function(${3:data}){ $1.on('data', function(${3:data}){
${4} $4
}); });
${1}.on('end', function(){ $1.on('end', function(){
${5} $5
}); });
}).listen(${6:8124}); }).listen(${6:8124});
endsnippet endsnippet
snippet pipe "pipe" snippet pipe "pipe"
pipe(${1:stream})${2} pipe(${1:stream})$2
endsnippet endsnippet
# Express snippets # Express snippets
snippet eget "express GET" snippet eget "express GET"
${1:app}.get('${2}', ${3}); ${1:app}.get('$2', $3);
endsnippet endsnippet
snippet epost "express POST" snippet epost "express POST"
${1:app}.post('${2}', ${3}); ${1:app}.post('$2', $3);
endsnippet endsnippet
snippet eput "express PUT" snippet eput "express PUT"
${1:app}.put('${2}', ${3}); ${1:app}.put('$2', $3);
endsnippet endsnippet
snippet edelete "express DELETE" snippet edelete "express DELETE"
${1:app}.delete('${2}', ${3}); ${1:app}.delete('$2', $3);
endsnippet endsnippet
# process snippets # process snippets

View file

@ -1,80 +1,80 @@
snippet sapmlabel snippet sapmlabel
var ${1} = new sap.m.Label({ var $1 = new sap.m.Label({
design : ${2}, design : $2,
text : ${3}, text : $3,
visible : ${4}, visible : $4,
textAlign : ${5}, textAlign : $5,
textDirection : ${6}, textDirection : $6,
width : ${7}, width : $7,
required : ${7} required : $7
}); });
snippet sapmtext snippet sapmtext
var ${1} = new sap.m.Text({ var $1 = new sap.m.Text({
text :${2}, text :$2,
textDirection :${3}, textDirection :$3,
visible :${4}, visible :$4,
wrapping : ${5}, wrapping : $5,
textAlign : ${6}, textAlign : $6,
width :${7}, width :$7,
maxLines :${8} maxLines :$8
}); });
snippet sapmbutton snippet sapmbutton
var ${1} = new sap.m.Button({ var $1 = new sap.m.Button({
text : ${2}, text : $2,
type : ${3}, type : $3,
width : ${4}, width : $4,
enabled :${5}, enabled :$5,
visible :${6}, visible :$6,
icon : ${7}, icon : $7,
iconFirst : ${8}, iconFirst : $8,
activeIcon :${9}, activeIcon :$9,
iconDensityAware : ${10}, iconDensityAware : $10,
}); });
snippet sapmflexbox snippet sapmflexbox
var ${1} = new sap.m.FlexBox({ var $1 = new sap.m.FlexBox({
visible : ${2}, visible : $2,
height : ${3}, height : $3,
width : ${4}, width : $4,
displayInline :${5}, displayInline :$5,
direction :${6}, direction :$6,
fitContainer : ${7}, fitContainer : $7,
renderType : ${8}, renderType : $8,
justifyContent :${9}, justifyContent :$9,
alignItems : ${10}, alignItems : $10,
items:[] items:[]
}); });
snippet sapmhbox snippet sapmhbox
var ${1} = new sap.m.HBox({ var $1 = new sap.m.HBox({
visible : ${2}, visible : $2,
height : ${3}, height : $3,
width : ${4}, width : $4,
displayInline :${5}, displayInline :$5,
direction :${6}, direction :$6,
fitContainer : ${7}, fitContainer : $7,
renderType : ${8}, renderType : $8,
justifyContent :${9}, justifyContent :$9,
alignItems : ${10}, alignItems : $10,
items:[] items:[]
}); });
snippet sapmvbox snippet sapmvbox
var ${1} = new sap.m.VBox({ var $1 = new sap.m.VBox({
visible : ${2}, visible : $2,
height : ${3}, height : $3,
width : ${4}, width : $4,
displayInline :${5}, displayInline :$5,
direction :${6}, direction :$6,
fitContainer : ${7}, fitContainer : $7,
renderType : ${8}, renderType : $8,
justifyContent :${9}, justifyContent :$9,
alignItems : ${10}, alignItems : $10,
items:[] items:[]
}); });
snippet sapcomponent snippet sapcomponent
sap.ui.controller("${1}", { sap.ui.controller("$1", {
onInit: function(){ onInit: function(){
}, },
onAfterRendering: function() { onAfterRendering: function() {
@ -86,120 +86,120 @@ snippet sapcomponent
}); });
snippet sapminput snippet sapminput
var ${1} = new sap.m.Input({ var $1 = new sap.m.Input({
value :${2}, value :$2,
width : ${3}, width : $3,
enabled :${4}, enabled :$4,
visible :${5}, visible :$5,
valueState :${6}, valueState :$6,
name : ${7}, name : $7,
placeholder : ${8}, placeholder : $8,
editable : ${9}, editable : $9,
type : ${10}, type : $10,
maxLength :${11}, maxLength :$11,
valueStateText :${12}, valueStateText :$12,
showValueStateMessage :${13}, showValueStateMessage :$13,
dateFormat :${14}, dateFormat :$14,
showValueHelp :${15}, showValueHelp :$15,
showSuggestion :${16}, showSuggestion :$16,
valueHelpOnly :${17}, valueHelpOnly :$17,
filterSuggests :${18}, filterSuggests :$18,
maxSuggestionWidth :${19}, maxSuggestionWidth :$19,
startSuggestion : ${20}, startSuggestion : $20,
showTableSuggestionValueHelp : ${21}, showTableSuggestionValueHelp : $21,
description : ${22}, description : $22,
fieldWidth : ${23}, fieldWidth : $23,
valueLiveUpdate :${24}, valueLiveUpdate :$24,
suggestionItems :[${25}], suggestionItems :[$25],
suggestionColumns : [${26}], suggestionColumns : [$26],
suggestionRows : [${27}], suggestionRows : [$27],
liveChange : ${28}, liveChange : $28,
valueHelpRequest :${29}, valueHelpRequest :$29,
suggest : ${30}, suggest : $30,
suggestionItemSelected : ${31} suggestionItemSelected : $31
}); });
snippet _sthis snippet _sthis
var _self = this; var _self = this;
snippet sapmresponsivepopup snippet sapmresponsivepopup
var ${1} = new sap.m.ResponsivePopover({ var $1 = new sap.m.ResponsivePopover({
placement :${2} ,//sap.m.PlacementType (default: sap.m.PlacementType.Right) placement :$2 ,//sap.m.PlacementType (default: sap.m.PlacementType.Right)
showHeader :${3} ,//boolean (default: true) showHeader :$3 ,//boolean (default: true)
title : ${4},//string title : $4,//string
icon :${5} ,//sap.ui.core.URI icon :$5 ,//sap.ui.core.URI
modal :${6} ,// boolean modal :$6 ,// boolean
offsetX :${7}, //int offsetX :$7, //int
offsetY :${8}, //int offsetY :$8, //int
contentWidth : ${9},//sap.ui.core.CSSSize contentWidth : $9,//sap.ui.core.CSSSize
contentHeight :${10}, //sap.ui.core.CSSSize contentHeight :$10, //sap.ui.core.CSSSize
horizontalScrolling :${11}, //boolean horizontalScrolling :$11, //boolean
verticalScrolling :${12}, //boolean verticalScrolling :$12, //boolean
showCloseButton :${13}, //boolean (default: true) showCloseButton :$13, //boolean (default: true)
//Aggregations //Aggregations
content :${14}, //sap.ui.core.Control[] content :$14, //sap.ui.core.Control[]
customHeader :${15}, //sap.m.IBar customHeader :$15, //sap.m.IBar
subHeader : ${16}, //sap.m.IBar subHeader : $16, //sap.m.IBar
beginButton :${17}, //sap.m.Button beginButton :$17, //sap.m.Button
endButton : ${18}, //sap.m.Button endButton : $18, //sap.m.Button
//Associations //Associations
initialFocus : ${19}, //string | sap.ui.core.Control initialFocus : $19, //string | sap.ui.core.Control
//Events //Events
beforeOpen :${20}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] beforeOpen :$20, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
afterOpen : ${21}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] afterOpen : $21, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
beforeClose : ${22}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] beforeClose : $22, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
afterClose : ${23} //fnList afterClose : $23 //fnList
}); });
snippet sapicon snippet sapicon
var ${1} = new sap.ui.core.Icon({ var $1 = new sap.ui.core.Icon({
src :${2} , //sap.ui.core.URI src :$2 , //sap.ui.core.URI
size :${3} , //sap.ui.core.CSSSize size :$3 , //sap.ui.core.CSSSize
color :${4} , //sap.ui.core.CSSColor color :$4 , //sap.ui.core.CSSColor
hoverColor : ${5} , // sap.ui.core.CSSColor hoverColor : $5 , // sap.ui.core.CSSColor
activeColor :${6} , //sap.ui.core.CSSColor activeColor :$6 , //sap.ui.core.CSSColor
width :${7} , //sap.ui.core.CSSSize width :$7 , //sap.ui.core.CSSSize
height : ${8} ,//sap.ui.core.CSSSize height : $8 ,//sap.ui.core.CSSSize
backgroundColor :${8} , //sap.ui.core.CSSColor backgroundColor :$8 , //sap.ui.core.CSSColor
hoverBackgroundColor :${9} , //sap.ui.core.CSSColor hoverBackgroundColor :$9 , //sap.ui.core.CSSColor
activeBackgroundColor :${10} , //sap.ui.core.CSSColor activeBackgroundColor :$10 , //sap.ui.core.CSSColor
visible :${11} , //boolean (default: true) visible :$11 , //boolean (default: true)
decorative : ${12} ,//boolean (default: true) decorative : $12 ,//boolean (default: true)
}); });
snippet extendVerticalL snippet extendVerticalL
sap.ui.layout.VerticalLayout.extend("${1}", { sap.ui.layout.VerticalLayout.extend("$1", {
metadata: { metadata: {
properties: { properties: {
${2} $2
}, },
aggregations: { aggregations: {
${3} $3
}, },
events: { events: {
${4} $4
} }
}, },
init: function(){ init: function(){
${5} $5
}, },
renderer: "${6}" renderer: "$6"
}); });
snippet extendHorizontalL snippet extendHorizontalL
sap.ui.layout.HorizontalLayout.extend("${1}", { sap.ui.layout.HorizontalLayout.extend("$1", {
metadata: { metadata: {
properties: { properties: {
${2} $2
}, },
aggregations: { aggregations: {
${3} $3
}, },
events: { events: {
${4} $4
} }
}, },
init: function(){ init: function(){
${5} $5
}, },
renderer: "${6}" renderer: "$6"
}); });

View file

@ -34,18 +34,6 @@ ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
endsnippet endsnippet
snippet for "for (...) {...} (counting up)" b
for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) {
${VISUAL}$0
}
endsnippet
snippet ford "for (...) {...} (counting down, faster)" b
for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) {
${VISUAL}$0
}
endsnippet
snippet fun "function (fun)" w snippet fun "function (fun)" w
function ${1:function_name}(${2:argument}) { function ${1:function_name}(${2:argument}) {
${VISUAL}$0 ${VISUAL}$0
@ -53,7 +41,7 @@ function ${1:function_name}(${2:argument}) {
endsnippet endsnippet
snippet vf "Function assigned to var" snippet vf "Function assigned to var"
${1:var }${2:function_name} = function $2(${3}) { ${1:var }${2:function_name} = function $2($3) {
${VISUAL}$0 ${VISUAL}$0
}; };
endsnippet endsnippet
@ -84,78 +72,4 @@ for (${1:prop} in ${2:obj}){
} }
endsnippet endsnippet
# Snippets for Console Debug Output
snippet ca "console.assert" b
console.assert(${1:assertion}, ${2:"${3:message}"});
endsnippet
snippet cclear "console.clear" b
console.clear();
endsnippet
snippet cdir "console.dir" b
console.dir(${1:object});
endsnippet
snippet cdirx "console.dirxml" b
console.dirxml(${1:object});
endsnippet
snippet ce "console.error" b
console.error(${1:"${2:value}"});
endsnippet
snippet cgroup "console.group" b
console.group("${1:label}");
${VISUAL}$0
console.groupEnd();
endsnippet
snippet cgroupc "console.groupCollapsed" b
console.groupCollapsed("${1:label}");
${VISUAL}$0
console.groupEnd();
endsnippet
snippet ci "console.info" b
console.info(${1:"${2:value}"});
endsnippet
snippet cl "console.log" b
console.log(${1:"${2:value}"});
endsnippet
snippet cd "console.debug" b
console.debug(${1:"${2:value}"});
endsnippet
snippet cprof "console.profile" b
console.profile("${1:label}");
${VISUAL}$0
console.profileEnd();
endsnippet
snippet ctable "console.table" b
console.table(${1:"${2:value}"});
endsnippet
snippet ctime "console.time" b
console.time("${1:label}");
${VISUAL}$0
console.timeEnd("$1");
endsnippet
snippet ctimestamp "console.timeStamp" b
console.timeStamp("${1:label}");
endsnippet
snippet ctrace "console.trace" b
console.trace();
endsnippet
snippet cw "console.warn" b
console.warn(${1:"${2:value}"});
endsnippet
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -53,9 +53,9 @@ use Illuminate\Support\ServiceProvider;
class ${2:`!v expand('%:t:r')`} extends ServiceProvider { class ${2:`!v expand('%:t:r')`} extends ServiceProvider {
public function register() { public function register() {
$this->app->bind('${4}Service', function ($app) { $this->app->bind('$4Service', function ($app) {
return new ${5}( return new $5(
$app->make('Repositories\\${6}Interface') $app->make('Repositories\\$6Interface')
); );
}); });
} }
@ -121,7 +121,7 @@ class ${2:`!v expand('%:t:r')`} extends \Eloquent {
public $timestamps = ${5:false}; public $timestamps = ${5:false};
protected $hidden = [${6}]; protected $hidden = [$6];
protected $guarded = [${7:'id'}]; protected $guarded = [${7:'id'}];
} }
@ -208,10 +208,10 @@ snippet l_r "Laravel Repository" b
* \date `!v strftime('%d-%m-%y')` * \date `!v strftime('%d-%m-%y')`
*/ */
namespace ${1:Repositories\\${2}}; namespace ${1:Repositories\\$2};
class ${3:`!v expand('%:t:r')`} extends \\${6} implements ${4:$3RepositoryInterface} { class ${3:`!v expand('%:t:r')`} extends \\$6 implements ${4:$3RepositoryInterface} {
${7} $7
} }
endsnippet endsnippet
@ -227,7 +227,7 @@ snippet l_s "Laravel Service" b
* \date `!v strftime('%d-%m-%y')` * \date `!v strftime('%d-%m-%y')`
*/ */
namespace Services\\${1}; namespace Services\\$1;
use ${3:Repositories\\${4:Interface}}; use ${3:Repositories\\${4:Interface}};
@ -265,6 +265,6 @@ class ${2:`!v expand('%:t:r')`} extends Facade {
* *
* \return string * \return string
*/ */
protected static function getFacadeAccessor() { return '${4:${3}Service}'; } protected static function getFacadeAccessor() { return '${4:$3Service}'; }
} }
endsnippet endsnippet

View file

@ -23,15 +23,15 @@ class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group() snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends ObjectBehavior ` extends ObjectBehavior
{ {
function it_${1}() function it_$1()
{ {
$0 ${0:${VISUAL}}
} }
} }
endsnippet endsnippet
snippet it "function it_does_something() { ... }" snippet it "function it_does_something() { ... }"
function it_${1}() function it_$1()
{ {
${0:${VISUAL}} ${0:${VISUAL}}
} }
@ -53,7 +53,7 @@ endsnippet
# Object construction # Object construction
snippet cw "$this->beConstructedWith($arg)" snippet cw "$this->beConstructedWith($arg)"
$this->beConstructedWith(${1}); $this->beConstructedWith($1);
endsnippet endsnippet
snippet ct "$this->beConstructedThrough($methodName, [$arg])" snippet ct "$this->beConstructedThrough($methodName, [$arg])"
@ -112,44 +112,44 @@ endsnippet
# Type matchers # Type matchers
snippet stype "$this->shouldHaveType('Type')" snippet stype "$this->shouldHaveType('Type')"
$this->shouldHaveType(${1}); $this->shouldHaveType($1);
endsnippet endsnippet
snippet sntype "$this->shouldNotHaveType('Type')" snippet sntype "$this->shouldNotHaveType('Type')"
$this->shouldNotHaveType(${1}); $this->shouldNotHaveType($1);
endsnippet endsnippet
snippet srinstance "$this->shouldReturnAnInstanceOf('Type')" snippet srinstance "$this->shouldReturnAnInstanceOf('Type')"
$this->shouldReturnAnInstanceOf(${1}); $this->shouldReturnAnInstanceOf($1);
endsnippet endsnippet
snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')" snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')"
$this->shouldNotReturnAnInstanceOf(${1}); $this->shouldNotReturnAnInstanceOf($1);
endsnippet endsnippet
snippet sbinstance "$this->shouldBeAnInstanceOf('Type')" snippet sbinstance "$this->shouldBeAnInstanceOf('Type')"
$this->shouldBeAnInstanceOf(${1}); $this->shouldBeAnInstanceOf($1);
endsnippet endsnippet
snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')" snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')"
$this->shouldNotBeAnInstanceOf(${1}); $this->shouldNotBeAnInstanceOf($1);
endsnippet endsnippet
snippet simplement "$this->shouldImplement('Type')" snippet simplement "$this->shouldImplement('Type')"
$this->shouldImplement(${1}); $this->shouldImplement($1);
endsnippet endsnippet
snippet snimplement "$this->shouldNotImplement('Type')" snippet snimplement "$this->shouldNotImplement('Type')"
$this->shouldNotImplement(${1}); $this->shouldNotImplement($1);
endsnippet endsnippet
# Object state matchers # Object state matchers
snippet sbstate "$this->shouldBeXYZ()" snippet sbstate "$this->shouldBeXYZ()"
$this->shouldBe${1}(); $this->shouldBe$1();
endsnippet endsnippet
snippet snbstate "$this->shouldNotBeXYZ()" snippet snbstate "$this->shouldNotBeXYZ()"
$this->shouldNotBe${1}(); $this->shouldNotBe$1();
endsnippet endsnippet
# Count matchers # Count matchers

View file

@ -67,25 +67,25 @@ endsnippet
snippet act "Symfony2 action" b snippet act "Symfony2 action" b
/** /**
* @Route("${3}", name="${4}") * @Route("$3", name="$4")
* @Method({${5:"POST"}}) * @Method({${5:"POST"}})
* @Template() * @Template()
*/ */
public function ${1}Action(${2}) public function $1Action($2)
{ {
${6} $6
} }
endsnippet endsnippet
snippet actt "Symfony2 action and template" b snippet actt "Symfony2 action and template" b
/** /**
* @Route("${3}", name="${4}") * @Route("$3", name="$4")
* @Method({${5:"GET"}}) * @Method({${5:"GET"}})
* @Template() * @Template()
*/ */
public function ${1}Action(${2}) public function $1Action($2)
{ {
${6} $6
return []; return [];
}`!p }`!p
relpath = os.path.relpath(path)` relpath = os.path.relpath(path)`
@ -116,8 +116,8 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
{ {
protected function configure() protected function configure()
{ {
$this->setName('${1}') $this->setName('$1')
->setDescription('${2}') ->setDescription('$2')
->setDefinition([ ->setDefinition([
new InputArgument('', InputArgument::REQUIRED, ''), new InputArgument('', InputArgument::REQUIRED, ''),
new InputOption('', null, InputOption::VALUE_NONE, ''), new InputOption('', null, InputOption::VALUE_NONE, ''),
@ -186,14 +186,14 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function transform(${1}) public function transform($1)
{ {
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function reverseTransform(${2}) public function reverseTransform($2)
{ {
} }
} }
@ -279,7 +279,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
*/ */
public function getName() public function getName()
{ {
return '${1}'; return '$1';
} }
} }
endsnippet endsnippet
@ -307,54 +307,54 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
endsnippet endsnippet
snippet redir "Symfony2 redirect" b snippet redir "Symfony2 redirect" b
$this->redirect($this->generateUrl('${1}', ${2})); $this->redirect($this->generateUrl('$1', $2));
endsnippet endsnippet
snippet usecontroller "Symfony2 use Symfony\..\Controller" b snippet usecontroller "Symfony2 use Symfony\..\Controller" b
use Symfony\Bundle\FrameworkBundle\Controller\Controller;${1} use Symfony\Bundle\FrameworkBundle\Controller\Controller;$1
endsnippet endsnippet
snippet usereauest "Symfony2 use Symfony\..\Request" b snippet usereauest "Symfony2 use Symfony\..\Request" b
use Symfony\Component\HttpFoundation\Request;${1} use Symfony\Component\HttpFoundation\Request;$1
endsnippet endsnippet
snippet useroute "Symfony2 use Sensio\..\Route" b snippet useroute "Symfony2 use Sensio\..\Route" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;${1} use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;$1
endsnippet endsnippet
snippet useresponse "Symfony2 use Symfony\..\Response" b snippet useresponse "Symfony2 use Symfony\..\Response" b
use Symfony\Component\HttpFoundation\Response;${1} use Symfony\Component\HttpFoundation\Response;$1
endsnippet endsnippet
snippet usefile "Symfony2 use Symfony\..\File" b snippet usefile "Symfony2 use Symfony\..\File" b
use Symfony\Component\HttpFoundation\File\UploadedFile;${1} use Symfony\Component\HttpFoundation\File\UploadedFile;$1
endsnippet endsnippet
snippet useassert "Symfony2 use Symfony\..\Constraints as Assert" b snippet useassert "Symfony2 use Symfony\..\Constraints as Assert" b
use Symfony\Component\Validator\Constraints as Assert;${1} use Symfony\Component\Validator\Constraints as Assert;$1
endsnippet endsnippet
snippet usetemplate "Symfony2 use Sensio\..\Template" b snippet usetemplate "Symfony2 use Sensio\..\Template" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;${1} use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;$1
endsnippet endsnippet
snippet usecache "Symfony2 use Sensio\..\Cache" b snippet usecache "Symfony2 use Sensio\..\Cache" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;${1} use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;$1
endsnippet endsnippet
snippet usemethod "Symfony2 use Sensio\..\Method" b snippet usemethod "Symfony2 use Sensio\..\Method" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;${1} use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;$1
endsnippet endsnippet
snippet usearray "Symfony2 use Doctrine\..\ArrayCollection" b snippet usearray "Symfony2 use Doctrine\..\ArrayCollection" b
use Doctrine\Common\Collections\ArrayCollection;${1} use Doctrine\Common\Collections\ArrayCollection;$1
endsnippet endsnippet
snippet useorm "Symfony2 use Doctrine\..\Mapping as ORM" b snippet useorm "Symfony2 use Doctrine\..\Mapping as ORM" b
use Doctrine\ORM\Mapping as ORM;${1} use Doctrine\ORM\Mapping as ORM;$1
endsnippet endsnippet
snippet usesecure "Symfony2 use JMS\..\Secure" b snippet usesecure "Symfony2 use JMS\..\Secure" b
use JMS\SecurityExtraBundle\Annotation\Secure;${1} use JMS\SecurityExtraBundle\Annotation\Secure;$1
endsnippet endsnippet

View file

@ -250,7 +250,7 @@ class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group() snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends \PHPUnit_Framework_TestCase ` extends \PHPUnit_Framework_TestCase
{ {
public function test${1}() public function test$1()
{ {
${0:${VISUAL}} ${0:${VISUAL}}
} }

View file

@ -32,17 +32,17 @@ endsnippet
snippet reqf "Required field" b snippet reqf "Required field" b
// ${4:TODO(`whoami`): Describe this field.} // ${4:TODO(`whoami`): Describe this field.}
optional ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required optional $1`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required
endsnippet endsnippet
snippet optf "Optional field" b snippet optf "Optional field" b
// ${4:TODO(`whoami`): Describe this field.} // ${4:TODO(`whoami`): Describe this field.}
optional ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; optional $1`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1};
endsnippet endsnippet
snippet repf "Repeated field" b snippet repf "Repeated field" b
// ${4:TODO(`whoami`): Describe this field.} // ${4:TODO(`whoami`): Describe this field.}
repeated ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; repeated $1`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1};
endsnippet endsnippet
snippet enum "Enumeration" b snippet enum "Enumeration" b

View file

@ -133,103 +133,103 @@ endsnippet
######################################################################## ########################################################################
snippet alert "Alert Function" b snippet alert "Alert Function" b
alert("${1:message}")${0} alert("${1:message}")$0
endsnippet endsnippet
snippet crit "Crit Function" b snippet crit "Crit Function" b
crit("${1:message}")${0} crit("${1:message}")$0
endsnippet endsnippet
snippet debug "Debug Function" b snippet debug "Debug Function" b
debug("${1:message}")${0} debug("${1:message}")$0
endsnippet endsnippet
snippet defined "Defined Function" b snippet defined "Defined Function" b
defined(${1:Resource}["${2:name}"])${0} defined(${1:Resource}["${2:name}"])$0
endsnippet endsnippet
snippet emerg "Emerg Function" b snippet emerg "Emerg Function" b
emerg("${1:message}")${0} emerg("${1:message}")$0
endsnippet endsnippet
snippet extlookup "Simple Extlookup" b snippet extlookup "Simple Extlookup" b
$${1:Variable} = extlookup("${2:Lookup}")${0} $${1:Variable} = extlookup("${2:Lookup}")$0
endsnippet endsnippet
snippet extlookup "Extlookup with defaults" b snippet extlookup "Extlookup with defaults" b
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0} $${1:Variable} = extlookup("${2:Lookup}", ${3:Default})$0
endsnippet endsnippet
snippet extlookup "Extlookup with defaults and custom data file" b snippet extlookup "Extlookup with defaults and custom data file" b
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0} $${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})$0
endsnippet endsnippet
snippet fail "Fail Function" b snippet fail "Fail Function" b
fail("${1:message}")${0} fail("${1:message}")$0
endsnippet endsnippet
snippet hiera "Hiera Function" b snippet hiera "Hiera Function" b
$${1:Variable} = hiera("${2:Lookup}")${0} $${1:Variable} = hiera("${2:Lookup}")$0
endsnippet endsnippet
snippet hiera "Hiera with defaults" b snippet hiera "Hiera with defaults" b
$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0} $${1:Variable} = hiera("${2:Lookup}", ${3:Default})$0
endsnippet endsnippet
snippet hiera "Hiera with defaults and override" b snippet hiera "Hiera with defaults and override" b
$${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})${0} $${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})$0
endsnippet endsnippet
snippet hiera_hash "Hiera Hash Function" b snippet hiera_hash "Hiera Hash Function" b
$${1:Variable} = hiera_hash("${2:Lookup}")${0} $${1:Variable} = hiera_hash("${2:Lookup}")$0
endsnippet endsnippet
snippet hiera_hash "Hiera Hash with defaults" b snippet hiera_hash "Hiera Hash with defaults" b
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})${0} $${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})$0
endsnippet endsnippet
snippet hiera_hash "Hiera Hash with defaults and override" b snippet hiera_hash "Hiera Hash with defaults and override" b
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})${0} $${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})$0
endsnippet endsnippet
snippet hiera_include "Hiera Include Function" b snippet hiera_include "Hiera Include Function" b
hiera_include("${1:Lookup}")${0} hiera_include("${1:Lookup}")$0
endsnippet endsnippet
snippet include "Include Function" b snippet include "Include Function" b
include ${1:classname}${0} include ${1:classname}$0
endsnippet endsnippet
snippet info "Info Function" b snippet info "Info Function" b
info("${1:message}")${0} info("${1:message}")$0
endsnippet endsnippet
snippet inline_template "Inline Template Function" b snippet inline_template "Inline Template Function" b
inline_template("<%= ${1:template} %>")${0} inline_template("<%= ${1:template} %>")$0
endsnippet endsnippet
snippet notice "Notice Function" b snippet notice "Notice Function" b
notice("${1:message}")${0} notice("${1:message}")$0
endsnippet endsnippet
snippet realize "Realize Function" b snippet realize "Realize Function" b
realize(${1:Resource}["${2:name}"])${0} realize(${1:Resource}["${2:name}"])$0
endsnippet endsnippet
snippet regsubst "Regsubst Function" b snippet regsubst "Regsubst Function" b
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0} regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')$0
endsnippet endsnippet
snippet split "Split Function" b snippet split "Split Function" b
$${1:Variable} = split($${1:Target}, '${2:regexp}')${0} $${1:Variable} = split($${1:Target}, '${2:regexp}')$0
endsnippet endsnippet
snippet versioncmp "Version Compare Function" b snippet versioncmp "Version Compare Function" b
$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0} $${1:Variable} = versioncmp('${1:version}', '${2:version}')$0
endsnippet endsnippet
snippet warning "Warning Function" b snippet warning "Warning Function" b
warning("${1:message}")${0} warning("${1:message}")$0
endsnippet endsnippet
# vim:ft=snippets: # vim:ft=snippets:

View file

@ -19,7 +19,7 @@ endsnippet
snippet with "with" b snippet with "with" b
with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}: with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}:
${3:${VISUAL:pass}} ${3:${VISUAL:pass}}
${0} $0
endsnippet endsnippet
snippet for "for loop" b snippet for "for loop" b

View file

@ -24,11 +24,11 @@ setwd("${1:`!p snip.rv = os.getcwd()`}")
endsnippet endsnippet
snippet as "Apply type on variable" w snippet as "Apply type on variable" w
as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL}) as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`($2${VISUAL})
endsnippet endsnippet
snippet is "Test type on variable" w snippet is "Test type on variable" w
is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL}) is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`($2${VISUAL})
endsnippet endsnippet
snippet dl "Download and install a package" b snippet dl "Download and install a package" b
@ -50,51 +50,51 @@ source('${0:file}')
endsnippet endsnippet
snippet if "If statement" snippet if "If statement"
if (${1}) { if ($1) {
${0} $0
} }
endsnippet endsnippet
snippet eif "Else-If statement" snippet eif "Else-If statement"
else if (${1}) { else if ($1) {
${0} $0
} }
endsnippet endsnippet
snippet el "Else statement" snippet el "Else statement"
else { else {
${0} $0
} }
endsnippet endsnippet
snippet ife "if .. else" snippet ife "if .. else"
if (${1}) { if ($1) {
${2} $2
} else { } else {
${3} $3
} }
endsnippet endsnippet
snippet wh "while loop" snippet wh "while loop"
while(${1}) { while($1) {
${2} $2
} }
endsnippet endsnippet
snippet for "for loop" snippet for "for loop"
for (${1:item} in ${2:list}) { for (${1:item} in ${2:list}) {
${3} $3
} }
endsnippet endsnippet
snippet fun "Function definition" snippet fun "Function definition"
${1:name} <- function (${2}) { ${1:name} <- function ($2) {
${0} $0
} }
endsnippet endsnippet
snippet ret "Return call" snippet ret "Return call"
return(${0}) return($0)
endsnippet endsnippet
snippet df "Data frame" snippet df "Data frame"

View file

@ -22,7 +22,7 @@ class ${1:Model}Controller < ApplicationController
$0 $0
private private
def find_${2} def find_$2
@$2 = ${3:$1}.find(params[:id]) if params[:id] @$2 = ${3:$1}.find(params[:id]) if params[:id]
end end
end end
@ -253,7 +253,7 @@ after_validation_on_update $0
endsnippet endsnippet
snippet asg "assert(var = assigns(:var))" snippet asg "assert(var = assigns(:var))"
assert(${1:var} = assigns(:${1}), "Cannot find @${1}") assert(${1:var} = assigns(:$1), "Cannot find @$1")
$0 $0
endsnippet endsnippet
@ -270,11 +270,11 @@ end
endsnippet endsnippet
snippet artnpp "assert_redirected_to (nested path plural)" snippet artnpp "assert_redirected_to (nested path plural)"
assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:${2}})} assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:$2})}
endsnippet endsnippet
snippet artnp "assert_redirected_to (nested path)" snippet artnp "assert_redirected_to (nested path)"
assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})} assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:$12}, ${16:@}${17:$13})}
endsnippet endsnippet
snippet artpp "assert_redirected_to (path plural)" snippet artpp "assert_redirected_to (path plural)"
@ -282,7 +282,7 @@ assert_redirected_to ${10:${2:model}s_path}
endsnippet endsnippet
snippet artp "assert_redirected_to (path)" snippet artp "assert_redirected_to (path)"
assert_redirected_to ${2:${12:model}_path(${13:@}${14:${12}})} assert_redirected_to ${2:${12:model}_path(${13:@}${14:$12})}
endsnippet endsnippet
snippet asrj "assert_rjs" snippet asrj "assert_rjs"
@ -324,7 +324,7 @@ before_validation_on_update
endsnippet endsnippet
snippet bt "belongs_to (bt)" snippet bt "belongs_to (bt)"
belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"} belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:$1_id}"}
endsnippet endsnippet
snippet crw "cattr_accessor" snippet crw "cattr_accessor"
@ -358,7 +358,7 @@ endsnippet
snippet deftg "def get request" snippet deftg "def get request"
def test_should_get_${1:action} def test_should_get_${1:action}
${2:@${3:model} = ${4:$3s}(:${5:fixture_name}) ${2:@${3:model} = ${4:$3s}(:${5:fixture_name})
}get :${1}${6:, :id => @$3.to_param} }get :$1${6:, :id => @$3.to_param}
assert_response :success assert_response :success
$0 $0
end end
@ -367,7 +367,7 @@ endsnippet
snippet deftp "def post request" snippet deftp "def post request"
def test_should_post_${1:action} def test_should_post_${1:action}
${3:@$2 = ${4:$2s}(:${5:fixture_name}) ${3:@$2 = ${4:$2s}(:${5:fixture_name})
}post :${1}${6:, :id => @$2.to_param}, :${2:model} => { $0 } }post :$1${6:, :id => @$2.to_param}, :${2:model} => { $0 }
assert_response :redirect assert_response :redirect
end end
@ -400,23 +400,23 @@ end
endsnippet endsnippet
snippet habtm "has_and_belongs_to_many (habtm)" snippet habtm "has_and_belongs_to_many (habtm)"
has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:${1}_id}"} has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:$1_id}"}
endsnippet endsnippet
snippet hm "has_many (hm)" snippet hm "has_many (hm)"
has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"} has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"}
endsnippet endsnippet
snippet hmt "has_many (through)" snippet hmt "has_many (through)"
has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:${2}_table_foreign_key_to_${1}_table}} has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:$2_table_foreign_key_to_$1_table}}
endsnippet endsnippet
snippet hmd "has_many :dependent => :destroy" snippet hmd "has_many :dependent => :destroy"
has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0 has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0
endsnippet endsnippet
snippet ho "has_one (ho)" snippet ho "has_one (ho)"
has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"} has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:$1_id}"}
endsnippet endsnippet
snippet logd "logger.debug" snippet logd "logger.debug"
@ -514,11 +514,11 @@ redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@ite
endsnippet endsnippet
snippet renpp "redirect_to (nested path plural)" snippet renpp "redirect_to (nested path plural)"
redirect_to(${2:${10:parent}_${11:child}_path(${12:@}${13:${10}})}) redirect_to(${2:${10:parent}_${11:child}_path(${12:@}${13:$10})})
endsnippet endsnippet
snippet renp "redirect_to (nested path)" snippet renp "redirect_to (nested path)"
redirect_to(${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}) redirect_to(${2:${12:parent}_${13:child}_path(${14:@}${15:$12}, ${16:@}${17:$13})})
endsnippet endsnippet
snippet repp "redirect_to (path plural)" snippet repp "redirect_to (path plural)"
@ -526,7 +526,7 @@ redirect_to(${2:${10:model}s_path})
endsnippet endsnippet
snippet rep "redirect_to (path)" snippet rep "redirect_to (path)"
redirect_to(${2:${12:model}_path(${13:@}${14:${12}})}) redirect_to(${2:${12:model}_path(${13:@}${14:$12})})
endsnippet endsnippet
snippet reb "redirect_to :back" snippet reb "redirect_to :back"
@ -882,12 +882,12 @@ end
endsnippet endsnippet
snippet trans "Translation snippet" snippet trans "Translation snippet"
I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}${3}', :default => "${1:some_text}"${4})${5:$0} I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}$3', :default => "${1:some_text}"$4)${5:$0}
endsnippet endsnippet
snippet route_spec snippet route_spec
it 'routes to #${1:action}' do it 'routes to #${1:action}' do
${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6} ${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})$6
end end
endsnippet endsnippet

View file

@ -28,7 +28,7 @@ SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
#http://docutils.sourceforge.net/docs/ref/rst/directives.html #http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['topic','sidebar','math','epigraph', DIRECTIVES = ['topic','sidebar','math','epigraph',
'parsed-literal','code','highlights', 'parsed-literal','code','highlights',
'pull-quote','compound','container', 'pull-quote','compound','container','table','csv-table',
'list-table','class','sectnum', 'list-table','class','sectnum',
'role','default-role','unicode', 'role','default-role','unicode',
'raw'] 'raw']
@ -238,6 +238,7 @@ if di == 'im':
if di == 'fi': if di == 'fi':
content=""" content="""
:alt: {0} :alt: {0}
{0}""".format(real_name) {0}""".format(real_name)
` `
..`!p snip.rv = " %s" % link if link else ""` $1`!p ..`!p snip.rv = " %s" % link if link else ""` $1`!p
@ -281,6 +282,23 @@ snippet ro "Text Roles" w
path))`:\`$2\`\ path))`:\`$2\`\
endsnippet endsnippet
snippet eu "Embedded URI" i
`!p
if has_cjk(vim.current.line):
snip.rv = "\ "`\`${1:${VISUAL:Text}} <${2:URI}>\`_`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = ""
`$0
endsnippet
snippet fnt "Footnote or Citation" i
[${1:Label}]_ $0
.. [$1] ${2:Reference}
endsnippet
############ ############
# Sphinx # # Sphinx #
############ ############

View file

@ -5,22 +5,22 @@
priority -50 priority -50
snippet let "let variable declaration" b snippet let "let variable declaration" b
let ${1:name}${2:: ${3:type}} = ${4}; let ${1:name}${2:: ${3:type}} = $4;
endsnippet endsnippet
snippet letm "let mut variable declaration" b snippet letm "let mut variable declaration" b
let mut ${1:name}${2:: ${3:type}} = ${4}; let mut ${1:name}${2:: ${3:type}} = $4;
endsnippet endsnippet
snippet fn "A function, optionally with arguments and return type." snippet fn "A function, optionally with arguments and return type."
fn ${1:function_name}(${2})${3/..*/ -> /}${3} { fn ${1:function_name}($2)${3/..*/ -> /}$3 {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet pfn "A public function, optionally with arguments and return type." snippet pfn "A public function, optionally with arguments and return type."
pub fn ${1:function_name}(${2})${3/..*/ -> /}${3} { pub fn ${1:function_name}($2)${3/..*/ -> /}$3 {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
@ -29,44 +29,44 @@ ${1:a}: ${2:T}${3:, arg}
endsnippet endsnippet
snippet || "Closure, anonymous function (inline)" i snippet || "Closure, anonymous function (inline)" i
${1:move }|${2}| { $3 } ${1:move }|$2| { $3 }
endsnippet endsnippet
snippet |} "Closure, anonymous function (block)" i snippet |} "Closure, anonymous function (block)" i
${1:move }|${2}| { ${1:move }|$2| {
$3 $3
} }
endsnippet endsnippet
snippet pri "print!(..)" b snippet pri "print!(..)" b
print!("${1}"${2/..*/, /}${2}); print!("$1"${2/..*/, /}$2);
endsnippet endsnippet
snippet pln "println!(..)" b snippet pln "println!(..)" b
println!("${1}"${2/..*/, /}${2}); println!("$1"${2/..*/, /}$2);
endsnippet endsnippet
snippet fmt "format!(..)" snippet fmt "format!(..)"
format!("${1}"${2/..*/, /}${2}); format!("$1"${2/..*/, /}$2);
endsnippet endsnippet
snippet macro "macro_rules!" b snippet macro "macro_rules!" b
macro_rules! ${1:name} { macro_rules! ${1:name} {
(${2:matcher}) => ( (${2:matcher}) => (
${3} $3
) )
} }
endsnippet endsnippet
snippet mod "A module" b snippet mod "A module" b
mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} { mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
snippet for "for .. in .." b snippet for "for .. in .." b
for ${1:i} in ${2} { for ${1:i} in $2 {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
@ -76,19 +76,19 @@ endsnippet
snippet st "Struct" b snippet st "Struct" b
struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} { struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
${VISUAL}${0} ${VISUAL}$0
} }
endsnippet endsnippet
# TODO: fancy dynamic field mirroring like Python slotclass # TODO: fancy dynamic field mirroring like Python slotclass
snippet stn "Struct with new constructor." b snippet stn "Struct with new constructor." b
pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} { pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
fd${0} fd$0
} }
impl $1 { impl $1 {
pub fn new(${2}) -> $1 { pub fn new($2) -> $1 {
$1 { ${3} } $1 { $3 }
} }
} }
endsnippet endsnippet
@ -99,7 +99,7 @@ endsnippet
snippet impl "Struct/Trait implementation" b snippet impl "Struct/Trait implementation" b
impl ${1:Type/Trait}${2: for ${3:Type}} { impl ${1:Type/Trait}${2: for ${3:Type}} {
${0} $0
} }
endsnippet endsnippet

View file

@ -5,6 +5,6 @@ for (${1:1}, ${2:10}) {${3: |i}|}
endsnippet endsnippet
snippet sdef snippet sdef
SynthDef(\\${1:synthName}, {${2: |${3:x}|} SynthDef(\\${1:synthName}, {${2: |${3:x}|}
${0} $0
}).add; }).add;
endsnippet endsnippet

View file

@ -5,21 +5,21 @@ priority -50
########################################################################### ###########################################################################
snippet for "for... (for)" b snippet for "for... (for)" b
for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} { for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} {
${4} $4
} }
endsnippet endsnippet
snippet foreach "foreach... (foreach)" snippet foreach "foreach... (foreach)"
foreach ${1:var} ${2:\$list} { foreach ${1:var} ${2:\$list} {
${3} $3
} }
endsnippet endsnippet
snippet if "if... (if)" b snippet if "if... (if)" b
if {${1:condition}} { if {${1:condition}} {
${2} $2
} }
endsnippet endsnippet
@ -27,7 +27,7 @@ endsnippet
snippet proc "proc... (proc)" b snippet proc "proc... (proc)" b
proc ${1:name} {${2:args}} \ proc ${1:name} {${2:args}} \
{ {
${3} $3
} }
endsnippet endsnippet
@ -35,16 +35,16 @@ endsnippet
snippet switch "switch... (switch)" b snippet switch "switch... (switch)" b
switch ${1:-exact} -- ${2:\$var} { switch ${1:-exact} -- ${2:\$var} {
${3:match} { ${3:match} {
${4} $4
} }
default {${5}} default {$5}
} }
endsnippet endsnippet
snippet while "while... (while)" b snippet while "while... (while)" b
while {${1:condition}} { while {${1:condition}} {
${2} $2
} }
endsnippet endsnippet

View file

@ -53,7 +53,7 @@ snippet desc "Description" b
endsnippet endsnippet
snippet it "Individual item" b snippet it "Individual item" b
\item ${1} \item $1
$0 $0
endsnippet endsnippet
@ -61,54 +61,54 @@ snippet part "Part" b
\part{${1:part name}} \part{${1:part name}}
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}} \label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
${0} $0
endsnippet endsnippet
snippet cha "Chapter" b snippet cha "Chapter" b
\chapter{${1:chapter name}} \chapter{${1:chapter name}}
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} \label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0} $0
endsnippet endsnippet
snippet sec "Section" b snippet sec "Section" b
\section{${1:section name}} \section{${1:section name}}
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} \label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0} $0
endsnippet endsnippet
snippet sub "Subsection" b snippet sub "Subsection" b
\subsection{${1:subsection name}} \subsection{${1:subsection name}}
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} \label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0} $0
endsnippet endsnippet
snippet ssub "Subsubsection" b snippet ssub "Subsubsection" b
\subsubsection{${1:subsubsection name}} \subsubsection{${1:subsubsection name}}
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} \label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0} $0
endsnippet endsnippet
snippet par "Paragraph" b snippet par "Paragraph" b
\paragraph{${1:paragraph name}} \paragraph{${1:paragraph name}}
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} \label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0} $0
endsnippet endsnippet
snippet subp "Subparagraph" b snippet subp "Subparagraph" b
\subparagraph{${1:subparagraph name}} \subparagraph{${1:subparagraph name}}
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} \label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0} $0
endsnippet endsnippet
snippet ni "Non-indented paragraph" b snippet ni "Non-indented paragraph" b
\noindent \noindent
${0} $0
endsnippet endsnippet
snippet pac "Package" b snippet pac "Package" b

View file

@ -13,11 +13,11 @@ snippet guard "script reload guard" b
if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700} if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700}
finish finish
endif endif
let $1 = 1${3} let $1 = 1$3
endsnippet endsnippet
snippet f "function" b snippet f "function" b
fun ${1:function_name}(${2}) fun ${1:function_name}($2)
${3:" code} ${3:" code}
endf endf
endsnippet endsnippet

View file

@ -96,7 +96,7 @@ snippet interface
} }
snippet try snippet try
try { try {
${1} ${1:${VISUAL}}
} catch (error:ErrorType) { } catch (error:ErrorType) {
${2} ${2}
} finally { } finally {
@ -115,11 +115,11 @@ snippet forr
# If Condition # If Condition
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
${0} ${0:${VISUAL}}
} }
snippet el snippet el
else { else {
${0} ${0:${VISUAL}}
} }
# Ternary conditional # Ternary conditional
snippet t snippet t

View file

@ -90,19 +90,19 @@ snippet fors for some
snippet if if snippet if if
if ${1} then if ${1} then
${0} ${0:${VISUAL}}
end if; end if;
snippet ife if ... else snippet ife if ... else
if ${1} then if ${1} then
${2} ${2:${VISUAL}}
else else
${0} ${0}
end if; end if;
snippet el else snippet el else
else else
${0} ${0:${VISUAL}}
snippet eif elsif snippet eif elsif
elsif ${1} then elsif ${1} then
@ -110,13 +110,13 @@ snippet eif elsif
snippet wh while snippet wh while
while ${1} loop while ${1} loop
${0} ${0:${VISUAL}}
end loop; end loop;
snippet nwh named while snippet nwh named while
${1}: ${1}:
while ${2} loop while ${2} loop
${0} ${0:${VISUAL}}
end loop $1; end loop $1;
snippet for for snippet for for

View file

@ -9,22 +9,22 @@ snippet dir
# <FilesMatch> # <FilesMatch>
snippet filesmatch snippet filesmatch
<FilesMatch "${1:regex}"> <FilesMatch "${1:regex}">
${0} ${0:${VISUAL}}
</FilesMatch> </FilesMatch>
# <IfModule> # <IfModule>
snippet ifmodule snippet ifmodule
<IfModule ${1:mod_example.c}> <IfModule ${1:mod_example.c}>
${0} ${0:${VISUAL}}
</IfModule> </IfModule>
# <LimitExcept> # <LimitExcept>
snippet limitexcept snippet limitexcept
<LimitExcept ${1:POST GET}> <LimitExcept ${1:POST GET}>
${0} ${0:${VISUAL}}
</LimitExcept> </LimitExcept>
# <Proxy> # <Proxy>
snippet proxy snippet proxy
<Proxy ${1:*}> <Proxy ${1:*}>
${0} ${0:${VISUAL}}
</Proxy> </Proxy>
# <VirtualHost> # <VirtualHost>
snippet virtualhost snippet virtualhost

View file

@ -20,7 +20,7 @@ snippet def
# if # if
snippet if snippet if
if (${1:/* condition */}) { if (${1:/* condition */}) {
${2} ${0:${VISUAL}}
} }
# else # else
snippet el snippet el

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