Skip to content
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

Pass custom handler to vim.lsp.buf.rename #22075

Open
sarmong opened this issue Jan 31, 2023 · 2 comments · May be fixed by #22598
Open

Pass custom handler to vim.lsp.buf.rename #22075

sarmong opened this issue Jan 31, 2023 · 2 comments · May be fixed by #22598
Assignees
Labels
enhancement feature request lsp
Milestone

Comments

@sarmong
Copy link
Sponsor Contributor

sarmong commented Jan 31, 2023

Problem

I want to extend vim.lsp.buf.rename with a custom handler. Currently, I have 3 options listed in :h lsp-handler-resolution.

1. Handler passed to |vim.lsp.buf_request()|, if any.
2. Handler defined in |vim.lsp.start_client()|, if any.
3. Handler defined in |vim.lsp.handlers|, if any.

Option 2 and 3 will not allow me to have two functions - one calling default handler, the second calling custom handler.
With option 1 I will have to duplicate all the logic located in vim.lsp.buf.rename function, which is not ideal.

Expected behavior

vim.lsp.buf.rename(nil, { handler = my_custom_handler })
@sarmong sarmong added the enhancement feature request label Jan 31, 2023
@sarmong
Copy link
Sponsor Contributor Author

sarmong commented Jan 31, 2023

Actually, for my usecase, it will be enough to pass on_list just like some other lsp function have, so that it can receive changes or documentChanges

@zeertzjq zeertzjq added the lsp label Jan 31, 2023
@glepnir
Copy link
Member

glepnir commented Jan 31, 2023

:h vim.lsp.with

@justinmk justinmk self-assigned this Mar 9, 2023
@justinmk justinmk added this to the 0.9 milestone Mar 9, 2023
justinmk added a commit to justinmk/neovim that referenced this issue Mar 10, 2023
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
@justinmk justinmk linked a pull request Mar 10, 2023 that will close this issue
justinmk added a commit to justinmk/neovim that referenced this issue Mar 10, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 11, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 11, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 11, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 11, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 12, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 12, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 13, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 15, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 15, 2023
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
justinmk added a commit to justinmk/neovim that referenced this issue Mar 20, 2023
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
@mfussenegger mfussenegger modified the milestones: 0.9, 0.10 Apr 5, 2023
@mfussenegger mfussenegger modified the milestones: 0.10, unplanned Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request lsp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants