mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 11:40:36 +00:00
refactor(incline.lua): change window placement to right for better UI consistency
feat(incline.lua): add function shortenPath to truncate long file paths for display
This commit is contained in:
@@ -2,61 +2,41 @@ local incline = require("incline")
|
|||||||
local helpers = require("incline.helpers")
|
local helpers = require("incline.helpers")
|
||||||
local devicons = require("nvim-web-devicons")
|
local devicons = require("nvim-web-devicons")
|
||||||
|
|
||||||
|
local function shortenPath(str, max)
|
||||||
|
if #str > max then
|
||||||
|
local start = #str - max + 1
|
||||||
|
return "..." .. string.sub(str, start)
|
||||||
|
end
|
||||||
|
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
incline.setup({
|
incline.setup({
|
||||||
window = {
|
window = {
|
||||||
padding = 0,
|
padding = 0,
|
||||||
margin = { horizontal = 0 },
|
margin = { horizontal = 0 },
|
||||||
},
|
placement = {
|
||||||
render = function(props)
|
horizontal = "right",
|
||||||
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
|
},
|
||||||
local filepath = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":p")
|
},
|
||||||
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
render = function(props)
|
||||||
local modified = vim.bo[props.buf].modified
|
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
|
||||||
|
local filepath = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":p")
|
||||||
|
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
||||||
|
local modified = vim.bo[props.buf].modified
|
||||||
|
|
||||||
local path = vim.fn.fnamemodify(filepath, ":~:.") -- Get relative path
|
local path = vim.fn.fnamemodify(filepath, ":~:.") -- Get relative path
|
||||||
|
path = shortenPath(path, 30)
|
||||||
|
|
||||||
-- local function get_git_diff()
|
-- Shorten path from the left if the entire line is longer than 100 characters
|
||||||
-- local icons = { removed = "", changed = "", added = "" }
|
|
||||||
-- local signs = vim.b[props.buf].gitsigns_status_dict
|
--
|
||||||
-- local labels = {}
|
return {
|
||||||
-- if signs == nil then
|
ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
|
||||||
-- return labels
|
" ",
|
||||||
-- end
|
{ path, gui = modified and "bold,italic" or "bold" },
|
||||||
-- for name, icon in pairs(icons) do
|
" ",
|
||||||
-- if tonumber(signs[name]) and signs[name] > 0 then
|
guibg = "#44406e",
|
||||||
-- table.insert(labels, { icon .. signs[name] .. " ", group = "Diff" .. name })
|
}
|
||||||
-- end
|
end,
|
||||||
-- end
|
|
||||||
-- if #labels > 0 then
|
|
||||||
-- table.insert(labels, { "┊ " })
|
|
||||||
-- end
|
|
||||||
-- return labels
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- local function get_diagnostic_label()
|
|
||||||
-- local icons = { error = "", warn = "", info = "", hint = "" }
|
|
||||||
-- local label = {}
|
|
||||||
--
|
|
||||||
-- for severity, icon in pairs(icons) do
|
|
||||||
-- local n = #vim.diagnostic.get(props.buf, { severity = vim.diagnostic.severity[string.upper(severity)] })
|
|
||||||
-- if n > 0 then
|
|
||||||
-- table.insert(label, { icon .. n .. " ", group = "DiagnosticSign" .. severity })
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- if #label > 0 then
|
|
||||||
-- table.insert(label, { "┊ " })
|
|
||||||
-- end
|
|
||||||
-- return label
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
return {
|
|
||||||
-- { get_diagnostic_label() },
|
|
||||||
-- { get_git_diff() },
|
|
||||||
ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
|
|
||||||
" ",
|
|
||||||
{ path, gui = modified and "bold,italic" or "bold" },
|
|
||||||
" ",
|
|
||||||
guibg = "#44406e",
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user