summaryrefslogtreecommitdiff
path: root/start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2024-07-15 20:05:47 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2024-07-15 20:05:47 +0100
commit522d56557b00246286d803425751a4334f3a94a5 (patch)
tree23ca335a3526197c2a6327ce10bfd58411b0a609 /start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua
parenta7b72fc27edac2305dbf0af807981bd703835b25 (diff)
Update lspconfig, add indent-blanklineHEADmaster
indent-blankline is probably old because I've actually been using it for ages, but I have a strict if-it-ain't-broke policy, so I'm not going to update it. lspconfig *was* broke though with nvim 0.10, so now it's fixed.
Diffstat (limited to 'start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua')
-rw-r--r--start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua127
1 files changed, 127 insertions, 0 deletions
diff --git a/start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua b/start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua
new file mode 100644
index 0000000..36198d0
--- /dev/null
+++ b/start/lspconfig-0.1.8/lua/lspconfig/server_configurations/texlab.lua
@@ -0,0 +1,127 @@
+local util = require 'lspconfig.util'
+
+local texlab_build_status = {
+ [0] = 'Success',
+ [1] = 'Error',
+ [2] = 'Failure',
+ [3] = 'Cancelled',
+}
+
+local texlab_forward_status = {
+ [0] = 'Success',
+ [1] = 'Error',
+ [2] = 'Failure',
+ [3] = 'Unconfigured',
+}
+
+local function buf_build(bufnr)
+ bufnr = util.validate_bufnr(bufnr)
+ 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)
+ 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 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)
+ 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
+-- 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' },
+ filetypes = { 'tex', 'plaintex', 'bib' },
+ root_dir = util.root_pattern('.git', '.latexmkrc', '.texlabroot', 'texlabroot', 'Tectonic.toml'),
+ single_file_support = true,
+ settings = {
+ texlab = {
+ rootDirectory = nil,
+ build = {
+ executable = 'latexmk',
+ args = { '-pdf', '-interaction=nonstopmode', '-synctex=1', '%f' },
+ onSave = false,
+ forwardSearchAfter = false,
+ },
+ auxDirectory = '.',
+ forwardSearch = {
+ executable = nil,
+ args = {},
+ },
+ chktex = {
+ onOpenAndSave = false,
+ onEdit = false,
+ },
+ diagnosticsDelay = 300,
+ latexFormatter = 'latexindent',
+ latexindent = {
+ ['local'] = nil, -- local is a reserved keyword
+ modifyLineBreaks = false,
+ },
+ bibtexFormatter = 'texlab',
+ formatterLineLength = 80,
+ },
+ },
+ },
+ commands = {
+ TexlabBuild = {
+ function()
+ buf_build(0)
+ end,
+ description = 'Build the current buffer',
+ },
+ TexlabForward = {
+ function()
+ buf_search(0)
+ end,
+ description = 'Forward search from current position',
+ },
+ },
+ docs = {
+ description = [[
+https://github.com/latex-lsp/texlab
+
+A completion engine built from scratch for (La)TeX.
+
+See https://github.com/latex-lsp/texlab/wiki/Configuration for configuration options.
+]],
+ },
+}