mirror of
https://github.com/amix/vimrc
synced 2024-12-13 21:52:38 +00:00
Updated plugins
This commit is contained in:
parent
a6de243fca
commit
fe46dfbbe6
141 changed files with 2790 additions and 1630 deletions
|
@ -303,7 +303,6 @@ fu! s:match_window_opts()
|
|||
let s:mw_res =
|
||||
\ s:mw =~ 'results:[^,]\+' ? str2nr(matchstr(s:mw, 'results:\zs\d\+'))
|
||||
\ : min([s:mw_max, &lines])
|
||||
let s:mw_res = max([s:mw_res, 1])
|
||||
endf
|
||||
"}}}1
|
||||
" * Open & Close {{{1
|
||||
|
@ -1995,9 +1994,14 @@ fu! s:bufnrfilpath(line)
|
|||
en
|
||||
let filpath = fnamemodify(filpath, ':p')
|
||||
let bufnr = bufnr('^'.filpath.'$')
|
||||
if (a:line =~ '[\/]\?\[\d\+\*No Name\]$' && !filereadable(filpath) && bufnr < 1)
|
||||
if (!filereadable(filpath) && bufnr < 1)
|
||||
if (a:line =~ '[\/]\?\[\d\+\*No Name\]$')
|
||||
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
|
||||
retu [bufnr, filpath]
|
||||
endf
|
||||
|
|
|
@ -137,8 +137,8 @@ fu! ctrlp#tag#id()
|
|||
endf
|
||||
|
||||
fu! ctrlp#tag#enter()
|
||||
let tfs = tagfiles()
|
||||
let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
|
||||
let tfs = get(g:, 'ctrlp_custom_tag_files', tagfiles())
|
||||
let s:tagfiles = type(tfs) == 3 && tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
|
||||
\ 'filereadable(v:val)') : []
|
||||
endf
|
||||
"}}}
|
||||
|
|
|
@ -148,6 +148,7 @@ The minimum and maximum heights:
|
|||
|
||||
The maximum number of results:
|
||||
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.
|
||||
|
||||
|
@ -1497,6 +1498,9 @@ Special thanks:~
|
|||
===============================================================================
|
||||
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~
|
||||
|
||||
+ New command: |YankLine()| to yank current line.
|
||||
|
|
|
@ -122,7 +122,7 @@ function! s:tranquilize()
|
|||
endfunction
|
||||
|
||||
function! s:hide_statusline()
|
||||
let &l:statusline = repeat(' ', winwidth(0))
|
||||
setlocal statusline=\
|
||||
endfunction
|
||||
|
||||
function! s:hide_linenr()
|
||||
|
@ -239,7 +239,7 @@ function! s:goyo_on(dim)
|
|||
set showtabline=0
|
||||
set noruler
|
||||
set fillchars+=vert:\
|
||||
set fillchars+=stl:.
|
||||
set fillchars+=stl:\
|
||||
set fillchars+=stlnc:\
|
||||
set sidescroll=1
|
||||
set sidescrolloff=0
|
||||
|
|
|
@ -301,10 +301,10 @@ endfunction
|
|||
"FUNCTION: Path._escChars() {{{1
|
||||
function! s:Path._escChars()
|
||||
if nerdtree#runningWindows()
|
||||
return " `\|\"#%&,?()\*^<>"
|
||||
return " `\|\"#%&,?()\*^<>$"
|
||||
endif
|
||||
|
||||
return " \\`\|\"#%&,?()\*^<>[]"
|
||||
return " \\`\|\"#%&,?()\*^<>[]$"
|
||||
endfunction
|
||||
|
||||
"FUNCTION: Path.getDir() {{{1
|
||||
|
|
|
@ -3226,7 +3226,7 @@ accepts the standard options described at |syntastic-config-makeprg|.
|
|||
|
||||
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:
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if has('reltime')
|
|||
lockvar! g:_SYNTASTIC_START
|
||||
endif
|
||||
|
||||
let g:_SYNTASTIC_VERSION = '3.8.0-10'
|
||||
let g:_SYNTASTIC_VERSION = '3.8.0-21'
|
||||
lockvar g:_SYNTASTIC_VERSION
|
||||
|
||||
" Sanity checks {{{1
|
||||
|
@ -67,6 +67,15 @@ else
|
|||
endif
|
||||
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
|
||||
|
||||
" Defaults {{{1
|
||||
|
@ -344,13 +353,6 @@ function! s:BufWinEnterHook(fname) abort " {{{2
|
|||
endfunction " }}}2
|
||||
|
||||
function! s:VimEnterHook() abort " {{{2
|
||||
let g:syntastic_version =
|
||||
\ g:_SYNTASTIC_VERSION .
|
||||
\ ' (Vim ' . v:version . (has('nvim') ? ', Neovim' : '') . ', ' .
|
||||
\ g:_SYNTASTIC_UNAME .
|
||||
\ (has('gui') ? ', GUI' : '') . ')'
|
||||
lockvar g:syntastic_version
|
||||
|
||||
let buf = bufnr('')
|
||||
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
|
||||
\ 'autocmd: VimEnter, buffer ' . buf . ' = ' . string(bufname(buf)) . ', &buftype = ' . string(&buftype))
|
||||
|
|
|
@ -13,28 +13,58 @@ main([File]) ->
|
|||
%% `rebar.config` is looked for,
|
||||
%% but it is not necessarily the one in the project root.
|
||||
%% I.e. it may be one deeper in the project file hierarchy.
|
||||
RebarFile = rebar_file(Dir),
|
||||
Profile = which_compile_opts_profile(filename:absname(File)),
|
||||
CompileOpts = case which_build_tool(Dir, Profile) of
|
||||
{rebar, RebarFile} ->
|
||||
%% `rebar.config` might contain relative paths.
|
||||
%% They are relative to the file! Not to the project root.
|
||||
RebarOpts = rebar_opts(Dir ++ "/" ++ RebarFile),
|
||||
%% 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")),
|
||||
%% `compile:file/2` requires the `{i, Path}` to be relative
|
||||
%% to CWD - no surprise here.
|
||||
compile:file(File, Defs ++ translate_paths(Dir, RebarOpts));
|
||||
compile:file(File, Defs ++ translate_paths(Dir, CompileOpts));
|
||||
|
||||
main(_) ->
|
||||
io:format("Usage: ~s <file>~n", [escript:script_name()]),
|
||||
halt(1).
|
||||
|
||||
rebar_file(Dir) ->
|
||||
DirList = filename:split(Dir),
|
||||
case lists:last(DirList) of
|
||||
"test" ->
|
||||
"rebar.test.config";
|
||||
_ ->
|
||||
"rebar.config"
|
||||
which_compile_opts_profile(File) ->
|
||||
case filename:basename(filename:dirname(File)) of
|
||||
"test" -> test;
|
||||
_ -> normal
|
||||
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) ->
|
||||
Dir = get_root(filename:dirname(RebarFile)),
|
||||
case file:consult(RebarFile) of
|
||||
|
@ -54,6 +84,165 @@ rebar_opts(RebarFile) ->
|
|||
rebar_opts("rebar.config")
|
||||
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() ->
|
||||
code:add_pathsa(filelib:wildcard("deps/*/ebin")),
|
||||
code:add_pathsa(nested_app_ebins()),
|
||||
|
|
|
@ -32,9 +32,12 @@ function! SyntaxCheckers_haxe_haxe_GetLocList() dict
|
|||
|
||||
if hxml !=# ''
|
||||
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({
|
||||
\ 'makeprg': makeprg,
|
||||
|
|
|
@ -25,7 +25,7 @@ function! SyntaxCheckers_javascript_flow_IsAvailable() dict
|
|||
if !executable(self.getExec())
|
||||
return 0
|
||||
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
|
||||
|
||||
function! SyntaxCheckers_javascript_flow_GetLocList() dict
|
||||
|
@ -34,8 +34,8 @@ function! SyntaxCheckers_javascript_flow_GetLocList() dict
|
|||
endif
|
||||
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'exe': self.getExecEscaped() . ' check',
|
||||
\ 'args_after': '--show-all-errors --json' })
|
||||
\ 'exe': self.getExecEscaped() . ' status',
|
||||
\ 'args_after': '--quiet --show-all-errors --json' })
|
||||
|
||||
let errorformat =
|
||||
\ '%f:%l:%c:%n: %m,' .
|
||||
|
|
|
@ -24,9 +24,12 @@ function! SyntaxCheckers_vala_valac_GetHighlightRegex(pos) " {{{1
|
|||
endfunction " }}}1
|
||||
|
||||
function! SyntaxCheckers_vala_valac_GetLocList() dict " {{{1
|
||||
let vala_pkg_args = join(map(s:GetValaModules(), '"--pkg ".v:val'), ' ')
|
||||
let vala_vapi_args = join(map(s:GetValaVapiDirs(), '"--vapidir ".v:val'), ' ')
|
||||
let makeprg = self.makeprgBuild({ 'args': '-C ' . vala_pkg_args . ' ' . vala_vapi_args })
|
||||
let buf = bufnr('')
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'args': '-C ' .
|
||||
\ s:GetValaOpts(buf, 'modules', 'modules', '--pkg') . ' ' .
|
||||
\ s:GetValaOpts(buf, 'vapi_dirs', 'vapidirs', '--vapidir'),
|
||||
\ })
|
||||
|
||||
let errorformat =
|
||||
\ '%A%f:%l.%c-%\d%\+.%\d%\+: %t%[a-z]%\+: %m,'.
|
||||
|
@ -40,38 +43,27 @@ endfunction " }}}1
|
|||
|
||||
" Utilities {{{1
|
||||
|
||||
function! s:GetValaModules() " {{{2
|
||||
if exists('g:syntastic_vala_modules') || exists('b:syntastic_vala_modules')
|
||||
let modules = syntastic#util#var('vala_modules')
|
||||
if type(modules) == type('')
|
||||
return split(modules, '\m\s\+')
|
||||
elseif type(modules) == type([])
|
||||
return copy(modules)
|
||||
function! s:GetValaOpts(buf, name, comment, cmd) " {{{2
|
||||
let var = syntastic#util#var('vala_' . a:name)
|
||||
if type(var) == type([])
|
||||
let opts = map(copy(var), 'syntastic#util#shescape(v:val)')
|
||||
elseif type(var) == type('')
|
||||
if var !=# ''
|
||||
let opts = split(var, '\s\+')
|
||||
else
|
||||
echoerr 'syntastic_vala_modules must be either list or string: fallback to in file modules string'
|
||||
endif
|
||||
endif
|
||||
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
|
||||
|
||||
let modules_line = search('^// modules: ', 'n')
|
||||
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)
|
||||
call map( filter(opts, 'v:val !=# ""'), 'syntastic#util#shescape(v:val)' )
|
||||
endif
|
||||
else
|
||||
echoerr 'syntastic_vala_vapi_dirs must be either a list, or a string: fallback to in-file modules string'
|
||||
endif
|
||||
call syntastic#log#error('syntastic_vala_' . a:name . ' must be either a list, or a string')
|
||||
return ''
|
||||
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\+' )
|
||||
return join(map(opts, string(a:cmd . ' ') . ' . v:val'))
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
|
|
@ -18,7 +18,7 @@ setlocal indentexpr=GetCoffeeHtmlIndent(v:lnum)
|
|||
|
||||
function! GetCoffeeHtmlIndent(curlinenum)
|
||||
" See if we're inside a coffeescript block.
|
||||
let scriptlnum = searchpair('<script [^>]*type="text/coffeescript"[^>]*>', '',
|
||||
let scriptlnum = searchpair('<script [^>]*type=[''"]\?text/coffeescript[''"]\?[^>]*>', '',
|
||||
\ '</script>', 'bWn')
|
||||
let prevlnum = prevnonblank(a:curlinenum)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ endif
|
|||
|
||||
" Syntax highlighting for text/coffeescript script tags
|
||||
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
|
||||
\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc
|
||||
\ containedin=htmlHead
|
||||
|
|
|
@ -4,4 +4,14 @@
|
|||
def: 42
|
||||
}
|
||||
</script>
|
||||
<script type='text/coffeescript'>
|
||||
abc = {
|
||||
def: 42
|
||||
}
|
||||
</script>
|
||||
<script type=text/coffeescript>
|
||||
abc = {
|
||||
def: 42
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -195,7 +195,7 @@ function! fugitive#detect(path) abort
|
|||
nnoremap <buffer> <silent> y<C-G> :call setreg(v:register, <SID>recall())<CR>
|
||||
endif
|
||||
let buffer = fugitive#buffer()
|
||||
if expand('%:p') =~# '//'
|
||||
if expand('%:p') =~# '://'
|
||||
call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', ''))
|
||||
endif
|
||||
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.{-}%($|\\@<!%(\\\\)*\|)@=')
|
||||
if exists(':terminal')
|
||||
let dir = s:repo().tree()
|
||||
if expand('%') != ''
|
||||
-tabedit %
|
||||
else
|
||||
-tabnew
|
||||
endif
|
||||
execute 'lcd' fnameescape(dir)
|
||||
execute 'terminal' git args
|
||||
else
|
||||
|
@ -2295,9 +2299,9 @@ function! s:Browse(bang,line1,count,...) abort
|
|||
|
||||
if empty(remote)
|
||||
let remote = '.'
|
||||
let raw = s:repo().git_chomp('config','remote.origin.url')
|
||||
let raw = s:repo().git_chomp('remote','get-url','origin')
|
||||
else
|
||||
let raw = s:repo().git_chomp('config','remote.'.remote.'.url')
|
||||
let raw = s:repo().git_chomp('remote','get-url',remote)
|
||||
endif
|
||||
if raw ==# ''
|
||||
let raw = remote
|
||||
|
|
4
sources_non_forked/vim-go/.gitignore
vendored
4
sources_non_forked/vim-go/.gitignore
vendored
|
@ -1,2 +1,6 @@
|
|||
doc/tags
|
||||
.DS_Store
|
||||
|
||||
# Test specific files
|
||||
FAILED
|
||||
test.log
|
||||
|
|
22
sources_non_forked/vim-go/.travis.yml
Normal file
22
sources_non_forked/vim-go/.travis.yml
Normal 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
|
||||
|
|
@ -1,7 +1,33 @@
|
|||
## 1.11 - Unplanned
|
||||
## unplanned
|
||||
|
||||
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_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]
|
||||
* 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:
|
||||
|
||||
|
@ -24,6 +52,22 @@ BUG FIXES:
|
|||
* Fix referencing a non defined variable for async commands when bang (!) was used
|
||||
* Fix `:GoDef` failing for a modified buffer if `hidden` was not set [gh-1132]
|
||||
* Fix `:GoDefStack` to allow popping from jump list when buffer is modified [gh-1133]
|
||||
* 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)
|
||||
|
|
7
sources_non_forked/vim-go/Makefile
Normal file
7
sources_non_forked/vim-go/Makefile
Normal file
|
@ -0,0 +1,7 @@
|
|||
all: test
|
||||
|
||||
test:
|
||||
@echo "==> Running tests"
|
||||
@./scripts/test.sh
|
||||
|
||||
.PHONY: all test
|
|
@ -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">
|
||||
<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:
|
||||
|
||||
```vim
|
||||
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>dt <Plug>(go-def-tab)
|
||||
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>dt <Plug>(go-def-tab)
|
||||
```
|
||||
|
||||
Open the relevant Godoc for the word under the cursor with `<leader>gd` or open
|
||||
it vertically with `<leader>gv`
|
||||
|
||||
```vim
|
||||
au FileType go nmap <Leader>gd <Plug>(go-doc)
|
||||
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
|
||||
au FileType go nmap <leader>gd <Plug>(go-doc)
|
||||
au FileType go nmap <leader>gv <Plug>(go-doc-vertical)
|
||||
```
|
||||
|
||||
Or open the Godoc in browser
|
||||
|
||||
```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
|
||||
with `<leader>s`
|
||||
|
||||
```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
|
||||
have disabled auto showing type info via `g:go_auto_type_info`)
|
||||
|
||||
```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
|
||||
|
||||
```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
|
||||
|
@ -245,8 +245,8 @@ Run `:GoRun` in a new tab, horizontal split or vertical split terminal
|
|||
|
||||
```vim
|
||||
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>rv <Plug>(go-run-vertical)
|
||||
au FileType go nmap <leader>rs <Plug>(go-run-split)
|
||||
au FileType go nmap <leader>rv <Plug>(go-run-vertical)
|
||||
```
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
People have asked for this for a long time, now you can be a fully supporter by
|
||||
|
|
|
@ -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
|
|
@ -25,7 +25,7 @@ function! go#asmfmt#Format() abort
|
|||
|
||||
" Write the current buffer to a tempfile.
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
call writefile(go#util#GetLines(), l:tmpname)
|
||||
|
||||
" Run asmfmt.
|
||||
let path = go#path#CheckBinPath("asmfmt")
|
||||
|
|
|
@ -32,8 +32,11 @@ function! go#cmd#Build(bang, ...) abort
|
|||
\})
|
||||
return
|
||||
elseif has('nvim')
|
||||
" if we have nvim, call it asynchronously and return early ;)
|
||||
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 ;)
|
||||
call go#jobcontrol#Spawn(a:bang, "build", args)
|
||||
return
|
||||
endif
|
||||
|
@ -419,7 +422,7 @@ function s:cmd_job(args) abort
|
|||
call go#statusline#Update(status_dir, status)
|
||||
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 start_options = {
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix'
|
||||
|
||||
function! s:gocodeCurrentBuffer() abort
|
||||
let buf = getline(1, '$')
|
||||
if &encoding != 'utf-8'
|
||||
let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")')
|
||||
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()
|
||||
call writefile(buf, file)
|
||||
|
||||
call writefile(go#util#GetLines(), file)
|
||||
return file
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ function s:coverage_job(args)
|
|||
call go#statusline#Update(status_dir, status)
|
||||
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 start_options = {
|
||||
|
|
|
@ -16,7 +16,7 @@ function! go#def#Jump(mode) abort
|
|||
if &modified
|
||||
" Write current unsaved buffer to a temp file and use the modified content
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
call writefile(go#util#GetLines(), l:tmpname)
|
||||
let fname = l:tmpname
|
||||
endif
|
||||
|
||||
|
@ -41,8 +41,7 @@ function! go#def#Jump(mode) abort
|
|||
let stdin_content = ""
|
||||
|
||||
if &modified
|
||||
let sep = go#util#LineEnding()
|
||||
let content = join(getline(1, '$'), sep)
|
||||
let content = join(go#util#GetLines(), "\n")
|
||||
let stdin_content = fname . "\n" . strlen(content) . "\n" . content
|
||||
call add(cmd, "-modified")
|
||||
endif
|
||||
|
@ -87,7 +86,7 @@ function! go#def#Jump(mode) abort
|
|||
return
|
||||
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
|
||||
endfunction
|
||||
|
||||
|
@ -96,10 +95,10 @@ function! s:jump_to_declaration_cb(mode, bin_name, job, exit_status, data) abort
|
|||
return
|
||||
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
|
||||
|
||||
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
|
||||
if a:bin_name == "godef"
|
||||
" 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
|
||||
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 start_options = {
|
||||
|
|
32
sources_non_forked/vim-go/autoload/go/def_test.vim
Normal file
32
sources_non_forked/vim-go/autoload/go/def_test.vim
Normal 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
|
|
@ -31,12 +31,11 @@ function! go#doc#OpenBrowser(...) abort
|
|||
|
||||
let import = out["import"]
|
||||
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/" . name
|
||||
else
|
||||
let godoc_url = "https://godoc.org/" . import . "#" . name
|
||||
let godoc_url = "https://godoc.org/" . import
|
||||
if decl !~ "^package"
|
||||
let godoc_url .= "#" . name
|
||||
endif
|
||||
|
||||
echo godoc_url
|
||||
|
@ -153,8 +152,7 @@ function! s:gogetdoc(json) abort
|
|||
" file size followed by newline
|
||||
" file contents
|
||||
let in = ""
|
||||
let sep = go#util#LineEnding()
|
||||
let content = join(getline(1, '$'), sep)
|
||||
let content = join(go#util#GetLines(), "\n")
|
||||
let in = fname . "\n" . strlen(content) . "\n" . content
|
||||
let command .= " -modified"
|
||||
let out = go#util#System(command, in)
|
||||
|
|
|
@ -2,26 +2,8 @@
|
|||
" Use of this source code is governed by a BSD-style
|
||||
" license that can be found in the LICENSE file.
|
||||
"
|
||||
" fmt.vim: Vim command to format Go files with gofmt.
|
||||
"
|
||||
" 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
|
||||
"
|
||||
" fmt.vim: Vim command to format Go files with gofmt (and gofmt compatible
|
||||
" toorls, such as goimports).
|
||||
|
||||
if !exists("g:go_fmt_command")
|
||||
let g:go_fmt_command = "gofmt"
|
||||
|
@ -67,6 +49,13 @@ function! go#fmt#Format(withGoimport) abort
|
|||
catch
|
||||
let l:curw = winsaveview()
|
||||
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
|
||||
" Save cursor position and many other things.
|
||||
let l:curw = winsaveview()
|
||||
|
@ -74,135 +63,32 @@ function! go#fmt#Format(withGoimport) abort
|
|||
|
||||
" Write current unsaved buffer to a temp file
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), 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
|
||||
call writefile(go#util#GetLines(), l:tmpname)
|
||||
if go#util#IsWin()
|
||||
let l:tmpname = tr(l:tmpname, '\', '/')
|
||||
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()
|
||||
let l:tmpname = tr(l:tmpname, '\', '/')
|
||||
endif
|
||||
let out = go#util#System(command . " " . l:tmpname)
|
||||
|
||||
if bin_name != "gofmt"
|
||||
let $GOPATH = old_gopath
|
||||
endif
|
||||
|
||||
let l:listtype = "locationlist"
|
||||
"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\+')
|
||||
let out = go#fmt#run(bin_name, l:tmpname, expand('%'))
|
||||
if go#util#ShellError() == 0
|
||||
" remove undo point caused via BufWritePre
|
||||
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
|
||||
call go#fmt#update_file(l:tmpname, expand('%'))
|
||||
elseif g:go_fmt_fail_silently == 0
|
||||
let splitted = split(out, '\n')
|
||||
"otherwise get the errors and put them to location list
|
||||
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]})
|
||||
let errors = s:parse_errors(out)
|
||||
call s:show_errors(errors)
|
||||
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
|
||||
|
||||
if g:go_fmt_experimental == 1
|
||||
" restore our undo history
|
||||
silent! exe 'rundo ' . tmpundofile
|
||||
call delete(tmpundofile)
|
||||
endif
|
||||
|
||||
if g:go_fmt_experimental == 1
|
||||
" Restore our cursor/windows positions, folds, etc.
|
||||
if empty(l:curw)
|
||||
silent! loadview
|
||||
|
@ -215,6 +101,134 @@ function! go#fmt#Format(withGoimport) abort
|
|||
endif
|
||||
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
|
||||
if get(g:, "go_fmt_autosave", 1)
|
||||
let g:go_fmt_autosave = 0
|
||||
|
@ -225,4 +239,5 @@ function! go#fmt#ToggleFmtAutoSave() abort
|
|||
let g:go_fmt_autosave = 1
|
||||
call go#util#EchoProgress("auto fmt enabled")
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
|
31
sources_non_forked/vim-go/autoload/go/fmt_test.vim
Normal file
31
sources_non_forked/vim-go/autoload/go/fmt_test.vim
Normal 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
|
|
@ -1,6 +1,6 @@
|
|||
" 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:
|
||||
" mode : guru mode, such as 'implements'
|
||||
" format : output format, either 'plain' or 'json'
|
||||
|
@ -34,10 +34,8 @@ function! s:guru_cmd(args) range abort
|
|||
let cmd = [bin_path]
|
||||
|
||||
let filename = fnamemodify(expand("%"), ':p:gs?\\?/?')
|
||||
let stdin_content = ""
|
||||
if &modified
|
||||
let sep = go#util#LineEnding()
|
||||
let content = join(getline(1, '$'), sep )
|
||||
let content = join(go#util#GetLines(), "\n")
|
||||
let result.stdin_content = filename . "\n" . strlen(content) . "\n" . content
|
||||
call add(cmd, "-modified")
|
||||
endif
|
||||
|
@ -127,7 +125,7 @@ function! s:sync_guru(args) abort
|
|||
|
||||
" run, forrest run!!!
|
||||
let command = join(result.cmd, " ")
|
||||
if &modified
|
||||
if has_key(result, 'stdin_content')
|
||||
let out = go#util#System(command, result.stdin_content)
|
||||
else
|
||||
let out = go#util#System(command)
|
||||
|
@ -198,10 +196,10 @@ function! s:async_guru(args) abort
|
|||
endfunction
|
||||
|
||||
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()
|
||||
call writefile(split(result.stdin_content, "\n"), l:tmpname, "b")
|
||||
let l:start_options.in_io = "file"
|
||||
|
@ -543,7 +541,7 @@ function! go#guru#ClearSameIds() abort
|
|||
endfor
|
||||
|
||||
" remove the autocmds we defined
|
||||
if exists("#BufWinEnter<buffer>")
|
||||
if exists("#BufWinEnter#<buffer>")
|
||||
autocmd! BufWinEnter <buffer>
|
||||
endif
|
||||
endfunction
|
||||
|
@ -635,7 +633,7 @@ function! go#guru#Tags(...) abort
|
|||
if !exists('g:go_guru_tags')
|
||||
call go#util#EchoSuccess("guru tags is not set")
|
||||
else
|
||||
call go#util#EchoSuccess("current guru tags: ". a:1)
|
||||
call go#util#EchoSuccess("current guru tags: ". g:go_guru_tags)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -38,6 +38,16 @@ endfunction
|
|||
" GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the
|
||||
" current files folder.
|
||||
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 = {
|
||||
\ 'desc': a:desc,
|
||||
\ 'bang': a:bang,
|
||||
|
@ -49,6 +59,9 @@ function! s:spawn(bang, desc, args) abort
|
|||
\ 'on_stdout': function('s:on_stdout'),
|
||||
\ 'on_stderr': function('s:on_stderr'),
|
||||
\ 'on_exit' : function('s:on_exit'),
|
||||
\ 'status_type' : status_type,
|
||||
\ 'status_dir' : status_dir,
|
||||
\ 'started_at' : started_at,
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
|
@ -91,6 +104,23 @@ endfunction
|
|||
" on_stderr handler. If there are no errors and a quickfix window is open,
|
||||
" it'll be closed.
|
||||
function! s:on_exit(job_id, exit_status, 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 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)
|
||||
|
||||
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)
|
||||
return
|
||||
endif
|
||||
|
||||
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#FilterValids(errors)
|
||||
|
@ -148,13 +184,13 @@ endfunction
|
|||
|
||||
" on_stdout is the stdout handler for jobstart(). It collects the output of
|
||||
" stderr and stores them to the jobs internal stdout list.
|
||||
function! s:on_stdout(job_id, data) dict abort
|
||||
function! s:on_stdout(job_id, data, event) dict abort
|
||||
call extend(self.stdout, a:data)
|
||||
endfunction
|
||||
|
||||
" on_stderr is the stderr handler for jobstart(). It collects the output of
|
||||
" stderr and stores them to the jobs internal stderr list.
|
||||
function! s:on_stderr(job_id, data) dict abort
|
||||
function! s:on_stderr(job_id, data, event) dict abort
|
||||
call extend(self.stderr, a:data)
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -10,10 +10,6 @@ if !exists("g:go_metalinter_enabled")
|
|||
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
|
||||
endif
|
||||
|
||||
if !exists("g:go_metalinter_deadline")
|
||||
let g:go_metalinter_deadline = "5s"
|
||||
endif
|
||||
|
||||
if !exists("g:go_golint_bin")
|
||||
let g:go_golint_bin = "golint"
|
||||
endif
|
||||
|
@ -48,16 +44,33 @@ function! go#lint#Gometa(autosave, ...) abort
|
|||
let cmd += [expand('%:p:h')]
|
||||
else
|
||||
" the user wants something else, let us use it.
|
||||
let cmd += [split(g:go_metalinter_command, " ")]
|
||||
let cmd += split(g:go_metalinter_command, " ")
|
||||
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')
|
||||
let deadline = get(g:, 'go_metalinter_deadline', 0)
|
||||
if deadline != 0
|
||||
let cmd += ["--deadline=" . deadline]
|
||||
endif
|
||||
|
||||
call s:lint_job({'cmd': cmd})
|
||||
return
|
||||
endif
|
||||
|
||||
" we add deadline only for sync mode
|
||||
let cmd += ["--deadline=" . g:go_metalinter_deadline]
|
||||
" We're calling gometalinter synchronously.
|
||||
|
||||
let cmd += ["--deadline=" . get(g:, 'go_metalinter_deadline', "5s")]
|
||||
|
||||
if a:autosave
|
||||
" include only messages for the active buffer
|
||||
let cmd += ["--include='^" . expand('%:p') . ".*$'"]
|
||||
|
@ -283,8 +296,8 @@ function s:lint_job(args)
|
|||
endfunction
|
||||
|
||||
let start_options = {
|
||||
\ 'callback': function("s:callback"),
|
||||
\ 'close_cb': function("s:close_cb"),
|
||||
\ 'callback': funcref("s:callback"),
|
||||
\ 'close_cb': funcref("s:close_cb"),
|
||||
\ }
|
||||
|
||||
call job_start(a:args.cmd, start_options)
|
||||
|
|
|
@ -110,6 +110,9 @@ function! go#path#Detect() abort
|
|||
endif
|
||||
endif
|
||||
|
||||
" Fix up the case where initial $GOPATH is empty,
|
||||
" and we end up with a trailing :
|
||||
let gopath = substitute(gopath, ":$", "", "")
|
||||
return gopath
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -85,8 +85,8 @@ function s:rename_job(args)
|
|||
endfunction
|
||||
|
||||
let start_options = {
|
||||
\ 'callback': function("s:callback"),
|
||||
\ 'close_cb': function("s:close_cb"),
|
||||
\ 'callback': funcref("s:callback"),
|
||||
\ 'close_cb': funcref("s:close_cb"),
|
||||
\ }
|
||||
|
||||
" modify GOPATH if needed
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("vim-go")
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("vim-go")
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("vim-go")
|
||||
}
|
|
@ -20,7 +20,7 @@ function! go#textobj#Function(mode) abort
|
|||
if &modified
|
||||
" Write current unsaved buffer to a temp file and use the modified content
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
call writefile(go#util#GetLines(), l:tmpname)
|
||||
let fname = l:tmpname
|
||||
endif
|
||||
|
||||
|
@ -107,7 +107,7 @@ function! go#textobj#FunctionJump(mode, direction) abort
|
|||
if &modified
|
||||
" Write current unsaved buffer to a temp file and use the modified content
|
||||
let l:tmpname = tempname()
|
||||
call writefile(getline(1, '$'), l:tmpname)
|
||||
call writefile(go#util#GetLines(), l:tmpname)
|
||||
let fname = l:tmpname
|
||||
endif
|
||||
|
||||
|
|
|
@ -305,4 +305,17 @@ function! go#util#EchoInfo(msg)
|
|||
redraw | echohl Debug | echom "vim-go: " . a:msg | echohl None
|
||||
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
|
||||
|
|
|
@ -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
|
||||
commands. If set to 1 it opens the test commands inside a new terminal
|
||||
according to |'g:go_term_mode'|, otherwise it will run them in the background
|
||||
just like `:GoBuild` and then display the status with
|
||||
|go#jobcontrol#Statusline()|. By default it is disabled.
|
||||
just like `:GoBuild`. By default it is disabled.
|
||||
>
|
||||
let g:go_term_enabled = 0
|
||||
<
|
||||
|
|
|
@ -151,6 +151,14 @@ if err != nil {
|
|||
${0}
|
||||
endsnippet
|
||||
|
||||
# error log snippet
|
||||
snippet errl "Error with log.Fatal(err)" !b
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
${0}
|
||||
endsnippet
|
||||
|
||||
# error multiple return
|
||||
snippet errn, "Error return with two return values" !b
|
||||
if err != nil {
|
||||
|
|
|
@ -132,6 +132,13 @@ abbr if err != nil { ... }
|
|||
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
|
||||
snippet errn,
|
||||
abbr if err != nil { return [...], err }
|
||||
|
|
|
@ -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
|
||||
" exist, to update current binaries pass 1 to the argument.
|
||||
function! s:GoInstallBinaries(updateBinaries)
|
||||
if $GOPATH == ""
|
||||
if $GOPATH == "" && go#util#gopath() == ""
|
||||
echohl Error
|
||||
echomsg "vim.go: $GOPATH is not set"
|
||||
echohl None
|
||||
|
|
81
sources_non_forked/vim-go/scripts/runtest.vim
Normal file
81
sources_non_forked/vim-go/scripts/runtest.vim
Normal 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!
|
|
@ -1,77 +1,29 @@
|
|||
#!/bin/bash -e
|
||||
#
|
||||
# Copyright 2012 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
#
|
||||
# Tests for import.vim.
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
cat > base.go <<EOF
|
||||
package test
|
||||
# cleanup test.log
|
||||
if [ -f "test.log" ]; then
|
||||
rm test.log
|
||||
fi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net"
|
||||
if [ -f "FAILED" ]; then
|
||||
rm FAILED
|
||||
fi
|
||||
|
||||
"mycorp/foo"
|
||||
)
|
||||
EOF
|
||||
for test_file in ../autoload/go/*_test.vim
|
||||
do
|
||||
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
|
||||
# Pattern is a PCRE expression that will match across lines.
|
||||
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
|
||||
# if Failed exists, test failed
|
||||
if [ -f "FAILED" ]; then
|
||||
echo 2>&1 "FAIL"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
" let OPTION_NAME = 0
|
||||
" in your ~/.vimrc file to disable particular options. You can also write:
|
||||
" let OPTION_NAME = 1
|
||||
" to enable particular options.
|
||||
" At present, all options default to on, except highlight of:
|
||||
" functions, methods, structs, operators, build constraints and interfaces.
|
||||
" to enable particular options. At present, all options default to off:
|
||||
"
|
||||
" - go_highlight_array_whitespace_error
|
||||
" Highlights white space after "[]".
|
||||
|
@ -36,23 +34,23 @@ if exists("b:current_syntax")
|
|||
endif
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if !exists("g:go_highlight_extra_types")
|
||||
let g:go_highlight_extra_types = 1
|
||||
let g:go_highlight_extra_types = 0
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
if !exists("g:go_highlight_operators")
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package pkg
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSample(t *testing.T) {
|
||||
Sample()
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
// set gopath before
|
||||
//go:generate go test --coverprofile=sample.out
|
||||
package pkg
|
||||
|
||||
func Sample() int {
|
||||
return 1
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package pkg
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSample(t *testing.T) {
|
||||
Sample()
|
||||
t.Fatal("itwillfail")
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package pkg
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSample(t *testing.T) {
|
||||
Sample()
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
|
@ -1,7 +0,0 @@
|
|||
package pkg1
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSample(t *testing.T) {
|
||||
Sample()
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
Vim syntax highlighting for Pug (formerly Jade) templates.
|
||||
|
||||
For best results consider using this with an (improved) HTML5 syntax plugin.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
|
|
|
@ -36,8 +36,9 @@ syntax keyword pugCommentTodo contained TODO FIXME XXX TBD
|
|||
syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo
|
||||
syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo keepend
|
||||
syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->" contains=pugCommentTodo
|
||||
syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=@htmlJavascript,pugHtmlArg,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent
|
||||
syn match pugClassChar "\." contained nextgroup=pugClass
|
||||
syn region pugAngular2 start="(" end=")" contains=htmlEvent
|
||||
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 pugIdChar "#[[{]\@!" contained nextgroup=pugId
|
||||
syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent
|
||||
|
|
|
@ -131,14 +131,14 @@ Don't add useless placeholder default texts like:
|
|||
|
||||
```
|
||||
if (${1:condition}){
|
||||
${2:some code here}
|
||||
${0:some code here}
|
||||
}
|
||||
```
|
||||
instead use:
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
When the snippet can be used to wrap existing code leverage `${VISUAL}`
|
||||
|
||||
Open questions:
|
||||
What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ?
|
||||
Which additional policies to add?
|
||||
|
|
|
@ -77,23 +77,23 @@ endsnippet
|
|||
# DATES #
|
||||
#########
|
||||
snippet date "YYYY-MM-DD" w
|
||||
`date +%Y-%m-%d`
|
||||
`!v strftime("%F")`
|
||||
endsnippet
|
||||
|
||||
snippet ddate "Month DD, YYYY" w
|
||||
`date +%B\ %d,\ %Y`
|
||||
`!v strftime("%b %d, %Y")`
|
||||
endsnippet
|
||||
|
||||
snippet diso "ISO format datetime" w
|
||||
`date +%Y-%m-%dT%H:%M:%S%:z`
|
||||
`!v strftime("%F %H:%M:%S%z")`
|
||||
endsnippet
|
||||
|
||||
snippet time "hh:mm" w
|
||||
`date +%H:%M`
|
||||
`!v strftime("%H:%M")`
|
||||
endsnippet
|
||||
|
||||
snippet datetime "YYYY-MM-DD hh:mm" w
|
||||
`date +%Y-%m-%d\ %H:%M`
|
||||
`!v strftime("%Y-%m-%d %H:%M")`
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
priority -50
|
||||
|
||||
snippet def "#define ..."
|
||||
#define ${1}
|
||||
#define $1
|
||||
endsnippet
|
||||
|
||||
snippet #ifndef "#ifndef ... #define ... #endif"
|
||||
|
@ -16,7 +16,7 @@ endsnippet
|
|||
|
||||
snippet #if "#if #endif" b
|
||||
#if ${1:0}
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
#endif
|
||||
endsnippet
|
||||
|
||||
|
@ -32,20 +32,20 @@ endsnippet
|
|||
snippet main "main() (main)"
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
return 0;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "for loop (for)"
|
||||
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fori "for int loop (fori)"
|
||||
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) {
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -60,7 +60,7 @@ else:
|
|||
snip.rv = snip.c`}
|
||||
#define $1
|
||||
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
|
||||
#endif /* end of include guard: $1 */
|
||||
endsnippet
|
||||
|
@ -71,7 +71,7 @@ endsnippet
|
|||
|
||||
snippet eli "else if .. (eli)"
|
||||
else if (${1:/* condition */}) {
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -86,14 +86,14 @@ struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} {
|
|||
endsnippet
|
||||
|
||||
snippet fun "function" b
|
||||
${1:void} ${2:function_name}(${3})
|
||||
${1:void} ${2:function_name}($3)
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fund "function declaration" b
|
||||
${1:void} ${2:function_name}(${3});
|
||||
${1:void} ${2:function_name}($3);
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
|
|
@ -12,7 +12,7 @@ snippet createClass "React define Class" b
|
|||
${1:classname}Class = React.createClass
|
||||
displayName: "$1"
|
||||
render: ->
|
||||
${2}
|
||||
$2
|
||||
$1 = React.createFactory($1)
|
||||
endsnippet
|
||||
|
||||
|
@ -23,58 +23,58 @@ endsnippet
|
|||
|
||||
snippet propType "React propType (key/value)" b
|
||||
${1:myVar}: React.PropTypes.${2:type}${3:.isRequired}
|
||||
${4}
|
||||
$4
|
||||
endsnippet
|
||||
|
||||
snippet setState "React setState" b
|
||||
@setState
|
||||
${1:myvar}: ${2:myvalue}
|
||||
${3}
|
||||
$3
|
||||
endsnippet
|
||||
|
||||
snippet getInitialState "React define getInitialState" b
|
||||
getInitialState: ->
|
||||
${1:myvar}: ${2:myvalue}
|
||||
${3}
|
||||
$3
|
||||
endsnippet
|
||||
|
||||
snippet getDefaultProps "React define getDefaultProps" b
|
||||
getDefaultProps: ->
|
||||
${1:myvar}: ${2:myvalue}
|
||||
${3}
|
||||
$3
|
||||
endsnippet
|
||||
|
||||
snippet componentWillMount "React define componentWillMount" b
|
||||
componentWillMount: ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet componentDidMount "React define componentDidMount" b
|
||||
componentDidMount: ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet componentWillReceiveProps "React define componentWillReceiveProps" b
|
||||
componentWillReceiveProps: (nextProps) ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet shouldComponentUpdate "React define shouldComponentUpdate" b
|
||||
shouldComponentUpdate: (nextProps, nextState) ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet componentWillUpdate "React define componentWillUpdate" b
|
||||
componentWillUpdate: (nextProps, nextState) ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet componentDidUpdate "React define componentDidUpdate" b
|
||||
componentDidUpdate: (prevProps, prevState) ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet componentWillUnmount "React define componentWillUnmount" b
|
||||
componentWillUnmount: ->
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
|
|
@ -27,7 +27,7 @@ endsnippet
|
|||
snippet ns "namespace .. (namespace)"
|
||||
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
|
||||
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')`}
|
||||
{
|
||||
private:
|
||||
${3}
|
||||
$3
|
||||
|
||||
public:
|
||||
$1();
|
||||
|
|
13
sources_non_forked/vim-snippets/UltiSnips/crystal.snippets
Normal file
13
sources_non_forked/vim-snippets/UltiSnips/crystal.snippets
Normal 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
|
|
@ -259,7 +259,7 @@ finally
|
|||
endsnippet
|
||||
|
||||
snippet throw "throw"
|
||||
throw new ${1}Exception("${2}");
|
||||
throw new $1Exception("$2");
|
||||
endsnippet
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
priority -50
|
||||
|
||||
snippet . "selector { }"
|
||||
$1 {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet p "padding"
|
||||
padding: ${1:0};$0
|
||||
endsnippet
|
||||
|
|
|
@ -23,7 +23,7 @@ mixin ${1:/*mixed_in*/} ${2:/*name*/};
|
|||
endsnippet
|
||||
|
||||
snippet new "new (new)"
|
||||
new ${1}(${2});
|
||||
new $1($2);
|
||||
endsnippet
|
||||
|
||||
snippet scpn "@safe const pure nothrow (scpn)"
|
||||
|
@ -98,7 +98,7 @@ endsnippet
|
|||
|
||||
snippet enf "enforce (enf)" b
|
||||
enforce(${1:/*condition*/},
|
||||
new ${2}Exception(${3:/*args*/}));
|
||||
new $2Exception(${3:/*args*/}));
|
||||
endsnippet
|
||||
|
||||
# Branches
|
||||
|
@ -106,14 +106,14 @@ endsnippet
|
|||
snippet if "if .. (if)"
|
||||
if(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ife "if .. else (ife)" b
|
||||
if(${1:/*condition*/})
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -124,14 +124,14 @@ endsnippet
|
|||
snippet el "else (el)" b
|
||||
else
|
||||
{
|
||||
${VISUAL}${1}
|
||||
${VISUAL}$1
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet elif "else if (elif)" b
|
||||
else if(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -139,10 +139,10 @@ snippet sw "switch (sw)"
|
|||
switch(${1:/*var*/})
|
||||
{
|
||||
case ${2:/*value*/}:
|
||||
${3}
|
||||
$3
|
||||
break;
|
||||
case ${4:/*value*/}:
|
||||
${5}
|
||||
$5
|
||||
break;
|
||||
${7:/*more cases*/}
|
||||
default:
|
||||
|
@ -154,10 +154,10 @@ snippet fsw "final switch (fsw)"
|
|||
final switch(${1:/*var*/})
|
||||
{
|
||||
case ${2:/*value*/}:
|
||||
${3}
|
||||
$3
|
||||
break;
|
||||
case ${4:/*value*/}:
|
||||
${5}
|
||||
$5
|
||||
break;
|
||||
${7:/*more cases*/}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ endsnippet
|
|||
|
||||
snippet case "case (case)" b
|
||||
case ${1:/*value*/}:
|
||||
${2}
|
||||
$2
|
||||
break;
|
||||
endsnippet
|
||||
|
||||
|
@ -178,42 +178,42 @@ endsnippet
|
|||
snippet do "do while (do)" b
|
||||
do
|
||||
{
|
||||
${VISUAL}${2}
|
||||
${VISUAL}$2
|
||||
} while(${1:/*condition*/});
|
||||
endsnippet
|
||||
|
||||
snippet wh "while (wh)" b
|
||||
while(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${2}
|
||||
${VISUAL}$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "for (for)" b
|
||||
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet forever "forever (forever)" b
|
||||
for(;;)
|
||||
{
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fore "foreach (fore)"
|
||||
foreach(${1:/*elem*/}; ${2:/*range*/})
|
||||
{
|
||||
${VISUAL}${3}
|
||||
${VISUAL}$3
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet forif "foreach if (forif)" b
|
||||
foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/})
|
||||
{
|
||||
${VISUAL}${4}
|
||||
${VISUAL}$4
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -222,7 +222,7 @@ snippet in "in contract (in)" b
|
|||
in
|
||||
{
|
||||
assert(${1:/*condition*/}, "${2:error message}");
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
body
|
||||
endsnippet
|
||||
|
@ -231,7 +231,7 @@ snippet out "out contract (out)" b
|
|||
out${1:(result)}
|
||||
{
|
||||
assert(${2:/*condition*/}, "${3:error message}");
|
||||
${4}
|
||||
$4
|
||||
}
|
||||
body
|
||||
endsnippet
|
||||
|
@ -240,7 +240,7 @@ snippet inv "invariant (inv)" b
|
|||
invariant()
|
||||
{
|
||||
assert(${1:/*condition*/}, "${2:error message}");
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -249,21 +249,21 @@ endsnippet
|
|||
snippet fun "function definition (fun)"
|
||||
${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow}
|
||||
{
|
||||
${VISUAL}${5}
|
||||
${VISUAL}$5
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet void "void function definition (void)"
|
||||
void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow}
|
||||
{
|
||||
${VISUAL}${4}
|
||||
${VISUAL}$4
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet this "ctor (this)" w
|
||||
this(${1:/*args*/})
|
||||
{
|
||||
${VISUAL}${2}
|
||||
${VISUAL}$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -295,16 +295,16 @@ endsnippet
|
|||
snippet scope "scope (scope)" b
|
||||
scope(${1:exit})
|
||||
{
|
||||
${VISUAL}${2}
|
||||
${VISUAL}$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
# With
|
||||
|
||||
snippet with "with (with)"
|
||||
with(${1})
|
||||
with($1)
|
||||
{
|
||||
${VISUAL}${2}
|
||||
${VISUAL}$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -315,7 +315,7 @@ try
|
|||
{
|
||||
${VISUAL}${1:/*code to try*/}
|
||||
}
|
||||
catch(${2}Exception e)
|
||||
catch($2Exception e)
|
||||
{
|
||||
${3:/*handle exception*/}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ try
|
|||
{
|
||||
${VISUAL}${1:/*code to try*/}
|
||||
}
|
||||
catch(${2}Exception e)
|
||||
catch($2Exception e)
|
||||
{
|
||||
${3:/*handle exception*/}
|
||||
}
|
||||
|
@ -337,14 +337,14 @@ finally
|
|||
endsnippet
|
||||
|
||||
snippet catch "catch (catch)" b
|
||||
catch(${1}Exception e)
|
||||
catch($1Exception e)
|
||||
{
|
||||
${2:/*handle exception*/}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet thr "throw (thr)"
|
||||
throw new ${1}Exception("${2}");
|
||||
throw new $1Exception("$2");
|
||||
endsnippet
|
||||
|
||||
|
||||
|
@ -353,35 +353,35 @@ endsnippet
|
|||
snippet struct "struct (struct)"
|
||||
struct ${1:`!p snip.rv = (snip.basename or "name")`}
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet union "union (union)"
|
||||
union ${1:`!p snip.rv = (snip.basename or "name")`}
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet class "class (class)"
|
||||
class ${1:`!p snip.rv = (snip.basename or "name")`}
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet inter "interface (inter)"
|
||||
interface ${1:`!p snip.rv = (snip.basename or "name")`}
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet enum "enum (enum)"
|
||||
enum ${1:`!p snip.rv = (snip.basename or "name")`}
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -390,7 +390,7 @@ endsnippet
|
|||
|
||||
snippet exc "exception declaration (exc)" b
|
||||
/// ${3:/*documentation*/}
|
||||
class ${1}Exception : ${2}Exception
|
||||
class $1Exception : $2Exception
|
||||
{
|
||||
public this(string msg, string file = __FILE__, int line = __LINE__)
|
||||
{
|
||||
|
@ -405,14 +405,14 @@ endsnippet
|
|||
snippet version "version (version)" b
|
||||
version(${1:/*version name*/})
|
||||
{
|
||||
${VISUAL}${2}
|
||||
${VISUAL}$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet debug "debug" b
|
||||
debug
|
||||
{
|
||||
${VISUAL}${1}
|
||||
${VISUAL}$1
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -422,7 +422,7 @@ endsnippet
|
|||
snippet temp "template (temp)" b
|
||||
template ${2:/*name*/}(${1:/*args*/})
|
||||
{
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -440,7 +440,7 @@ endsnippet
|
|||
snippet unittest "unittest (unittest)" b
|
||||
unittest
|
||||
{
|
||||
${1}
|
||||
$1
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -450,21 +450,21 @@ endsnippet
|
|||
snippet opDis "opDispatch (opDis)" b
|
||||
${1:/*return type*/} opDispatch(string s)()
|
||||
{
|
||||
${2};
|
||||
$2;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet op= "opAssign (op=)" b
|
||||
void opAssign(${1} rhs) ${2:@safe pure nothrow}
|
||||
void opAssign($1 rhs) ${2:@safe pure nothrow}
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet opCmp "opCmp (opCmp)" b
|
||||
int opCmp(${1} rhs) @safe const pure nothrow
|
||||
int opCmp($1 rhs) @safe const pure nothrow
|
||||
{
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -484,7 +484,7 @@ endsnippet
|
|||
snippet toString "toString (toString)" b
|
||||
string toString() @safe const pure nothrow
|
||||
{
|
||||
${1}
|
||||
$1
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -493,7 +493,7 @@ endsnippet
|
|||
|
||||
|
||||
snippet todo "TODO (todo)"
|
||||
// TODO: ${1}
|
||||
// TODO: $1
|
||||
endsnippet
|
||||
|
||||
|
||||
|
@ -509,16 +509,16 @@ snippet fdoc "function ddoc block (fdoc)" b
|
|||
/// ${1:description}
|
||||
///
|
||||
/// ${2:Params: ${3:param} = ${4:param description}
|
||||
/// ${5}}
|
||||
/// $5}
|
||||
///
|
||||
/// ${6:Returns: ${7:return value}}
|
||||
///
|
||||
/// ${8:Throws: ${9}Exception ${10}}
|
||||
/// ${8:Throws: $9Exception $10}
|
||||
endsnippet
|
||||
|
||||
snippet Par "Params (Par)"
|
||||
Params: ${1:param} = ${2:param description}
|
||||
/// ${3}
|
||||
/// $3
|
||||
endsnippet
|
||||
|
||||
snippet Ret "Returns (Ret)"
|
||||
|
@ -526,7 +526,7 @@ Returns: ${1:return value/s}
|
|||
endsnippet
|
||||
|
||||
snippet Thr "Throws (Thr)"
|
||||
Throws: ${1}Exception ${2}
|
||||
Throws: $1Exception $2
|
||||
endsnippet
|
||||
|
||||
snippet Example "Examples (Example)"
|
||||
|
@ -556,7 +556,7 @@ snippet gpl "GPL (gpl)" b
|
|||
//
|
||||
// Copyright (C) ${1:Author}, `!v strftime("%Y")`
|
||||
|
||||
${2}
|
||||
$2
|
||||
endsnippet
|
||||
|
||||
snippet boost "Boost (boost)" b
|
||||
|
@ -565,7 +565,7 @@ snippet boost "Boost (boost)" b
|
|||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
${2}
|
||||
$2
|
||||
endsnippet
|
||||
|
||||
|
||||
|
@ -577,8 +577,8 @@ snippet module "New module (module)" b
|
|||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// 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
|
||||
|
|
|
@ -124,7 +124,7 @@ endsnippet
|
|||
|
||||
snippet model "Model" b
|
||||
class ${1:MODELNAME}(models.Model):
|
||||
${0}
|
||||
$0
|
||||
class Meta:
|
||||
verbose_name = "$1"
|
||||
verbose_name_plural = "$1s"
|
||||
|
@ -275,19 +275,19 @@ endsnippet
|
|||
# VIEWS SNIPPETS
|
||||
|
||||
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_filter = ('${3}',)
|
||||
list_display = ('$2',)
|
||||
list_filter = ('$3',)
|
||||
inlines = [
|
||||
${4}Inline,
|
||||
$4Inline,
|
||||
]
|
||||
raw_id_fields = ('${5}',)
|
||||
readonly_fields = ('${6}',)
|
||||
search_fields = ['${7}']
|
||||
admin.site.register(${1}, ${1}Admin)
|
||||
raw_id_fields = ('$5',)
|
||||
readonly_fields = ('$6',)
|
||||
search_fields = ['$7']
|
||||
admin.site.register($1, $1Admin)
|
||||
endsnippet
|
||||
|
||||
snippet createview "Generic Create View" b
|
||||
|
@ -315,27 +315,27 @@ class ${1:MODEL_NAME}ListView(ListView):
|
|||
endsnippet
|
||||
|
||||
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}
|
||||
max_num = ${4:20}
|
||||
extra = ${5:1}
|
||||
raw_id_fields = (${6},)
|
||||
raw_id_fields = ($6,)
|
||||
endsnippet
|
||||
|
||||
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}
|
||||
max_num = ${4:20}
|
||||
extra = ${5:1}
|
||||
raw_id_fields = (${6},)
|
||||
raw_id_fields = ($6,)
|
||||
endsnippet
|
||||
|
||||
snippet templateview "Generic Template View" b
|
||||
|
|
|
@ -27,12 +27,12 @@ def textmate_var(var, snip):
|
|||
endglobal
|
||||
|
||||
|
||||
snippet % "<% ${0} %>" i
|
||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
|
||||
snippet % "<% $0 %>" i
|
||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`$0`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
|
||||
endsnippet
|
||||
|
||||
snippet = "<%= ${0} %>" i
|
||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
||||
snippet = "<%= $0 %>" i
|
||||
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`$0`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
|
||||
endsnippet
|
||||
|
||||
###########################################################################
|
||||
|
@ -150,11 +150,11 @@ snippet licai "link_to (controller, action, id)" w
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
snippet lipp "link_to (path plural)" w
|
||||
|
@ -162,7 +162,7 @@ snippet lipp "link_to (path plural)" w
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet lim "link_to model" w
|
||||
|
|
|
@ -53,7 +53,7 @@ endsnippet
|
|||
|
||||
snippet switch "Switch statement" b
|
||||
switch ${1:expression}${1/(.+)/ /}{
|
||||
case${0}
|
||||
case$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
|
|
@ -12,33 +12,6 @@ def x(snip):
|
|||
snip.rv = ""
|
||||
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
|
||||
<!DOCTYPE html>
|
||||
|
||||
|
@ -83,45 +56,6 @@ snippet left "Left (left)"
|
|||
←
|
||||
endsnippet
|
||||
|
||||
snippet option "Option (option)"
|
||||
⌥
|
||||
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 #
|
||||
#############
|
||||
|
@ -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)`>
|
||||
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)`>
|
||||
endsnippet
|
||||
|
||||
|
||||
snippet opt "Option" w
|
||||
snippet option "Option" w
|
||||
<option${1: value="${2:option}"}>${3:$2}</option>
|
||||
endsnippet
|
||||
|
||||
|
@ -145,15 +79,15 @@ snippet select "Select Box" w
|
|||
endsnippet
|
||||
|
||||
|
||||
snippet textarea "XHTML <textarea>" w
|
||||
snippet textarea "HTML <textarea>" w
|
||||
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
|
||||
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>
|
||||
endsnippet
|
||||
|
||||
snippet base "XHTML <base>" w
|
||||
snippet base "HTML <base>" w
|
||||
<base href="$1"${2: target="$3"}`!p x(snip)`>
|
||||
endsnippet
|
||||
|
||||
|
@ -229,12 +163,12 @@ snippet meta "XHTML <meta>" w
|
|||
<meta name="${1:name}" content="${2:content}"`!p x(snip)`>
|
||||
endsnippet
|
||||
|
||||
snippet scriptsrc "XHTML <script src...>" w
|
||||
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>
|
||||
snippet scriptsrc "HTML <script src...>" w
|
||||
<script src="$1" charset="${3:utf-8}"></script>
|
||||
endsnippet
|
||||
|
||||
snippet script "XHTML <script>" w
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
snippet script "HTML <script>" w
|
||||
<script charset="utf-8">
|
||||
${0:${VISUAL}}
|
||||
</script>
|
||||
endsnippet
|
||||
|
@ -304,20 +238,6 @@ snippet fieldset "Fieldset" w
|
|||
</fieldset>
|
||||
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
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
endsnippet
|
||||
|
|
|
@ -4,24 +4,24 @@
|
|||
priority -50
|
||||
|
||||
snippet id
|
||||
id="${1}"${2}
|
||||
id="$1"$2
|
||||
endsnippet
|
||||
|
||||
snippet idn
|
||||
id="${1}" name="${2:$1}"
|
||||
id="$1" name="${2:$1}"
|
||||
endsnippet
|
||||
|
||||
snippet label_and_input
|
||||
<label for="${2:$1}">${1}</label>
|
||||
<input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="${7}" />${8}
|
||||
<label for="${2:$1}">$1</label>
|
||||
<input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="$7" />$8
|
||||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet submit
|
||||
<input type="submit" value="${2}" ${3}/>${7}
|
||||
<input type="submit" value="$2" $3/>$7
|
||||
endsnippet
|
||||
|
||||
snippet textarea
|
||||
|
|
|
@ -4,30 +4,30 @@ extends html
|
|||
|
||||
# Generic Tags
|
||||
snippet % "" bi
|
||||
{% ${1} %}${2}
|
||||
{% $1 %}$2
|
||||
endsnippet
|
||||
|
||||
snippet %% "" bi
|
||||
{% ${1:tag_name} %}
|
||||
${2}
|
||||
$2
|
||||
{% end$1 %}
|
||||
endsnippet
|
||||
|
||||
snippet { "" bi
|
||||
{{ ${1} }}${2}
|
||||
{{ $1 }}$2
|
||||
endsnippet
|
||||
|
||||
# Template Tags
|
||||
|
||||
snippet autoescape "" bi
|
||||
{% autoescape ${1:off} %}
|
||||
${2}
|
||||
$2
|
||||
{% endautoescape %}
|
||||
endsnippet
|
||||
|
||||
snippet block "" bi
|
||||
{% block ${1} %}
|
||||
${2}
|
||||
{% block $1 %}
|
||||
$2
|
||||
{% endblock $1 %}
|
||||
endsnippet
|
||||
|
||||
|
@ -37,12 +37,12 @@ endsnippet
|
|||
|
||||
snippet comment "" bi
|
||||
{% comment %}
|
||||
${1}
|
||||
$1
|
||||
{% endcomment %}
|
||||
endsnippet
|
||||
|
||||
snippet cycle "" bi
|
||||
{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %}
|
||||
{% cycle ${1:val1} ${2:val2} ${3:as $4} %}
|
||||
endsnippet
|
||||
|
||||
snippet debug "" bi
|
||||
|
@ -54,76 +54,76 @@ snippet extends "" bi
|
|||
endsnippet
|
||||
|
||||
snippet filter "" bi
|
||||
{% filter ${1} %}
|
||||
${2}
|
||||
{% filter $1 %}
|
||||
$2
|
||||
{% endfilter %}
|
||||
endsnippet
|
||||
|
||||
snippet firstof "" bi
|
||||
{% firstof ${1} %}
|
||||
{% firstof $1 %}
|
||||
endsnippet
|
||||
|
||||
snippet for "" bi
|
||||
{% for ${1} in ${2} %}
|
||||
${3}
|
||||
{% for $1 in $2 %}
|
||||
$3
|
||||
{% endfor %}
|
||||
endsnippet
|
||||
|
||||
snippet empty "" bi
|
||||
{% empty %}
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet if "" bi
|
||||
{% if ${1} %}
|
||||
${2}
|
||||
{% if $1 %}
|
||||
$2
|
||||
{% endif %}
|
||||
endsnippet
|
||||
|
||||
snippet iif "" bi
|
||||
{% if ${1} %}${2}{% endif %}
|
||||
{% if $1 %}$2{% endif %}
|
||||
endsnippet
|
||||
|
||||
snippet ielse "" bi
|
||||
{% else %}${1}
|
||||
{% else %}$1
|
||||
endsnippet
|
||||
|
||||
snippet else "" bi
|
||||
{% else %}
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet ielif "" bi
|
||||
{% elif %}${1}
|
||||
{% elif %}$1
|
||||
endsnippet
|
||||
|
||||
snippet elif "" bi
|
||||
{% elif %}
|
||||
${1}
|
||||
$1
|
||||
endsnippet
|
||||
|
||||
snippet ifchanged "" bi
|
||||
{% ifchanged %}${1}{% endifchanged %}
|
||||
{% ifchanged %}$1{% endifchanged %}
|
||||
endsnippet
|
||||
|
||||
snippet ifequal "" bi
|
||||
{% ifequal ${1} ${2} %}
|
||||
${3}
|
||||
{% ifequal $1 $2 %}
|
||||
$3
|
||||
{% endifequal %}
|
||||
endsnippet
|
||||
|
||||
snippet ifnotequal "" bi
|
||||
{% ifnotequal ${1} ${2} %}
|
||||
${3}
|
||||
{% ifnotequal $1 $2 %}
|
||||
$3
|
||||
{% endifnotequal %}
|
||||
endsnippet
|
||||
|
||||
snippet include "" bi
|
||||
{% include "${1}" %}
|
||||
{% include "$1" %}
|
||||
endsnippet
|
||||
|
||||
snippet load "" bi
|
||||
{% load ${1} %}
|
||||
{% load $1 %}
|
||||
endsnippet
|
||||
|
||||
snippet now "" bi
|
||||
|
@ -131,15 +131,15 @@ snippet now "" bi
|
|||
endsnippet
|
||||
|
||||
snippet regroup "" bi
|
||||
{% regroup ${1} by ${2} as ${3} %}
|
||||
{% regroup $1 by $2 as $3 %}
|
||||
endsnippet
|
||||
|
||||
snippet spaceless "" bi
|
||||
{% spaceless %}${1}{% endspaceless %}
|
||||
{% spaceless %}$1{% endspaceless %}
|
||||
endsnippet
|
||||
|
||||
snippet ssi "" bi
|
||||
{% ssi ${1} %}
|
||||
{% ssi $1 %}
|
||||
endsnippet
|
||||
|
||||
snippet trans "" bi
|
||||
|
@ -147,7 +147,7 @@ snippet trans "" bi
|
|||
endsnippet
|
||||
|
||||
snippet url "" bi
|
||||
{% url ${1} as ${2} %}
|
||||
{% url $1 as $2 %}
|
||||
endsnippet
|
||||
|
||||
snippet widthratio "" bi
|
||||
|
@ -155,7 +155,7 @@ snippet widthratio "" bi
|
|||
endsnippet
|
||||
|
||||
snippet with "" bi
|
||||
{% with ${1} as ${2} %}
|
||||
{% with $1 as $2 %}
|
||||
${VISUAL}
|
||||
{% endwith %}
|
||||
endsnippet
|
||||
|
@ -197,7 +197,7 @@ snippet blocktrans "" bi
|
|||
endsnippet
|
||||
|
||||
snippet lorem "" bi
|
||||
{% lorem ${1} %}
|
||||
{% lorem $1 %}
|
||||
endsnippet
|
||||
|
||||
# Template Filters
|
||||
|
@ -209,91 +209,91 @@ endsnippet
|
|||
# Note: Template tags that take no arguments are not implemented.
|
||||
|
||||
snippet add "" bi
|
||||
add:"${1}"
|
||||
add:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet center "" bi
|
||||
center:"${1}"
|
||||
center:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet cut "" bi
|
||||
cut:"${1}"
|
||||
cut:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet date "" bi
|
||||
date:"${1}"
|
||||
date:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet default "" bi
|
||||
default:"${1}"
|
||||
default:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet defaultifnone "" bi
|
||||
default_if_none:"${1}"
|
||||
default_if_none:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet dictsort "" bi
|
||||
dictsort:"${1}"
|
||||
dictsort:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet dictsortrev "" bi
|
||||
dictsortreversed:"${1}"
|
||||
dictsortreversed:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet divisibleby "" bi
|
||||
divisibleby:"${1}"
|
||||
divisibleby:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet floatformat "" bi
|
||||
floatformat:"${1}"
|
||||
floatformat:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet getdigit "" bi
|
||||
get_digit:"${1}"
|
||||
get_digit:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet join "" bi
|
||||
join:"${1}"
|
||||
join:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet lengthis "" bi
|
||||
length_is:"${1}"
|
||||
length_is:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet pluralize "" bi
|
||||
pluralize:"${1}"
|
||||
pluralize:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet removetags "" bi
|
||||
removetags:"${1}"
|
||||
removetags:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet slice "" bi
|
||||
slice:"${1}"
|
||||
slice:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet stringformat "" bi
|
||||
stringformat:"${1}"
|
||||
stringformat:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet time "" bi
|
||||
time:"${1}"
|
||||
time:"$1"
|
||||
endsnippet
|
||||
|
||||
snippet truncatewords "" bi
|
||||
truncatewords:${1}
|
||||
truncatewords:$1
|
||||
endsnippet
|
||||
|
||||
snippet truncatewordshtml "" bi
|
||||
truncatewords_html:${1}
|
||||
truncatewords_html:$1
|
||||
endsnippet
|
||||
|
||||
snippet urlizetrunc "" bi
|
||||
urlizetrunc:${1}
|
||||
urlizetrunc:$1
|
||||
endsnippet
|
||||
|
||||
snippet wordwrap "" bi
|
||||
wordwrap:${1}
|
||||
wordwrap:$1
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
|
|
@ -48,7 +48,7 @@ $0
|
|||
endsnippet
|
||||
|
||||
snippet /o|v/ "new Object or variable" br
|
||||
${1:Object} ${2:var} = new $1(${3});
|
||||
${1:Object} ${2:var} = new $1($3);
|
||||
endsnippet
|
||||
|
||||
snippet f "field" b
|
||||
|
@ -310,13 +310,13 @@ try {
|
|||
endsnippet
|
||||
|
||||
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
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet m "method" b
|
||||
${1:private} ${2:void} ${3:method}(${4}) {
|
||||
${1:private} ${2:void} ${3:method}($4) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
|
|
@ -19,7 +19,7 @@ config(function($1) {
|
|||
endsnippet
|
||||
|
||||
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
|
||||
}]);
|
||||
endsnippet
|
||||
|
@ -31,29 +31,29 @@ controller('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)
|
|||
endsnippet
|
||||
|
||||
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 {
|
||||
restrict: '${3:EA}',
|
||||
link: function(scope, element, attrs) {
|
||||
${0}
|
||||
$0
|
||||
}
|
||||
};
|
||||
}]);
|
||||
endsnippet
|
||||
|
||||
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 {
|
||||
restrict: '${3:EA}',
|
||||
link: function(scope, element, attrs) {
|
||||
${0}
|
||||
$0
|
||||
}
|
||||
};
|
||||
}]);
|
||||
endsnippet
|
||||
|
||||
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
|
||||
}]);
|
||||
endsnippet
|
||||
|
@ -65,7 +65,7 @@ factory('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$
|
|||
endsnippet
|
||||
|
||||
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
|
||||
}]);
|
||||
endsnippet
|
||||
|
|
|
@ -5,48 +5,48 @@ snippet #! "shebang"
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet ex "module.exports"
|
||||
module.exports = ${1};
|
||||
module.exports = $1;
|
||||
endsnippet
|
||||
|
||||
snippet hcs "http.createServer"
|
||||
http.createServer(${1}).listen(${2});
|
||||
http.createServer($1).listen($2);
|
||||
endsnippet
|
||||
|
||||
snippet ncs "net.createServer"
|
||||
net.createServer(function(${1:socket}){
|
||||
${1}.on('data', function(${3:data}){
|
||||
${4}
|
||||
$1.on('data', function(${3:data}){
|
||||
$4
|
||||
});
|
||||
${1}.on('end', function(){
|
||||
${5}
|
||||
$1.on('end', function(){
|
||||
$5
|
||||
});
|
||||
}).listen(${6:8124});
|
||||
endsnippet
|
||||
|
||||
snippet pipe "pipe"
|
||||
pipe(${1:stream})${2}
|
||||
pipe(${1:stream})$2
|
||||
endsnippet
|
||||
|
||||
# Express snippets
|
||||
|
||||
snippet eget "express GET"
|
||||
${1:app}.get('${2}', ${3});
|
||||
${1:app}.get('$2', $3);
|
||||
endsnippet
|
||||
|
||||
snippet epost "express POST"
|
||||
${1:app}.post('${2}', ${3});
|
||||
${1:app}.post('$2', $3);
|
||||
endsnippet
|
||||
|
||||
snippet eput "express PUT"
|
||||
${1:app}.put('${2}', ${3});
|
||||
${1:app}.put('$2', $3);
|
||||
endsnippet
|
||||
|
||||
snippet edelete "express DELETE"
|
||||
${1:app}.delete('${2}', ${3});
|
||||
${1:app}.delete('$2', $3);
|
||||
endsnippet
|
||||
|
||||
# process snippets
|
||||
|
|
|
@ -1,80 +1,80 @@
|
|||
snippet sapmlabel
|
||||
var ${1} = new sap.m.Label({
|
||||
design : ${2},
|
||||
text : ${3},
|
||||
visible : ${4},
|
||||
textAlign : ${5},
|
||||
textDirection : ${6},
|
||||
width : ${7},
|
||||
required : ${7}
|
||||
var $1 = new sap.m.Label({
|
||||
design : $2,
|
||||
text : $3,
|
||||
visible : $4,
|
||||
textAlign : $5,
|
||||
textDirection : $6,
|
||||
width : $7,
|
||||
required : $7
|
||||
});
|
||||
|
||||
snippet sapmtext
|
||||
var ${1} = new sap.m.Text({
|
||||
text :${2},
|
||||
textDirection :${3},
|
||||
visible :${4},
|
||||
wrapping : ${5},
|
||||
textAlign : ${6},
|
||||
width :${7},
|
||||
maxLines :${8}
|
||||
var $1 = new sap.m.Text({
|
||||
text :$2,
|
||||
textDirection :$3,
|
||||
visible :$4,
|
||||
wrapping : $5,
|
||||
textAlign : $6,
|
||||
width :$7,
|
||||
maxLines :$8
|
||||
});
|
||||
|
||||
snippet sapmbutton
|
||||
var ${1} = new sap.m.Button({
|
||||
text : ${2},
|
||||
type : ${3},
|
||||
width : ${4},
|
||||
enabled :${5},
|
||||
visible :${6},
|
||||
icon : ${7},
|
||||
iconFirst : ${8},
|
||||
activeIcon :${9},
|
||||
iconDensityAware : ${10},
|
||||
var $1 = new sap.m.Button({
|
||||
text : $2,
|
||||
type : $3,
|
||||
width : $4,
|
||||
enabled :$5,
|
||||
visible :$6,
|
||||
icon : $7,
|
||||
iconFirst : $8,
|
||||
activeIcon :$9,
|
||||
iconDensityAware : $10,
|
||||
});
|
||||
snippet sapmflexbox
|
||||
var ${1} = new sap.m.FlexBox({
|
||||
visible : ${2},
|
||||
height : ${3},
|
||||
width : ${4},
|
||||
displayInline :${5},
|
||||
direction :${6},
|
||||
fitContainer : ${7},
|
||||
renderType : ${8},
|
||||
justifyContent :${9},
|
||||
alignItems : ${10},
|
||||
var $1 = new sap.m.FlexBox({
|
||||
visible : $2,
|
||||
height : $3,
|
||||
width : $4,
|
||||
displayInline :$5,
|
||||
direction :$6,
|
||||
fitContainer : $7,
|
||||
renderType : $8,
|
||||
justifyContent :$9,
|
||||
alignItems : $10,
|
||||
items:[]
|
||||
});
|
||||
snippet sapmhbox
|
||||
var ${1} = new sap.m.HBox({
|
||||
visible : ${2},
|
||||
height : ${3},
|
||||
width : ${4},
|
||||
displayInline :${5},
|
||||
direction :${6},
|
||||
fitContainer : ${7},
|
||||
renderType : ${8},
|
||||
justifyContent :${9},
|
||||
alignItems : ${10},
|
||||
var $1 = new sap.m.HBox({
|
||||
visible : $2,
|
||||
height : $3,
|
||||
width : $4,
|
||||
displayInline :$5,
|
||||
direction :$6,
|
||||
fitContainer : $7,
|
||||
renderType : $8,
|
||||
justifyContent :$9,
|
||||
alignItems : $10,
|
||||
items:[]
|
||||
});
|
||||
|
||||
snippet sapmvbox
|
||||
var ${1} = new sap.m.VBox({
|
||||
visible : ${2},
|
||||
height : ${3},
|
||||
width : ${4},
|
||||
displayInline :${5},
|
||||
direction :${6},
|
||||
fitContainer : ${7},
|
||||
renderType : ${8},
|
||||
justifyContent :${9},
|
||||
alignItems : ${10},
|
||||
var $1 = new sap.m.VBox({
|
||||
visible : $2,
|
||||
height : $3,
|
||||
width : $4,
|
||||
displayInline :$5,
|
||||
direction :$6,
|
||||
fitContainer : $7,
|
||||
renderType : $8,
|
||||
justifyContent :$9,
|
||||
alignItems : $10,
|
||||
items:[]
|
||||
});
|
||||
|
||||
snippet sapcomponent
|
||||
sap.ui.controller("${1}", {
|
||||
sap.ui.controller("$1", {
|
||||
onInit: function(){
|
||||
},
|
||||
onAfterRendering: function() {
|
||||
|
@ -86,120 +86,120 @@ snippet sapcomponent
|
|||
});
|
||||
|
||||
snippet sapminput
|
||||
var ${1} = new sap.m.Input({
|
||||
value :${2},
|
||||
width : ${3},
|
||||
enabled :${4},
|
||||
visible :${5},
|
||||
valueState :${6},
|
||||
name : ${7},
|
||||
placeholder : ${8},
|
||||
editable : ${9},
|
||||
type : ${10},
|
||||
maxLength :${11},
|
||||
valueStateText :${12},
|
||||
showValueStateMessage :${13},
|
||||
dateFormat :${14},
|
||||
showValueHelp :${15},
|
||||
showSuggestion :${16},
|
||||
valueHelpOnly :${17},
|
||||
filterSuggests :${18},
|
||||
maxSuggestionWidth :${19},
|
||||
startSuggestion : ${20},
|
||||
showTableSuggestionValueHelp : ${21},
|
||||
description : ${22},
|
||||
fieldWidth : ${23},
|
||||
valueLiveUpdate :${24},
|
||||
suggestionItems :[${25}],
|
||||
suggestionColumns : [${26}],
|
||||
suggestionRows : [${27}],
|
||||
liveChange : ${28},
|
||||
valueHelpRequest :${29},
|
||||
suggest : ${30},
|
||||
suggestionItemSelected : ${31}
|
||||
var $1 = new sap.m.Input({
|
||||
value :$2,
|
||||
width : $3,
|
||||
enabled :$4,
|
||||
visible :$5,
|
||||
valueState :$6,
|
||||
name : $7,
|
||||
placeholder : $8,
|
||||
editable : $9,
|
||||
type : $10,
|
||||
maxLength :$11,
|
||||
valueStateText :$12,
|
||||
showValueStateMessage :$13,
|
||||
dateFormat :$14,
|
||||
showValueHelp :$15,
|
||||
showSuggestion :$16,
|
||||
valueHelpOnly :$17,
|
||||
filterSuggests :$18,
|
||||
maxSuggestionWidth :$19,
|
||||
startSuggestion : $20,
|
||||
showTableSuggestionValueHelp : $21,
|
||||
description : $22,
|
||||
fieldWidth : $23,
|
||||
valueLiveUpdate :$24,
|
||||
suggestionItems :[$25],
|
||||
suggestionColumns : [$26],
|
||||
suggestionRows : [$27],
|
||||
liveChange : $28,
|
||||
valueHelpRequest :$29,
|
||||
suggest : $30,
|
||||
suggestionItemSelected : $31
|
||||
});
|
||||
snippet _sthis
|
||||
var _self = this;
|
||||
|
||||
snippet sapmresponsivepopup
|
||||
var ${1} = new sap.m.ResponsivePopover({
|
||||
placement :${2} ,//sap.m.PlacementType (default: sap.m.PlacementType.Right)
|
||||
showHeader :${3} ,//boolean (default: true)
|
||||
title : ${4},//string
|
||||
icon :${5} ,//sap.ui.core.URI
|
||||
modal :${6} ,// boolean
|
||||
offsetX :${7}, //int
|
||||
offsetY :${8}, //int
|
||||
contentWidth : ${9},//sap.ui.core.CSSSize
|
||||
contentHeight :${10}, //sap.ui.core.CSSSize
|
||||
horizontalScrolling :${11}, //boolean
|
||||
verticalScrolling :${12}, //boolean
|
||||
showCloseButton :${13}, //boolean (default: true)
|
||||
var $1 = new sap.m.ResponsivePopover({
|
||||
placement :$2 ,//sap.m.PlacementType (default: sap.m.PlacementType.Right)
|
||||
showHeader :$3 ,//boolean (default: true)
|
||||
title : $4,//string
|
||||
icon :$5 ,//sap.ui.core.URI
|
||||
modal :$6 ,// boolean
|
||||
offsetX :$7, //int
|
||||
offsetY :$8, //int
|
||||
contentWidth : $9,//sap.ui.core.CSSSize
|
||||
contentHeight :$10, //sap.ui.core.CSSSize
|
||||
horizontalScrolling :$11, //boolean
|
||||
verticalScrolling :$12, //boolean
|
||||
showCloseButton :$13, //boolean (default: true)
|
||||
//Aggregations
|
||||
content :${14}, //sap.ui.core.Control[]
|
||||
customHeader :${15}, //sap.m.IBar
|
||||
subHeader : ${16}, //sap.m.IBar
|
||||
beginButton :${17}, //sap.m.Button
|
||||
endButton : ${18}, //sap.m.Button
|
||||
content :$14, //sap.ui.core.Control[]
|
||||
customHeader :$15, //sap.m.IBar
|
||||
subHeader : $16, //sap.m.IBar
|
||||
beginButton :$17, //sap.m.Button
|
||||
endButton : $18, //sap.m.Button
|
||||
//Associations
|
||||
initialFocus : ${19}, //string | sap.ui.core.Control
|
||||
initialFocus : $19, //string | sap.ui.core.Control
|
||||
//Events
|
||||
beforeOpen :${20}, //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]
|
||||
afterClose : ${23} //fnList
|
||||
beforeOpen :$20, //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]
|
||||
afterClose : $23 //fnList
|
||||
});
|
||||
|
||||
snippet sapicon
|
||||
var ${1} = new sap.ui.core.Icon({
|
||||
src :${2} , //sap.ui.core.URI
|
||||
size :${3} , //sap.ui.core.CSSSize
|
||||
color :${4} , //sap.ui.core.CSSColor
|
||||
hoverColor : ${5} , // sap.ui.core.CSSColor
|
||||
activeColor :${6} , //sap.ui.core.CSSColor
|
||||
width :${7} , //sap.ui.core.CSSSize
|
||||
height : ${8} ,//sap.ui.core.CSSSize
|
||||
backgroundColor :${8} , //sap.ui.core.CSSColor
|
||||
hoverBackgroundColor :${9} , //sap.ui.core.CSSColor
|
||||
activeBackgroundColor :${10} , //sap.ui.core.CSSColor
|
||||
visible :${11} , //boolean (default: true)
|
||||
decorative : ${12} ,//boolean (default: true)
|
||||
var $1 = new sap.ui.core.Icon({
|
||||
src :$2 , //sap.ui.core.URI
|
||||
size :$3 , //sap.ui.core.CSSSize
|
||||
color :$4 , //sap.ui.core.CSSColor
|
||||
hoverColor : $5 , // sap.ui.core.CSSColor
|
||||
activeColor :$6 , //sap.ui.core.CSSColor
|
||||
width :$7 , //sap.ui.core.CSSSize
|
||||
height : $8 ,//sap.ui.core.CSSSize
|
||||
backgroundColor :$8 , //sap.ui.core.CSSColor
|
||||
hoverBackgroundColor :$9 , //sap.ui.core.CSSColor
|
||||
activeBackgroundColor :$10 , //sap.ui.core.CSSColor
|
||||
visible :$11 , //boolean (default: true)
|
||||
decorative : $12 ,//boolean (default: true)
|
||||
});
|
||||
snippet extendVerticalL
|
||||
sap.ui.layout.VerticalLayout.extend("${1}", {
|
||||
sap.ui.layout.VerticalLayout.extend("$1", {
|
||||
metadata: {
|
||||
properties: {
|
||||
${2}
|
||||
$2
|
||||
},
|
||||
aggregations: {
|
||||
${3}
|
||||
$3
|
||||
},
|
||||
events: {
|
||||
${4}
|
||||
$4
|
||||
}
|
||||
},
|
||||
init: function(){
|
||||
${5}
|
||||
$5
|
||||
},
|
||||
|
||||
renderer: "${6}"
|
||||
renderer: "$6"
|
||||
});
|
||||
snippet extendHorizontalL
|
||||
sap.ui.layout.HorizontalLayout.extend("${1}", {
|
||||
sap.ui.layout.HorizontalLayout.extend("$1", {
|
||||
metadata: {
|
||||
properties: {
|
||||
${2}
|
||||
$2
|
||||
},
|
||||
aggregations: {
|
||||
${3}
|
||||
$3
|
||||
},
|
||||
events: {
|
||||
${4}
|
||||
$4
|
||||
}
|
||||
},
|
||||
init: function(){
|
||||
${5}
|
||||
$5
|
||||
},
|
||||
|
||||
renderer: "${6}"
|
||||
renderer: "$6"
|
||||
});
|
||||
|
|
|
@ -34,18 +34,6 @@ ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
|
|||
|
||||
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
|
||||
function ${1:function_name}(${2:argument}) {
|
||||
${VISUAL}$0
|
||||
|
@ -53,7 +41,7 @@ function ${1:function_name}(${2:argument}) {
|
|||
endsnippet
|
||||
|
||||
snippet vf "Function assigned to var"
|
||||
${1:var }${2:function_name} = function $2(${3}) {
|
||||
${1:var }${2:function_name} = function $2($3) {
|
||||
${VISUAL}$0
|
||||
};
|
||||
endsnippet
|
||||
|
@ -84,78 +72,4 @@ for (${1:prop} in ${2:obj}){
|
|||
}
|
||||
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:
|
||||
|
|
|
@ -53,9 +53,9 @@ use Illuminate\Support\ServiceProvider;
|
|||
class ${2:`!v expand('%:t:r')`} extends ServiceProvider {
|
||||
|
||||
public function register() {
|
||||
$this->app->bind('${4}Service', function ($app) {
|
||||
return new ${5}(
|
||||
$app->make('Repositories\\${6}Interface')
|
||||
$this->app->bind('$4Service', function ($app) {
|
||||
return new $5(
|
||||
$app->make('Repositories\\$6Interface')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class ${2:`!v expand('%:t:r')`} extends \Eloquent {
|
|||
|
||||
public $timestamps = ${5:false};
|
||||
|
||||
protected $hidden = [${6}];
|
||||
protected $hidden = [$6];
|
||||
|
||||
protected $guarded = [${7:'id'}];
|
||||
}
|
||||
|
@ -208,10 +208,10 @@ snippet l_r "Laravel Repository" b
|
|||
* \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} {
|
||||
${7}
|
||||
class ${3:`!v expand('%:t:r')`} extends \\$6 implements ${4:$3RepositoryInterface} {
|
||||
$7
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -227,7 +227,7 @@ snippet l_s "Laravel Service" b
|
|||
* \date `!v strftime('%d-%m-%y')`
|
||||
*/
|
||||
|
||||
namespace Services\\${1};
|
||||
namespace Services\\$1;
|
||||
|
||||
use ${3:Repositories\\${4:Interface}};
|
||||
|
||||
|
@ -265,6 +265,6 @@ class ${2:`!v expand('%:t:r')`} extends Facade {
|
|||
*
|
||||
* \return string
|
||||
*/
|
||||
protected static function getFacadeAccessor() { return '${4:${3}Service}'; }
|
||||
protected static function getFacadeAccessor() { return '${4:$3Service}'; }
|
||||
}
|
||||
endsnippet
|
||||
|
|
|
@ -23,15 +23,15 @@ class `!p
|
|||
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
||||
` extends ObjectBehavior
|
||||
{
|
||||
function it_${1}()
|
||||
function it_$1()
|
||||
{
|
||||
$0
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet it "function it_does_something() { ... }"
|
||||
function it_${1}()
|
||||
function it_$1()
|
||||
{
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ endsnippet
|
|||
|
||||
# Object construction
|
||||
snippet cw "$this->beConstructedWith($arg)"
|
||||
$this->beConstructedWith(${1});
|
||||
$this->beConstructedWith($1);
|
||||
endsnippet
|
||||
|
||||
snippet ct "$this->beConstructedThrough($methodName, [$arg])"
|
||||
|
@ -112,44 +112,44 @@ endsnippet
|
|||
|
||||
# Type matchers
|
||||
snippet stype "$this->shouldHaveType('Type')"
|
||||
$this->shouldHaveType(${1});
|
||||
$this->shouldHaveType($1);
|
||||
endsnippet
|
||||
|
||||
snippet sntype "$this->shouldNotHaveType('Type')"
|
||||
$this->shouldNotHaveType(${1});
|
||||
$this->shouldNotHaveType($1);
|
||||
endsnippet
|
||||
|
||||
snippet srinstance "$this->shouldReturnAnInstanceOf('Type')"
|
||||
$this->shouldReturnAnInstanceOf(${1});
|
||||
$this->shouldReturnAnInstanceOf($1);
|
||||
endsnippet
|
||||
|
||||
snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')"
|
||||
$this->shouldNotReturnAnInstanceOf(${1});
|
||||
$this->shouldNotReturnAnInstanceOf($1);
|
||||
endsnippet
|
||||
|
||||
snippet sbinstance "$this->shouldBeAnInstanceOf('Type')"
|
||||
$this->shouldBeAnInstanceOf(${1});
|
||||
$this->shouldBeAnInstanceOf($1);
|
||||
endsnippet
|
||||
|
||||
snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')"
|
||||
$this->shouldNotBeAnInstanceOf(${1});
|
||||
$this->shouldNotBeAnInstanceOf($1);
|
||||
endsnippet
|
||||
|
||||
snippet simplement "$this->shouldImplement('Type')"
|
||||
$this->shouldImplement(${1});
|
||||
$this->shouldImplement($1);
|
||||
endsnippet
|
||||
|
||||
snippet snimplement "$this->shouldNotImplement('Type')"
|
||||
$this->shouldNotImplement(${1});
|
||||
$this->shouldNotImplement($1);
|
||||
endsnippet
|
||||
|
||||
# Object state matchers
|
||||
snippet sbstate "$this->shouldBeXYZ()"
|
||||
$this->shouldBe${1}();
|
||||
$this->shouldBe$1();
|
||||
endsnippet
|
||||
|
||||
snippet snbstate "$this->shouldNotBeXYZ()"
|
||||
$this->shouldNotBe${1}();
|
||||
$this->shouldNotBe$1();
|
||||
endsnippet
|
||||
|
||||
# Count matchers
|
||||
|
|
|
@ -67,25 +67,25 @@ endsnippet
|
|||
|
||||
snippet act "Symfony2 action" b
|
||||
/**
|
||||
* @Route("${3}", name="${4}")
|
||||
* @Route("$3", name="$4")
|
||||
* @Method({${5:"POST"}})
|
||||
* @Template()
|
||||
*/
|
||||
public function ${1}Action(${2})
|
||||
public function $1Action($2)
|
||||
{
|
||||
${6}
|
||||
$6
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet actt "Symfony2 action and template" b
|
||||
/**
|
||||
* @Route("${3}", name="${4}")
|
||||
* @Route("$3", name="$4")
|
||||
* @Method({${5:"GET"}})
|
||||
* @Template()
|
||||
*/
|
||||
public function ${1}Action(${2})
|
||||
public function $1Action($2)
|
||||
{
|
||||
${6}
|
||||
$6
|
||||
return [];
|
||||
}`!p
|
||||
relpath = os.path.relpath(path)`
|
||||
|
@ -116,8 +116,8 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('${1}')
|
||||
->setDescription('${2}')
|
||||
$this->setName('$1')
|
||||
->setDescription('$2')
|
||||
->setDefinition([
|
||||
new InputArgument('', InputArgument::REQUIRED, ''),
|
||||
new InputOption('', null, InputOption::VALUE_NONE, ''),
|
||||
|
@ -186,14 +186,14 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function transform(${1})
|
||||
public function transform($1)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function reverseTransform(${2})
|
||||
public function reverseTransform($2)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|||
*/
|
||||
public function getName()
|
||||
{
|
||||
return '${1}';
|
||||
return '$1';
|
||||
}
|
||||
}
|
||||
endsnippet
|
||||
|
@ -307,54 +307,54 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|||
endsnippet
|
||||
|
||||
snippet redir "Symfony2 redirect" b
|
||||
$this->redirect($this->generateUrl('${1}', ${2}));
|
||||
$this->redirect($this->generateUrl('$1', $2));
|
||||
endsnippet
|
||||
|
||||
snippet usecontroller "Symfony2 use Symfony\..\Controller" b
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;${1}
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;$1
|
||||
endsnippet
|
||||
|
||||
snippet usereauest "Symfony2 use Symfony\..\Request" b
|
||||
use Symfony\Component\HttpFoundation\Request;${1}
|
||||
use Symfony\Component\HttpFoundation\Request;$1
|
||||
endsnippet
|
||||
|
||||
snippet useroute "Symfony2 use Sensio\..\Route" b
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;${1}
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;$1
|
||||
endsnippet
|
||||
|
||||
snippet useresponse "Symfony2 use Symfony\..\Response" b
|
||||
use Symfony\Component\HttpFoundation\Response;${1}
|
||||
use Symfony\Component\HttpFoundation\Response;$1
|
||||
endsnippet
|
||||
|
||||
snippet usefile "Symfony2 use Symfony\..\File" b
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;${1}
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;$1
|
||||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet usetemplate "Symfony2 use Sensio\..\Template" b
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;${1}
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;$1
|
||||
endsnippet
|
||||
|
||||
snippet usecache "Symfony2 use Sensio\..\Cache" b
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;${1}
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;$1
|
||||
endsnippet
|
||||
|
||||
snippet usemethod "Symfony2 use Sensio\..\Method" b
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;${1}
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;$1
|
||||
endsnippet
|
||||
|
||||
snippet usearray "Symfony2 use Doctrine\..\ArrayCollection" b
|
||||
use Doctrine\Common\Collections\ArrayCollection;${1}
|
||||
use Doctrine\Common\Collections\ArrayCollection;$1
|
||||
endsnippet
|
||||
|
||||
snippet useorm "Symfony2 use Doctrine\..\Mapping as ORM" b
|
||||
use Doctrine\ORM\Mapping as ORM;${1}
|
||||
use Doctrine\ORM\Mapping as ORM;$1
|
||||
endsnippet
|
||||
|
||||
snippet usesecure "Symfony2 use JMS\..\Secure" b
|
||||
use JMS\SecurityExtraBundle\Annotation\Secure;${1}
|
||||
use JMS\SecurityExtraBundle\Annotation\Secure;$1
|
||||
endsnippet
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ class `!p
|
|||
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
||||
` extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test${1}()
|
||||
public function test$1()
|
||||
{
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
|
|
|
@ -32,17 +32,17 @@ endsnippet
|
|||
|
||||
snippet reqf "Required field" b
|
||||
// ${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
|
||||
|
||||
snippet optf "Optional field" b
|
||||
// ${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
|
||||
|
||||
snippet repf "Repeated field" b
|
||||
// ${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
|
||||
|
||||
snippet enum "Enumeration" b
|
||||
|
|
|
@ -133,103 +133,103 @@ endsnippet
|
|||
########################################################################
|
||||
|
||||
snippet alert "Alert Function" b
|
||||
alert("${1:message}")${0}
|
||||
alert("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet crit "Crit Function" b
|
||||
crit("${1:message}")${0}
|
||||
crit("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet debug "Debug Function" b
|
||||
debug("${1:message}")${0}
|
||||
debug("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet defined "Defined Function" b
|
||||
defined(${1:Resource}["${2:name}"])${0}
|
||||
defined(${1:Resource}["${2:name}"])$0
|
||||
endsnippet
|
||||
|
||||
snippet emerg "Emerg Function" b
|
||||
emerg("${1:message}")${0}
|
||||
emerg("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet extlookup "Simple Extlookup" b
|
||||
$${1:Variable} = extlookup("${2:Lookup}")${0}
|
||||
$${1:Variable} = extlookup("${2:Lookup}")$0
|
||||
endsnippet
|
||||
|
||||
snippet extlookup "Extlookup with defaults" b
|
||||
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0}
|
||||
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})$0
|
||||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet fail "Fail Function" b
|
||||
fail("${1:message}")${0}
|
||||
fail("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet hiera "Hiera Function" b
|
||||
$${1:Variable} = hiera("${2:Lookup}")${0}
|
||||
$${1:Variable} = hiera("${2:Lookup}")$0
|
||||
endsnippet
|
||||
|
||||
snippet hiera "Hiera with defaults" b
|
||||
$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0}
|
||||
$${1:Variable} = hiera("${2:Lookup}", ${3:Default})$0
|
||||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet hiera_hash "Hiera Hash Function" b
|
||||
$${1:Variable} = hiera_hash("${2:Lookup}")${0}
|
||||
$${1:Variable} = hiera_hash("${2:Lookup}")$0
|
||||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
snippet hiera_include "Hiera Include Function" b
|
||||
hiera_include("${1:Lookup}")${0}
|
||||
hiera_include("${1:Lookup}")$0
|
||||
endsnippet
|
||||
|
||||
snippet include "Include Function" b
|
||||
include ${1:classname}${0}
|
||||
include ${1:classname}$0
|
||||
endsnippet
|
||||
|
||||
snippet info "Info Function" b
|
||||
info("${1:message}")${0}
|
||||
info("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet inline_template "Inline Template Function" b
|
||||
inline_template("<%= ${1:template} %>")${0}
|
||||
inline_template("<%= ${1:template} %>")$0
|
||||
endsnippet
|
||||
|
||||
snippet notice "Notice Function" b
|
||||
notice("${1:message}")${0}
|
||||
notice("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
snippet realize "Realize Function" b
|
||||
realize(${1:Resource}["${2:name}"])${0}
|
||||
realize(${1:Resource}["${2:name}"])$0
|
||||
endsnippet
|
||||
|
||||
snippet regsubst "Regsubst Function" b
|
||||
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0}
|
||||
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')$0
|
||||
endsnippet
|
||||
|
||||
snippet split "Split Function" b
|
||||
$${1:Variable} = split($${1:Target}, '${2:regexp}')${0}
|
||||
$${1:Variable} = split($${1:Target}, '${2:regexp}')$0
|
||||
endsnippet
|
||||
|
||||
snippet versioncmp "Version Compare Function" b
|
||||
$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0}
|
||||
$${1:Variable} = versioncmp('${1:version}', '${2:version}')$0
|
||||
endsnippet
|
||||
|
||||
snippet warning "Warning Function" b
|
||||
warning("${1:message}")${0}
|
||||
warning("${1:message}")$0
|
||||
endsnippet
|
||||
|
||||
# vim:ft=snippets:
|
||||
|
|
|
@ -19,7 +19,7 @@ endsnippet
|
|||
snippet with "with" b
|
||||
with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}:
|
||||
${3:${VISUAL:pass}}
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet for "for loop" b
|
||||
|
|
|
@ -24,11 +24,11 @@ setwd("${1:`!p snip.rv = os.getcwd()`}")
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
snippet dl "Download and install a package" b
|
||||
|
@ -50,51 +50,51 @@ source('${0:file}')
|
|||
endsnippet
|
||||
|
||||
snippet if "If statement"
|
||||
if (${1}) {
|
||||
${0}
|
||||
if ($1) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet eif "Else-If statement"
|
||||
else if (${1}) {
|
||||
${0}
|
||||
else if ($1) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet el "Else statement"
|
||||
else {
|
||||
${0}
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ife "if .. else"
|
||||
if (${1}) {
|
||||
${2}
|
||||
if ($1) {
|
||||
$2
|
||||
} else {
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet wh "while loop"
|
||||
while(${1}) {
|
||||
${2}
|
||||
while($1) {
|
||||
$2
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "for loop"
|
||||
for (${1:item} in ${2:list}) {
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet fun "Function definition"
|
||||
${1:name} <- function (${2}) {
|
||||
${0}
|
||||
${1:name} <- function ($2) {
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ret "Return call"
|
||||
return(${0})
|
||||
return($0)
|
||||
endsnippet
|
||||
|
||||
snippet df "Data frame"
|
||||
|
|
|
@ -22,7 +22,7 @@ class ${1:Model}Controller < ApplicationController
|
|||
$0
|
||||
|
||||
private
|
||||
def find_${2}
|
||||
def find_$2
|
||||
@$2 = ${3:$1}.find(params[:id]) if params[:id]
|
||||
end
|
||||
end
|
||||
|
@ -253,7 +253,7 @@ after_validation_on_update $0
|
|||
endsnippet
|
||||
|
||||
snippet asg "assert(var = assigns(:var))"
|
||||
assert(${1:var} = assigns(:${1}), "Cannot find @${1}")
|
||||
assert(${1:var} = assigns(:$1), "Cannot find @$1")
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
|
@ -270,11 +270,11 @@ end
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
snippet artpp "assert_redirected_to (path plural)"
|
||||
|
@ -282,7 +282,7 @@ assert_redirected_to ${10:${2:model}s_path}
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet asrj "assert_rjs"
|
||||
|
@ -324,7 +324,7 @@ before_validation_on_update
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet crw "cattr_accessor"
|
||||
|
@ -358,7 +358,7 @@ endsnippet
|
|||
snippet deftg "def get request"
|
||||
def test_should_get_${1:action}
|
||||
${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
|
||||
$0
|
||||
end
|
||||
|
@ -367,7 +367,7 @@ endsnippet
|
|||
snippet deftp "def post request"
|
||||
def test_should_post_${1:action}
|
||||
${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
|
||||
|
||||
end
|
||||
|
@ -400,23 +400,23 @@ end
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
snippet logd "logger.debug"
|
||||
|
@ -514,11 +514,11 @@ redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@ite
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
snippet repp "redirect_to (path plural)"
|
||||
|
@ -526,7 +526,7 @@ redirect_to(${2:${10:model}s_path})
|
|||
endsnippet
|
||||
|
||||
snippet rep "redirect_to (path)"
|
||||
redirect_to(${2:${12:model}_path(${13:@}${14:${12}})})
|
||||
redirect_to(${2:${12:model}_path(${13:@}${14:$12})})
|
||||
endsnippet
|
||||
|
||||
snippet reb "redirect_to :back"
|
||||
|
@ -882,12 +882,12 @@ end
|
|||
endsnippet
|
||||
|
||||
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
|
||||
|
||||
snippet route_spec
|
||||
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
|
||||
endsnippet
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
|
|||
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
|
||||
DIRECTIVES = ['topic','sidebar','math','epigraph',
|
||||
'parsed-literal','code','highlights',
|
||||
'pull-quote','compound','container',
|
||||
'pull-quote','compound','container','table','csv-table',
|
||||
'list-table','class','sectnum',
|
||||
'role','default-role','unicode',
|
||||
'raw']
|
||||
|
@ -238,6 +238,7 @@ if di == 'im':
|
|||
if di == 'fi':
|
||||
content="""
|
||||
:alt: {0}
|
||||
|
||||
{0}""".format(real_name)
|
||||
`
|
||||
..`!p snip.rv = " %s" % link if link else ""` $1`!p
|
||||
|
@ -281,6 +282,23 @@ snippet ro "Text Roles" w
|
|||
path))`:\`$2\`\
|
||||
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 #
|
||||
############
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
priority -50
|
||||
|
||||
snippet let "let variable declaration" b
|
||||
let ${1:name}${2:: ${3:type}} = ${4};
|
||||
let ${1:name}${2:: ${3:type}} = $4;
|
||||
endsnippet
|
||||
|
||||
snippet letm "let mut variable declaration" b
|
||||
let mut ${1:name}${2:: ${3:type}} = ${4};
|
||||
let mut ${1:name}${2:: ${3:type}} = $4;
|
||||
endsnippet
|
||||
|
||||
snippet fn "A function, optionally with arguments and return type."
|
||||
fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
|
||||
${VISUAL}${0}
|
||||
fn ${1:function_name}($2)${3/..*/ -> /}$3 {
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pfn "A public function, optionally with arguments and return type."
|
||||
pub fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
|
||||
${VISUAL}${0}
|
||||
pub fn ${1:function_name}($2)${3/..*/ -> /}$3 {
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -29,44 +29,44 @@ ${1:a}: ${2:T}${3:, arg}
|
|||
endsnippet
|
||||
|
||||
snippet || "Closure, anonymous function (inline)" i
|
||||
${1:move }|${2}| { $3 }
|
||||
${1:move }|$2| { $3 }
|
||||
endsnippet
|
||||
|
||||
snippet |} "Closure, anonymous function (block)" i
|
||||
${1:move }|${2}| {
|
||||
${1:move }|$2| {
|
||||
$3
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet pri "print!(..)" b
|
||||
print!("${1}"${2/..*/, /}${2});
|
||||
print!("$1"${2/..*/, /}$2);
|
||||
endsnippet
|
||||
|
||||
snippet pln "println!(..)" b
|
||||
println!("${1}"${2/..*/, /}${2});
|
||||
println!("$1"${2/..*/, /}$2);
|
||||
endsnippet
|
||||
|
||||
snippet fmt "format!(..)"
|
||||
format!("${1}"${2/..*/, /}${2});
|
||||
format!("$1"${2/..*/, /}$2);
|
||||
endsnippet
|
||||
|
||||
snippet macro "macro_rules!" b
|
||||
macro_rules! ${1:name} {
|
||||
(${2:matcher}) => (
|
||||
${3}
|
||||
$3
|
||||
)
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet mod "A module" b
|
||||
mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet for "for .. in .." b
|
||||
for ${1:i} in ${2} {
|
||||
${VISUAL}${0}
|
||||
for ${1:i} in $2 {
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
@ -76,19 +76,19 @@ endsnippet
|
|||
|
||||
snippet st "Struct" b
|
||||
struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
|
||||
${VISUAL}${0}
|
||||
${VISUAL}$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
# TODO: fancy dynamic field mirroring like Python slotclass
|
||||
snippet stn "Struct with new constructor." b
|
||||
pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
|
||||
fd${0}
|
||||
fd$0
|
||||
}
|
||||
|
||||
impl $1 {
|
||||
pub fn new(${2}) -> $1 {
|
||||
$1 { ${3} }
|
||||
pub fn new($2) -> $1 {
|
||||
$1 { $3 }
|
||||
}
|
||||
}
|
||||
endsnippet
|
||||
|
@ -99,7 +99,7 @@ endsnippet
|
|||
|
||||
snippet impl "Struct/Trait implementation" b
|
||||
impl ${1:Type/Trait}${2: for ${3:Type}} {
|
||||
${0}
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@ for (${1:1}, ${2:10}) {${3: |i}|}
|
|||
endsnippet
|
||||
snippet sdef
|
||||
SynthDef(\\${1:synthName}, {${2: |${3:x}|}
|
||||
${0}
|
||||
$0
|
||||
}).add;
|
||||
endsnippet
|
||||
|
|
|
@ -5,21 +5,21 @@ priority -50
|
|||
###########################################################################
|
||||
snippet for "for... (for)" b
|
||||
for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} {
|
||||
${4}
|
||||
$4
|
||||
}
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet foreach "foreach... (foreach)"
|
||||
foreach ${1:var} ${2:\$list} {
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet if "if... (if)" b
|
||||
if {${1:condition}} {
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
|
||||
endsnippet
|
||||
|
@ -27,7 +27,7 @@ endsnippet
|
|||
snippet proc "proc... (proc)" b
|
||||
proc ${1:name} {${2:args}} \
|
||||
{
|
||||
${3}
|
||||
$3
|
||||
}
|
||||
|
||||
endsnippet
|
||||
|
@ -35,16 +35,16 @@ endsnippet
|
|||
snippet switch "switch... (switch)" b
|
||||
switch ${1:-exact} -- ${2:\$var} {
|
||||
${3:match} {
|
||||
${4}
|
||||
$4
|
||||
}
|
||||
default {${5}}
|
||||
default {$5}
|
||||
}
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet while "while... (while)" b
|
||||
while {${1:condition}} {
|
||||
${2}
|
||||
$2
|
||||
}
|
||||
|
||||
endsnippet
|
||||
|
|
|
@ -53,7 +53,7 @@ snippet desc "Description" b
|
|||
endsnippet
|
||||
|
||||
snippet it "Individual item" b
|
||||
\item ${1}
|
||||
\item $1
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
|
@ -61,54 +61,54 @@ snippet part "Part" b
|
|||
\part{${1:part name}}
|
||||
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet cha "Chapter" b
|
||||
\chapter{${1:chapter name}}
|
||||
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet sec "Section" b
|
||||
\section{${1:section name}}
|
||||
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet sub "Subsection" b
|
||||
\subsection{${1:subsection name}}
|
||||
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ssub "Subsubsection" b
|
||||
\subsubsection{${1:subsubsection name}}
|
||||
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet par "Paragraph" b
|
||||
\paragraph{${1:paragraph name}}
|
||||
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet subp "Subparagraph" b
|
||||
\subparagraph{${1:subparagraph name}}
|
||||
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
|
||||
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet ni "Non-indented paragraph" b
|
||||
\noindent
|
||||
${0}
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pac "Package" b
|
||||
|
|
|
@ -13,11 +13,11 @@ snippet guard "script reload guard" b
|
|||
if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700}
|
||||
finish
|
||||
endif
|
||||
let $1 = 1${3}
|
||||
let $1 = 1$3
|
||||
endsnippet
|
||||
|
||||
snippet f "function" b
|
||||
fun ${1:function_name}(${2})
|
||||
fun ${1:function_name}($2)
|
||||
${3:" code}
|
||||
endf
|
||||
endsnippet
|
||||
|
|
|
@ -96,7 +96,7 @@ snippet interface
|
|||
}
|
||||
snippet try
|
||||
try {
|
||||
${1}
|
||||
${1:${VISUAL}}
|
||||
} catch (error:ErrorType) {
|
||||
${2}
|
||||
} finally {
|
||||
|
@ -115,11 +115,11 @@ snippet forr
|
|||
# If Condition
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
snippet el
|
||||
else {
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
# Ternary conditional
|
||||
snippet t
|
||||
|
|
|
@ -90,19 +90,19 @@ snippet fors for some
|
|||
|
||||
snippet if if
|
||||
if ${1} then
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
end if;
|
||||
|
||||
snippet ife if ... else
|
||||
if ${1} then
|
||||
${2}
|
||||
${2:${VISUAL}}
|
||||
else
|
||||
${0}
|
||||
end if;
|
||||
|
||||
snippet el else
|
||||
else
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
|
||||
snippet eif elsif
|
||||
elsif ${1} then
|
||||
|
@ -110,13 +110,13 @@ snippet eif elsif
|
|||
|
||||
snippet wh while
|
||||
while ${1} loop
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
end loop;
|
||||
|
||||
snippet nwh named while
|
||||
${1}:
|
||||
while ${2} loop
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
end loop $1;
|
||||
|
||||
snippet for for
|
||||
|
|
|
@ -9,22 +9,22 @@ snippet dir
|
|||
# <FilesMatch>
|
||||
snippet filesmatch
|
||||
<FilesMatch "${1:regex}">
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
</FilesMatch>
|
||||
# <IfModule>
|
||||
snippet ifmodule
|
||||
<IfModule ${1:mod_example.c}>
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
</IfModule>
|
||||
# <LimitExcept>
|
||||
snippet limitexcept
|
||||
<LimitExcept ${1:POST GET}>
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
</LimitExcept>
|
||||
# <Proxy>
|
||||
snippet proxy
|
||||
<Proxy ${1:*}>
|
||||
${0}
|
||||
${0:${VISUAL}}
|
||||
</Proxy>
|
||||
# <VirtualHost>
|
||||
snippet virtualhost
|
||||
|
|
|
@ -20,7 +20,7 @@ snippet def
|
|||
# if
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2}
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
# else
|
||||
snippet el
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue