-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
lsp: Add more configuration for handlers #13977
Conversation
This pull request has been mentioned on Neovim Discourse. There might be relevant details there: https://neovim.discourse.group/t/how-to-customize-lsp-actions/349/5 |
Found this issue while trying to configure the jump-to-definition handler. With this approach, I guess that if we want to have multiple mappings (e.g.: open definition in split and vsplit), it would look something like this: function open_definition_vsplit ()
local handler = vim.lsp.with(
vim.lsp.handlers.location, {
location_callback = function(location)
vim.cmd [[vsplit]]
vim.lsp.util.jump_to_location(location)
end
}
local params = vim.lsp.util.make_position_params()
vim.lsp.buf_request(0, 'textDocument/definition', params, handler)
end
vim.api.nvim_set_keymap("n", "gdv", "<cmd>lua open_definition_vsplit()<cr>", opts) |
@tjdevries What needs to get done for this to get merged? I'll take it over. |
Probably just add a test and fix conflicts? |
This is pretty out of date, closing as we've changed a lot of this code now. |
@jlesquembre do you have by any chance a 2022 version of your snippet? |
I am looking at reviving some form of this. #22598 |
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce `vim.on_before()`. Example: vim.on_before(vim.lsp.handlers, 'textDocument/definition', function() vim.notify('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce `vim.on_before()`. Example: vim.on_before(vim.lsp.handlers, 'textDocument/definition', function() vim.notify('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
Problem: No easy way to hook into LSP request/response handlers. (No mention of "before" or "after" in `:help lsp`...) Solution: Introduce vim.on_fun(), a generic way to "hook into" any function before/after it is called. Example: vim.on_fun(vim.lsp.handlers, 'textDocument/definition', function() vim.print('before, yay') end) Fixes neovim#20568 Fixes neovim#22075 Fixes neovim#22323 Related: neovim#13977
If someone wants to take this over, this is pretty similar to the concept that we were going for in #12966
This will allow you to more easily manage / re-use internal logic for doing location handling, without having to copy and paste.