aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorDimitris Dimitropoulos <dimitris.dimitropoulos00@gmail.com>2024-08-21 12:22:36 +0300
committerGitHub <noreply@github.com>2024-08-21 17:22:36 +0800
commit6ecab74936b16b8a4d76246906b729e546220f1b (patch)
tree3c93824dac51a02e17d08317686a6e12605876c6 /lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.tar
nvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.tar.gz
nvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.tar.bz2
nvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.tar.lz
nvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.tar.xz
nvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.tar.zst
nvim-lspconfig-6ecab74936b16b8a4d76246906b729e546220f1b.zip
feat(texlab): give the find environments command a ui wrapper (#3263)
* feat(texlab): give the find environments command a ui wrapper * fix(texlab): use make_params util function Signed-off-by: Dimitris Dimitropoulos <dimitris.dimitropoulos00@gmail.com> --------- Signed-off-by: Dimitris Dimitropoulos <dimitris.dimitropoulos00@gmail.com>
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/server_configurations/texlab.lua26
1 files changed, 18 insertions, 8 deletions
diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua
index 7b079d27..e520f305 100644
--- a/lua/lspconfig/server_configurations/texlab.lua
+++ b/lua/lspconfig/server_configurations/texlab.lua
@@ -113,20 +113,30 @@ local function buf_find_envs(bufnr)
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] },
- },
- },
+ arguments = { vim.lsp.util.make_position_params() },
}, 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)
+ local env_names = {}
+ local max_length = 1
+ for _, env in ipairs(result) do
+ table.insert(env_names, env.name.text)
+ max_length = math.max(max_length, string.len(env.name.text))
+ end
+ for i, name in ipairs(env_names) do
+ env_names[i] = string.rep(' ', i - 1) .. name
+ end
+ vim.lsp.util.open_floating_preview(env_names, '', {
+ height = #env_names,
+ width = math.max((max_length + #env_names - 1), (string.len 'Environments')),
+ focusable = false,
+ focus = false,
+ border = require('lspconfig.ui.windows').default_options.border or 'single',
+ title = 'Environments',
+ })
end, bufnr)
end