1
0
mirror of https://github.com/amix/vimrc synced 2025-06-23 23:15:01 +08:00

Updated plugins

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

View File

@ -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:

View File

@ -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))

View File

@ -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),
%% `rebar.config` might contain relative paths.
%% They are relative to the file! Not to the project root.
RebarOpts = rebar_opts(Dir ++ "/" ++ RebarFile),
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.
%% 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()),

View File

@ -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,

View File

@ -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,' .

View File

@ -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'
let opts = []
for line in filter(getbufline(a:buf, 1, 100), 'v:val =~# ' . string('\m^//\s\+' . a:comment . ':\s*'))
call extend(opts, split( matchstr(line, '\m^//\s\+' . a:comment . ':\s*\zs.*'), '\s\+' ))
endfor
call map( filter(opts, 'v:val !=# ""'), 'syntastic#util#shescape(v:val)' )
endif
else
call syntastic#log#error('syntastic_vala_' . a:name . ' must be either a list, or a string')
return ''
endif
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)
else
echoerr 'syntastic_vala_vapi_dirs must be either a list, or a string: fallback to in-file modules string'
endif
endif
let vapi_line = search('^//\s*vapidirs:\s*','n')
let vapi_str = getline(vapi_line)
return split( substitute( vapi_str, '\m^//\s*vapidirs:\s*', '', 'g' ), '\m\s\+' )
return join(map(opts, string(a:cmd . ' ') . ' . v:val'))
endfunction " }}}2
" }}}1