move to feline.nvim

This commit is contained in:
siduck76 2021-08-26 10:48:13 +05:30
parent 9635b45404
commit 80d36cca00
4 changed files with 219 additions and 230 deletions

View file

@ -82,7 +82,7 @@ M.plugin_status = {
comment = true, -- universal commentor comment = true, -- universal commentor
dashboard = true, -- a nice looking dashboard dashboard = true, -- a nice looking dashboard
esc_insertmode = true, -- escape from insert mode using custom keys esc_insertmode = true, -- escape from insert mode using custom keys
galaxyline = true, -- statusline feline = true, -- statusline
gitsigns = true, -- gitsigns in statusline gitsigns = true, -- gitsigns in statusline
lspkind = true, -- lsp enhancements lspkind = true, -- lsp enhancements
lspsignature = true, -- lsp enhancements lspsignature = true, -- lsp enhancements

View file

@ -86,7 +86,7 @@ M.plugin_status = {
comment = true, -- universal commentor comment = true, -- universal commentor
dashboard = true, -- a nice looking dashboard dashboard = true, -- a nice looking dashboard
esc_insertmode = true, -- escape from insert mode using custom keys esc_insertmode = true, -- escape from insert mode using custom keys
galaxyline = true, -- statusline feline = true, -- statusline
gitsigns = true, -- gitsigns in statusline gitsigns = true, -- gitsigns in statusline
lspkind = true, -- lsp enhancements lspkind = true, -- lsp enhancements
lspsignature = true, -- lsp enhancements lspsignature = true, -- lsp enhancements

View file

@ -1,14 +1,5 @@
local colors = require("colors").get() local colors = require("colors").get()
local lsp = require "feline.providers.lsp"
local present1, gl = pcall(require, "galaxyline")
local present2, condition = pcall(require, "galaxyline.condition")
if not (present1 or present2) then
return
end
local gls = gl.section
gl.short_line_list = { " " }
local icon_styles = { local icon_styles = {
default = { default = {
@ -18,7 +9,6 @@ local icon_styles = {
vi_mode_icon = "", vi_mode_icon = "",
position_icon = "", position_icon = "",
}, },
arrow = { arrow = {
left = "", left = "",
right = "", right = "",
@ -55,264 +45,263 @@ local icon_styles = {
local user_statusline_style = require("core.utils").load_config().ui.plugin.statusline.style local user_statusline_style = require("core.utils").load_config().ui.plugin.statusline.style
local statusline_style = icon_styles[user_statusline_style] local statusline_style = icon_styles[user_statusline_style]
local left_separator = statusline_style.left -- Initialize the components table
local right_separator = statusline_style.right local components = {
left = { active = {}, inactive = {} },
mid = { active = {}, inactive = {} },
right = { active = {}, inactive = {} },
}
gls.left[1] = { components.left.active[1] = {
FirstElement = { provider = statusline_style.main_icon,
provider = function()
return "" hl = {
end, fg = colors.statusline_bg,
highlight = { colors.nord_blue, colors.nord_blue }, bg = colors.nord_blue,
},
right_sep = { str = statusline_style.right, hl = {
fg = colors.nord_blue,
bg = colors.one_bg2,
} },
}
components.left.active[2] = {
provider = statusline_style.right,
hl = {
fg = colors.one_bg2,
bg = colors.lightbg,
}, },
} }
gls.left[2] = { components.left.active[3] = {
statusIcon = { provider = function()
provider = function() local filename = vim.fn.expand "%:t"
return statusline_style.main_icon local extension = vim.fn.expand "%:e"
end, local icon = require("nvim-web-devicons").get_icon(filename, extension)
highlight = { colors.statusline_bg, colors.nord_blue }, if icon == nil then
separator = right_separator, icon = ""
separator_highlight = { colors.nord_blue, colors.one_bg2 }, return icon
end
return icon .. " " .. filename .. " "
end,
hl = {
fg = colors.white,
bg = colors.lightbg,
}, },
right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } },
} }
gls.left[3] = { components.left.active[4] = {
left_arow2 = { provider = function()
provider = function() end, local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
separator = right_separator .. " ", return "" .. dir_name .. " "
separator_highlight = { colors.one_bg2, colors.lightbg }, end,
hl = {
fg = colors.grey_fg2,
bg = colors.lightbg2,
}, },
right_sep = { str = statusline_style.right, hi = {
fg = colors.lightbg2,
bg = colors.statusline_bg,
} },
} }
gls.left[4] = { components.left.active[5] = {
FileIcon = { provider = "git_diff_added",
provider = "FileIcon", hl = {
condition = condition.buffer_not_empty, fg = colors.grey_fg2,
highlight = { colors.white, colors.lightbg }, bg = colors.statusline_bg,
}, },
icon = "",
}
-- diffModfified
components.left.active[6] = {
provider = "git_diff_changed",
hl = {
fg = colors.grey_fg2,
bg = colors.statusline_bg,
},
icon = "",
}
-- diffRemove
components.left.active[7] = {
provider = "git_diff_removed",
hl = {
fg = colors.grey_fg2,
bg = colors.statusline_bg,
},
icon = "",
} }
gls.left[5] = { components.left.active[8] = {
FileName = { provider = "diagnostic_errors",
provider = function() enabled = function()
local fileinfo = require "galaxyline.provider_fileinfo" return lsp.diagnostics_exist "Error"
end,
if vim.api.nvim_buf_get_name(0):len() == 0 then hl = { fg = colors.red },
return "" icon = "",
end
return fileinfo.get_current_file_name("", "")
end,
highlight = { colors.white, colors.lightbg },
separator = right_separator,
separator_highlight = { colors.lightbg, colors.lightbg2 },
},
} }
gls.left[6] = { components.left.active[9] = {
current_dir = { provider = "diagnostic_warnings",
provider = function() enabled = function()
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") return lsp.diagnostics_exist "Warning"
return "" .. dir_name .. " " end,
end, hl = { fg = colors.yellow },
highlight = { colors.grey_fg2, colors.lightbg2 }, icon = "",
separator = right_separator,
separator_highlight = { colors.lightbg2, colors.statusline_bg },
},
} }
local checkwidth = function() components.left.active[10] = {
local squeeze_width = vim.fn.winwidth(0) / 2 provider = "diagnostic_hints",
if squeeze_width > 30 then enabled = function()
return true return lsp.diagnostics_exist "Hint"
end end,
return false hl = { fg = colors.grey_fg2 },
end icon = "",
gls.left[7] = {
DiffAdd = {
provider = "DiffAdd",
condition = checkwidth,
icon = "",
highlight = { colors.white, colors.statusline_bg },
},
} }
gls.left[8] = { components.left.active[11] = {
DiffModified = { provider = "diagnostic_info",
provider = "DiffModified", enabled = function()
condition = checkwidth, return lsp.diagnostics_exist "Information"
icon = "", end,
highlight = { colors.grey_fg2, colors.statusline_bg }, hl = { fg = colors.green },
}, icon = "",
} }
gls.left[9] = { components.right.active[1] = {
DiffRemove = { provider = function()
provider = "DiffRemove", if lsp.is_lsp_attached then
condition = checkwidth, return " " .. "" .. " LSP"
icon = "", end
highlight = { colors.grey_fg2, colors.statusline_bg }, end,
}, hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
} }
gls.left[10] = { components.right.active[2] = {
DiagnosticError = { provider = "git_branch",
provider = "DiagnosticError", hl = {
icon = "", fg = colors.grey_fg2,
highlight = { colors.red, colors.statusline_bg }, bg = colors.statusline_bg,
}, },
icon = "",
} }
gls.left[11] = { components.right.active[3] = {
DiagnosticWarn = { provider = " " .. statusline_style.left,
provider = "DiagnosticWarn", hl = {
icon = "", fg = colors.one_bg2,
highlight = { colors.yellow, colors.statusline_bg }, bg = colors.statusline_bg,
},
}
gls.right[1] = {
lsp_status = {
provider = function()
local clients = vim.lsp.get_active_clients()
if next(clients) ~= nil then
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return " " .. "" .. " LSP"
end
end
return ""
else
return ""
end
end,
highlight = { colors.grey_fg2, colors.statusline_bg },
},
}
gls.right[2] = {
GitIcon = {
provider = function()
return ""
end,
condition = require("galaxyline.condition").check_git_workspace,
highlight = { colors.grey_fg2, colors.statusline_bg },
separator = " ",
separator_highlight = { colors.statusline_bg, colors.statusline_bg },
},
}
gls.right[3] = {
GitBranch = {
provider = "GitBranch",
condition = require("galaxyline.condition").check_git_workspace,
highlight = { colors.grey_fg2, colors.statusline_bg },
}, },
} }
local mode_colors = { local mode_colors = {
['n'] = { "NORMAL", colors.red }, ["n"] = { "NORMAL", colors.red },
['no'] = { "N-PENDING", colors.red }, ["no"] = { "N-PENDING", colors.red },
['i'] = { "INSERT", colors.dark_purple }, ["i"] = { "INSERT", colors.dark_purple },
['ic'] = { "INSERT", colors.dark_purple }, ["ic"] = { "INSERT", colors.dark_purple },
['t'] = { "TERMINAL", colors.green }, ["t"] = { "TERMINAL", colors.green },
['v'] = { "VISUAL", colors.cyan }, ["v"] = { "VISUAL", colors.cyan },
['V'] = { "V-LINE", colors.cyan }, ["V"] = { "V-LINE", colors.cyan },
[''] = { "V-BLOCK", colors.cyan }, [""] = { "V-BLOCK", colors.cyan },
['R'] = { "REPLACE", colors.orange }, ["R"] = { "REPLACE", colors.orange },
['Rv'] = { "V-REPLACE", colors.orange }, ["Rv"] = { "V-REPLACE", colors.orange },
['s'] = { "SELECT", colors.nord_blue }, ["s"] = { "SELECT", colors.nord_blue },
['S'] = { "S-LINE", colors.nord_blue }, ["S"] = { "S-LINE", colors.nord_blue },
[''] = { "S-BLOCK", colors.nord_blue }, [""] = { "S-BLOCK", colors.nord_blue },
['c'] = { "COMMAND", colors.pink }, ["c"] = { "COMMAND", colors.pink },
['cv'] = { "COMMAND", colors.pink }, ["cv"] = { "COMMAND", colors.pink },
['ce'] = { "COMMAND", colors.pink }, ["ce"] = { "COMMAND", colors.pink },
['r'] = { "PROMPT", colors.teal }, ["r"] = { "PROMPT", colors.teal },
['rm'] = { "MORE", colors.teal }, ["rm"] = { "MORE", colors.teal },
['r?'] = { "CONFIRM", colors.teal }, ["r?"] = { "CONFIRM", colors.teal },
['!'] = { "SHELL", colors.green }, ["!"] = { "SHELL", colors.green },
} }
local mode = function(n) local chad_mode_hl = function()
return mode_colors[vim.fn.mode()][n] return {
fg = mode_colors[vim.fn.mode()][2],
bg = colors.one_bg,
}
end end
gls.right[4] = { components.right.active[4] = {
left_arrow = { provider = statusline_style.left,
provider = function() end, hl = function()
separator = " " .. left_separator, return {
separator_highlight = { colors.one_bg2, colors.statusline_bg }, fg = mode_colors[vim.fn.mode()][2],
bg = colors.one_bg2,
}
end,
}
components.right.active[5] = {
provider = statusline_style.vi_mode_icon,
hl = function()
return {
fg = colors.statusline_bg,
bg = mode_colors[vim.fn.mode()][2],
}
end,
}
components.right.active[6] = {
provider = function()
return " " .. mode_colors[vim.fn.mode()][1] .. " "
end,
hl = chad_mode_hl,
}
components.right.active[7] = {
provider = statusline_style.left,
hl = {
fg = colors.grey,
bg = colors.one_bg,
}, },
} }
gls.right[5] = { components.right.active[8] = {
left_round = { provider = statusline_style.left,
provider = function() hl = {
vim.cmd("hi Galaxyleft_round guifg=" .. mode(2)) fg = colors.green,
return left_separator bg = colors.grey,
end,
highlight = { "GalaxyViMode", colors.one_bg2 },
}, },
} }
gls.right[6] = { components.right.active[9] = {
viMode_icon = { provider = statusline_style.position_icon,
provider = function() hl = {
vim.cmd("hi GalaxyviMode_icon guibg=" .. mode(2)) fg = colors.black,
return statusline_style.vi_mode_icon bg = colors.green,
end,
highlight = { colors.statusline_bg, colors.red },
}, },
} }
gls.right[7] = { components.right.active[10] = {
ViMode = { provider = function()
provider = function() local current_line = vim.fn.line "."
vim.cmd("hi GalaxyViMode guifg=" .. mode(2)) local total_line = vim.fn.line "$"
return " " .. mode(1) .. " "
end, if current_line == 1 then
highlight = { "GalaxyViMode", colors.lightbg }, return " Top "
elseif current_line == vim.fn.line "$" then
return " Bot "
end
local result, _ = math.modf((current_line / total_line) * 100)
return " " .. result .. " % "
end,
hl = {
fg = colors.green,
bg = colors.one_bg,
}, },
} }
gls.right[8] = { require("feline").setup {
left_arrow2 = { default_bg = colors.statusline_bg,
provider = function() end, default_fg = colors.fg,
separator = left_separator, components = components,
separator_highlight = { colors.grey, colors.lightbg },
},
}
gls.right[9] = {
some_RoundIcon = {
provider = function()
return statusline_style.position_icon
end,
separator = left_separator,
separator_highlight = { colors.green, colors.grey },
highlight = { colors.lightbg, colors.green },
},
}
gls.right[10] = {
line_percentage = {
provider = function()
local current_line = vim.fn.line "."
local total_line = vim.fn.line "$"
if current_line == 1 then
return " Top "
elseif current_line == vim.fn.line "$" then
return " Bot "
end
local result, _ = math.modf((current_line / total_line) * 100)
return " " .. result .. "% "
end,
highlight = { colors.green, colors.lightbg },
},
} }

View file

@ -38,8 +38,8 @@ return packer.startup(function()
} }
use { use {
"glepnir/galaxyline.nvim", "famiu/feline.nvim",
disable = not plugin_status.galaxyline, disable = not plugin_status.feline,
after = "nvim-web-devicons", after = "nvim-web-devicons",
config = function() config = function()
require "plugins.configs.statusline" require "plugins.configs.statusline"
@ -49,7 +49,7 @@ return packer.startup(function()
use { use {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
disable = not plugin_status.bufferline, disable = not plugin_status.bufferline,
after = "galaxyline.nvim", after = "feline.nvim",
config = function() config = function()
require "plugins.configs.bufferline" require "plugins.configs.bufferline"
end, end,