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

feat(texlab): add cancelBuild #2977

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lua/lspconfig/server_configurations/texlab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ local texlab_forward_status = vim.tbl_add_reverse_lookup {
Unconfigured = 3,
}

local function buf_cancel_build()
local texlab_client = util.get_active_client_by_name(0, 'texlab')
if texlab_client then
texlab_client.request('workspace/executeCommand', { command = 'texlab.cancelBuild' }, function(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't workspace/executeCommand part of the LSP spec? should this use :help vim.lsp.commands ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply and the suggestion. Reading the docs on the vim.lsp.commands I too think it should be used here. However, the docs were not very helpful on how to implement it, even looking at the source code in neovim i could not get it to work. Moreover, i found another implementation with the request in the following part from the es-lint config. I could really use some help regarding how to proceed, thanks in advance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoping that @glepnir can help.

i found another implementation with the request in the following part from the es-lint config.

Perhaps that pattern can be lifted into util.lua in this repo. We need to avoid copy-pasting lots of code in all of these configs.

if err then
error(tostring(err))
end
vim.notify 'Build cancelled'
end, 0)
end
end

local function buf_build(bufnr)
bufnr = util.validate_bufnr(bufnr)
local texlab_client = util.get_active_client_by_name(bufnr, 'texlab')
Expand Down Expand Up @@ -114,6 +126,12 @@ return {
end,
description = 'Forward search from current position',
},
TexlabCancel = {
function()
buf_cancel_build()
end,
description = 'Cancel the current build',
},
},
docs = {
description = [[
Expand Down
Loading