mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
docs: docs for rename
This commit is contained in:
parent
6673551e12
commit
dd97a2a659
2 changed files with 40 additions and 3 deletions
|
@ -5,14 +5,16 @@ local M = {}
|
|||
local uv = vim.uv or vim.loop
|
||||
|
||||
---@param path string
|
||||
function M.realpath(path)
|
||||
local function realpath(path)
|
||||
return vim.fs.normalize(uv.fs_realpath(path) or path)
|
||||
end
|
||||
|
||||
-- Prompt for the new filename,
|
||||
-- do the rename, and trigger LSP handlers
|
||||
function M.rename_file()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local old = assert(M.realpath(vim.api.nvim_buf_get_name(buf)))
|
||||
local root = assert(M.realpath(uv.cwd() or "."))
|
||||
local old = assert(realpath(vim.api.nvim_buf_get_name(buf)))
|
||||
local root = assert(realpath(uv.cwd() or "."))
|
||||
|
||||
if old:find(root, 1, true) ~= 1 then
|
||||
root = vim.fn.fnamemodify(old, ":p:h")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue