diff options
| author | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-13 10:45:30 -0800 |
|---|---|---|
| committer | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-13 10:45:30 -0800 |
| commit | b97bcbeddc3902911c2e9ab5f13b5327a81c745f (patch) | |
| tree | e67248064e95eac70f02e5e422c3eb2a8fed0b11 /lua/common_lsp/texlab.lua | |
| parent | Add vim function for texlab. (diff) | |
| download | nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.tar nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.tar.gz nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.tar.bz2 nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.tar.lz nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.tar.xz nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.tar.zst nvim-lspconfig-b97bcbeddc3902911c2e9ab5f13b5327a81c745f.zip | |
Add skeleton and refactor texlab.
Diffstat (limited to 'lua/common_lsp/texlab.lua')
| -rw-r--r-- | lua/common_lsp/texlab.lua | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/lua/common_lsp/texlab.lua b/lua/common_lsp/texlab.lua index 44f468d8..a24393e1 100644 --- a/lua/common_lsp/texlab.lua +++ b/lua/common_lsp/texlab.lua @@ -5,23 +5,8 @@ local lsp = vim.lsp local M = {} -local texlab_build_status = vim.tbl_add_reverse_lookup { - Success = 0; - Error = 1; - Failure = 2; - Cancelled = 3; -} - -- 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) - local settings = config.texlab_settings - for part in vim.gsplit(section, '.', true) do - settings = settings[part] - end - return settings -end - local default_config default_config = { name = "texlab"; @@ -39,13 +24,6 @@ default_config = { } } -local function nvim_command(command) - validate { command = { command, 's' } } - for line in vim.gsplit(command, "\n", true) do - api.nvim_command(line) - end -end - local function setup_callbacks(config) config.callbacks = config.callbacks or {} @@ -65,7 +43,7 @@ local function setup_callbacks(config) local result = {} for _, item in ipairs(params.items) do if item.section then - local value = lookup_configuration(config, item.section) or vim.NIL + local value = util.lookup_section(config.texlab_settings, item.section) or vim.NIL print(string.format("config[%q] = %s", item.section, vim.inspect(value))) table.insert(result, value) end @@ -101,7 +79,7 @@ end -- -- {name} -- Defaults to "texlab" -function M.texlab(config) +function M.setup(config) config = vim.tbl_extend("keep", config, default_config) util.tbl_deep_extend(config.texlab_settings, default_config.texlab_settings) @@ -117,20 +95,27 @@ function M.texlab(config) config.on_attach = util.add_hook_after(config.on_attach, function(client, bufnr) if bufnr == api.nvim_get_current_buf() then - M.texlab_setup_commands() + M._setup_buffer() else - nvim_command(string.format("autocmd BufEnter <buffer=%d> ++once lua require'common_lsp/texlab'.texlab_setup_commands()", bufnr)) + util.nvim_multiline_command(string.format("autocmd BufEnter <buffer=%d> ++once lua require'common_lsp/texlab'._setup_buffer()", bufnr)) end end) lsp.add_filetype_config(config) end -function M.texlab_setup_commands() - nvim_command [[ +function M._setup_buffer() + util.nvim_multiline_command [[ command! TexlabBuild lua require'common_lsp/texlab'.texlab_buf_build(0) ]] end +local texlab_build_status = vim.tbl_add_reverse_lookup { + Success = 0; + Error = 1; + Failure = 2; + Cancelled = 3; +} + function M.texlab_buf_build(bufnr) bufnr = util.validate_bufnr(bufnr) local params = { textDocument = { uri = vim.uri_from_bufnr(bufnr) } } |
