feat: claude text editor tool (#1631)

This commit is contained in:
yetone
2025-03-19 00:09:49 +08:00
committed by GitHub
parent a8baee4354
commit 191d7b8783
11 changed files with 308 additions and 45 deletions

View File

@@ -916,6 +916,8 @@ function M.get_mentions()
}
end
---@param filepath string
---@return integer|nil bufnr
local function get_opened_buffer_by_filepath(filepath)
local project_root = M.get_project_root()
local absolute_path = M.join_paths(project_root, filepath)
@@ -925,10 +927,16 @@ local function get_opened_buffer_by_filepath(filepath)
return nil
end
---@param filepath string
---@return integer bufnr
function M.get_or_create_buffer_with_filepath(filepath)
-- Check if a buffer with this filepath already exists
local existing_buf = get_opened_buffer_by_filepath(filepath)
if existing_buf then return existing_buf end
if existing_buf then
-- goto this buffer
api.nvim_set_current_buf(existing_buf)
return existing_buf
end
-- Create a new buffer without setting its name
local buf = api.nvim_create_buf(true, false)