diff options
| author | ranjithshegde <ranjithshegde@gmail.com> | 2021-11-29 15:05:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-29 09:05:53 -0500 |
| commit | 8436a197cc76f33fc2dc26145272c66cf5ee193d (patch) | |
| tree | 199d2043f614fd18026e6d8be8aee37d2eae4edf /lua/lspconfig/server_configurations/texlab.lua | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.tar nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.tar.gz nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.tar.bz2 nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.tar.lz nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.tar.xz nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.tar.zst nvim-lspconfig-8436a197cc76f33fc2dc26145272c66cf5ee193d.zip | |
chore: use client.request instead of buf_request (#1503)
* Use client.request directly instead of vim.lsp.buf_request to call methods
that are outside the official LSP specification, such as clangd's
"textDocument/switchSourceHeader".
* This avoids sending an inapplicable request to all servers, as we cannot
ahead of time validate the methods a given server supports.
Diffstat (limited to 'lua/lspconfig/server_configurations/texlab.lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/texlab.lua | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua index 4bcb6c81..1e43976a 100644 --- a/lua/lspconfig/server_configurations/texlab.lua +++ b/lua/lspconfig/server_configurations/texlab.lua @@ -1,5 +1,4 @@ local util = require 'lspconfig.util' -local lsp = vim.lsp local texlab_build_status = vim.tbl_add_reverse_lookup { Success = 0, @@ -17,39 +16,49 @@ local texlab_forward_status = vim.tbl_add_reverse_lookup { local function buf_build(bufnr) bufnr = util.validate_bufnr(bufnr) + local texlab_client = util.get_active_client_by_name(bufnr, 'texlab') local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) }, } - lsp.buf_request( - bufnr, - 'textDocument/build', - params, - util.compat_handler(function(err, result) - if err then - error(tostring(err)) - end - print('Build ' .. texlab_build_status[result.status]) - end) - ) + if texlab_client then + texlab_client.request( + 'textDocument/build', + params, + util.compat_handler(function(err, result) + if err then + error(tostring(err)) + end + print('Build ' .. texlab_build_status[result.status]) + end), + bufnr + ) + else + print 'method textDocument/build is not supported by any servers active on the current buffer' + end end local function buf_search(bufnr) bufnr = util.validate_bufnr(bufnr) + local texlab_client = util.get_active_client_by_name(bufnr, 'texlab') local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) }, position = { line = vim.fn.line '.' - 1, character = vim.fn.col '.' }, } - lsp.buf_request( - bufnr, - 'textDocument/forwardSearch', - params, - util.compat_handler(function(err, result) - if err then - error(tostring(err)) - end - print('Search ' .. texlab_forward_status[result.status]) - end) - ) + if texlab_client then + texlab_client.request( + 'textDocument/forwardSearch', + params, + util.compat_handler(function(err, result) + if err then + error(tostring(err)) + end + print('Search ' .. texlab_forward_status[result.status]) + end), + bufnr + ) + else + print 'method textDocument/forwardSearch is not supported by any servers active on the current buffer' + end end -- bufnr isn't actually required here, but we need a valid buffer in order to |
