diff options
| author | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-13 10:18:58 -0800 |
|---|---|---|
| committer | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-13 10:18:58 -0800 |
| commit | 92f7256ddcc1f966210e576599ef84922ab659bb (patch) | |
| tree | 6013c3d7fbc2796998673a7ee4448bf5137b5874 /lua | |
| parent | Use spaces instead of tabs. (diff) | |
| download | nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.tar nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.tar.gz nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.tar.bz2 nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.tar.lz nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.tar.xz nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.tar.zst nvim-lspconfig-92f7256ddcc1f966210e576599ef84922ab659bb.zip | |
Add more documentation and clean up.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/common_lsp/texlab.lua | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/lua/common_lsp/texlab.lua b/lua/common_lsp/texlab.lua index bf1503d0..44f468d8 100644 --- a/lua/common_lsp/texlab.lua +++ b/lua/common_lsp/texlab.lua @@ -12,27 +12,6 @@ local texlab_build_status = vim.tbl_add_reverse_lookup { Cancelled = 3; } -function M.texlab_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, method, result, client_id) - 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? -function M.texlab_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 - -- TODO support more of https://github.com/microsoft/vscode-languageserver-node/blob/master/protocol/src/protocol.progress.proposed.md local function lookup_configuration(config, section) @@ -47,7 +26,7 @@ local default_config default_config = { name = "texlab"; cmd = {"texlab"}; - filetype = {"tex"}; + filetype = {"tex", "bib"}; texlab_log_level = lsp.protocol.MessageType.Warning; texlab_settings = { latex = { @@ -95,6 +74,33 @@ local function setup_callbacks(config) end end +-- A function to set up texlab easier. +-- +-- Additionally, it sets up the following commands: +-- - TexlabBuild: builds the current buffer. +-- +-- {config} is the same as |vim.lsp.add_filetype_config()|, but with some +-- additions and changes: +-- +-- {texlab_log_level} +-- controls the level of logs to show from build processes and other +-- window/logMessage events. By default it is set to +-- vim.lsp.protocol.MessageType.Warning instead of +-- vim.lsp.protocol.MessageType.Log. +-- +-- {texlab_settings} +-- The settings specified here https://texlab.netlify.com/docs/reference/configuration. +-- This is a table, and the keys are case sensitive. +-- Example: `texlab_settings = { latex = { build = { executable = "latexmk" } } }` +-- +-- {filetype} +-- Defaults to {"tex", "bib"} +-- +-- {cmd} +-- Defaults to {"texlab"} +-- +-- {name} +-- Defaults to "texlab" function M.texlab(config) config = vim.tbl_extend("keep", config, default_config) @@ -125,5 +131,26 @@ function M.texlab_setup_commands() ]] end +function M.texlab_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, method, result, client_id) + 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? +function M.texlab_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 M -- vim:et ts=2 sw=2 |
