aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/texlab.lua
diff options
context:
space:
mode:
authorHirokazu Hata <h.hata.ai.t@gmail.com>2020-09-06 17:49:21 +0900
committerHirokazu Hata <h.hata.ai.t@gmail.com>2020-09-06 17:49:21 +0900
commitddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de (patch)
treec301c7a765535dcb5387d76cc71e28d845dcce23 /lua/lspconfig/texlab.lua
parentMerge pull request #238 from steelsojka/angular-ls (diff)
downloadnvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.tar
nvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.tar.gz
nvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.tar.bz2
nvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.tar.lz
nvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.tar.xz
nvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.tar.zst
nvim-lspconfig-ddcd9e6aae50d6397e43e4fc9ba0cf7a82cc79de.zip
Rename nvim_lsp to lspconfig
Diffstat (limited to 'lua/lspconfig/texlab.lua')
-rw-r--r--lua/lspconfig/texlab.lua85
1 files changed, 85 insertions, 0 deletions
diff --git a/lua/lspconfig/texlab.lua b/lua/lspconfig/texlab.lua
new file mode 100644
index 00000000..b6e08927
--- /dev/null
+++ b/lua/lspconfig/texlab.lua
@@ -0,0 +1,85 @@
+local configs = require 'lspconfig/configs'
+local util = require 'lspconfig/util'
+local lsp = vim.lsp
+
+local texlab_build_status = vim.tbl_add_reverse_lookup {
+ Success = 0;
+ Error = 1;
+ Failure = 2;
+ Cancelled = 3;
+}
+
+local function buf_build(bufnr)
+ bufnr = util.validate_bufnr(bufnr)
+ local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) } }
+ lsp.buf_request(bufnr, 'textDocument/build', params,
+ function(err, _, result, _)
+ if err then error(tostring(err)) end
+ print("Build "..texlab_build_status[result.status])
+ 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
+
+configs.texlab = {
+ default_config = {
+ cmd = {"texlab"};
+ filetypes = {"tex", "bib"};
+ root_dir = vim.loop.os_homedir;
+ settings = {
+ latex = {
+ build = {
+ args = {"-pdf", "-interaction=nonstopmode", "-synctex=1"};
+ executable = "latexmk";
+ onSave = false;
+ };
+ forwardSearch = {
+ args = {};
+ executable = nil;
+ onSave = false;
+ };
+ lint = {
+ onChange = false;
+ };
+ };
+ bibtex = {
+ formatting = {
+ lineLength = 120
+ };
+ };
+ };
+ };
+ commands = {
+ TexlabBuild = {
+ function()
+ buf_build(0)
+ end;
+ description = "Build the current buffer";
+ };
+ };
+ docs = {
+ description = [[
+https://texlab.netlify.com/
+
+A completion engine built from scratch for (La)TeX.
+
+See https://texlab.netlify.com/docs/reference/configuration for configuration options.
+]];
+ default_config = {
+ root_dir = "vim's starting directory";
+ };
+ };
+}
+
+configs.texlab.buf_build = buf_build
+-- vim:et ts=2 sw=2