-
-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom actions for finder? #1523
Comments
Found a discussion that's nearly identical https://github.com/orgs/nvimdev/discussions/1495#discussion-7301203 That said, it sparked an alternative idea: require("lspsaga").setup({
finder = {
keys = {
open = "<cr>" -- Set Enter to open the file
},
actions = {
open = function (filepath) ... end
}
},
})
If you're on board with that route I'm happy to draft a PR. Thoughts? |
Problem: There are use cases where you may wish to call a function instead of mapping a command directly to a key action for the finder UI. Solution: Supports configuring a `lspsaga.config.finder.actions` object mapping action names to callable functions. ```lua require('lspsaga').setup({ finder = { keys = { open = "<CR>", }, actions = { open = function (fname) print("Selected filename", fname) end }, } }) ``` Additionally, this wraps the final `api.nvim_win_set_cursor(0, pos)` call in `xpcall` given that this may fail if the function does not finish synchronously, like spawning a telescope interface. Fixes nvimdev#1523
Decided to try drafting a PR anyway given it's a pretty minimal amount of changes. |
Is your feature request related to a problem? Please describe.
I created a telescope plugin for myself that takes a filepath and presents options to open it in the current window, new tab, vsplit left, vsplit right, split above, and split below. Ideally, I would like to get the filepath that was selected from the lspsaga finder UI to open up my telescope picker to choose the desired action. This would normalize my bindings across neovim while reducing steps to remember.
Describe the solution you'd like
There's two options that could work:
Describe alternatives you've considered
I looked at the finder implementation and saw that it's mostly iterating the config settings for keys, so was thinking I could do something like the following:
But that doesn't seem to work, I'll have to check but maybe unsupported commands are stripped from the config?
I could fork it and make my changes, but then I'll have to be on top of your upstream changes and I'd much rather try and find a way to make lspsaga better than create a worse version of it.
Additional context
Open to alternative ideas here!
The text was updated successfully, but these errors were encountered: