mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-07-01 11:22:23 +02:00
Compare commits
2 Commits
5f8e087d8a
...
25f8a5cd15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25f8a5cd15 | ||
|
|
cc449aec74 |
@@ -23,10 +23,13 @@ function M.tabline()
|
|||||||
local label = i .. ': ' .. vim.fn.fnamemodify(bufname, ':t') .. modified
|
local label = i .. ': ' .. vim.fn.fnamemodify(bufname, ':t') .. modified
|
||||||
|
|
||||||
-- truncate/pad to fixed tab_width
|
-- truncate/pad to fixed tab_width
|
||||||
if #label > tab_width - 2 then
|
if vim.fn.strwidth(label) > tab_width - 2 then
|
||||||
label = label:sub(1, tab_width - 3) .. '…'
|
while vim.fn.strwidth(label) > tab_width - 3 and #label > 0 do
|
||||||
|
label = label:sub(1, -2)
|
||||||
|
end
|
||||||
|
label = label .. '…'
|
||||||
end
|
end
|
||||||
label = label .. string.rep(' ', tab_width - #label)
|
label = label .. string.rep(' ', tab_width - vim.fn.strwidth(label))
|
||||||
|
|
||||||
tabs[i] = (i == current_tab and '%#TabLineSel#' or '%#TabLine#') .. label
|
tabs[i] = (i == current_tab and '%#TabLineSel#' or '%#TabLine#') .. label
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -242,14 +242,12 @@ local function smart_save(force_save_as)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Preserve cursor position and undo history
|
-- Preserve cursor position
|
||||||
local old_buf = vim.api.nvim_get_current_buf()
|
local old_buf = vim.api.nvim_get_current_buf()
|
||||||
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
||||||
local undo_history = vim.fn.getbufinfo(old_buf)[1].changedtick
|
|
||||||
vim.cmd('edit ' .. vim.fn.fnameescape(filename))
|
vim.cmd('edit ' .. vim.fn.fnameescape(filename))
|
||||||
vim.cmd 'filetype detect'
|
vim.cmd 'filetype detect'
|
||||||
vim.api.nvim_win_set_cursor(0, cursor_pos)
|
vim.api.nvim_win_set_cursor(0, cursor_pos)
|
||||||
vim.cmd 'undojoin'
|
|
||||||
vim.api.nvim_buf_delete(old_buf, { force = true })
|
vim.api.nvim_buf_delete(old_buf, { force = true })
|
||||||
end
|
end
|
||||||
print('Saved as ' .. filename)
|
print('Saved as ' .. filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user