Large rewrite, simplify keymapping, utilize as much keys from Lazy as
possible. Reduce manually setup plugins and utilize opts instead.
This commit is contained in:
parent
72eb62b9cb
commit
43020a4d12
17 changed files with 408 additions and 780 deletions
|
|
@ -1,95 +1,86 @@
|
|||
return {
|
||||
"b0o/incline.nvim",
|
||||
dependencies = {
|
||||
"lewis6991/gitsigns.nvim"
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opts = {},
|
||||
keys = {
|
||||
{ "[g", function() require("gitsigns").nav_hunk("prev") end, },
|
||||
{ "]g", function() require("gitsigns").nav_hunk("next") end, },
|
||||
}
|
||||
}
|
||||
},
|
||||
event = "VeryLazy",
|
||||
lazy = true,
|
||||
config = function()
|
||||
local gitsigns = require("gitsigns")
|
||||
gitsigns.setup({})
|
||||
local devicons = require("nvim-web-devicons")
|
||||
require("incline").setup({
|
||||
window = {
|
||||
padding = 0,
|
||||
},
|
||||
hide = {
|
||||
cursorline = true,
|
||||
},
|
||||
render = function(props)
|
||||
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
|
||||
if filename == "" then
|
||||
filename = "[No Name]"
|
||||
end
|
||||
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
||||
opts = {
|
||||
window = {
|
||||
padding = 0,
|
||||
},
|
||||
hide = {
|
||||
cursorline = true,
|
||||
},
|
||||
render = function(props)
|
||||
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
|
||||
if filename == "" then
|
||||
filename = "[No Name]"
|
||||
end
|
||||
local ft_icon, ft_color = require("nvim-web-devicons").get_icon_color(filename)
|
||||
|
||||
local function get_git_diff()
|
||||
local icons = { removed = "", changed = "", added = "" }
|
||||
local signs = vim.b[props.buf].gitsigns_status_dict
|
||||
local labels = {}
|
||||
if signs == nil then
|
||||
return labels
|
||||
end
|
||||
for name, icon in pairs(icons) do
|
||||
if tonumber(signs[name]) and signs[name] > 0 then
|
||||
table.insert(labels, { icon .. " " .. signs[name] .. " ", group = "Diff" .. name })
|
||||
end
|
||||
end
|
||||
if #labels > 0 then
|
||||
table.insert(labels, { "┊ " })
|
||||
end
|
||||
local function get_git_diff()
|
||||
local icons = { removed = "", changed = "", added = "" }
|
||||
local signs = vim.b[props.buf].gitsigns_status_dict
|
||||
local labels = {}
|
||||
if signs == nil then
|
||||
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
|
||||
for name, icon in pairs(icons) do
|
||||
if tonumber(signs[name]) and signs[name] > 0 then
|
||||
table.insert(labels, { icon .. " " .. signs[name] .. " ", group = "Diff" .. name })
|
||||
end
|
||||
if #label > 0 then
|
||||
table.insert(label, { "┊ " })
|
||||
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
|
||||
return label
|
||||
end
|
||||
if #label > 0 then
|
||||
table.insert(label, { "┊ " })
|
||||
end
|
||||
return label
|
||||
end
|
||||
|
||||
local function get_arrow_label()
|
||||
local statusline = require("arrow.statusline")
|
||||
if statusline.is_on_arrow_file(props.buf) == nil then
|
||||
return ""
|
||||
end
|
||||
|
||||
local function get_arrow_label()
|
||||
local statusline = require("arrow.statusline")
|
||||
if statusline.is_on_arrow_file(props.buf) == nil then
|
||||
return ""
|
||||
end
|
||||
return " " .. statusline.text_for_statusline_with_icons(props.buf)
|
||||
end
|
||||
|
||||
return " " .. statusline.text_for_statusline_with_icons(props.buf)
|
||||
end
|
||||
|
||||
return {
|
||||
guibg = "#1e2030",
|
||||
guifg = "#cad3f5",
|
||||
{ " " },
|
||||
{ get_diagnostic_label() },
|
||||
{ get_git_diff() },
|
||||
{ (ft_icon or "") .. " ", guifg = ft_color, guibg = "none" },
|
||||
{ filename .. " ┊", gui = vim.bo[props.buf].modified and "bold,italic" or "bold" },
|
||||
{ get_arrow_label() .. " " .. vim.api.nvim_win_get_number(props.win), group = "DevIconWindows" },
|
||||
{ " " }
|
||||
}
|
||||
end,
|
||||
|
||||
require("utils").add_keymaps({
|
||||
n = {
|
||||
["[g"] = {
|
||||
cmd = function() gitsigns.nav_hunk("prev") end
|
||||
},
|
||||
["]g"] = {
|
||||
cmd = function() gitsigns.nav_hunk("next") end
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
end,
|
||||
return {
|
||||
guibg = "#1e2030",
|
||||
guifg = "#cad3f5",
|
||||
{ " " },
|
||||
{ get_diagnostic_label() },
|
||||
{ get_git_diff() },
|
||||
{ (ft_icon or "") .. " ", guifg = ft_color, guibg = "none" },
|
||||
{ filename .. " ┊", gui = vim.bo[props.buf].modified and "bold,italic" or "bold" },
|
||||
{ get_arrow_label() .. " " .. vim.api.nvim_win_get_number(props.win), group = "DevIconWindows" },
|
||||
{ " " }
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue