nvim-config

Log | Files | Refs | Submodules | README

commit f453b82d3880eabe241a4a323697a0ba52580c75
parent 3cdb1c571482bda12a6f07a866ac71309561b72c
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date:   Wed, 27 Jul 2022 19:08:20 +0200

Update

Diffstat:
Mlua/lsp_config.lua | 49+++++++++++++++++++++++--------------------------
1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua @@ -28,8 +28,8 @@ local function progress_handle(infos) return false end -vim.api.nvim_create_autocmd({ "User LspProgressUpdate" }, { - pattern = "*", +vim.api.nvim_create_autocmd({ "User" }, { + pattern = "LspProgressUpdate", callback = progress_handle }) @@ -159,8 +159,11 @@ local augroup = vim.api.nvim_create_augroup("User_LSP", {}) local find_root = function(markers, file) local dirs = vim.fs.find(markers, { upward = true, path = vim.fs.dirname(file) }) - local source = dirs[1] or file - return vim.fn.fnamemodify(source, ":p:h") + local source = vim.fn.fnamemodify(dirs[1] or file, ":p") + if source:sub(-1) == "/" then + source = vim.fs.dirname(source) + end + return vim.fs.dirname(source) end local function setup_lsp(name, filetypes, command, ucommands, config) @@ -187,6 +190,7 @@ local function setup_lsp(name, filetypes, command, ucommands, config) if not cfg.root_dir then cfg.root_dir = find_root(cfg.root_markers or { ".git" }, args.file) end + cfg.cmd_cwd = cfg.root_dir vim.lsp.start(cfg) end }) @@ -196,6 +200,7 @@ end local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true +capabilities.workspace.configuration = true local default_config = { capabilities = capabilities, on_attach = on_attach } -- A bit of notes for the future me @@ -316,6 +321,7 @@ local system_lsps = { print('Build ' .. texlab_build_status[result.status]) end, bufnr) end, + Forward = function(client, bufnr) local texlab_forward_status = vim.tbl_add_reverse_lookup { Success = 0, @@ -335,43 +341,34 @@ local system_lsps = { end print('Search ' .. texlab_forward_status[result.status]) end) + end, + + CleanAuxiliary = function(client, bufnr) + local uri = vim.uri_from_bufnr(bufnr) + client.request("workspace/executeCommand", + { command = "texlab.cleanAuxiliary", arguments = { document = { uri = uri } } }) + end, + + CleanArtifacts = function(client, bufnr) + local uri = vim.uri_from_bufnr(bufnr) + client.request("workspace/executeCommand", + { command = "texlab.cleanArtifacts", arguments = { document = { uri = uri } } }) end }, cfg = { + trace = "verbose", capabilities = capabilities, on_attach = texlab_attach, - on_init = function(client) - client.cleanAuxiliary = function(uri) - uri = uri or vim.uri_from_bufnr(vim.api.nvim_get_current_buf()) - client.request("workspace/executeCommand", - { command = "texlab.cleanAuxiliary", arguments = { document = { uri = uri } } }) - end - - client.cleanArtifacts = function(uri) - uri = uri or vim.uri_from_bufnr(vim.api.nvim_get_current_buf()) - client.request("workspace/executeCommand", - { command = "texlab.cleanArtifacts", arguments = { document = { uri = uri } } }) - end - end, settings = { texlab = { build = { - executable = 'latexmk', - args = { '-pdf', '-interaction=nonstopmode', '-synctex=1', '%f' }, onSave = true, forwardSearchAfter = false, }, - latexFormatter = 'latexindent', - latexindent = { - ['local'] = nil, -- local is a reserved keyword - modifyLineBreaks = false, - }, - auxDirectory = '.', forwardSearch = { executable = "zathura", args = { "--synctex-forward", "%l:1:%f", "%p" } }, - rootDirectory = ".", } }, },