Closes #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.
This commit is contained in:
parent
bbe5153fcb
commit
82f734a7c2
9 changed files with 278 additions and 113 deletions
|
@ -5,6 +5,7 @@ let s:go_to_definition_map = {}
|
||||||
|
|
||||||
" Enable automatic updates of the tagstack
|
" Enable automatic updates of the tagstack
|
||||||
let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1)
|
let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1)
|
||||||
|
let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer')
|
||||||
|
|
||||||
" Used to get the definition map in tests.
|
" Used to get the definition map in tests.
|
||||||
function! ale#definition#GetMap() abort
|
function! ale#definition#GetMap() abort
|
||||||
|
@ -134,6 +135,10 @@ function! s:GoToLSPDefinition(linter, options, capability) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#definition#GoTo(options) abort
|
function! ale#definition#GoTo(options) abort
|
||||||
|
if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command')
|
||||||
|
execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.'''
|
||||||
|
endif
|
||||||
|
|
||||||
for l:linter in ale#linter#Get(&filetype)
|
for l:linter in ale#linter#Get(&filetype)
|
||||||
if !empty(l:linter.lsp)
|
if !empty(l:linter.lsp)
|
||||||
call s:GoToLSPDefinition(l:linter, a:options, 'definition')
|
call s:GoToLSPDefinition(l:linter, a:options, 'definition')
|
||||||
|
@ -142,6 +147,10 @@ function! ale#definition#GoTo(options) abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#definition#GoToType(options) abort
|
function! ale#definition#GoToType(options) abort
|
||||||
|
if !get(g:, 'ale_ignore_2_7_warnings') && has_key(a:options, 'deprecated_command')
|
||||||
|
execute 'echom '':' . a:options.deprecated_command . ' is deprecated. Use `let g:ale_ignore_2_7_warnings = 1` to disable this message.'''
|
||||||
|
endif
|
||||||
|
|
||||||
for l:linter in ale#linter#Get(&filetype)
|
for l:linter in ale#linter#Get(&filetype)
|
||||||
if !empty(l:linter.lsp)
|
if !empty(l:linter.lsp)
|
||||||
" TODO: handle typeDefinition for tsserver if supported by the
|
" TODO: handle typeDefinition for tsserver if supported by the
|
||||||
|
@ -154,3 +163,33 @@ function! ale#definition#GoToType(options) abort
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! ale#definition#GoToCommandHandler(command, ...) abort
|
||||||
|
let l:options = {}
|
||||||
|
|
||||||
|
if len(a:000) > 0
|
||||||
|
for l:option in a:000
|
||||||
|
if l:option is? '-tab'
|
||||||
|
let l:options.open_in = 'tab'
|
||||||
|
elseif l:option is? '-split'
|
||||||
|
let l:options.open_in = 'split'
|
||||||
|
elseif l:option is? '-vsplit'
|
||||||
|
let l:options.open_in = 'vsplit'
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !has_key(l:options, 'open_in')
|
||||||
|
let l:default_navigation = ale#Var(bufnr(''), 'default_navigation')
|
||||||
|
|
||||||
|
if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0
|
||||||
|
let l:options.open_in = l:default_navigation
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:command is# 'type'
|
||||||
|
call ale#definition#GoToType(l:options)
|
||||||
|
else
|
||||||
|
call ale#definition#GoTo(l:options)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: Preview windows for showing whatever information in.
|
" 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.
|
" Open a preview window and show some lines in it.
|
||||||
" A second argument can be passed as a Dictionary with options. They are...
|
" A second argument can be passed as a Dictionary with options. They are...
|
||||||
"
|
"
|
||||||
|
@ -67,9 +75,24 @@ function! ale#preview#ShowSelection(item_list, ...) abort
|
||||||
|
|
||||||
call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'})
|
call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'})
|
||||||
let b:ale_preview_item_list = a:item_list
|
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
|
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_list = get(b:, 'ale_preview_item_list', [])
|
||||||
let l:item = get(l:item_list, getpos('.')[1] - 1, {})
|
let l:item = get(l:item_list, getpos('.')[1] - 1, {})
|
||||||
|
|
||||||
|
@ -77,22 +100,20 @@ function! s:Open(open_in_tab) abort
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !a:open_in_tab
|
:q!
|
||||||
:q!
|
|
||||||
endif
|
|
||||||
|
|
||||||
call ale#util#Open(
|
call ale#util#Open(
|
||||||
\ l:item.filename,
|
\ l:item.filename,
|
||||||
\ l:item.line,
|
\ l:item.line,
|
||||||
\ l:item.column,
|
\ l:item.column,
|
||||||
\ {'open_in_tab': a:open_in_tab},
|
\ {'open_in': a:open_in},
|
||||||
\)
|
\)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#preview#OpenSelectionInBuffer() abort
|
function! ale#preview#OpenSelection() abort
|
||||||
call s:Open(0)
|
call s:Open(b:ale_preview_item_open_in)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#preview#OpenSelectionInTab() abort
|
function! ale#preview#OpenSelectionInTab() abort
|
||||||
call s:Open(1)
|
call s:Open('tab')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer')
|
||||||
|
|
||||||
let s:references_map = {}
|
let s:references_map = {}
|
||||||
|
|
||||||
" Used to get the references map in tests.
|
" Used to get the references map in tests.
|
||||||
|
@ -99,7 +101,8 @@ function! s:OnReady(line, column, options, linter, lsp_details) abort
|
||||||
let l:request_id = ale#lsp#Send(l:id, l:message)
|
let l:request_id = ale#lsp#Send(l:id, l:message)
|
||||||
|
|
||||||
let s:references_map[l:request_id] = {
|
let s:references_map[l:request_id] = {
|
||||||
\ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0
|
\ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0,
|
||||||
|
\ 'open_in': get(a:options, 'open_in', 'current-buffer'),
|
||||||
\}
|
\}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -110,10 +113,24 @@ function! ale#references#Find(...) abort
|
||||||
for l:option in a:000
|
for l:option in a:000
|
||||||
if l:option is? '-relative'
|
if l:option is? '-relative'
|
||||||
let l:options.use_relative_paths = 1
|
let l:options.use_relative_paths = 1
|
||||||
|
elseif l:option is? '-tab'
|
||||||
|
let l:options.open_in = 'tab'
|
||||||
|
elseif l:option is? '-split'
|
||||||
|
let l:options.open_in = 'split'
|
||||||
|
elseif l:option is? '-vsplit'
|
||||||
|
let l:options.open_in = 'vsplit'
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !has_key(l:options, 'open_in')
|
||||||
|
let l:default_navigation = ale#Var(bufnr(''), 'default_navigation')
|
||||||
|
|
||||||
|
if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0
|
||||||
|
let l:options.open_in = l:default_navigation
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
let l:buffer = bufnr('')
|
let l:buffer = bufnr('')
|
||||||
let [l:line, l:column] = getpos('.')[1:2]
|
let [l:line, l:column] = getpos('.')[1:2]
|
||||||
let l:column = min([l:column, len(getline(l:line))])
|
let l:column = min([l:column, len(getline(l:line))])
|
||||||
|
|
|
@ -91,17 +91,17 @@ endfunction
|
||||||
" options['open_in'] can be:
|
" options['open_in'] can be:
|
||||||
" current-buffer (default)
|
" current-buffer (default)
|
||||||
" tab
|
" tab
|
||||||
" vertical-split
|
" split
|
||||||
" horizontal-split
|
" vsplit
|
||||||
function! ale#util#Open(filename, line, column, options) abort
|
function! ale#util#Open(filename, line, column, options) abort
|
||||||
let l:open_in = get(a:options, 'open_in', 'current-buffer')
|
let l:open_in = get(a:options, 'open_in', 'current-buffer')
|
||||||
let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename)
|
let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename)
|
||||||
|
|
||||||
if l:open_in is# 'tab'
|
if l:open_in is# 'tab'
|
||||||
call ale#util#Execute('tabedit ' . l:args_to_open)
|
call ale#util#Execute('tabedit ' . l:args_to_open)
|
||||||
elseif l:open_in is# 'horizontal-split'
|
elseif l:open_in is# 'split'
|
||||||
call ale#util#Execute('split ' . l:args_to_open)
|
call ale#util#Execute('split ' . l:args_to_open)
|
||||||
elseif l:open_in is# 'vertical-split'
|
elseif l:open_in is# 'vsplit'
|
||||||
call ale#util#Execute('vsplit ' . l:args_to_open)
|
call ale#util#Execute('vsplit ' . l:args_to_open)
|
||||||
elseif bufnr(a:filename) isnot bufnr('')
|
elseif bufnr(a:filename) isnot bufnr('')
|
||||||
" Open another file only if we need to.
|
" Open another file only if we need to.
|
||||||
|
|
142
doc/ale.txt
142
doc/ale.txt
|
@ -478,12 +478,9 @@ would like to use. An example here shows the available options for symbols >
|
||||||
|
|
||||||
ALE supports jumping to the files and locations where symbols are defined
|
ALE supports jumping to the files and locations where symbols are defined
|
||||||
through any enabled LSP linters. The locations ALE will jump to depend on the
|
through any enabled LSP linters. The locations ALE will jump to depend on the
|
||||||
information returned by LSP servers. The following commands are supported:
|
information returned by LSP servers. The |ALEGoToDefinition| command will jump
|
||||||
|
to the definition of symbols under the cursor. See the documentation for the
|
||||||
|ALEGoToDefinition| - Open the definition of the symbol under the cursor.
|
command for configuring how the location will be displayed.
|
||||||
|ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab.
|
|
||||||
|ALEGoToDefinitionInSplit| - The same, but in a new split.
|
|
||||||
|ALEGoToDefinitionInVSplit| - The same, but in a new vertical split.
|
|
||||||
|
|
||||||
ALE will update Vim's |tagstack| automatically unless |g:ale_update_tagstack| is
|
ALE will update Vim's |tagstack| automatically unless |g:ale_update_tagstack| is
|
||||||
set to `0`.
|
set to `0`.
|
||||||
|
@ -493,15 +490,10 @@ set to `0`.
|
||||||
|
|
||||||
ALE supports jumping to the files and locations where symbols' types are
|
ALE supports jumping to the files and locations where symbols' types are
|
||||||
defined through any enabled LSP linters. The locations ALE will jump to depend
|
defined through any enabled LSP linters. The locations ALE will jump to depend
|
||||||
on the information returned by LSP servers. The following commands are
|
on the information returned by LSP servers. The |ALEGoToTypeDefinition|
|
||||||
supported:
|
command will jump to the definition of symbols under the cursor. See the
|
||||||
|
documentation for the command for configuring how the location will be
|
||||||
|ALEGoToTypeDefinition| - Open the definition of the symbol's type under
|
displayed.
|
||||||
the cursor.
|
|
||||||
|ALEGoToTypeDefinitionInTab| - The same, but for opening the file in a new tab.
|
|
||||||
|ALEGoToTypeDefinitionInSplit| - The same, but in a new split.
|
|
||||||
|ALEGoToTypeDefinitionInVSplit| - The same, but in a new vertical split.
|
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
5.4 Find References *ale-find-references*
|
5.4 Find References *ale-find-references*
|
||||||
|
@ -666,7 +658,7 @@ g:ale_completion_delay *g:ale_completion_delay*
|
||||||
|
|
||||||
|
|
||||||
g:ale_completion_enabled *g:ale_completion_enabled*
|
g:ale_completion_enabled *g:ale_completion_enabled*
|
||||||
b:ale_completion_enabled *b:ale_completion_enabled*
|
*b:ale_completion_enabled*
|
||||||
|
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `0`
|
Default: `0`
|
||||||
|
@ -793,6 +785,16 @@ g:ale_cursor_detail *g:ale_cursor_detail*
|
||||||
loaded for messages to be displayed. See |ale-lint-settings-on-startup|.
|
loaded for messages to be displayed. See |ale-lint-settings-on-startup|.
|
||||||
|
|
||||||
|
|
||||||
|
g:ale_default_navigation *g:ale_default_navigation*
|
||||||
|
*b:ale_default_navigation*
|
||||||
|
|
||||||
|
Type: |String|
|
||||||
|
Default: `'buffer'`
|
||||||
|
|
||||||
|
The default method for navigating away from the current buffer to another
|
||||||
|
buffer, such as for |ALEFindReferences:|, or |ALEGoToDefinition|.
|
||||||
|
|
||||||
|
|
||||||
g:ale_disable_lsp *g:ale_disable_lsp*
|
g:ale_disable_lsp *g:ale_disable_lsp*
|
||||||
*b:ale_disable_lsp*
|
*b:ale_disable_lsp*
|
||||||
|
|
||||||
|
@ -845,7 +847,7 @@ g:ale_echo_msg_error_str *g:ale_echo_msg_error_str*
|
||||||
|
|
||||||
|
|
||||||
g:ale_echo_msg_format *g:ale_echo_msg_format*
|
g:ale_echo_msg_format *g:ale_echo_msg_format*
|
||||||
b:ale_echo_msg_format *b:ale_echo_msg_format*
|
*b:ale_echo_msg_format*
|
||||||
|
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'%code: %%s'`
|
Default: `'%code: %%s'`
|
||||||
|
@ -924,7 +926,7 @@ g:ale_enabled *g:ale_enabled*
|
||||||
|
|
||||||
|
|
||||||
g:ale_exclude_highlights *g:ale_exclude_highlights*
|
g:ale_exclude_highlights *g:ale_exclude_highlights*
|
||||||
b:ale_exclude_highlights *b:ale_exclude_highlights*
|
*b:ale_exclude_highlights*
|
||||||
|
|
||||||
Type: |List|
|
Type: |List|
|
||||||
Default: `[]`
|
Default: `[]`
|
||||||
|
@ -961,7 +963,7 @@ g:ale_fixers *g:ale_fixers*
|
||||||
<
|
<
|
||||||
|
|
||||||
g:ale_fix_on_save *g:ale_fix_on_save*
|
g:ale_fix_on_save *g:ale_fix_on_save*
|
||||||
b:ale_fix_on_save *b:ale_fix_on_save*
|
*b:ale_fix_on_save*
|
||||||
|
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `0`
|
Default: `0`
|
||||||
|
@ -983,7 +985,7 @@ b:ale_fix_on_save *b:ale_fix_on_save*
|
||||||
|
|
||||||
|
|
||||||
g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore*
|
g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore*
|
||||||
b:ale_fix_on_save_ignore *b:ale_fix_on_save_ignore*
|
*b:ale_fix_on_save_ignore*
|
||||||
|
|
||||||
Type: |Dictionary| or |List|
|
Type: |Dictionary| or |List|
|
||||||
Default: `{}`
|
Default: `{}`
|
||||||
|
@ -1359,7 +1361,7 @@ g:ale_list_vertical *g:ale_list_vertical*
|
||||||
|
|
||||||
|
|
||||||
g:ale_loclist_msg_format *g:ale_loclist_msg_format*
|
g:ale_loclist_msg_format *g:ale_loclist_msg_format*
|
||||||
b:ale_loclist_msg_format *b:ale_loclist_msg_format*
|
*b:ale_loclist_msg_format*
|
||||||
|
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `g:ale_echo_msg_format`
|
Default: `g:ale_echo_msg_format`
|
||||||
|
@ -1411,7 +1413,7 @@ g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity*
|
||||||
|
|
||||||
|
|
||||||
g:ale_lsp_root *g:ale_lsp_root*
|
g:ale_lsp_root *g:ale_lsp_root*
|
||||||
b:ale_lsp_root *b:ale_lsp_root*
|
*b:ale_lsp_root*
|
||||||
|
|
||||||
Type: |Dictionary| or |String|
|
Type: |Dictionary| or |String|
|
||||||
Default: {}
|
Default: {}
|
||||||
|
@ -1892,7 +1894,8 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor*
|
||||||
|
|
||||||
|
|
||||||
g:ale_virtualtext_delay *g:ale_virtualtext_delay*
|
g:ale_virtualtext_delay *g:ale_virtualtext_delay*
|
||||||
b:ale_virtualtext_delay *b:ale_virtualtext_delay*
|
*b:ale_virtualtext_delay*
|
||||||
|
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `10`
|
Default: `10`
|
||||||
|
|
||||||
|
@ -1911,7 +1914,7 @@ g:ale_virtualtext_prefix *g:ale_virtualtext_prefix*
|
||||||
Prefix to be used with |g:ale_virtualtext_cursor|.
|
Prefix to be used with |g:ale_virtualtext_cursor|.
|
||||||
|
|
||||||
g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names*
|
g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names*
|
||||||
b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names*
|
*b:ale_virtualenv_dir_names*
|
||||||
|
|
||||||
Type: |List|
|
Type: |List|
|
||||||
Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']`
|
Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']`
|
||||||
|
@ -1925,7 +1928,7 @@ b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names*
|
||||||
|
|
||||||
|
|
||||||
g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines*
|
g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines*
|
||||||
b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines*
|
*b:ale_warn_about_trailing_blank_lines*
|
||||||
|
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `1`
|
Default: `1`
|
||||||
|
@ -1937,7 +1940,7 @@ b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines*
|
||||||
|
|
||||||
|
|
||||||
g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace*
|
g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace*
|
||||||
b:ale_warn_about_trailing_whitespace *b:ale_warn_about_trailing_whitespace*
|
*b:ale_warn_about_trailing_whitespace*
|
||||||
|
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `1`
|
Default: `1`
|
||||||
|
@ -2704,11 +2707,23 @@ ALEFindReferences *ALEFindReferences*
|
||||||
Enter key (`<CR>`) can be used to jump to a referencing location, or the `t`
|
Enter key (`<CR>`) can be used to jump to a referencing location, or the `t`
|
||||||
key can be used to jump to the location in a new tab.
|
key can be used to jump to the location in a new tab.
|
||||||
|
|
||||||
|
The locations opened in different ways using the following variations.
|
||||||
|
|
||||||
|
`:ALEFindReferences -tab` - Open the location in a new tab.
|
||||||
|
`:ALEFindReferences -split` - Open the location in a horizontal split.
|
||||||
|
`:ALEFindReferences -vsplit` - Open the location in a vertical split.
|
||||||
|
|
||||||
|
The default method used for navigating to a new location can be changed
|
||||||
|
by modifying |g:ale_default_navigation|.
|
||||||
|
|
||||||
|
The selection can be opened again with the |ALERepeatSelection| command.
|
||||||
|
|
||||||
You can jump back to the position you were at before going to a reference of
|
You can jump back to the position you were at before going to a reference of
|
||||||
something with jump motions like CTRL-O. See |jump-motions|.
|
something with jump motions like CTRL-O. See |jump-motions|.
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_find_references)` is defined for this command.
|
A plug mapping `<Plug>(ale_find_references)` is defined for this command.
|
||||||
|
|
||||||
|
|
||||||
ALEFix *ALEFix*
|
ALEFix *ALEFix*
|
||||||
|
|
||||||
Fix problems with the current buffer. See |ale-fix| for more information.
|
Fix problems with the current buffer. See |ale-fix| for more information.
|
||||||
|
@ -2723,12 +2738,21 @@ ALEFixSuggest *ALEFixSuggest*
|
||||||
See |ale-fix| for more information.
|
See |ale-fix| for more information.
|
||||||
|
|
||||||
|
|
||||||
ALEGoToDefinition *ALEGoToDefinition*
|
ALEGoToDefinition `<options>` *ALEGoToDefinition*
|
||||||
|
|
||||||
Jump to the definition of a symbol under the cursor using the enabled LSP
|
Jump to the definition of a symbol under the cursor using the enabled LSP
|
||||||
linters for the buffer. ALE will jump to a definition if an LSP server
|
linters for the buffer. ALE will jump to a definition if an LSP server
|
||||||
provides a location to jump to. Otherwise, ALE will do nothing.
|
provides a location to jump to. Otherwise, ALE will do nothing.
|
||||||
|
|
||||||
|
The locations opened in different ways using the following variations.
|
||||||
|
|
||||||
|
`:ALEGoToDefinition -tab` - Open the location in a new tab.
|
||||||
|
`:ALEGoToDefinition -split` - Open the location in a horizontal split.
|
||||||
|
`:ALEGoToDefinition -vsplit` - Open the location in a vertical split.
|
||||||
|
|
||||||
|
The default method used for navigating to a new location can be changed
|
||||||
|
by modifying |g:ale_default_navigation|.
|
||||||
|
|
||||||
You can jump back to the position you were at before going to the definition
|
You can jump back to the position you were at before going to the definition
|
||||||
of something with jump motions like CTRL-O. See |jump-motions|.
|
of something with jump motions like CTRL-O. See |jump-motions|.
|
||||||
|
|
||||||
|
@ -2739,30 +2763,6 @@ ALEGoToDefinition *ALEGoToDefinition*
|
||||||
A plug mapping `<Plug>(ale_go_to_definition)` is defined for this command.
|
A plug mapping `<Plug>(ale_go_to_definition)` is defined for this command.
|
||||||
|
|
||||||
|
|
||||||
ALEGoToDefinitionInTab *ALEGoToDefinitionInTab*
|
|
||||||
|
|
||||||
The same as |ALEGoToDefinition|, but opens results in a new tab.
|
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_go_to_definition_in_tab)` is defined for this
|
|
||||||
command.
|
|
||||||
|
|
||||||
|
|
||||||
ALEGoToDefinitionInSplit *ALEGoToDefinitionInSplit*
|
|
||||||
|
|
||||||
The same as |ALEGoToDefinition|, but opens results in a new split.
|
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_go_to_definition_in_split)` is defined for this
|
|
||||||
command.
|
|
||||||
|
|
||||||
|
|
||||||
ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit*
|
|
||||||
|
|
||||||
The same as |ALEGoToDefinition|, but opens results in a new vertical split.
|
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_go_to_definition_in_vsplit)` is defined for this
|
|
||||||
command.
|
|
||||||
|
|
||||||
|
|
||||||
ALEGoToTypeDefinition *ALEGoToTypeDefinition*
|
ALEGoToTypeDefinition *ALEGoToTypeDefinition*
|
||||||
|
|
||||||
This works similar to |ALEGoToDefinition| but instead jumps to the
|
This works similar to |ALEGoToDefinition| but instead jumps to the
|
||||||
|
@ -2770,6 +2770,15 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition*
|
||||||
definition if an LSP server provides a location to jump to. Otherwise, ALE
|
definition if an LSP server provides a location to jump to. Otherwise, ALE
|
||||||
will do nothing.
|
will do nothing.
|
||||||
|
|
||||||
|
The locations opened in different ways using the following variations.
|
||||||
|
|
||||||
|
`:ALEGoToTypeDefinition -tab` - Open the location in a new tab.
|
||||||
|
`:ALEGoToTypeDefinition -split` - Open the location in a horizontal split.
|
||||||
|
`:ALEGoToTypeDefinition -vsplit` - Open the location in a vertical split.
|
||||||
|
|
||||||
|
The default method used for navigating to a new location can be changed
|
||||||
|
by modifying |g:ale_default_navigation|.
|
||||||
|
|
||||||
You can jump back to the position you were at before going to the definition
|
You can jump back to the position you were at before going to the definition
|
||||||
of something with jump motions like CTRL-O. See |jump-motions|.
|
of something with jump motions like CTRL-O. See |jump-motions|.
|
||||||
|
|
||||||
|
@ -2777,31 +2786,6 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition*
|
||||||
command.
|
command.
|
||||||
|
|
||||||
|
|
||||||
ALEGoToTypeDefinitionInTab *ALEGoToTypeDefinitionInTab*
|
|
||||||
|
|
||||||
The same as |ALEGoToTypeDefinition|, but opens results in a new tab.
|
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_go_to_type_definition_in_tab)` is defined for
|
|
||||||
this command.
|
|
||||||
|
|
||||||
|
|
||||||
ALEGoToTypeDefinitionInSplit *ALEGoToTypeDefinitionInSplit*
|
|
||||||
|
|
||||||
The same as |ALEGoToTypeDefinition|, but opens results in a new split.
|
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_go_to_type_definition_in_split)` is defined for
|
|
||||||
this command.
|
|
||||||
|
|
||||||
|
|
||||||
ALEGoToTypeDefinitionInVSplit *ALEGoToTypeDefinitionInVSplit*
|
|
||||||
|
|
||||||
The same as |ALEGoToTypeDefinition|, but opens results in a new vertical
|
|
||||||
split.
|
|
||||||
|
|
||||||
A plug mapping `<Plug>(ale_go_to_type_definition_in_vsplit)` is defined for
|
|
||||||
this command.
|
|
||||||
|
|
||||||
|
|
||||||
ALEHover *ALEHover*
|
ALEHover *ALEHover*
|
||||||
|
|
||||||
Print brief information about the symbol under the cursor, taken from any
|
Print brief information about the symbol under the cursor, taken from any
|
||||||
|
@ -2827,6 +2811,11 @@ ALERename *ALERename*
|
||||||
The user will be prompted for a new name.
|
The user will be prompted for a new name.
|
||||||
|
|
||||||
|
|
||||||
|
ALERepeatSelection *ALERepeatSelection*
|
||||||
|
|
||||||
|
Repeat the last selection displayed in the preview window.
|
||||||
|
|
||||||
|
|
||||||
ALESymbolSearch `<query>` *ALESymbolSearch*
|
ALESymbolSearch `<query>` *ALESymbolSearch*
|
||||||
|
|
||||||
Search for symbols in the workspace, taken from any available LSP linters.
|
Search for symbols in the workspace, taken from any available LSP linters.
|
||||||
|
@ -3135,7 +3124,6 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()*
|
||||||
|
|
||||||
'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))}
|
'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))}
|
||||||
<
|
<
|
||||||
|
|
||||||
The following `options` can be provided.
|
The following `options` can be provided.
|
||||||
|
|
||||||
`output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for
|
`output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for
|
||||||
|
|
|
@ -12,5 +12,5 @@ noremap <buffer> A <NOP>
|
||||||
noremap <buffer> o <NOP>
|
noremap <buffer> o <NOP>
|
||||||
noremap <buffer> O <NOP>
|
noremap <buffer> O <NOP>
|
||||||
" Keybinds for opening selection items.
|
" Keybinds for opening selection items.
|
||||||
noremap <buffer> <CR> :call ale#preview#OpenSelectionInBuffer()<CR>
|
noremap <buffer> <CR> :call ale#preview#OpenSelection()<CR>
|
||||||
noremap <buffer> t :call ale#preview#OpenSelectionInTab()<CR>
|
noremap <buffer> t :call ale#preview#OpenSelectionInTab()<CR>
|
||||||
|
|
|
@ -202,16 +202,23 @@ command! -bar -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEF
|
||||||
command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype)
|
command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype)
|
||||||
|
|
||||||
" Go to definition for tsserver and LSP
|
" Go to definition for tsserver and LSP
|
||||||
command! -bar ALEGoToDefinition :call ale#definition#GoTo({})
|
command! -bar -nargs=* ALEGoToDefinition :call ale#definition#GoToCommandHandler('', <f-args>)
|
||||||
command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab'})
|
|
||||||
command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'})
|
" Deprecated commands we have to keep for now.
|
||||||
command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'})
|
command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab', 'deprecated_command': 'ALEGoToDefinitionInTab'})
|
||||||
|
command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'split', 'deprecated_command': 'ALEGoToDefinitionInSplit'})
|
||||||
|
command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vsplit', 'deprecated_command': 'ALEGoToDefinitionInVSplit'})
|
||||||
|
|
||||||
" Go to type definition for tsserver and LSP
|
" Go to type definition for tsserver and LSP
|
||||||
command! -bar ALEGoToTypeDefinition :call ale#definition#GoToType({})
|
command! -bar -nargs=* ALEGoToTypeDefinition :call ale#definition#GoToCommandHandler('type', <f-args>)
|
||||||
command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab'})
|
|
||||||
command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'horizontal-split'})
|
" Deprecated commands we have to keep for now.
|
||||||
command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vertical-split'})
|
command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab', 'deprecated_command': 'ALEGoToTypeDefinitionInTab'})
|
||||||
|
command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'split', 'deprecated_command': 'ALEGoToTypeDefinitionInSplit'})
|
||||||
|
command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vsplit', 'deprecated_command': 'ALEGoToTypeDefinitionInVSplit'})
|
||||||
|
|
||||||
|
" Repeat a previous selection in the preview window
|
||||||
|
command! -bar ALERepeatSelection :call ale#preview#RepeatSelection()
|
||||||
|
|
||||||
" Find references for tsserver and LSP
|
" Find references for tsserver and LSP
|
||||||
command! -bar -nargs=* ALEFindReferences :call ale#references#Find(<f-args>)
|
command! -bar -nargs=* ALEFindReferences :call ale#references#Find(<f-args>)
|
||||||
|
@ -260,18 +267,21 @@ nnoremap <silent> <Plug>(ale_lint) :ALELint<Return>
|
||||||
nnoremap <silent> <Plug>(ale_detail) :ALEDetail<Return>
|
nnoremap <silent> <Plug>(ale_detail) :ALEDetail<Return>
|
||||||
nnoremap <silent> <Plug>(ale_fix) :ALEFix<Return>
|
nnoremap <silent> <Plug>(ale_fix) :ALEFix<Return>
|
||||||
nnoremap <silent> <Plug>(ale_go_to_definition) :ALEGoToDefinition<Return>
|
nnoremap <silent> <Plug>(ale_go_to_definition) :ALEGoToDefinition<Return>
|
||||||
nnoremap <silent> <Plug>(ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab<Return>
|
|
||||||
nnoremap <silent> <Plug>(ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit<Return>
|
|
||||||
nnoremap <silent> <Plug>(ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit<Return>
|
|
||||||
nnoremap <silent> <Plug>(ale_go_to_type_definition) :ALEGoToTypeDefinition<Return>
|
nnoremap <silent> <Plug>(ale_go_to_type_definition) :ALEGoToTypeDefinition<Return>
|
||||||
nnoremap <silent> <Plug>(ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab<Return>
|
|
||||||
nnoremap <silent> <Plug>(ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit<Return>
|
|
||||||
nnoremap <silent> <Plug>(ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit<Return>
|
|
||||||
nnoremap <silent> <Plug>(ale_find_references) :ALEFindReferences<Return>
|
nnoremap <silent> <Plug>(ale_find_references) :ALEFindReferences<Return>
|
||||||
nnoremap <silent> <Plug>(ale_hover) :ALEHover<Return>
|
nnoremap <silent> <Plug>(ale_hover) :ALEHover<Return>
|
||||||
nnoremap <silent> <Plug>(ale_documentation) :ALEDocumentation<Return>
|
nnoremap <silent> <Plug>(ale_documentation) :ALEDocumentation<Return>
|
||||||
inoremap <silent> <Plug>(ale_complete) <C-\><C-O>:ALEComplete<Return>
|
inoremap <silent> <Plug>(ale_complete) <C-\><C-O>:ALEComplete<Return>
|
||||||
nnoremap <silent> <Plug>(ale_rename) :ALERename<Return>
|
nnoremap <silent> <Plug>(ale_rename) :ALERename<Return>
|
||||||
|
nnoremap <silent> <Plug>(ale_repeat_selection) :ALERepeatSelection<Return>
|
||||||
|
|
||||||
|
" Deprecated <Plug> mappings
|
||||||
|
nnoremap <silent> <Plug>(ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab<Return>
|
||||||
|
nnoremap <silent> <Plug>(ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit<Return>
|
||||||
|
nnoremap <silent> <Plug>(ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit<Return>
|
||||||
|
nnoremap <silent> <Plug>(ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab<Return>
|
||||||
|
nnoremap <silent> <Plug>(ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit<Return>
|
||||||
|
nnoremap <silent> <Plug>(ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit<Return>
|
||||||
|
|
||||||
" Set up autocmd groups now.
|
" Set up autocmd groups now.
|
||||||
call ale#events#Init()
|
call ale#events#Init()
|
||||||
|
|
|
@ -2,6 +2,8 @@ Before:
|
||||||
call ale#test#SetDirectory('/testplugin/test')
|
call ale#test#SetDirectory('/testplugin/test')
|
||||||
call ale#test#SetFilename('dummy.txt')
|
call ale#test#SetFilename('dummy.txt')
|
||||||
|
|
||||||
|
Save g:ale_default_navigation
|
||||||
|
|
||||||
let g:old_filename = expand('%:p')
|
let g:old_filename = expand('%:p')
|
||||||
let g:Callback = ''
|
let g:Callback = ''
|
||||||
let g:expr_list = []
|
let g:expr_list = []
|
||||||
|
@ -12,6 +14,7 @@ Before:
|
||||||
let g:capability_checked = ''
|
let g:capability_checked = ''
|
||||||
let g:conn_id = v:null
|
let g:conn_id = v:null
|
||||||
let g:InitCallback = v:null
|
let g:InitCallback = v:null
|
||||||
|
let g:ale_default_navigation = 'buffer'
|
||||||
|
|
||||||
runtime autoload/ale/lsp_linter.vim
|
runtime autoload/ale/lsp_linter.vim
|
||||||
runtime autoload/ale/lsp.vim
|
runtime autoload/ale/lsp.vim
|
||||||
|
@ -63,6 +66,8 @@ Before:
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
if g:conn_id isnot v:null
|
if g:conn_id isnot v:null
|
||||||
call ale#lsp#RemoveConnectionWithID(g:conn_id)
|
call ale#lsp#RemoveConnectionWithID(g:conn_id)
|
||||||
endif
|
endif
|
||||||
|
@ -152,6 +157,20 @@ Execute(Results should be shown for tsserver responses):
|
||||||
\ g:item_list
|
\ g:item_list
|
||||||
AssertEqual {}, ale#references#GetMap()
|
AssertEqual {}, ale#references#GetMap()
|
||||||
|
|
||||||
|
" We should be able to repeat selections with ALERepeatSelection
|
||||||
|
let g:ale_item_list = []
|
||||||
|
|
||||||
|
ALERepeatSelection
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {'filename': '/foo/bar/app.ts', 'column': 9, 'line': 9, 'match': 'import {doSomething} from ''./whatever'''},
|
||||||
|
\ {'filename': '/foo/bar/app.ts', 'column': 3, 'line': 804, 'match': 'doSomething()'},
|
||||||
|
\ {'filename': '/foo/bar/other/app.ts', 'column': 3, 'line': 51, 'match': 'doSomething()'},
|
||||||
|
\ ],
|
||||||
|
\ g:item_list
|
||||||
|
AssertEqual {}, ale#references#GetMap()
|
||||||
|
|
||||||
Execute(The preview window should not be opened for empty tsserver responses):
|
Execute(The preview window should not be opened for empty tsserver responses):
|
||||||
call ale#references#SetMap({3: {}})
|
call ale#references#SetMap({3: {}})
|
||||||
call ale#references#HandleTSServerResponse(1, {
|
call ale#references#HandleTSServerResponse(1, {
|
||||||
|
@ -195,7 +214,7 @@ Execute(tsserver reference requests should be sent):
|
||||||
\ [0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
\ [0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
||||||
\ ],
|
\ ],
|
||||||
\ g:message_list
|
\ g:message_list
|
||||||
AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap()
|
AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
Execute('-relative' argument should enable 'use_relative_paths' in HandleTSServerResponse):
|
Execute('-relative' argument should enable 'use_relative_paths' in HandleTSServerResponse):
|
||||||
runtime ale_linters/typescript/tsserver.vim
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
|
@ -205,7 +224,48 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleTSServe
|
||||||
|
|
||||||
call g:InitCallback()
|
call g:InitCallback()
|
||||||
|
|
||||||
AssertEqual {'42': {'use_relative_paths': 1}}, ale#references#GetMap()
|
AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 1}}, ale#references#GetMap()
|
||||||
|
|
||||||
|
Execute(`-tab` should display results in tabs):
|
||||||
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
|
ALEFindReferences -tab
|
||||||
|
|
||||||
|
call g:InitCallback()
|
||||||
|
|
||||||
|
AssertEqual {'42': {'open_in': 'tab', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
|
Execute(The default navigation type should be used):
|
||||||
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
|
let g:ale_default_navigation = 'tab'
|
||||||
|
ALEFindReferences
|
||||||
|
|
||||||
|
call g:InitCallback()
|
||||||
|
|
||||||
|
AssertEqual {'42': {'open_in': 'tab', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
|
Execute(`-split` should display results in splits):
|
||||||
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
|
ALEFindReferences -split
|
||||||
|
|
||||||
|
call g:InitCallback()
|
||||||
|
|
||||||
|
AssertEqual {'42': {'open_in': 'split', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
|
Execute(`-vsplit` should display results in vsplits):
|
||||||
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
|
ALEFindReferences -vsplit
|
||||||
|
|
||||||
|
call g:InitCallback()
|
||||||
|
|
||||||
|
AssertEqual {'42': {'open_in': 'vsplit', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
Given python(Some Python file):
|
Given python(Some Python file):
|
||||||
foo
|
foo
|
||||||
|
@ -302,7 +362,7 @@ Execute(LSP reference requests should be sent):
|
||||||
\ ],
|
\ ],
|
||||||
\ g:message_list
|
\ g:message_list
|
||||||
|
|
||||||
AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap()
|
AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 0}}, ale#references#GetMap()
|
||||||
|
|
||||||
Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResponse):
|
Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResponse):
|
||||||
runtime ale_linters/python/pyls.vim
|
runtime ale_linters/python/pyls.vim
|
||||||
|
@ -313,4 +373,4 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResp
|
||||||
|
|
||||||
call g:InitCallback()
|
call g:InitCallback()
|
||||||
|
|
||||||
AssertEqual {'42': {'use_relative_paths': 1}}, ale#references#GetMap()
|
AssertEqual {'42': {'open_in': 'current-buffer', 'use_relative_paths': 1}}, ale#references#GetMap()
|
||||||
|
|
|
@ -2,6 +2,8 @@ Before:
|
||||||
call ale#test#SetDirectory('/testplugin/test')
|
call ale#test#SetDirectory('/testplugin/test')
|
||||||
call ale#test#SetFilename('dummy.txt')
|
call ale#test#SetFilename('dummy.txt')
|
||||||
|
|
||||||
|
Save g:ale_default_navigation
|
||||||
|
|
||||||
let g:old_filename = expand('%:p')
|
let g:old_filename = expand('%:p')
|
||||||
let g:Callback = ''
|
let g:Callback = ''
|
||||||
let g:message_list = []
|
let g:message_list = []
|
||||||
|
@ -9,6 +11,7 @@ Before:
|
||||||
let g:capability_checked = ''
|
let g:capability_checked = ''
|
||||||
let g:conn_id = v:null
|
let g:conn_id = v:null
|
||||||
let g:InitCallback = v:null
|
let g:InitCallback = v:null
|
||||||
|
let g:ale_default_navigation = 'buffer'
|
||||||
|
|
||||||
runtime autoload/ale/linter.vim
|
runtime autoload/ale/linter.vim
|
||||||
runtime autoload/ale/lsp_linter.vim
|
runtime autoload/ale/lsp_linter.vim
|
||||||
|
@ -54,6 +57,8 @@ Before:
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
if g:conn_id isnot v:null
|
if g:conn_id isnot v:null
|
||||||
call ale#lsp#RemoveConnectionWithID(g:conn_id)
|
call ale#lsp#RemoveConnectionWithID(g:conn_id)
|
||||||
endif
|
endif
|
||||||
|
@ -164,7 +169,7 @@ Execute(Other files should be jumped to for definition responses in tabs too):
|
||||||
AssertEqual {}, ale#definition#GetMap()
|
AssertEqual {}, ale#definition#GetMap()
|
||||||
|
|
||||||
Execute(Other files should be jumped to for definition responses in splits too):
|
Execute(Other files should be jumped to for definition responses in splits too):
|
||||||
call ale#definition#SetMap({3: {'open_in': 'horizontal-split'}})
|
call ale#definition#SetMap({3: {'open_in': 'split'}})
|
||||||
call ale#definition#HandleTSServerResponse(
|
call ale#definition#HandleTSServerResponse(
|
||||||
\ 1,
|
\ 1,
|
||||||
\ {
|
\ {
|
||||||
|
@ -189,7 +194,7 @@ Execute(Other files should be jumped to for definition responses in splits too):
|
||||||
AssertEqual {}, ale#definition#GetMap()
|
AssertEqual {}, ale#definition#GetMap()
|
||||||
|
|
||||||
Execute(Other files should be jumped to for definition responses in vsplits too):
|
Execute(Other files should be jumped to for definition responses in vsplits too):
|
||||||
call ale#definition#SetMap({3: {'open_in': 'vertical-split'}})
|
call ale#definition#SetMap({3: {'open_in': 'vsplit'}})
|
||||||
call ale#definition#HandleTSServerResponse(
|
call ale#definition#HandleTSServerResponse(
|
||||||
\ 1,
|
\ 1,
|
||||||
\ {
|
\ {
|
||||||
|
@ -241,7 +246,32 @@ Execute(tsserver tab definition requests should be sent):
|
||||||
runtime ale_linters/typescript/tsserver.vim
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
call setpos('.', [bufnr(''), 2, 5, 0])
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
ALEGoToDefinitionInTab
|
ALEGoToDefinition -tab
|
||||||
|
|
||||||
|
" We shouldn't register the callback yet.
|
||||||
|
AssertEqual '''''', string(g:Callback)
|
||||||
|
|
||||||
|
AssertEqual type(function('type')), type(g:InitCallback)
|
||||||
|
call g:InitCallback()
|
||||||
|
|
||||||
|
AssertEqual 'definition', g:capability_checked
|
||||||
|
AssertEqual
|
||||||
|
\ 'function(''ale#definition#HandleTSServerResponse'')',
|
||||||
|
\ string(g:Callback)
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ ale#lsp#tsserver_message#Change(bufnr('')),
|
||||||
|
\ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
|
||||||
|
\ ],
|
||||||
|
\ g:message_list
|
||||||
|
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
|
||||||
|
|
||||||
|
Execute(The default navigation type should be used):
|
||||||
|
runtime ale_linters/typescript/tsserver.vim
|
||||||
|
call setpos('.', [bufnr(''), 2, 5, 0])
|
||||||
|
|
||||||
|
let g:ale_default_navigation = 'tab'
|
||||||
|
ALEGoToDefinition
|
||||||
|
|
||||||
" We shouldn't register the callback yet.
|
" We shouldn't register the callback yet.
|
||||||
AssertEqual '''''', string(g:Callback)
|
AssertEqual '''''', string(g:Callback)
|
||||||
|
@ -448,7 +478,7 @@ Execute(LSP tab definition requests should be sent):
|
||||||
let b:ale_linters = ['pyls']
|
let b:ale_linters = ['pyls']
|
||||||
call setpos('.', [bufnr(''), 1, 5, 0])
|
call setpos('.', [bufnr(''), 1, 5, 0])
|
||||||
|
|
||||||
ALEGoToDefinitionInTab
|
ALEGoToDefinition -tab
|
||||||
|
|
||||||
" We shouldn't register the callback yet.
|
" We shouldn't register the callback yet.
|
||||||
AssertEqual '''''', string(g:Callback)
|
AssertEqual '''''', string(g:Callback)
|
||||||
|
|
Reference in a new issue