Skip to content

fix(lsp): add silent options in code_action params table #22651

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

Closed
wants to merge 1 commit into from

Conversation

glepnir
Copy link
Member

@glepnir glepnir commented Mar 13, 2023

sometimes is annoying . add a new field silent in options table to disable run this notify when there is no code actions.

@github-actions github-actions bot added lsp lua stdlib labels Mar 13, 2023
@marvim marvim requested a review from a team March 13, 2023 05:43
@justinmk
Copy link
Member

justinmk commented Mar 13, 2023

This is too special-case and the use-case is not explained.

vim.lsp.buf.code_action() , typically shows a menu. I don't see why you wouldn't want a tiny "no actions available" message if there are no actions available, since invoking vim.lsp.buf.code_action() explicitly is asking for some sort of feedback.

@justinmk justinmk closed this Mar 13, 2023
@marvim marvim removed the request for review from a team March 13, 2023 12:37
@justinmk
Copy link
Member

justinmk commented Mar 13, 2023

With #22598 one can use this hack to clear the screen after code_action():

lua vim.func.on_fun(vim.lsp.buf, 'code_action', function()
    vim.cmd[[call timer_start(100, {->luaeval('print(" ")')})]]
end)

A more ideal approach would be for vim.lsp.buf.code_action() to return a promise as @mfussenegger described in that PR discussion. Then one could do something like:

lua vim.func.on_fun(vim.lsp.buf, 'code_action', function(fn, args)
    local promise = fn(unpack(args))
    promise.then(function()
        vim.cmd.redraw()  -- or some other way to clear the screen
    end)
end)

@glepnir
Copy link
Member Author

glepnir commented Mar 14, 2023

I already notice that pr. but what i mean in this pr. when you set the apply = true in code action it will execute the first actions. like if you config this in BufWritePre with import actions. if no actions it will show this notify. maybe pr as a temporary solutions ...support silent in autocmd is useful.

@justinmk
Copy link
Member

As mentioned, too special-case. Perhaps all of these LSP features should accept something like a on_done or on_after callback to address all of these use-cases. But as described in #22598 (comment) , ideally would be more like :

  1. Have some kind of future/promise/async-thunk/whatever (relates a bit to Lua: structured concurrency, Promises, task pipelines #19624) that each of the vim.lsp.buf methods returns that allows to
    a) cancel
    b) use the synthesized result of the operation by being able to attach an additional callback or map the result. This would address feat(lsp): return result of buf_request() in LSP functions #18372 and lots of other feature requests.
    c) await (coroutine aware) or get(blocking) the result.

I already have some local version where I played around with this a bit. There I also have a new vim.lsp.request that would replace buf_request, buf_request_all and buf_request_sync and also solve the mixed-encoding warnings.

  1. Maybe add a LspResponse autocmd that's triggered whenever a response is received with data set to the payload as a generic listener mechanism.

The short-term solution could be to add LspResponse.

@glepnir
Copy link
Member Author

glepnir commented Mar 14, 2023

looks useful ? not sure. when there have this pr i will take a look at this. currently refactor pmenu now .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants