diff options
author | Ben Kraft <benkraft@khanacademy.org> | 2018-12-12 11:35:57 -0800 |
---|---|---|
committer | Ben Kraft <ben@benkraft.org> | 2018-12-19 18:35:56 -0500 |
commit | 73a204dd006c1ad1d7562e5970dbb41975b94727 (patch) | |
tree | 6b08b89311db2c570faad18401372425f6ee5c5f /autoload | |
parent | 2cfa09e02d65cd06649fb1ae5f988b7a110a124d (diff) | |
download | ale-73a204dd006c1ad1d7562e5970dbb41975b94727.zip |
Add versions of ALEGoToDefinition that open in splits
This is just like `:ALEGoToDefinitionInTab`, only a (v)split instead of
a tab. Fixes #2140.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/definition.vim | 2 | ||||
-rw-r--r-- | autoload/ale/util.vim | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/autoload/ale/definition.vim b/autoload/ale/definition.vim index 984a4f9d..79d12596 100644 --- a/autoload/ale/definition.vim +++ b/autoload/ale/definition.vim @@ -86,7 +86,7 @@ function! s:OnReady(linter, lsp_details, line, column, options, ...) abort let l:request_id = ale#lsp#Send(l:id, l:message) let s:go_to_definition_map[l:request_id] = { - \ 'open_in_tab': get(a:options, 'open_in_tab', 0), + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), \} endfunction diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim index bb478957..ee9359f8 100644 --- a/autoload/ale/util.vim +++ b/autoload/ale/util.vim @@ -87,12 +87,25 @@ function! ale#util#GetFunction(string_or_ref) abort return a:string_or_ref endfunction +" Open the file (at the given line). +" options['open_in'] can be: +" current-buffer (default) +" tab +" vertical-split +" horizontal-split function! ale#util#Open(filename, line, column, options) abort - if get(a:options, 'open_in_tab', 0) - call ale#util#Execute('tabedit +' . a:line . ' ' . fnameescape(a:filename)) + let l:open_in = get(a:options, 'open_in', 'current-buffer') + let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename) + + if l:open_in is# 'tab' + call ale#util#Execute('tabedit ' . l:args_to_open) + elseif l:open_in is# 'horizontal-split' + call ale#util#Execute('split ' . l:args_to_open) + elseif l:open_in is# 'vertical-split' + call ale#util#Execute('vsplit ' . l:args_to_open) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. - call ale#util#Execute('edit +' . a:line . ' ' . fnameescape(a:filename)) + call ale#util#Execute('edit ' . l:args_to_open) else normal! m` endif |