Compare commits

...

4 Commits

Author SHA1 Message Date
David JULIEN 403304b60d
Merge branch 'dev' into venus
nvim: add mini.surround plugin
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2023-02-25 23:33:17 +01:00
David JULIEN 31862695f8 [nvim] feat: add mini.surround plugin 2023-02-25 23:24:49 +01:00
David JULIEN 14c84e7728
Merge branch 'dev' into venus
nvim: replace path in statusline by "/.../" when useful
2023-02-22 19:35:51 +01:00
David JULIEN 85b4b08824 [nvim] feat: replace path in statusline by "/.../" when useful 2023-02-22 19:35:15 +01:00
2 changed files with 21 additions and 3 deletions

View File

@ -40,5 +40,10 @@ return {
require("mini.indentscope").setup(opts)
end,
},
{
"echasnovski/mini.surround",
version = '*',
config = function() require("mini.surround").setup() end,
}
}

View File

@ -107,7 +107,13 @@ local function shorten_path(path, max_len)
end
local segments = vim.split(path, sep)
for idx = 1, #segments - 1 do
local start = 1
if segments[1] == "~" then
start = start + 1
end
for idx = start, #segments - 1 do
if len <= max_len then
break
end
@ -122,6 +128,13 @@ local function shorten_path(path, max_len)
len = len - (#segment - #shortened)
end
if (len > max_len and #segments > 3) then
while (len > max_len and #segments > 3) do
table.remove(segments, 2)
end
table.insert(segments,2, "...")
end
return table.concat(segments, sep)
end
@ -174,7 +187,7 @@ local function statusline_focused()
local left = table.concat {
gen_section(accent_color, { get_mode_display_name(mg) }),
gen_section("%#Middle#", { shorten_path(file, winwidth / 3) }),
gen_section("%#Middle#", { shorten_path(file, winwidth / 2) }),
gen_section("%#Bottom#", { "%m", "%r" }),
gen_section(
"%#Alert#",
@ -223,7 +236,7 @@ local function statusline_not_focused()
local winwidth = vim.fn.winwidth(0)
return table.concat {
gen_section("%#StatuslineNF#", {
shorten_path(file, winwidth / 3),
shorten_path(file, winwidth / 2),
"%m"
}),
"%=",