From 73a204dd006c1ad1d7562e5970dbb41975b94727 Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Wed, 12 Dec 2018 11:35:57 -0800 Subject: Add versions of ALEGoToDefinition that open in splits This is just like `:ALEGoToDefinitionInTab`, only a (v)split instead of a tab. Fixes #2140. --- autoload/ale/definition.vim | 2 +- autoload/ale/util.vim | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'autoload') 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 -- cgit v1.2.3