diff options
| author | Dimitris Dimitropoulos <121033874+DimitrisDimitropoulos@users.noreply.github.com> | 2024-06-22 16:09:30 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-22 21:09:30 +0800 |
| commit | 18630395c934aa944e674f051e541c64c9b54214 (patch) | |
| tree | db25dce16071e1dbcf2226470042f62da4248d77 /lua | |
| parent | ci: bump nvim-neorocks/luarocks-tag-release from 6 to 7 (#3217) (diff) | |
| download | nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.tar nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.tar.gz nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.tar.bz2 nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.tar.lz nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.tar.xz nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.tar.zst nvim-lspconfig-18630395c934aa944e674f051e541c64c9b54214.zip | |
feat(texlab): add support for worksapce commands (#3218)
* feat(texlab): add support for worksapce commands
* fix: correct formatting
* fix: correct validation in cancel_build
* fix: correct validation in dependency_graph
* fix: update error handling
* fix: add missing return
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/texlab.lua | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua index 36198d0a..a3181764 100644 --- a/lua/lspconfig/server_configurations/texlab.lua +++ b/lua/lspconfig/server_configurations/texlab.lua @@ -54,6 +54,53 @@ local function buf_search(bufnr) end end +local function buf_cancel_build(bufnr) + bufnr = util.validate_bufnr(bufnr) + if not util.get_active_client_by_name(bufnr, 'texlab') then + return vim.notify('Texlab client not found', vim.log.levels.ERROR) + end + vim.lsp.buf.execute_command { command = 'texlab.cancelBuild' } + vim.notify('Build cancelled', vim.log.levels.INFO) +end + +local function dependency_graph(bufnr) + bufnr = util.validate_bufnr(bufnr) + local texlab_client = util.get_active_client_by_name(bufnr, 'texlab') + if not texlab_client then + return vim.notify('Texlab client not found', vim.log.levels.ERROR) + end + texlab_client.request('workspace/executeCommand', { command = 'texlab.showDependencyGraph' }, function(err, result) + if err then + return vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR) + end + vim.notify('The dependency graph has been generated:\n' .. result, vim.log.levels.INFO) + end, 0) +end + +local function cleanArtifacts(bufnr) + bufnr = util.validate_bufnr(bufnr) + if not util.get_active_client_by_name(bufnr, 'texlab') then + return vim.notify('Texlab client not found', vim.log.levels.ERROR) + end + vim.lsp.buf.execute_command { + command = 'texlab.cleanArtifacts', + arguments = { { uri = vim.uri_from_bufnr(bufnr) } }, + } + vim.notify('Artifacts cleaned successfully', vim.log.levels.INFO) +end + +local function cleanAuxiliary(bufnr) + bufnr = util.validate_bufnr(bufnr) + if not util.get_active_client_by_name(bufnr, 'texlab') then + return vim.notify('Texlab client not found', vim.log.levels.ERROR) + end + vim.lsp.buf.execute_command { + command = 'texlab.cleanAuxiliary', + arguments = { { uri = vim.uri_from_bufnr(bufnr) } }, + } + vim.notify('Auxiliary files cleaned successfully', vim.log.levels.INFO) +end + -- bufnr isn't actually required here, but we need a valid buffer in order to -- be able to find the client for buf_request. -- TODO find a client by looking through buffers for a valid client? @@ -114,6 +161,30 @@ return { end, description = 'Forward search from current position', }, + TexlabCancelBuild = { + function() + buf_cancel_build(0) + end, + description = 'Cancel the current build', + }, + TexlabDependencyGraph = { + function() + dependency_graph(0) + end, + description = 'Show the dependency graph', + }, + TexlabCleanArtifacts = { + function() + cleanArtifacts(0) + end, + description = 'Clean the artifacts', + }, + TexlabCleanAuxiliary = { + function() + cleanAuxiliary(0) + end, + description = 'Clean the auxiliary files', + }, }, docs = { description = [[ |
