diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-24 23:01:07 -0500 |
|---|---|---|
| committer | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-25 23:46:21 -0500 |
| commit | 6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e (patch) | |
| tree | 7f2bf25ca5456b23304295dba8fe0005e85a5c10 /lua/lspconfig/server_configurations/texlab.lua | |
| parent | fix: only set cmd_cwd if filepath exists (#1485) (diff) | |
| download | nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.tar nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.tar.gz nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.tar.bz2 nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.tar.lz nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.tar.xz nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.tar.zst nvim-lspconfig-6c2fb86c6a03e20abea5ddd17d735885f0b7cb5e.zip | |
feat: expose configs
Diffstat (limited to 'lua/lspconfig/server_configurations/texlab.lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/texlab.lua | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/texlab.lua b/lua/lspconfig/server_configurations/texlab.lua new file mode 100644 index 00000000..982f0a2c --- /dev/null +++ b/lua/lspconfig/server_configurations/texlab.lua @@ -0,0 +1,127 @@ +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 texlab_forward_status = vim.tbl_add_reverse_lookup { + Success = 0, + Error = 1, + Failure = 2, + Unconfigured = 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, + util.compat_handler(function(err, result) + if err then + error(tostring(err)) + end + print('Build ' .. texlab_build_status[result.status]) + end) + ) +end + +local function buf_search(bufnr) + bufnr = util.validate_bufnr(bufnr) + 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) + ) +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', 'bib' }, + root_dir = function(fname) + return util.root_pattern '.latexmkrc'(fname) or util.find_git_ancestor(fname) + end, + 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/blob/master/docs/options.md for configuration options. +]], + }, +} |
