ojroques / nvim-lspfuzzy

A Neovim plugin to make the LSP client use FZF
BSD 2-Clause "Simplified" License
315 stars 11 forks source link

call lua function in action #27

Closed ViRu-ThE-ViRuS closed 2 years ago

ViRu-ThE-ViRuS commented 2 years ago

hey, I have a setup using fzf.vim and nvim-lspfuzzy, with a custom function to send fzf selections to q qflist.

qf_populate = function(lines, mode)
    if mode == nil then
        lines = core.foreach(lines, function(item) return { filename = item, lnum = 1, col = 1 } end)
        mode = "r"
    end

    vim.fn.setqflist(lines, mode)
    vim.cmd [[
        copen
        setlocal statusline=%!v:lua.StatusLine('QuickFix')
        setlocal nobuflisted
        wincmd p
        echo hello
    ]]
end

and my fzf_actions is set as:

vim.g.fzf_action = {
    ["ctrl-q"] = qf_populate,
    ["ctrl-x"] = "split",
    ["ctrl-v"] = "vsplit"
}

this setup works for fzf.vim, and a few custom LSP handlers I wrote (using qf_populate for multi-file refactors). How can I get lspfuzzy to call this function, with the first param as the lines. ?

ojroques commented 2 years ago

Hello,

If you use <tab> to select multiple entries with lspfuzzy, then select one entry with <CR>, the plugin jumps to the selected entry and put the remaining entries into the quicklist. Does that suit the workflow you're requesting?

ViRu-ThE-ViRuS commented 2 years ago

Yes its the functionality i want, but i want to set the statusline and also want the ability to extend it . Is it possible to call the lua function? Fzf.vim is able to.

ojroques commented 2 years ago

It should work like you want in the latest commit. Can you try and tell me if it does?

ViRu-ThE-ViRuS commented 2 years ago

@ojroques yes it is perfect! I really appreciate you responding and reacting so quickly on this amazing project, it just shows the commitment, and effort you have put into making so many of our developer experiences better! Thank you :)

ViRu-ThE-ViRuS commented 2 years ago

@ojroques okay I am noticing that even after calling the action function, it automatically sets the qflist and opens that split, which defeats the purpose of my qf_list function. I we can let action take complete control over what happens with the selections, which makes it more like the last callback.

I suggest letting the call return after calling functional action. What do you think?