diff options
| author | Dimitris Dimitropoulos <dimitris.dimitropoulos00@gmail.com> | 2024-07-03 10:01:09 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-03 15:01:09 +0800 |
| commit | 9c9470f19520733fcaacc1da01274cb78feae26d (patch) | |
| tree | 0fed08f54b12c525d540215a38f763641534001e /lua | |
| parent | feat: do not process commands if it's func type (#3200) (diff) | |
| download | nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.tar nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.tar.gz nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.tar.bz2 nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.tar.lz nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.tar.xz nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.tar.zst nvim-lspconfig-9c9470f19520733fcaacc1da01274cb78feae26d.zip | |
feat(texlab): add change environments workspace command (#3227)
* feat(texlab): add change environments workspace command
* feat(texlab): correct tostring placement
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/texlab.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua index edf250cd..3f559317 100644 --- a/lua/lspconfig/server_configurations/texlab.lua +++ b/lua/lspconfig/server_configurations/texlab.lua @@ -124,6 +124,28 @@ local function buf_find_envs(bufnr) end, bufnr) end +local function buf_change_env(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 + local new = vim.fn.input 'Enter the new environment name: ' + if not new or new == '' then + return vim.notify('No environment name provided', vim.log.levels.WARN) + end + local pos = vim.api.nvim_win_get_cursor(0) + vim.lsp.buf.execute_command { + command = 'texlab.changeEnvironment', + arguments = { + { + textDocument = { uri = vim.uri_from_bufnr(bufnr) }, + position = { line = pos[1] - 1, character = pos[2] }, + newName = tostring(new), + }, + }, + } +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? @@ -214,6 +236,12 @@ return { end, description = 'Find the environments at current position', }, + TexlabChangeEnvironment = { + function() + buf_change_env(0) + end, + description = 'Change the environment at current position', + }, }, docs = { description = [[ |
