From 342c06bd0959b61be72fbec97ba5c5758d6cc762 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Wed, 28 May 2025 14:55:25 +0200 Subject: [PATCH 1/3] [FIX] nvim: replace print by nvim_echo() --- plugin/command.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugin/command.lua b/plugin/command.lua index 7dfad10..9d3a314 100644 --- a/plugin/command.lua +++ b/plugin/command.lua @@ -4,9 +4,6 @@ command.target = "0.4.0" command.bin_path = "" local download = function(url, output_path, asset_type) - print("Starting download from: " .. url) - print("Saving to: " .. output_path) - local stdout = vim.uv.new_pipe(false) local stderr = vim.uv.new_pipe(false) @@ -19,6 +16,9 @@ local download = function(url, output_path, asset_type) cmd = "git" args = { "clone", "-q", url, output_path} end + vim.api.nvim_echo({{"Starting download from: " .. url}}, true, {}) + vim.api.nvim_echo({{"Saving to: " .. output_path}}, true, {}) + handle = vim.uv.spawn(cmd, { args = args, stdio = { nil, stdout, stderr }, @@ -27,11 +27,13 @@ local download = function(url, output_path, asset_type) stderr:close() handle:close() - if code == 0 then - print("\nDownload successful!") - else - print("\nDownload failed with exit code " .. code) + local msg = {"\nDownload successful!"} + if code ~= 0 then + msg = {"\nDownload failed with exit code " .. code} end + vim.schedule(function() + vim.api.nvim_echo({msg}, true, {}) + end) end) stdout:read_start(function(err, data) @@ -64,7 +66,7 @@ local download_requirements = function() if vim.fn.isdirectory(path) == 0 then download('https://github.com/python/typeshed.git', path, 'repo') else - print("typeshed already downloaded") + vim.api.nvim_echo({{"typeshed already downloaded"}}, true, {}) end else vim.api.nvim_err_writeln("git needed to download python typeshed") From 1eb0f3f1f6bedec982be68b826d66f3b9aab8323 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Wed, 28 May 2025 14:56:42 +0200 Subject: [PATCH 2/3] [FIX] nvim: change rule at download Set the downloaded server executable mod at the download step instead of after. --- plugin/command.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/command.lua b/plugin/command.lua index 9d3a314..bc7ccde 100644 --- a/plugin/command.lua +++ b/plugin/command.lua @@ -30,6 +30,8 @@ local download = function(url, output_path, asset_type) local msg = {"\nDownload successful!"} if code ~= 0 then msg = {"\nDownload failed with exit code " .. code} + else + vim.uv.fs_chmod(output_path, 493) end vim.schedule(function() vim.api.nvim_echo({msg}, true, {}) @@ -71,7 +73,6 @@ local download_requirements = function() else vim.api.nvim_err_writeln("git needed to download python typeshed") end - os.execute('chmod +x ' .. bin_path) vim.cmd.LspStart('odools') end From e0456716ddff812c584b7f60973818637d931d1c Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Wed, 28 May 2025 14:57:59 +0200 Subject: [PATCH 3/3] [FIX] nvim: make sure the server is deleted before installing a new one --- plugin/command.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugin/command.lua b/plugin/command.lua index bc7ccde..9d8be84 100644 --- a/plugin/command.lua +++ b/plugin/command.lua @@ -1,4 +1,3 @@ -local util = require('odools.utils') local command = {} command.target = "0.4.0" command.bin_path = "" @@ -10,6 +9,10 @@ local download = function(url, output_path, asset_type) local handle local args, cmd if asset_type == "file" then + if vim.fn.filereadable(output_path) == 1 then + vim.api.nvim_echo({{"Delete previous file"}}, true, {}) + vim.uv.fs_unlink(output_path) + end cmd = "wget" args = { "-qO", output_path, url } else @@ -61,7 +64,6 @@ local download_requirements = function() if vim.fn.isdirectory(bin_dir_path) == 0 then os.execute('mkdir -p ' .. bin_dir_path) end - vim.cmd.LspStop('odools') download("https://github.com/odoo/odoo-ls/releases/download/" .. command.target .. "/odoo_ls_server", bin_path, 'file') if vim.fn.executable('git') == 1 then local path = bin_dir_path .. '/typeshed' @@ -73,7 +75,7 @@ local download_requirements = function() else vim.api.nvim_err_writeln("git needed to download python typeshed") end - vim.cmd.LspStart('odools') + vim.cmd.LspRestart('odools') end local odoo_command = function(opts)