aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorDimitris Dimitropoulos <dimitris.dimitropoulos00@gmail.com>2024-08-21 14:19:41 +0300
committerGitHub <noreply@github.com>2024-08-21 19:19:41 +0800
commitb21c166bbf337734f2a39734a905c1c3e298205c (patch)
treef522e9a1857f76398eddcd6e4fa7994de25ccfc3 /lua
parentfeat(texlab): give the find environments command a ui wrapper (#3263) (diff)
downloadnvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.tar
nvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.tar.gz
nvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.tar.bz2
nvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.tar.lz
nvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.tar.xz
nvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.tar.zst
nvim-lspconfig-b21c166bbf337734f2a39734a905c1c3e298205c.zip
fix(texlab): do not pass buf as parameter (#3276)
* fix(texlab): do not pass buf as parameter Signed-off-by: Dimitris Dimitropoulos <dimitris.dimitropoulos00@gmail.com> * fix(texlab): use make_params lsp util 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.lua74
1 files changed, 26 insertions, 48 deletions
diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua
index e520f305..7f039f52 100644
--- a/lua/lspconfig/server_configurations/texlab.lua
+++ b/lua/lspconfig/server_configurations/texlab.lua
@@ -14,16 +14,11 @@ local texlab_forward_status = {
[3] = 'Unconfigured',
}
-local function buf_build(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function buf_build()
+ local bufnr = vim.api.nvim_get_current_buf()
local texlab_client = util.get_active_client_by_name(bufnr, 'texlab')
- local pos = vim.api.nvim_win_get_cursor(0)
- local params = {
- textDocument = { uri = vim.uri_from_bufnr(bufnr) },
- position = { line = pos[1] - 1, character = pos[2] },
- }
if texlab_client then
- texlab_client.request('textDocument/build', params, function(err, result)
+ texlab_client.request('textDocument/build', vim.lsp.util.make_position_params(), function(err, result)
if err then
error(tostring(err))
end
@@ -37,16 +32,11 @@ local function buf_build(bufnr)
end
end
-local function buf_search(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function buf_search()
+ local bufnr = vim.api.nvim_get_current_buf()
local texlab_client = util.get_active_client_by_name(bufnr, 'texlab')
- local pos = vim.api.nvim_win_get_cursor(0)
- local params = {
- textDocument = { uri = vim.uri_from_bufnr(bufnr) },
- position = { line = pos[1] - 1, character = pos[2] },
- }
if texlab_client then
- texlab_client.request('textDocument/forwardSearch', params, function(err, result)
+ texlab_client.request('textDocument/forwardSearch', vim.lsp.util.make_position_params(), function(err, result)
if err then
error(tostring(err))
end
@@ -60,8 +50,8 @@ local function buf_search(bufnr)
end
end
-local function buf_cancel_build(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function buf_cancel_build()
+ local bufnr = vim.api.nvim_get_current_buf()
if not util.get_active_client_by_name(bufnr, 'texlab') then
return vim.notify('Texlab client not found', vim.log.levels.ERROR)
end
@@ -69,8 +59,8 @@ local function buf_cancel_build(bufnr)
vim.notify('Build cancelled', vim.log.levels.INFO)
end
-local function dependency_graph(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function dependency_graph()
+ local bufnr = vim.api.nvim_get_current_buf()
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)
@@ -83,8 +73,8 @@ local function dependency_graph(bufnr)
end, 0)
end
-local function cleanArtifacts(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function cleanArtifacts()
+ local bufnr = vim.api.nvim_get_current_buf()
if not util.get_active_client_by_name(bufnr, 'texlab') then
return vim.notify('Texlab client not found', vim.log.levels.ERROR)
end
@@ -95,8 +85,8 @@ local function cleanArtifacts(bufnr)
vim.notify('Artifacts cleaned successfully', vim.log.levels.INFO)
end
-local function cleanAuxiliary(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function cleanAuxiliary()
+ local bufnr = vim.api.nvim_get_current_buf()
if not util.get_active_client_by_name(bufnr, 'texlab') then
return vim.notify('Texlab client not found', vim.log.levels.ERROR)
end
@@ -107,8 +97,8 @@ 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 function buf_find_envs()
+ local bufnr = vim.api.nvim_get_current_buf()
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)
@@ -140,8 +130,8 @@ local function buf_find_envs(bufnr)
end, bufnr)
end
-local function buf_change_env(bufnr)
- bufnr = util.validate_bufnr(bufnr)
+local function buf_change_env()
+ local bufnr = vim.api.nvim_get_current_buf()
if not util.get_active_client_by_name(bufnr, 'texlab') then
return vim.notify('Texlab client not found', vim.log.levels.ERROR)
end
@@ -162,18 +152,6 @@ local function buf_change_env(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?
--- local function build_cancel_all(bufnr)
--- bufnr = util.validate_bufnr(bufnr)
--- local params = { token = "texlab-build-*" }
--- lsp.buf_request(bufnr, 'window/progress/cancel', params, function(err, method, result, client_id)
--- if err then error(tostring(err)) end
--- print("Cancel result", vim.inspect(result))
--- end)
--- end
-
return {
default_config = {
cmd = { 'texlab' },
@@ -212,49 +190,49 @@ return {
commands = {
TexlabBuild = {
function()
- buf_build(0)
+ buf_build()
end,
description = 'Build the current buffer',
},
TexlabForward = {
function()
- buf_search(0)
+ buf_search()
end,
description = 'Forward search from current position',
},
TexlabCancelBuild = {
function()
- buf_cancel_build(0)
+ buf_cancel_build()
end,
description = 'Cancel the current build',
},
TexlabDependencyGraph = {
function()
- dependency_graph(0)
+ dependency_graph()
end,
description = 'Show the dependency graph',
},
TexlabCleanArtifacts = {
function()
- cleanArtifacts(0)
+ cleanArtifacts()
end,
description = 'Clean the artifacts',
},
TexlabCleanAuxiliary = {
function()
- cleanAuxiliary(0)
+ cleanAuxiliary()
end,
description = 'Clean the auxiliary files',
},
TexlabFindEnvironments = {
function()
- buf_find_envs(0)
+ buf_find_envs()
end,
description = 'Find the environments at current position',
},
TexlabChangeEnvironment = {
function()
- buf_change_env(0)
+ buf_change_env()
end,
description = 'Change the environment at current position',
},