From 5c5fd2701dfbcbafa0678dc6e85eae938dd4fa22 Mon Sep 17 00:00:00 2001 From: Dimitris Dimitropoulos <121033874+DimitrisDimitropoulos@users.noreply.github.com> Date: Sat, 29 Jun 2024 09:48:43 +0300 Subject: feat(texlab): add find environments workspace command (#3225) --- lua/lspconfig/server_configurations/texlab.lua | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua index a3181764..edf250cd 100644 --- a/lua/lspconfig/server_configurations/texlab.lua +++ b/lua/lspconfig/server_configurations/texlab.lua @@ -101,6 +101,29 @@ local function cleanAuxiliary(bufnr) vim.notify('Auxiliary files cleaned successfully', vim.log.levels.INFO) end +local function buf_find_envs(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 + local pos = vim.api.nvim_win_get_cursor(0) + texlab_client.request('workspace/executeCommand', { + command = 'texlab.findEnvironments', + arguments = { + { + textDocument = { uri = vim.uri_from_bufnr(bufnr) }, + position = { line = pos[1] - 1, character = pos[2] }, + }, + }, + }, function(err, result) + if err then + return vim.notify(err.code .. ': ' .. err.message, vim.log.levels.ERROR) + end + return vim.notify('The environments are:\n' .. vim.inspect(result), vim.log.levels.INFO) + end, bufnr) +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? @@ -185,6 +208,12 @@ return { end, description = 'Clean the auxiliary files', }, + TexlabFindEnvironments = { + function() + buf_find_envs(0) + end, + description = 'Find the environments at current position', + }, }, docs = { description = [[ -- cgit v1.2.3-70-g09d2