forked from dense-analysis/ale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes dense-analysis#3019 - Implement default navigation
Default navigation for commands that jump to new locations has been implemented with the `ale_default_navigation` variable, and all commands that jump to locations now support `-tab`, `-split`, or `-vsplit` arguments for overriding the default navigation behavior.
- Loading branch information
Showing
9 changed files
with
278 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
" Author: w0rp <[email protected]> | ||
" Description: Preview windows for showing whatever information in. | ||
|
||
if !has_key(s:, 'last_selection_list') | ||
let s:last_selection_list = [] | ||
endif | ||
|
||
if !has_key(s:, 'last_selection_open_in') | ||
let s:last_selection_open_in = 'current-buffer' | ||
endif | ||
|
||
" Open a preview window and show some lines in it. | ||
" A second argument can be passed as a Dictionary with options. They are... | ||
" | ||
|
@@ -67,32 +75,45 @@ function! ale#preview#ShowSelection(item_list, ...) abort | |
|
||
call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'}) | ||
let b:ale_preview_item_list = a:item_list | ||
let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') | ||
|
||
" Remove the last preview | ||
let s:last_selection_list = b:ale_preview_item_list | ||
let s:last_selection_open_in = b:ale_preview_item_open_in | ||
endfunction | ||
|
||
function! s:Open(open_in_tab) abort | ||
function! ale#preview#RepeatSelection() abort | ||
if empty(s:last_selection_list) | ||
return | ||
endif | ||
|
||
call ale#preview#ShowSelection(s:last_selection_list, { | ||
\ 'open_in': s:last_selection_open_in, | ||
\}) | ||
endfunction | ||
|
||
function! s:Open(open_in) abort | ||
let l:item_list = get(b:, 'ale_preview_item_list', []) | ||
let l:item = get(l:item_list, getpos('.')[1] - 1, {}) | ||
|
||
if empty(l:item) | ||
return | ||
endif | ||
|
||
if !a:open_in_tab | ||
:q! | ||
endif | ||
:q! | ||
|
||
call ale#util#Open( | ||
\ l:item.filename, | ||
\ l:item.line, | ||
\ l:item.column, | ||
\ {'open_in_tab': a:open_in_tab}, | ||
\ {'open_in': a:open_in}, | ||
\) | ||
endfunction | ||
|
||
function! ale#preview#OpenSelectionInBuffer() abort | ||
call s:Open(0) | ||
function! ale#preview#OpenSelection() abort | ||
call s:Open(b:ale_preview_item_open_in) | ||
endfunction | ||
|
||
function! ale#preview#OpenSelectionInTab() abort | ||
call s:Open(1) | ||
call s:Open('tab') | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.