-
Notifications
You must be signed in to change notification settings - Fork 792
NullLsStop and NullLsStart #896
Comments
Stopping the client is pretty simple and works as expected local null_ls_stop = function()
local null_ls_client
for _, client in ipairs(vim.lsp.get_active_clients()) do
if client.name == "null-ls" then
null_ls_client = client
end
end
if not null_ls_client then
return
end
null_ls_client.stop()
end
vim.api.nvim_create_user_command("NullLsStop", null_ls_stop, {}) Restarting clients, however, is harder. lspconfig has different logic to do this and it's not directly implemented in Neovim itself. A more null-ls-friendly way of doing this would be to use the source API to manipulate all registered sources: vim.api.nvim_create_user_command("NullLsToggle", function()
-- you can also create commands to disable or enable sources
require("null-ls").toggle({})
end, {}) This isn't exactly the same, since the client will still be active and shown in the |
Thanks man that'll be enough for me. |
I think this would require more work to align with user expectations. For example, because of how the null-ls client works, stopping it doesn't clear existing diagnostics. Likewise, I tried messing with the code to make it possible to start a client if the old one is stopped, but it doesn't attach to the current buffer right away and generally behaves weirdly. I'm not against including these as part of the API (I'd leave it up to users to define commands) so I'm happy to leave this open, but I think the underlying use case of "I want to stop null-ls from running but maybe restart it later" is already handled by the source API, so I won't work on it myself or accept a PR that adds complexity. |
makes perfect sense. |
Closing this as I think the source API already provides a solution. |
Sounds good, can you share what was added? |
Nothing was added - what I meant is that the source API (docs linked) already provides ways to start, stop, and toggle the availability of null-ls. Adding a stop command would be easy, but adding a restart command is not, and I don't think the complexity is worth it. |
Issues
Feature description
2 additional ex-commands:
NullLsStop
andNullLsStart
Since lsp-config's
LspStart
andLspStop
don't know about clients not started through it, we need to have an easy way of stopping and starting the client.Help
No
Implementation help
The text was updated successfully, but these errors were encountered: