aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim_lsp/util.lua
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-26 06:01:11 -0800
committerGitHub <noreply@github.com>2019-11-26 06:01:11 -0800
commiteb01aca460d3a657c8fda36e64d101d85dbd9f78 (patch)
tree52f6229735db80ac44b0262a5eb0f3711968d208 /lua/nvim_lsp/util.lua
parentMerge pull request #46 from neovim/fix-lsp-followup (diff)
downloadnvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.tar
nvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.tar.gz
nvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.tar.bz2
nvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.tar.lz
nvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.tar.xz
nvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.tar.zst
nvim-lspconfig-eb01aca460d3a657c8fda36e64d101d85dbd9f78.zip
Add sumneko_lua installation and util.sh helper. (#49)
* Add sumneko_lua installation and util.sh helper. * Add vspackage extraction for package.json information via vscode name. * Allow specifying a tempdir at DOCGEN_TEMPDIR * Fix on_new_config and add docs for root_dir * User settings titles are not always useful
Diffstat (limited to 'lua/nvim_lsp/util.lua')
-rw-r--r--lua/nvim_lsp/util.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/lua/nvim_lsp/util.lua b/lua/nvim_lsp/util.lua
index d015c932..0f96dd59 100644
--- a/lua/nvim_lsp/util.lua
+++ b/lua/nvim_lsp/util.lua
@@ -1,3 +1,4 @@
+local vim = vim
local validate = vim.validate
local api = vim.api
local lsp = vim.lsp
@@ -361,6 +362,66 @@ function M.npm_installer(config)
}
end
+function M.sh(script, cwd)
+ api.nvim_command("10new")
+ assert(cwd and M.path.is_dir(cwd), "sh: Invalid directory")
+ local winnr = api.nvim_get_current_win()
+ local bufnr = api.nvim_get_current_buf()
+ local stdin = uv.new_pipe(false)
+ local stdout = uv.new_pipe(false)
+ local stderr = uv.new_pipe(false)
+ local handle, pid
+ handle, pid = uv.spawn("sh", {
+ stdio = {stdin, stdout, stderr};
+ cwd = cwd;
+ }, function()
+ stdin:close()
+ stdout:close()
+ stderr:close()
+ handle:close()
+ vim.schedule(function()
+ api.nvim_command("silent bwipeout! "..bufnr)
+ end)
+ end)
+
+ -- If the buffer closes, then kill our process.
+ api.nvim_buf_attach(bufnr, false, {
+ on_detach = function()
+ if not handle:is_closing() then
+ handle:kill(15)
+ end
+ end;
+ })
+
+ local output_buf = ''
+ local function update_chunk(err, chunk)
+ if chunk then
+ output_buf = output_buf..chunk
+ local lines = vim.split(output_buf, '\n', true)
+ api.nvim_buf_set_option(bufnr, "modifiable", true)
+ api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
+ api.nvim_buf_set_option(bufnr, "modifiable", false)
+ api.nvim_buf_set_option(bufnr, "modified", false)
+ if api.nvim_win_is_valid(winnr) then
+ api.nvim_win_set_cursor(winnr, {#lines, 0})
+ end
+ end
+ end
+ update_chunk = vim.schedule_wrap(update_chunk)
+ stdout:read_start(update_chunk)
+ stderr:read_start(update_chunk)
+ stdin:write(script)
+ stdin:write("\n")
+ stdin:shutdown()
+end
+
+function M.format_vspackage_url(extension_name)
+ local org, package = unpack(vim.split(extension_name, ".", true))
+ assert(org and package)
+ return string.format("https://marketplace.visualstudio.com/_apis/public/gallery/publishers/%s/vsextensions/%s/latest/vspackage", org, package)
+end
+
+
function M.utf8_config(config)
config.capabilities = config.capabilities or lsp.protocol.make_client_capabilities()
config.capabilities.offsetEncoding = {"utf-8", "utf-16"}