From f3d63d45985577f7a9cb07cc58d5243864112cad Mon Sep 17 00:00:00 2001 From: Chanakan Mungtin Date: Mon, 2 May 2022 18:47:20 +0700 Subject: [PATCH] make sure to use node on js file --- lua/copilot/copilot_handler.lua | 45 +++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/lua/copilot/copilot_handler.lua b/lua/copilot/copilot_handler.lua index 13835b74..b6a6dac2 100644 --- a/lua/copilot/copilot_handler.lua +++ b/lua/copilot/copilot_handler.lua @@ -22,20 +22,37 @@ local register_autocmd = function () end M.merge_server_opts = function (params) - return vim.tbl_deep_extend("force", { - cmd = { require("copilot.util").get_copilot_path(params.plugin_manager_path) }, - name = "copilot", - trace = "messages", - root_dir = vim.loop.cwd(), - autostart = true, - on_init = function(_, _) - vim.schedule(M.buf_attach_copilot) - vim.schedule(register_autocmd) - end, - on_attach = function() - vim.schedule_wrap(params.on_attach()) - end, - }, params.server_opts_overrides or {}) + if vim.fn.has("win32") then + return vim.tbl_deep_extend("force", { + cmd = { 'node', require("copilot.util").get_copilot_path(params.plugin_manager_path) }, + name = "copilot", + trace = "messages", + root_dir = vim.loop.cwd(), + autostart = true, + on_init = function(_, _) + vim.schedule(M.buf_attach_copilot) + vim.schedule(register_autocmd) + end, + on_attach = function() + vim.schedule_wrap(params.on_attach()) + end, + }, params.server_opts_overrides or {}) + else + return vim.tbl_deep_extend("force", { + cmd = { require("copilot.util").get_copilot_path(params.plugin_manager_path) }, + name = "copilot", + trace = "messages", + root_dir = vim.loop.cwd(), + autostart = true, + on_init = function(_, _) + vim.schedule(M.buf_attach_copilot) + vim.schedule(register_autocmd) + end, + on_attach = function() + vim.schedule_wrap(params.on_attach()) + end, + }, params.server_opts_overrides or {}) + end end M.start = function(params)