From 0d48f54f6e6a6f50f0f98f7d7beccbbaa7ac6c78 Mon Sep 17 00:00:00 2001 From: jinzhongjia Date: Wed, 8 Jan 2025 13:03:55 +0800 Subject: [PATCH] little fix --- lua/LspUI/lib/util.lua | 16 ++++++++++++++++ lua/LspUI/signature/util.lua | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/LspUI/lib/util.lua b/lua/LspUI/lib/util.lua index 46a426e..d25d7ec 100644 --- a/lua/LspUI/lib/util.lua +++ b/lua/LspUI/lib/util.lua @@ -241,4 +241,20 @@ function M.trim_empty_lines(lines) return vim.list_extend({}, lines, start, finish) end +-- 定义一个函数,将消息写入文件 +--- @param message any +---@param file_path string +function M.write_message_to_file(message, file_path) + local fd = uv.fs_open(file_path, "a", 438) -- 438 是文件权限,等同于 0666 + if not fd then + print("无法打开文件: " .. file_path) + return + end + + local stat = uv.fs_fstat(fd) + ---@diagnostic disable-next-line: need-check-nil + uv.fs_write(fd, message .. "\n", stat.size) + uv.fs_close(fd) +end + return M diff --git a/lua/LspUI/signature/util.lua b/lua/LspUI/signature/util.lua index d812b1f..7134d3b 100644 --- a/lua/LspUI/signature/util.lua +++ b/lua/LspUI/signature/util.lua @@ -28,10 +28,17 @@ local build_signature_info = function(help, client_name) return nil end + -- TODO: this is some debug info, maybe remove + -- write_message_to_file( + -- vim.inspect(help), + -- "C:\\Users\\jin\\Downloads\\log.txt" + -- ) + local active_signature, active_parameter -- this logic is in order to handle certain lsp specification implementations that are not standard if client_name == "basedpyright" then - active_signature = help.activeSignature and help.activeSignature or 1 + active_signature = help.activeSignature and help.activeSignature + 1 + or 1 active_parameter = help.activeParameter and help.activeParameter or 1 else active_signature = help.activeSignature and help.activeSignature + 1