nvim-config

Log | Files | Refs | Submodules | README

commit 9727229a7b50fd3183610ec4fa3ab4655e0f5681
parent 31308ea2f0fd29ffb53515c5f789f391bb51a479
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Wed, 20 Jul 2022 11:20:44 +0200

fix(texlab): add big hacks to build main latex file

Diffstat:
Mlua/lsp_config.lua | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -85,6 +85,38 @@ end local function texlab_attach(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>m', '<cmd>TexlabForward<CR>', { noremap = true, silent = true }) + + -- HAXX TO BUILD THE MAIN FILE + local texlab_build_status = vim.tbl_add_reverse_lookup { + Success = 0, + Error = 1, + Failure = 2, + Cancelled = 3, + } + + local mainbuf = nil + for _, bid in ipairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_is_loaded(bid) and vim.api.nvim_buf_get_option(bid, "filetype") == "tex" then + mainbuf = bid + break + end + end + local params = { + textDocument = { uri = vim.uri_from_bufnr(mainbuf) }, + } + + vim.keymap.set('n', '<Leader><CR>', function() + if client then + client.request('textDocument/build', params, 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, { buffer = bufnr }) vim.lsp.protocol.SymbolKind = { 'file'; 'sec';