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,252 +45,242 @@ 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,
hl = {
fg = colors.statusline_bg,
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,
},
}
components.left.active[3] = {
provider = function() provider = function()
return "" local filename = vim.fn.expand "%:t"
end, local extension = vim.fn.expand "%:e"
highlight = { colors.nord_blue, colors.nord_blue }, local icon = require("nvim-web-devicons").get_icon(filename, extension)
}, if icon == nil then
} icon = ""
return icon
gls.left[2] = {
statusIcon = {
provider = function()
return statusline_style.main_icon
end,
highlight = { colors.statusline_bg, colors.nord_blue },
separator = right_separator,
separator_highlight = { colors.nord_blue, colors.one_bg2 },
},
}
gls.left[3] = {
left_arow2 = {
provider = function() end,
separator = right_separator .. " ",
separator_highlight = { colors.one_bg2, colors.lightbg },
},
}
gls.left[4] = {
FileIcon = {
provider = "FileIcon",
condition = condition.buffer_not_empty,
highlight = { colors.white, colors.lightbg },
},
}
gls.left[5] = {
FileName = {
provider = function()
local fileinfo = require "galaxyline.provider_fileinfo"
if vim.api.nvim_buf_get_name(0):len() == 0 then
return ""
end end
return icon .. " " .. filename .. " "
return fileinfo.get_current_file_name("", "")
end, end,
highlight = { colors.white, colors.lightbg }, hl = {
separator = right_separator, fg = colors.white,
separator_highlight = { colors.lightbg, colors.lightbg2 }, bg = colors.lightbg,
}, },
right_sep = { str = statusline_style.right, hl = { fg = colors.lightbg, bg = colors.lightbg2 } },
} }
gls.left[6] = { components.left.active[4] = {
current_dir = {
provider = function() provider = function()
local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
return "" .. dir_name .. " " return "" .. dir_name .. " "
end, end,
highlight = { colors.grey_fg2, colors.lightbg2 },
separator = right_separator, hl = {
separator_highlight = { colors.lightbg2, colors.statusline_bg }, fg = colors.grey_fg2,
bg = colors.lightbg2,
}, },
right_sep = { str = statusline_style.right, hi = {
fg = colors.lightbg2,
bg = colors.statusline_bg,
} },
} }
local checkwidth = function() components.left.active[5] = {
local squeeze_width = vim.fn.winwidth(0) / 2 provider = "git_diff_added",
if squeeze_width > 30 then hl = {
return true fg = colors.grey_fg2,
end bg = colors.statusline_bg,
return false },
end
gls.left[7] = {
DiffAdd = {
provider = "DiffAdd",
condition = checkwidth,
icon = "", icon = "",
highlight = { colors.white, colors.statusline_bg },
},
} }
-- diffModfified
gls.left[8] = { components.left.active[6] = {
DiffModified = { provider = "git_diff_changed",
provider = "DiffModified", hl = {
condition = checkwidth, fg = colors.grey_fg2,
bg = colors.statusline_bg,
},
icon = "", icon = "",
highlight = { colors.grey_fg2, colors.statusline_bg },
},
} }
-- diffRemove
gls.left[9] = { components.left.active[7] = {
DiffRemove = { provider = "git_diff_removed",
provider = "DiffRemove", hl = {
condition = checkwidth, fg = colors.grey_fg2,
bg = colors.statusline_bg,
},
icon = "", icon = "",
highlight = { colors.grey_fg2, colors.statusline_bg },
},
} }
gls.left[10] = { components.left.active[8] = {
DiagnosticError = { provider = "diagnostic_errors",
provider = "DiagnosticError", enabled = function()
return lsp.diagnostics_exist "Error"
end,
hl = { fg = colors.red },
icon = "", icon = "",
highlight = { colors.red, colors.statusline_bg },
},
} }
gls.left[11] = { components.left.active[9] = {
DiagnosticWarn = { provider = "diagnostic_warnings",
provider = "DiagnosticWarn", enabled = function()
return lsp.diagnostics_exist "Warning"
end,
hl = { fg = colors.yellow },
icon = "", icon = "",
highlight = { colors.yellow, colors.statusline_bg },
},
} }
gls.right[1] = { components.left.active[10] = {
lsp_status = { provider = "diagnostic_hints",
enabled = function()
return lsp.diagnostics_exist "Hint"
end,
hl = { fg = colors.grey_fg2 },
icon = "",
}
components.left.active[11] = {
provider = "diagnostic_info",
enabled = function()
return lsp.diagnostics_exist "Information"
end,
hl = { fg = colors.green },
icon = "",
}
components.right.active[1] = {
provider = function() provider = function()
local clients = vim.lsp.get_active_clients() if lsp.is_lsp_attached then
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" return " " .. "" .. " LSP"
end end
end
return ""
else
return ""
end
end, end,
highlight = { colors.grey_fg2, colors.statusline_bg }, hl = { fg = colors.grey_fg2, bg = colors.statusline_bg },
},
} }
gls.right[2] = { components.right.active[2] = {
GitIcon = { provider = "git_branch",
provider = function() hl = {
return "" fg = colors.grey_fg2,
end, bg = colors.statusline_bg,
condition = require("galaxyline.condition").check_git_workspace,
highlight = { colors.grey_fg2, colors.statusline_bg },
separator = " ",
separator_highlight = { colors.statusline_bg, colors.statusline_bg },
}, },
icon = "",
} }
gls.right[3] = { components.right.active[3] = {
GitBranch = { provider = " " .. statusline_style.left,
provider = "GitBranch", hl = {
condition = require("galaxyline.condition").check_git_workspace, fg = colors.one_bg2,
highlight = { colors.grey_fg2, colors.statusline_bg }, bg = 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,
} }
gls.right[5] = {
left_round = {
provider = function()
vim.cmd("hi Galaxyleft_round guifg=" .. mode(2))
return left_separator
end, end,
highlight = { "GalaxyViMode", colors.one_bg2 },
},
} }
gls.right[6] = { components.right.active[5] = {
viMode_icon = { provider = statusline_style.vi_mode_icon,
provider = function() hl = function()
vim.cmd("hi GalaxyviMode_icon guibg=" .. mode(2)) return {
return statusline_style.vi_mode_icon fg = colors.statusline_bg,
bg = mode_colors[vim.fn.mode()][2],
}
end, end,
highlight = { colors.statusline_bg, colors.red },
},
} }
gls.right[7] = { components.right.active[6] = {
ViMode = {
provider = function() provider = function()
vim.cmd("hi GalaxyViMode guifg=" .. mode(2)) return " " .. mode_colors[vim.fn.mode()][1] .. " "
return " " .. mode(1) .. " "
end, end,
highlight = { "GalaxyViMode", colors.lightbg }, hl = chad_mode_hl,
}
components.right.active[7] = {
provider = statusline_style.left,
hl = {
fg = colors.grey,
bg = colors.one_bg,
}, },
} }
gls.right[8] = { components.right.active[8] = {
left_arrow2 = { provider = statusline_style.left,
provider = function() end, hl = {
separator = left_separator, fg = colors.green,
separator_highlight = { colors.grey, colors.lightbg }, bg = colors.grey,
}, },
} }
gls.right[9] = { components.right.active[9] = {
some_RoundIcon = { provider = statusline_style.position_icon,
provider = function() hl = {
return statusline_style.position_icon fg = colors.black,
end, bg = colors.green,
separator = left_separator,
separator_highlight = { colors.green, colors.grey },
highlight = { colors.lightbg, colors.green },
}, },
} }
gls.right[10] = { components.right.active[10] = {
line_percentage = {
provider = function() provider = function()
local current_line = vim.fn.line "." local current_line = vim.fn.line "."
local total_line = vim.fn.line "$" local total_line = vim.fn.line "$"
@ -313,6 +293,15 @@ gls.right[10] = {
local result, _ = math.modf((current_line / total_line) * 100) local result, _ = math.modf((current_line / total_line) * 100)
return " " .. result .. " % " return " " .. result .. " % "
end, end,
highlight = { colors.green, colors.lightbg },
hl = {
fg = colors.green,
bg = colors.one_bg,
}, },
} }
require("feline").setup {
default_bg = colors.statusline_bg,
default_fg = colors.fg,
components = components,
}

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,