mirror of
https://github.com/boxpositron/absolute-vim.git
synced 2026-02-28 11:40:36 +00:00
style(incline.lua): fix indentation and formatting for better code readability
feat(incline.lua): add hide option to hide cursorline in the setup configuration feat(incline.lua): improve path shortening logic for long lines in the render function
This commit is contained in:
@@ -3,40 +3,43 @@ local helpers = require("incline.helpers")
|
|||||||
local devicons = require("nvim-web-devicons")
|
local devicons = require("nvim-web-devicons")
|
||||||
|
|
||||||
local function shortenPath(str, max)
|
local function shortenPath(str, max)
|
||||||
if #str > max then
|
if #str > max then
|
||||||
local start = #str - max + 1
|
local start = #str - max + 1
|
||||||
return "..." .. string.sub(str, start)
|
return "..." .. string.sub(str, start)
|
||||||
end
|
end
|
||||||
|
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
incline.setup({
|
incline.setup({
|
||||||
window = {
|
hide = {
|
||||||
padding = 0,
|
cursorline = true,
|
||||||
margin = { horizontal = 0 },
|
},
|
||||||
placement = {
|
window = {
|
||||||
horizontal = "right",
|
padding = 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)
|
path = shortenPath(path, 30)
|
||||||
|
|
||||||
-- Shorten path from the left if the entire line is longer than 100 characters
|
-- Shorten path from the left if the entire line is longer than 100 characters
|
||||||
|
|
||||||
--
|
--
|
||||||
return {
|
return {
|
||||||
ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
|
ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
|
||||||
" ",
|
" ",
|
||||||
{ path, gui = modified and "bold,italic" or "bold" },
|
{ path, gui = modified and "bold,italic" or "bold" },
|
||||||
" ",
|
" ",
|
||||||
guibg = "#44406e",
|
guibg = "#44406e",
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user