diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 22e964c1..5caaeb84 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -56,8 +56,7 @@ jobs: - name: Run build scripts run: | - nvim -l build/init.lua - + nvim -u scripts/init.lua -l build/init.lua - name: Run tests run: | diff --git a/.gitignore b/.gitignore index 2244da04..6ea0368a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ data.db data.db* .luarc.json +dist/ diff --git a/README.md b/README.md index a82e4bdd..9298fc94 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,10 @@ You can check that you're logged in by then running `:checkhealth sg` Requires: - nvim 0.9 or nvim nightly -- Cargo to build (pre-built binary/dylibs options to come) -- Node.js >= 18.17.0 (LTS) at runtime for [`cody-agent.js` - sourcegraph](./dist/cody-agent.js) +- Node.js >= 18.17.0 (LTS) at runtime for [`cody-agent.js`](github.com/sourcegraph/cody) + +(By default, sg.nvim downloads released binaries from Github. If you prefer to build the plugin yourself, you'll need `cargo` to build) + ### Install diff --git a/build/init.lua b/build/init.lua index 41af86e4..6917c86f 100644 --- a/build/init.lua +++ b/build/init.lua @@ -1,51 +1,71 @@ --- TODO: Can switch to vim.system later -local system = function(cmd, opts) - local status = {} - opts = opts or {} - - opts.on_stdout = function(_, data) - if data then - print(table.concat(data, "")) +local sourced_filename = (function() + return vim.fn.fnamemodify(vim.fs.normalize(debug.getinfo(2, "S").source:sub(2)), ":p") +end)() + +-- Add sourcegraph plugin to runtimepath +-- This let's us require "sg.config" and "sg.build" +vim.opt.rtp:prepend(vim.fn.fnamemodify(sourced_filename, ":h:h")) + +local ok, config = pcall(require, "sg.config") +if not ok then + config = {} +end + +-- This is the default path of downloading binaries +if config.download_binaries or config.download_binaries == nil then + return require("sg.build").download() +else + -- This is the path to build these manually. + + -- TODO: Can switch to vim.system later + local system = function(cmd, opts) + local status = {} + opts = opts or {} + + opts.on_stdout = function(_, data) + if data then + print(table.concat(data, "")) + end end - end - opts.on_stderr = function(_, data) - if data then - print(table.concat(data, "")) + opts.on_stderr = function(_, data) + if data then + print(table.concat(data, "")) + end end - end - opts.on_exit = function(_, code) - if code ~= 0 then - status.errored = true - return + opts.on_exit = function(_, code) + if code ~= 0 then + status.errored = true + return + end + + status.done = true + print "" end - status.done = true - print "" + vim.fn.jobstart(cmd, opts) + return status end - vim.fn.jobstart(cmd, opts) - return status -end + print "=====================" + print "installing sg.nvim..." + print "=====================" -print "=====================" -print "installing sg.nvim..." -print "=====================" + -- Wait for up to ten minutes...? Idk, maybe that's too long + -- or short haha. I don't know what build times are for other people + local wait_for_status = function(status) + vim.wait(10 * 60 * 1000, function() + return status.done or status.errored + end, 200) + end --- Wait for up to ten minutes...? Idk, maybe that's too long --- or short haha. I don't know what build times are for other people -local wait_for_status = function(status) - vim.wait(10 * 60 * 1000, function() - return status.done or status.errored - end, 200) -end + local status_bins = system { "cargo", "build", "--bins" } + wait_for_status(status_bins) -local status_bins = system { "cargo", "build", "--bins" } -wait_for_status(status_bins) + if status_bins.errored then + error "failed to build the binaries" + end -if status_bins.errored then - error "failed to build the binaries" + print "success\n" end - -print "success\n" diff --git a/doc/sg.txt b/doc/sg.txt index aed0bf9b..e8205ab1 100644 --- a/doc/sg.txt +++ b/doc/sg.txt @@ -34,6 +34,9 @@ sg.config *sg.config* Configuration Options: ~ + {download_binaries} (boolean) Default true, download + latest release from + Github {node_executable} (string) path to node executable {cody_agent} (string) path to the cody-agent js bundle @@ -200,16 +203,6 @@ COMMANDS *sg.commands* Default commands for interacting with Sourcegraph - *:SourcegraphLink* -:SourcegraphLink ~ - Get a sourcegraph link to the current repo + file + line. Automatically - adds it to your '+' register - - *:SourcegraphSearch* -:SourcegraphSearch ~ - Run a search. For more sourcegraph search syntax, refer to online - documentation - *:SourcegraphLogin* :SourcegraphLogin ~ Get prompted for endpoint and access_token if you don't want to set them @@ -220,6 +213,22 @@ Default commands for interacting with Sourcegraph Rebuild the Sourcegraph crates and required dependencies (in case build failed during installation) + *:SourcegraphDownloadBinaries* +:SourcegraphDownloadBinaries ~ + (Re-)Download the sourcegraph binaries. This should happen during + installation but you can force redownloading the binaries this way to + ensure that sg.nvim is properly installed. + + *:SourcegraphLink* +:SourcegraphLink ~ + Get a sourcegraph link to the current repo + file + line. Automatically + adds it to your '+' register + + *:SourcegraphSearch* +:SourcegraphSearch ~ + Run a search. For more sourcegraph search syntax, refer to online + documentation + diff --git a/lua/sg/auth.lua b/lua/sg/auth.lua index 67df8ab0..d4e9832e 100644 --- a/lua/sg/auth.lua +++ b/lua/sg/auth.lua @@ -101,6 +101,20 @@ M.get = function(ordering) return nil, nil end +M.get_all_valid = function(ordering) + ordering = ordering or config.auth_strategy + + local results = {} + for _, order in ipairs(ordering) do + local res = M.get { order } + if res then + table.insert(results, { res, order }) + end + end + + return results +end + M.valid = function() return M.get() ~= nil end @@ -116,8 +130,8 @@ M.set_nvim_auth = function(opts) assert(opts.endpoint, "[sg-cody] Nvim auth must have an endpoint") local cody_data = data.get_cody_data() - cody_data.token = data.token - cody_data.endpoint = data.endpoint + cody_data.token = opts.token + cody_data.endpoint = opts.endpoint data.write_cody_data(cody_data) end diff --git a/lua/sg/build.lua b/lua/sg/build.lua new file mode 100644 index 00000000..07d5b54b --- /dev/null +++ b/lua/sg/build.lua @@ -0,0 +1,100 @@ +--[[ + +NOTE!! This file cannot depend on anything besides sg.* +- RTP is not always set up during build time. So don't add anything other items. +- Preferably, this only uses sg.utils + +--]] + +local sourced_filename = (function() + return vim.fn.fnamemodify(vim.fs.normalize(debug.getinfo(2, "S").source:sub(2)), ":p") +end)() + +local plugin_root = vim.fn.fnamemodify(sourced_filename, ":h:h:h") + +local utils = require "sg.utils" +local system = utils.system +local joinpath = utils.joinpath + +local os_uname = vim.loop.os_uname() +local sysname = os_uname.sysname:lower() +local machine = os_uname.machine + +local basename = (function() + if sysname == "linux" then + return "sg-x86_64-unknown-linux-gnu" + end + + if sysname == "windows_nt" then + return "sg-x86_64-pc-windows-msvc" + end + + if sysname == "darwin" then + if machine == "arm64" then + return "sg-aarch64-apple-darwin" + else + return "sg-x86_64-apple-darwin" + end + end + + error "Must have a valid basename" +end)() + +local fullname = (function() + if sysname == "windows_nt" then + return basename .. ".zip" + end + + return basename .. ".tar.xz" +end)() + +local link = "https://github.com/sourcegraph/sg.nvim/releases/latest/download/" .. fullname + +local M = {} + +local tarfile = joinpath(plugin_root, "dist", fullname) +local move_to_dist = function(bin) + return vim.loop.fs_rename(joinpath(plugin_root, "dist", basename, bin), joinpath(plugin_root, "dist", bin)) +end + +M.download = function() + -- TODO: Proper error handling here. + -- Right now, nvim won't exit with a non-zero exit code + -- if you run this with nvim -l build/init.lua + -- because we don't force the error in the main thread. + -- + -- so we need to vim.wait for them. + vim.notify "[sg] Starting to download binaries..." + + -- TODO: Windows + -- Check that we have curl + -- Check what to do to zip + + local curl = system({ "curl", link, "-L", "-o", tarfile }):wait() + if curl.code ~= 0 then + error("Failed to execute downloading release" .. vim.inspect(curl)) + end + print "[sg] Done downloading" + + local tar = system({ "tar", "-xvf", tarfile, "-C", joinpath(plugin_root, "dist/") }):wait() + if tar.code ~= 0 then + error("Failed to untar release" .. tar) + end + print "[sg] Done extracting" + + local lsp_rename = move_to_dist "sg-lsp" + if not lsp_rename then + error("Failed to rename sg-lsp: " .. vim.inspect(lsp_rename)) + return + end + + local agent_rename = move_to_dist "sg-nvim-agent" + if not agent_rename then + error("Failed to rename sg-nvim-agent" .. vim.inspect(agent_rename)) + return + end + + vim.notify "[sg] Download complete" +end + +return M diff --git a/lua/sg/config.lua b/lua/sg/config.lua index 0b258b8b..f1e74af0 100644 --- a/lua/sg/config.lua +++ b/lua/sg/config.lua @@ -15,6 +15,7 @@ local types = require "sg.types" ---@class sg.config +---@field download_binaries boolean: Default true, download latest release from Github ---@field node_executable string: path to node executable ---@field cody_agent string: path to the cody-agent js bundle ---@field did_change_debounce number: Number of ms to debounce changes @@ -25,6 +26,7 @@ local types = require "sg.types" ---@type sg.config local config = {} +config.download_binaries = true config.node_executable = "node" config.cody_agent = vim.api.nvim_get_runtime_file("dist/cody-agent.js", false)[1] diff --git a/lua/sg/health.lua b/lua/sg/health.lua index 18f25312..56c10a02 100644 --- a/lua/sg/health.lua +++ b/lua/sg/health.lua @@ -1,5 +1,4 @@ local void = require("plenary.async").void -local block_on = require("plenary.async").util.block_on local M = {} local report_nvim = function() @@ -13,14 +12,13 @@ local report_nvim = function() end local report_lib = function() - -- TODO: This should probably just check that the binary exists? - if 1 ~= vim.fn.executable "cargo" then - vim.health.error "Unable to find valid cargo executable." + vim.health.error "Unable to find valid cargo executable. Trying to build sg.nvim will fail. Instead use `:SourcegraphDownloadBinaries`" + return false else local result = require("sg.utils").system({ "cargo", "--version" }, { text = true }):wait() if result.code ~= 0 then - vim.health.error "cargo failed to run `cargo --version`" + vim.health.error "cargo failed to run `cargo --version`. Instead use `:SourcegraphDownloadBinaries`" for _, msg in ipairs(vim.split(result.stdout, "\n")) do vim.health.info(msg) @@ -28,10 +26,14 @@ local report_lib = function() for _, msg in ipairs(vim.split(result.stderr, "\n")) do vim.health.info(msg) end + + return false else vim.health.ok "Found `cargo` is executable" end end + + return true end local report_nvim_agent = function() @@ -50,21 +52,25 @@ local report_env = function() local ok = true - local creds, strategy = auth.get() - vim.health.info(string.format("Auth strategy order: %s", vim.inspect(require("sg.config").auth_strategy))) - if not creds then + local all_valid = auth.get_all_valid() + if vim.tbl_isempty(all_valid) then vim.health.error "No valid auth strategy detected. See `:help sg` for more info." ok = false - end - - if ok then - assert(creds, "must have valid credentials") - - vim.health.ok "Authentication setup correctly" - vim.health.ok(string.format(" endpoint set to: %s", creds.endpoint)) - vim.health.ok(string.format(" strategy used: %s", strategy)) + else + for idx, valid in ipairs(all_valid) do + local creds, strategy = unpack(valid) + assert(creds, "must have valid credentials") + + if idx == 1 then + vim.health.ok(string.format(' Authentication setup correctly ("%s")', strategy)) + vim.health.ok(string.format(" endpoint set to: %s", creds.endpoint)) + else + vim.health.ok(string.format(' Backup Authentication also available ("%s")', strategy)) + vim.health.ok(string.format(" endpoint set to: %s", creds.endpoint)) + end + end end local err, info @@ -78,10 +84,21 @@ local report_env = function() if err then vim.health.error(" Sourcegraph Connection info failed: " .. vim.inspect(err)) + ok = false else vim.health.ok(" Sourcegraph Connection info: " .. vim.inspect(info)) end + local expected_cargo_version = require "sg.private.cargo_version" + if expected_cargo_version ~= info.sg_nvim_version then + vim.health.error "Mismatched cargo and expected version. Update using :SourcegraphDownloadBinaries or :SourcegraphBuild" + vim.health.error(string.format("Exptected: %s | Found: %s", expected_cargo_version, info.sg_nvim_version)) + + ok = false + else + vim.health.ok("Found correct binary versions: " .. expected_cargo_version .. " = " .. info.sg_nvim_version) + end + return ok end diff --git a/lua/sg/notify.lua b/lua/sg/notify.lua index 149089af..134aaaac 100644 --- a/lua/sg/notify.lua +++ b/lua/sg/notify.lua @@ -1,7 +1,15 @@ local M = {} M.NO_AUTH = function() - vim.notify_once "[sg-cody] Unable to find valid authentication strategy. See `:help sg.auth`" + vim.notify_once "[sg-cody] Unable to find valid authentication strategy. See `:help sg.auth` and then restart nvim" + + return nil +end + +M.NO_BUILD = function() + vim.notify_once "[sg-cody] Unable to find cody binaries. You may not have run `nvim -l build/init.lua` and then restart nvim" + + return nil end M.INVALID_AUTH = function() diff --git a/lua/sg/private/cargo_version.lua b/lua/sg/private/cargo_version.lua new file mode 100644 index 00000000..82238182 --- /dev/null +++ b/lua/sg/private/cargo_version.lua @@ -0,0 +1,15 @@ +local sourced_filename = (function() + return vim.fn.fnamemodify(vim.fs.normalize(debug.getinfo(2, "S").source:sub(2)), ":p") +end)() +local plugin_root = vim.fn.fnamemodify(sourced_filename, ":h:h:h:h") + +return (function() + local lines = vim.fn.readfile(require("sg.utils").joinpath(plugin_root, "Cargo.toml")) + for _, line in ipairs(lines) do + if vim.startswith(line, "version =") then + return vim.trim(vim.split(line, "=")[2]:gsub('"', "")) + end + end + + error "[sg] unable to find cargo version" +end)() diff --git a/lua/sg/private/find_artifact.lua b/lua/sg/private/find_artifact.lua index ebad6241..99e5dae2 100644 --- a/lua/sg/private/find_artifact.lua +++ b/lua/sg/private/find_artifact.lua @@ -19,6 +19,7 @@ M.find_rust_bin = function(cmd) end local directories = { + "/dist/", "/target/debug/", "/target/release/", "/bin/", @@ -36,7 +37,7 @@ M.find_rust_bin = function(cmd) sort_by_time(candidates) local result = candidates[1] if not result then - error(string.format("Failed to load %s: You probably did not run `nvim -l build/init.lua`", cmd)) + return nil end return result.path @@ -77,7 +78,7 @@ M.find_rust_lib = function(name) end end - error(string.format("Failed to load %s: You probably did not run `nvim -l build/init.lua`", name)) + -- error(string.format("Failed to load %s: You probably did not run `nvim -l build/init.lua`", name)) end return M diff --git a/lua/sg/request.lua b/lua/sg/request.lua index 4f35d0e6..931c3f69 100644 --- a/lua/sg/request.lua +++ b/lua/sg/request.lua @@ -1,3 +1,14 @@ +-- Verify that the environment is properly configured +local creds = require("sg.auth").get() +if not creds then + return require("sg.notify").NO_AUTH() +end + +local bin_sg_nvim = require("sg.config").get_nvim_agent() +if not bin_sg_nvim then + return require("sg.notify").NO_BUILD() +end + -- Attempt to clear SG_SG_CLIENT if one is already -- running currently. -- @@ -13,23 +24,14 @@ if SG_SG_CLIENT then end local log = require "sg.log" - -local vendored_rpc = require "sg.vendored.vim-lsp-rpc" +local lsp = require "sg.vendored.vim-lsp-rpc" local M = {} local notification_handlers = {} local server_handlers = {} -local auth = require "sg.auth" -local creds = auth.get() -if not creds then - require("sg.notify").NO_AUTH() - return nil -end - -local bin_sg_nvim = require("sg.config").get_nvim_agent() -SG_SG_CLIENT = vendored_rpc.start(bin_sg_nvim, {}, { +SG_SG_CLIENT = lsp.start(bin_sg_nvim, {}, { notification = function(method, data) if notification_handlers[method] then notification_handlers[method](data) diff --git a/lua/sg/rpc.lua b/lua/sg/rpc.lua index c02ba7bc..f34b6317 100644 --- a/lua/sg/rpc.lua +++ b/lua/sg/rpc.lua @@ -1,6 +1,10 @@ ---@tag sg.rpc ---@config { ["module"] = "sg.rpc" } +if not require "sg.request" then + return {} +end + local req = require("sg.request").request local rpc = {} diff --git a/lua/sg/utils.lua b/lua/sg/utils.lua index 612f3dc0..f859e232 100644 --- a/lua/sg/utils.lua +++ b/lua/sg/utils.lua @@ -1,5 +1,10 @@ -local async = require "plenary.async" +--[[ +NOTE: Do not require from this file to any other SG files. + This makes sure that this can be required without + anything else being built and/or linked up. + +--]] local utils = {} utils.once = function(f) @@ -52,9 +57,12 @@ end -- Probably will break on me unexpectedly. Nice utils.system = vim.system or (require "sg.vendored.vim-system") -utils.async_system = async.wrap(function(cmd, opts, on_exit) - return utils.system(cmd, opts, vim.schedule_wrap(on_exit)) -end, 3) +local ok, async = pcall(require, "plenary.async") +if ok then + utils.async_system = async.wrap(function(cmd, opts, on_exit) + return utils.system(cmd, opts, vim.schedule_wrap(on_exit)) + end, 3) +end -- From https://gist.github.com/jrus/3197011 utils.uuid = function() diff --git a/plugin/sg.lua b/plugin/sg.lua index a88fbc67..8ebc2b7d 100644 --- a/plugin/sg.lua +++ b/plugin/sg.lua @@ -6,6 +6,57 @@ local void = require("plenary.async").void +---@command SourcegraphLogin [[ +--- Get prompted for endpoint and access_token if you don't +--- want to set them via environment variables. +---@command ]] +vim.api.nvim_create_user_command("SourcegraphLogin", function() + local auth = require "sg.auth" + + auth.set_nvim_auth() + + vim.notify "[sg-cody] Changes will come into effect after a restart" +end, { + desc = "Login and store credentials for later use (an alternative to the environment variables", +}) + +---@command SourcegraphBuild [[ +--- Rebuild the Sourcegraph crates and required dependencies (in case build failed during installation) +---@command ]] +vim.api.nvim_create_user_command("SourcegraphBuild", function() + local plugin_file = require("plenary.debug_utils").sourced_filepath() + local root = vim.fn.fnamemodify(plugin_file, ":h:h") + local build = require("sg.utils").joinpath(root, "build", "init.lua") + print "Starting sourcegraph build:" + + require("sg.utils").system({ "nvim", "-l", build }, { cwd = root, text = true }, function(obj) + print(obj.stdout) + print(obj.stderr) + if obj.code ~= 0 then + error "Sourcegraph Build Failed. Check `:messages`" + else + print "Sourcegraph Build Success! Build log in `:messages`" + end + end) +end, { + desc = "Rebuild the Sourcegraph crates and required dependencies (in case build failed during installation)", +}) + +---@command SourcegraphDownloadBinaries [[ +--- (Re-)Download the sourcegraph binaries. This should happen during installation +--- but you can force redownloading the binaries this way to ensure that sg.nvim +--- is properly installed. +---@command ]] +vim.api.nvim_create_user_command("SourcegraphDownloadBinaries", function() + require("sg.build").download() +end, { + desc = "(Re-)download the sourcegraph binaries", +}) + +if not require "sg.request" then + return +end + local bufread = require "sg.bufread" -- TODO: I don't know how to turn off this https://* stuff and not make netrw users mad @@ -19,7 +70,7 @@ vim.api.nvim_create_autocmd("BufReadCmd", { group = vim.api.nvim_create_augroup("sourcegraph-bufread", { clear = true }), pattern = { "sg://*", "https://sourcegraph.com/*" }, callback = function(event) - bufread.edit(event.buf or vim.api.nvim_get_current_buf(), vim.fn.expand "" --[[--@as string]]) + bufread.edit(event.buf or vim.api.nvim_get_current_buf(), vim.fn.expand "" --[[@as string]]) end, desc = "Sourcegraph link and protocol handler", }) @@ -88,39 +139,3 @@ vim.api.nvim_create_user_command("SourcegraphSearch", function(args) end, { desc = "Run a search on your connected Sourcegraph instance", }) - ----@command SourcegraphLogin [[ ---- Get prompted for endpoint and access_token if you don't ---- want to set them via environment variables. ----@command ]] -vim.api.nvim_create_user_command("SourcegraphLogin", function() - local auth = require "sg.auth" - - auth.set_nvim_auth() - - vim.notify "[sg-cody] Changes will come into effect after a restart" -end, { - desc = "Login and store credentials for later use (an alternative to the environment variables", -}) - ----@command SourcegraphBuild [[ ---- Rebuild the Sourcegraph crates and required dependencies (in case build failed during installation) ----@command ]] -vim.api.nvim_create_user_command("SourcegraphBuild", function() - local plugin_file = require("plenary.debug_utils").sourced_filepath() - local root = vim.fn.fnamemodify(plugin_file, ":h:h") - local build = require("sg.utils").joinpath(root, "build", "init.lua") - print "Starting sourcegraph build:" - - require("sg.utils").system({ "nvim", "-l", build }, { cwd = root, text = true }, function(obj) - print(obj.stdout) - print(obj.stderr) - if obj.code ~= 0 then - error "Sourcegraph Build Failed. Check `:messages`" - else - print "Sourcegraph Build Success! Build log in `:messages`" - end - end) -end, { - desc = "Rebuild the Sourcegraph crates and required dependencies (in case build failed during installation)", -}) diff --git a/scratch/cody-is-great.psh b/scratch/cody-is-great.psh new file mode 100644 index 00000000..d5ffe402 --- /dev/null +++ b/scratch/cody-is-great.psh @@ -0,0 +1,19 @@ +$link = "https://example.com/file.tar.gz" +$tarfile = "file.tar.gz" + +Invoke-WebRequest -Uri $link -OutFile $tarfile + +if ($?) { + Write-Output "Done downloading" + + Expand-Archive -Path $tarfile -DestinationPath .\dist\ + if ($?) { + Write-Output "Done extracting" + } + else { + Write-Output "Failed to extract archive" + } +} +else { + Write-Output "Failed to download file" +} diff --git a/scratch/download.lua b/scratch/download.lua new file mode 100644 index 00000000..8cf47f41 --- /dev/null +++ b/scratch/download.lua @@ -0,0 +1,75 @@ +local void = require("plenary.async").void +local uv = require("plenary.async").uv +local async_system = require("sg.utils").async_system + +local os_uname = vim.loop.os_uname() +local sysname = os_uname.sysname:lower() +local machine = os_uname.machine + +local basename = (function() + if sysname == "linux" then + return "sg-x86_64-unknown-linux-gnu" + end + + if sysname == "windows" then + return "sg-x86_64-pc-windows-msvc" + end + + if sysname == "darwin" then + if machine == "arm64" then + return "sg-aarch64-apple-darwin" + else + return "sg-x86_64-apple-darwin" + end + end + + error "Must have a valid basename" +end)() + +local fullname = (function() + if sysname == "windows" then + return basename .. ".zip" + end + + return basename .. ".tar.xz" +end)() + +local link = "https://github.com/sourcegraph/sg.nvim/releases/latest/download/" .. fullname + +void(function() + local tarfile = "dist/" .. fullname + + -- TODO: Windows + -- Check that we have curl + -- Check what to do to zip + + local curl = async_system { "curl", link, "-L", "-o", tarfile } + if curl.code ~= 0 then + vim.print("Failed to execute downloading release", curl) + return + end + print "Done downloading" + + local tar = async_system { "tar", "-xvf", tarfile, "-C", "dist/" } + if tar.code ~= 0 then + vim.print("Failed to untar release", tar) + return + end + print "Done extracting" + + local rename = function(bin_name) + return uv.fs_rename("dist/" .. basename .. "/" .. bin_name, "dist/" .. bin_name) + end + + local lsp_rename = rename "sg-lsp" + if lsp_rename ~= nil then + vim.print("Failed to rename sg-lsp", lsp_rename) + end + + local agent_rename = rename "sg-nvim-agent" + if agent_rename ~= nil then + vim.print("Failed to rename sg-nvim-agent", agent_rename) + end + + print "Done renaming" +end)() diff --git a/scripts/init.lua b/scripts/init.lua index f26fac32..6242cf7f 100644 --- a/scripts/init.lua +++ b/scripts/init.lua @@ -9,3 +9,8 @@ vim.cmd [[runtime! plugin/plenary.vim]] vim.cmd [[runtime! plugin/sg.lua]] vim.cmd [[runtime! plugin/cody.lua]] vim.cmd [[runtime! plugin/cody-agent.lua]] + +require("sg").setup { + download_binaries = false, + accept_tos = true, +}