diff options
| author | William Boman <william@redwill.se> | 2021-10-01 18:54:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-01 18:54:02 +0200 |
| commit | 3b01dd3fb16d3755581750bcf81b39f05e1e4046 (patch) | |
| tree | f7e5fc5b4e31d05f583525dd1396760aed5b2409 /lua | |
| parent | fix parsing stdout/stderr chunks into proper lines (diff) | |
| download | mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.tar mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.tar.gz mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.tar.bz2 mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.tar.lz mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.tar.xz mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.tar.zst mason-3b01dd3fb16d3755581750bcf81b39f05e1e4046.zip | |
clangd: fix installing on Windows (#113)
Resolves #112.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/servers/clangd/init.lua | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/lua/nvim-lsp-installer/servers/clangd/init.lua b/lua/nvim-lsp-installer/servers/clangd/init.lua index 3fc9d9c6..1a0c817e 100644 --- a/lua/nvim-lsp-installer/servers/clangd/init.lua +++ b/lua/nvim-lsp-installer/servers/clangd/init.lua @@ -1,9 +1,12 @@ local server = require "nvim-lsp-installer.server" local path = require "nvim-lsp-installer.path" -local platform = require "nvim-lsp-installer.platform" local Data = require "nvim-lsp-installer.data" local std = require "nvim-lsp-installer.installers.std" +local platform = require "nvim-lsp-installer.platform" local context = require "nvim-lsp-installer.installers.context" +local installers = require "nvim-lsp-installer.installers" + +local uv = vim.loop return function(name, root_dir) return server.Server:new { @@ -20,28 +23,59 @@ return function(name, root_dir) context.capture(function(ctx) return std.unzip_remote(ctx.github_release_file) end), - function(server, callback, context) - vim.loop.fs_symlink( - path.concat { + installers.when { + unix = function(server, callback, context) + local path = path.concat { server.root_dir, ("clangd_%s"):format(context.requested_server_version), "bin", "clangd", - }, - path.concat { server.root_dir, "clangd" }, - function(err, success) - if not success then - context.stdio_sink.stderr(tostring(err)) - callback(false) - else - callback(true) + } + local new_path = path.concat { server.root_dir, "clangd" } + context.stdio_sink.stdout(("Creating symlink from %s to %s\n"):format(path, new_path)) + uv.fs_symlink( + path, + new_path, + function(err, success) + if not success then + context.stdio_sink.stderr(tostring(err) .. "\n") + callback(false) + else + callback(true) + end + end + ) + print(vim.inspect(test)) + end, + win = function (server,callback,context) + context.stdio_sink.stdout("Creating clangd.bat...\n") + uv.fs_open(path.concat { server.root_dir, "clangd.bat" }, "w", 438, function (err, fd) + local path = path.concat { + server.root_dir, + ("clangd_%s"):format(context.requested_server_version), + "bin", + "clangd.exe", + } + if err then + context.stdio_sink.stderr(tostring(err) .. "\n") + return callback(false) end - end - ) - end, + uv.fs_write(fd, ("@call %q %%*"):format(path), -1, function (err) + if err then + context.stdio_sink.stderr(tostring(err) .. "\n") + callback(false) + else + context.stdio_sink.stdout("Created clangd.bat\n") + callback(true) + end + assert(uv.fs_close(fd)) + end) + end) + end + }, }, default_options = { - cmd = { path.concat { root_dir, "clangd" } }, + cmd = { path.concat { root_dir, platform.is_win and "clangd.bat" or "clangd" } }, }, } end |
