mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-28 04:22:27 +08:00
Implement a preview window for selecting locations to open
This commit is contained in:
@@ -13,26 +13,10 @@ function! ale#definition#SetMap(map) abort
|
||||
let s:go_to_definition_map = a:map
|
||||
endfunction
|
||||
|
||||
" This function is used so we can check the execution of commands without
|
||||
" running them.
|
||||
function! ale#definition#Execute(expr) abort
|
||||
execute a:expr
|
||||
endfunction
|
||||
|
||||
function! ale#definition#ClearLSPData() abort
|
||||
let s:go_to_definition_map = {}
|
||||
endfunction
|
||||
|
||||
function! ale#definition#Open(options, filename, line, column) abort
|
||||
if a:options.open_in_tab
|
||||
call ale#definition#Execute('tabedit ' . fnameescape(a:filename))
|
||||
else
|
||||
call ale#definition#Execute('edit ' . fnameescape(a:filename))
|
||||
endif
|
||||
|
||||
call cursor(a:line, a:column)
|
||||
endfunction
|
||||
|
||||
function! ale#definition#HandleTSServerResponse(conn_id, response) abort
|
||||
if get(a:response, 'command', '') is# 'definition'
|
||||
\&& has_key(s:go_to_definition_map, a:response.request_seq)
|
||||
@@ -43,7 +27,7 @@ function! ale#definition#HandleTSServerResponse(conn_id, response) abort
|
||||
let l:line = a:response.body[0].start.line
|
||||
let l:column = a:response.body[0].start.offset
|
||||
|
||||
call ale#definition#Open(l:options, l:filename, l:line, l:column)
|
||||
call ale#util#Open(l:filename, l:line, l:column, l:options)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
@@ -67,7 +51,7 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort
|
||||
let l:line = l:item.range.start.line + 1
|
||||
let l:column = l:item.range.start.character
|
||||
|
||||
call ale#definition#Open(l:options, l:filename, l:line, l:column)
|
||||
call ale#util#Open(l:filename, l:line, l:column, l:options)
|
||||
break
|
||||
endfor
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user