From f1ab803b9bbd3e4a75d2b314dd11330b110c218d Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Sat, 22 Jul 2023 21:19:27 -0700 Subject: [PATCH 1/4] code for copilot-rs usage + debug --- lua/copilot/api.lua | 1 - lua/copilot/auth.lua | 2 ++ lua/copilot/client.lua | 42 ++++++++++++++++++++++-------------------- lua/copilot/util.lua | 1 + 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lua/copilot/api.lua b/lua/copilot/api.lua index 64fc0691..151f8b54 100644 --- a/lua/copilot/api.lua +++ b/lua/copilot/api.lua @@ -1,5 +1,4 @@ local mod = {} - ---@param callback? fun(err: any|nil, data: table, ctx: table): nil ---@return any|nil err ---@return table data diff --git a/lua/copilot/auth.lua b/lua/copilot/auth.lua index d539a829..a1124ff8 100644 --- a/lua/copilot/auth.lua +++ b/lua/copilot/auth.lua @@ -1,4 +1,6 @@ local api = require("copilot.api") +local auth = require("copilot.auth") + local c = require("copilot.client") local M = {} diff --git a/lua/copilot/client.lua b/lua/copilot/client.lua index df948ccf..dcfcc281 100644 --- a/lua/copilot/client.lua +++ b/lua/copilot/client.lua @@ -47,9 +47,10 @@ end ---@return string function M.get_node_version() if not M.node_version then - local node = config.get("copilot_node_command") + -- local node = config.get("copilot_node_command") + local cmd = { "/home/zach/Dev/copilot/copilot-rs/target/debug/copilot-rs" } - local cmd = { node, "--version" } + -- local cmd = { node, "--version" } local cmd_output_table = vim.fn.systemlist(cmd, nil, false) local cmd_output = cmd_output_table[#cmd_output_table] local cmd_exit_code = vim.v.shell_error @@ -176,10 +177,11 @@ local function prepare_client_config(overrides) M.startup_error = nil return vim.tbl_deep_extend("force", { - cmd = { - node, - agent_path, - }, + cmd = { "/home/zach/Dev/copilot/copilot-rs/target/debug/copilot-rs" }, + -- cmd = { + -- node, + -- agent_path, + -- }, root_dir = vim.loop.cwd(), name = "copilot", get_language_id = function(_, filetype) @@ -190,20 +192,20 @@ local function prepare_client_config(overrides) M.capabilities = initialize_result.capabilities end - vim.schedule(function() - ---@type copilot_set_editor_info_params - local set_editor_info_params = util.get_editor_info() - set_editor_info_params.editorInfo.version = set_editor_info_params.editorInfo.version - .. " + Node.js " - .. M.get_node_version() - set_editor_info_params.editorConfiguration = util.get_editor_configuration() - set_editor_info_params.networkProxy = util.get_network_proxy() - api.set_editor_info(client, set_editor_info_params, function(err) - if err then - vim.notify(string.format("[copilot] setEditorInfo failure: %s", err), vim.log.levels.ERROR) - end - end) - end) + -- vim.schedule(function() + -- ---@type copilot_set_editor_info_params + -- local set_editor_info_params = util.get_editor_info() + -- set_editor_info_params.editorInfo.version = set_editor_info_params.editorInfo.version + -- .. " + Node.js " + -- .. M.get_node_version() + -- set_editor_info_params.editorConfiguration = util.get_editor_configuration() + -- set_editor_info_params.networkProxy = util.get_network_proxy() + -- -- api.set_editor_info(client, set_editor_info_params, function(err) + -- -- if err then + -- -- vim.notify(string.format("[copilot] setEditorInfo failure: %s", err), vim.log.levels.ERROR) + -- -- end + -- end) + -- end) end, on_exit = function(_code, _signal, client_id) if M.id == client_id then diff --git a/lua/copilot/util.lua b/lua/copilot/util.lua index 1dc75c98..8a2bd5be 100644 --- a/lua/copilot/util.lua +++ b/lua/copilot/util.lua @@ -182,6 +182,7 @@ function M.get_doc_params(overrides) relativePath = params.doc.relativePath, } params.position = params.doc.position + print(vim.inspect(params)) return params end From a72b9c630368df1cd1987bc6414ceadf893104f0 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Sun, 23 Jul 2023 19:17:25 -0700 Subject: [PATCH 2/4] use release verson --- lua/copilot/client.lua | 6 +----- lua/copilot/util.lua | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lua/copilot/client.lua b/lua/copilot/client.lua index dcfcc281..74808a5a 100644 --- a/lua/copilot/client.lua +++ b/lua/copilot/client.lua @@ -48,7 +48,7 @@ end function M.get_node_version() if not M.node_version then -- local node = config.get("copilot_node_command") - local cmd = { "/home/zach/Dev/copilot/copilot-rs/target/debug/copilot-rs" } + local cmd = { "/home/zach/Dev/copilot/copilot-rs/target/release/copilot-rs" } -- local cmd = { node, "--version" } local cmd_output_table = vim.fn.systemlist(cmd, nil, false) @@ -178,10 +178,6 @@ local function prepare_client_config(overrides) return vim.tbl_deep_extend("force", { cmd = { "/home/zach/Dev/copilot/copilot-rs/target/debug/copilot-rs" }, - -- cmd = { - -- node, - -- agent_path, - -- }, root_dir = vim.loop.cwd(), name = "copilot", get_language_id = function(_, filetype) diff --git a/lua/copilot/util.lua b/lua/copilot/util.lua index 8a2bd5be..b60a8165 100644 --- a/lua/copilot/util.lua +++ b/lua/copilot/util.lua @@ -182,8 +182,6 @@ function M.get_doc_params(overrides) relativePath = params.doc.relativePath, } params.position = params.doc.position - print(vim.inspect(params)) - return params end From 4d0d107a5d883c9759474e35fc0ed202e3db34ec Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Mon, 31 Jul 2023 22:23:32 -0700 Subject: [PATCH 3/4] log command --- lua/copilot/client.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/copilot/client.lua b/lua/copilot/client.lua index 74808a5a..ccdb15eb 100644 --- a/lua/copilot/client.lua +++ b/lua/copilot/client.lua @@ -2,6 +2,7 @@ local api = require("copilot.api") local config = require("copilot.config") local util = require("copilot.util") +local cmd = {"/home/zach/Dev/copilot/copilot-rs/target/release/copilot-rs" } local is_disabled = false local M = { @@ -48,7 +49,6 @@ end function M.get_node_version() if not M.node_version then -- local node = config.get("copilot_node_command") - local cmd = { "/home/zach/Dev/copilot/copilot-rs/target/release/copilot-rs" } -- local cmd = { node, "--version" } local cmd_output_table = vim.fn.systemlist(cmd, nil, false) @@ -177,7 +177,11 @@ local function prepare_client_config(overrides) M.startup_error = nil return vim.tbl_deep_extend("force", { - cmd = { "/home/zach/Dev/copilot/copilot-rs/target/debug/copilot-rs" }, + cmd = cmd, + cmd_env = { + RUST_LOG="info", + RUST_BACKTRACE="FULL", + }, root_dir = vim.loop.cwd(), name = "copilot", get_language_id = function(_, filetype) From 26a56da1adeb2e55680a1be666ec37940ced4876 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 4 Aug 2023 00:31:42 -0700 Subject: [PATCH 4/4] working --- lua/copilot/client.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/copilot/client.lua b/lua/copilot/client.lua index ccdb15eb..fe4b8bfe 100644 --- a/lua/copilot/client.lua +++ b/lua/copilot/client.lua @@ -179,7 +179,7 @@ local function prepare_client_config(overrides) return vim.tbl_deep_extend("force", { cmd = cmd, cmd_env = { - RUST_LOG="info", + RUST_LOG="debug", RUST_BACKTRACE="FULL", }, root_dir = vim.loop.cwd(),