Repository: autozimu/LanguageClient-neovim (language: rust)

Issue:
open buffer in a split or tab when selecting references in fzf window
## Is your feature request related to a problem? Please describe.
In default fzf window(eg. created by calling `:FZF `), pressing `ctrl-v` can open file in a new vertical splitted  window. But in fzf window created by language client's references function, this doesn't work. Is there anything different ?

## Describe the solution you'd like
Respect fzf's option `g:fzf_action` and support opening buffer in a split or tab.


Discussion / hints:
hello, did you resolve your problem? 

Fix patch:
diff --git a/autoload/LanguageClient.vim b/autoload/LanguageClient.vim
index c626666f2..5699c0f0a 100644
--- a/autoload/LanguageClient.vim
+++ b/autoload/LanguageClient.vim
@@ -271,6 +271,15 @@ function! s:selectionUI_funcref(source, sink) abort
     endif
 endfunction
 
+function! s:GetFZFAction() abort
+    let l:default_fzf_action = {
+                \ 'ctrl-t': 'tab split',
+                \ 'ctrl-x': 'split',
+                \ 'ctrl-v': 'vsplit'
+                \ }
+    return get(g:, 'fzf_action', l:default_fzf_action)
+endfunction
+
 function! s:FZF(source, sink) abort
     if !get(g:, 'loaded_fzf')
         call s:Echoerr('FZF not loaded!')
@@ -285,9 +294,11 @@ function! s:FZF(source, sink) abort
             let l:options = []
         endif
     endif
+    call add(l:options, '--expect='.join(keys(s:GetFZFAction()), ','))
+
     call fzf#run(fzf#wrap({
                 \ 'source': a:source,
-                \ 'sink': function(a:sink),
+                \ 'sink*': function(a:sink),
                 \ 'options': l:options,
                 \ }))
     if has('nvim') && !has('nvim-0.4')
diff --git a/doc/LanguageClient.txt b/doc/LanguageClient.txt
index 0714b059d..1dda46749 100644
--- a/doc/LanguageClient.txt
+++ b/doc/LanguageClient.txt
@@ -228,10 +228,11 @@ Valid options: "fzf" | "quickfix" | "location-list" | |Funcref|
 If you use a |Funcref|, the referenced function should have two arguments
 (source, sink). The "source" argument can be either a command string or a
 list. The sink argument can be a command string or a |Funcref| that takes the
-selected line as its first argument.
+selected line as its argument.
 
-An example implementation is "s:FZF()" in autoload/LanguageClient.vim. For
-details, see the source and sink arguments of fzf#run():
+An example implementation is "s:FZF()" in autoload/LanguageClient.vim which
+supports opening selected file in different ways (configurable via
+|g:fzf_action|). For details, see the source and sink arguments of fzf#run():
 https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun
 
 Another example, this time using vim-clap: >
diff --git a/src/language_server_protocol.rs b/src/language_server_protocol.rs
index a6585e7d9..a1b9246bd 100644
--- a/src/language_server_protocol.rs
+++ b/src/language_server_protocol.rs
@@ -3271,13 +3271,19 @@ impl LanguageClient {
             }
         };
 
-        let lines = <Vec<String>>::deserialize(&params)?;
+        let lines = <Vec<String>>::deserialize(&params[0])?;
         if lines.is_empty() {
             anyhow!("No selection!");
         }
 
+        let fzf_action: HashMap<String, String> = self.vim()?.eval("s:GetFZFAction()")?;
+        let goto_cmd = match lines.get(0) {
+            Some(action) if fzf_action.contains_key(action) => fzf_action.get(action).cloned(),
+            _ => Some("edit".to_string()),
+        };
+
         let location = lines
-            .get(0)
+            .get(1)
             .ok_or_else(|| anyhow!("Failed to get line! lines: {:?}", lines))?
             .split('\t')
             .next()
@@ -3304,7 +3310,7 @@ impl LanguageClient {
             .parse::<u32>()?
             - 1;
 
-        self.edit(&None, &filename)?;
+        self.edit(&goto_cmd, &filename)?;
         self.vim()?.cursor(line + 1, character + 1)?;
 
         Ok(())


Test patch: