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

Updated plugins and added vim-jade

This commit is contained in:
amix
2016-01-05 15:18:45 -03:00
parent 3aabd8befd
commit 795a8fb80d
35 changed files with 1036 additions and 131 deletions

View File

@ -27,7 +27,7 @@ function! go#cmd#Build(bang, ...)
" if we have nvim, call it asynchronously and return early ;)
if has('nvim')
call go#jobcontrol#Spawn("build", args)
call go#jobcontrol#Spawn(a:bang, "build", args)
return
endif
@ -36,14 +36,22 @@ function! go#cmd#Build(bang, ...)
let default_makeprg = &makeprg
let &makeprg = "go " . join(args, ' ')
if g:go_dispatch_enabled && exists(':Make') == 2
call go#util#EchoProgress("building dispatched ...")
silent! exe 'Make'
else
silent! exe 'lmake!'
endif
redraw!
" execute make inside the source folder so we can parse the errors
" correctly
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
try
execute cd . fnameescape(expand("%:p:h"))
if g:go_dispatch_enabled && exists(':Make') == 2
call go#util#EchoProgress("building dispatched ...")
silent! exe 'Make'
else
silent! exe 'lmake!'
endif
redraw!
finally
execute cd . fnameescape(dir)
endtry
let errors = go#list#Get()
call go#list#Window(len(errors))
@ -62,9 +70,9 @@ endfunction
" Run runs the current file (and their dependencies if any) in a new terminal.
function! go#cmd#RunTerm(mode)
function! go#cmd#RunTerm(bang, mode)
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
call go#term#newmode(cmd, a:mode)
call go#term#newmode(a:bang, cmd, a:mode)
endfunction
" Run runs the current file (and their dependencies if any) and outputs it.
@ -73,7 +81,7 @@ endfunction
" calling long running apps will block the whole UI.
function! go#cmd#Run(bang, ...)
if has('nvim')
call go#cmd#RunTerm('')
call go#cmd#RunTerm(a:bang, '')
return
endif
@ -168,9 +176,9 @@ function! go#cmd#Test(bang, compile, ...)
if has('nvim')
if get(g:, 'go_term_enabled', 0)
call go#term#new(["go"] + args)
call go#term#new(a:bang, ["go"] + args)
else
call go#jobcontrol#Spawn("test", args)
call go#jobcontrol#Spawn(a:bang, "test", args)
endif
return
endif
@ -195,6 +203,9 @@ function! go#cmd#Test(bang, compile, ...)
call go#list#Window(len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst()
elseif empty(errors)
" failed to parse errors, output the original content
call go#util#EchoError(out)
endif
echon "vim-go: " | echohl ErrorMsg | echon "[test] FAIL" | echohl None
else

View File

@ -5,11 +5,11 @@ let s:jobs = {}
" Spawn is a wrapper around s:spawn. It can be executed by other files and
" scripts if needed. Desc defines the description for printing the status
" during the job execution (useful for statusline integration).
function! go#jobcontrol#Spawn(desc, args)
function! go#jobcontrol#Spawn(bang, desc, args)
" autowrite is not enabled for jobs
call go#cmd#autowrite()
let job = s:spawn(a:desc, a:args)
let job = s:spawn(a:bang, a:desc, a:args)
return job.id
endfunction
@ -40,9 +40,10 @@ endfunction
" a job is started a reference will be stored inside s:jobs. spawn changes the
" GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the
" current files folder.
function! s:spawn(desc, args)
function! s:spawn(bang, desc, args)
let job = {
\ 'desc': a:desc,
\ 'bang': a:bang,
\ 'winnr': winnr(),
\ 'importpath': go#package#ImportPath(expand('%:p:h')),
\ 'state': "RUNNING",
@ -68,8 +69,8 @@ function! s:spawn(desc, args)
endfor
let dir = getcwd()
execute cd . fnameescape(expand("%:p:h"))
let jobdir = fnameescape(expand("%:p:h"))
execute cd . jobdir
" append the subcommand, such as 'build'
let argv = ['go'] + a:args
@ -77,6 +78,7 @@ function! s:spawn(desc, args)
" run, forrest, run!
let id = jobstart(argv, job)
let job.id = id
let job.dir = jobdir
let s:jobs[id] = job
execute cd . fnameescape(dir)
@ -91,21 +93,9 @@ endfunction
" references and also displaying errors in the quickfix window collected by
" on_stderr handler. If there are no errors and a quickfix window is open,
" it'll be closed.
function! s:on_exit(job_id, data)
function! s:on_exit(job_id, exit_status)
let std_combined = self.stderr + self.stdout
if empty(std_combined)
call go#list#Clean()
call go#list#Window()
let self.state = "SUCCESS"
return
endif
let errors = go#tool#ParseErrors(std_combined)
let errors = go#tool#FilterValids(errors)
if !len(errors)
" no errors could be past, just return
if a:exit_status == 0
call go#list#Clean()
call go#list#Window()
@ -115,11 +105,29 @@ function! s:on_exit(job_id, data)
let self.state = "FAILED"
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
try
execute cd self.dir
let errors = go#tool#ParseErrors(std_combined)
let errors = go#tool#FilterValids(errors)
finally
execute cd . fnameescape(dir)
endtry
if !len(errors)
" failed to parse errors, output the original content
call go#util#EchoError(std_combined[0])
return
endif
" if we are still in the same windows show the list
if self.winnr == winnr()
call go#list#Populate(errors)
call go#list#Window(len(errors))
call go#list#JumpToFirst()
if !empty(errors) && !self.bang
call go#list#JumpToFirst()
endif
endif
endfunction

View File

@ -35,6 +35,9 @@ function! go#rename#Rename(bang, ...)
call go#list#Window(len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst()
elseif empty(errors)
" failed to parse errors, output the original content
call go#util#EchoError(out)
endif
return
else

View File

@ -7,12 +7,12 @@ let s:jobs = {}
" new creates a new terminal with the given command. Mode is set based on the
" global variable g:go_term_mode, which is by default set to :vsplit
function! go#term#new(cmd)
call go#term#newmode(a:cmd, g:go_term_mode)
function! go#term#new(bang, cmd)
call go#term#newmode(a:bang, a:cmd, g:go_term_mode)
endfunction
" new creates a new terminal with the given command and window mode.
function! go#term#newmode(cmd, mode)
function! go#term#newmode(bang, cmd, mode)
let mode = a:mode
if empty(mode)
let mode = g:go_term_mode
@ -39,6 +39,7 @@ function! go#term#newmode(cmd, mode)
let job = {
\ 'stderr' : [],
\ 'stdout' : [],
\ 'bang' : a:bang,
\ 'on_stdout': function('s:on_stdout'),
\ 'on_stderr': function('s:on_stderr'),
\ 'on_exit' : function('s:on_exit'),
@ -110,7 +111,9 @@ function! s:on_exit(job_id, data)
call go#list#Populate(errors)
call go#list#Window(len(errors))
call go#list#JumpToFirst()
if !self.bang
call go#list#JumpToFirst()
endif
else
call go#list#Clean()
call go#list#Window()