Skip to content

Commit 1ab5e01

Browse files
committed
Add option g:run_use_loclist
1 parent e7c5c65 commit 1ab5e01

File tree

3 files changed

+62
-11
lines changed

3 files changed

+62
-11
lines changed

autoload/run.vim

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@ endfunction
365365

366366
function! run#RunListToggle() abort
367367
if run#is_qf_open()
368-
cclose
368+
silent call run#closelist()
369369
else
370370
call run#update_run_jobs()
371-
silent copen
371+
silent call run#openlist()
372372
endif
373373
endfunction
374374

@@ -471,13 +471,13 @@ function! run#RunBrowseLogs(...) abort
471471
call add(qf_output, qf_item)
472472
endfor
473473

474-
silent call setqflist(qf_output)
475-
silent call setqflist([], 'a', {'title': 'RunLogs'})
474+
silent call run#setlist(qf_output)
475+
silent call run#setlist([], 'a', {'title': 'RunLogs'})
476476
let limit = min([limit, len(qf_output)])
477477
let msg = 'Showing the last ' . limit . ' saved logs.'
478478
call run#print_formatted('Normal', msg)
479479
if !run#is_qf_open()
480-
silent copen
480+
silent call run#openlist()
481481
endif
482482
endfunction
483483

@@ -493,16 +493,60 @@ function! run#RunDeleteLogs() abort
493493
endif
494494
call system('rm ' . g:rundir . '/*.log')
495495

496-
let qf_title = get(getqflist({'title': 1}), 'title')
496+
let qf_title = get(run#getlist({'title': 1}), 'title')
497497
if run#is_qf_open() && qf_title ==# 'RunLogs'
498-
silent call setqflist([])
499-
silent call setqflist([], 'a', {'title': 'RunLogs'})
498+
silent call run#setlist([])
499+
silent call run#setlist([], 'a', {'title': 'RunLogs'})
500500
endif
501501
call run#print_formatted('WarningMsg', 'Deleted all logs.')
502502
endfunction
503503

504504

505505
" utility
506+
function! run#setlist(...)
507+
if g:run_use_loclist
508+
if a:0 ==# 1
509+
call setloclist(0, a:1)
510+
elseif a:0 ==# 2
511+
call setloclist(0, a:1, a:2)
512+
elseif a:0 ==# 3
513+
call setloclist(0, a:1, a:2, a:3)
514+
endif
515+
else
516+
if a:0 ==# 1
517+
call setqflist(a:1)
518+
elseif a:0 ==# 2
519+
call setqflist(a:1, a:2)
520+
elseif a:0 ==# 3
521+
call setqflist(a:1, a:2, a:3)
522+
endif
523+
endif
524+
endfunction
525+
526+
function! run#getlist(arg)
527+
if g:run_use_loclist
528+
call getloclist(a:arg)
529+
else
530+
call getqflist(a:arg)
531+
endif
532+
endfunction
533+
534+
function! run#openlist()
535+
if g:run_use_loclist
536+
lopen
537+
else
538+
copen
539+
endif
540+
endfunction
541+
542+
function! run#closelist()
543+
if g:run_use_loclist
544+
lclose
545+
else
546+
cclose
547+
endif
548+
endfunction
549+
506550
function! run#cmd_input_open_editor(editor_lines, timestamp, ...)
507551
let options = get(a:, 1, {})
508552
let is_send = get(options, 'is_send')
@@ -582,8 +626,8 @@ function! run#update_run_jobs()
582626
call extend(s:run_jobs[val['timestamp']], { 'status': status })
583627
endfor
584628

585-
silent call setqflist(qf_output)
586-
silent call setqflist([], 'a', {'title': 'RunList'})
629+
silent call run#setlist(qf_output)
630+
silent call run#setlist([], 'a', {'title': 'RunList'})
587631
endfunction
588632

589633
function! run#alert_and_update(content, ...)
@@ -594,7 +638,7 @@ function! run#alert_and_update(content, ...)
594638

595639
call run#update_run_jobs()
596640
if (!g:run_quiet_default || run#is_qf_open()) && !get(options, 'quiet')
597-
silent copen
641+
silent call run#openlist()
598642
endif
599643
let msg_format = get(options, 'msg_format', 'Normal')
600644
call run#print_formatted(msg_format, a:content)

doc/vim-run.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ g:run_shell *g:run_shell*
156156
157157
let g:run_shell = $SHELL (default)
158158
<
159+
g:run_use_loclist *g:run_use_loclist*
160+
If enabled, the |RunList| will use the |location-list| of the current window
161+
instead of the default |quickfix| list. >
162+
163+
let g:run_use_loclist = 0 (default)
164+
159165
g:run_quiet_default *g:run_quiet_default*
160166
If enabled, all |:Run| commands will not open the |RunList| whenever jobs
161167
start or stop. Note that whenever jobs are updated and the |RunList| is

plugin/run.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ endif
3434
" user vars
3535
let g:rundir = get(g:, 'rundir', $HOME . '/.vim/rundir')
3636
let g:run_shell = get(g:, 'run_shell', $SHELL)
37+
let g:run_use_loclist = get(g:, 'run_use_loclist', 0)
3738
let g:run_quiet_default = get(g:, 'run_quiet_default', 0)
3839
let g:run_autosave_logs = get(g:, 'run_autosave_logs', 0)
3940
let g:run_nostream_default = get(g:, 'run_nostream_default', 0)

0 commit comments

Comments
 (0)