feat: use feline instead of lualine

This commit is contained in:
fiplox 2023-06-20 19:00:40 +02:00
parent fcfeec97a0
commit 6f4b4ae1b8
4 changed files with 346 additions and 47 deletions

View File

@ -16,7 +16,7 @@ vim.opt.runtimepath:prepend(lazypath)
vim.api.nvim_create_autocmd('User', {
pattern = 'LazyVimStarted',
callback = function()
require 'lualine'
require 'feline'
require 'config.mappings'
require 'config.autocmd'
-- require 'noice'

View File

@ -49,4 +49,288 @@ M.lsp_config = {
},
}
M.lspservername = function()
local msg = ''
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then return msg end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end
M.feline_theme = {
fg = '#c9d1d9',
bg = '#101010',
green = '#66cc66',
yellow = '#ffdd11',
purple = '#c678dd',
orange = '#cc8c3c',
peanut = '#f6d5a4',
red = '#e06c75',
aqua = '#61afef',
bg2 = '#484848',
dark_red = '#f75f5f',
normal = '#A9A9A9'
}
M.feline_vi_mode_colors = {
NORMAL = 'normal',
OP = 'green',
INSERT = 'yellow',
VISUAL = 'orange',
LINES = 'orange',
BLOCK = 'dark_red',
REPLACE = 'red',
COMMAND = 'aqua',
}
local left_component_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local right_component_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local left_section_separator = {
str = '█',
hl = {
fg = 'normal',
},
}
local right_section_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local function selectionCount()
local isVisualMode = vim.fn.mode():find("[Vv]")
if not isVisualMode then return "" end
local starts = vim.fn.line("v")
local ends = vim.fn.line(".")
local lines = starts <= ends and ends - starts + 1 or starts - ends + 1
return "" .. tostring(lines) .. "L " .. tostring(vim.fn.wordcount().visual_chars) .. "C"
end
M.feline_c = {
right_separator = {
provider = '',
left_sep = ' ',
hl = {
fg = '#484848'
}
},
left_separator = {
provider = '',
left_sep = ' ',
hl = {
fg = '#484848'
}
},
vim_mode = {
provider = {
name = 'vi_mode',
opts = {
show_mode_name = true,
-- padding = "center", -- Uncomment for extra padding.
},
},
hl = function()
return {
bg = require('feline.providers.vi_mode').get_mode_color(),
fg = 'bg',
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = 'block',
right_sep = {
str = '█',
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
},
},
diagnostic_errors = {
provider = 'diagnostic_errors',
hl = {
fg = 'red',
},
},
diagnostic_warnings = {
provider = 'diagnostic_warnings',
hl = {
fg = 'yellow',
},
},
diagnostic_hints = {
provider = 'diagnostic_hints',
hl = {
fg = 'aqua',
},
},
diagnostic_info = {
provider = 'diagnostic_info',
},
file_info = {
provider = {
name = 'file_info',
opts = {
colored_icon = true,
type = 'relative-short',
},
},
hl = {
fg = 'bg2',
},
left_sep = ' ',
},
lsp_client_names = {
provider = 'lsp_client_names',
hl = {
fg = 'bg2',
},
left_sep = 'right',
},
file_type = {
provider = {
name = 'file_type',
opts = {
filetype_icon = false,
colored_icon = false,
case = 'lowercase',
},
},
hl = {
fg = 'bg2',
},
left_sep = left_component_separator,
right_sep = ' ',
},
file_encoding = {
provider = 'file_encoding',
hl = {
fg = 'bg2',
},
left_sep = left_component_separator,
right_sep = ' ',
},
position = {
provider = 'position',
hl = function()
return {
bg = require('feline.providers.vi_mode').get_mode_color(),
fg = 'bg',
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
right_sep = 'block',
left_sep = {
str = '█',
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
},
},
select_count = {
provider = selectionCount,
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = ' ',
right_sep = ' ',
},
line_percentage = {
provider = 'line_percentage',
hl = {
fg = 'normal',
},
left_sep = ' ',
right_sep = ' ',
},
scroll_bar = {
provider = 'scroll_bar',
hl = {
fg = 'yellow',
style = 'bold',
},
},
search_count = {
provider = 'search_count',
left_sep = left_component_separator,
right_sep = ' ',
},
macro = {
provider = 'macro',
hl = {
style = 'bold',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitBranch = {
provider = 'git_branch',
hl = {
fg = 'peanut',
bg = 'bg2',
style = 'bold',
},
left_sep = ' ',
right_sep = right_section_separator,
},
gitDiffAdded = {
provider = 'git_diff_added',
hl = {
fg = 'green',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffRemoved = {
provider = 'git_diff_removed',
hl = {
fg = 'red',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffChanged = {
provider = 'git_diff_changed',
hl = {
fg = 'fg',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'right_filled',
},
}
return M

61
lua/plugins/feline.lua Normal file
View File

@ -0,0 +1,61 @@
return {
'feline-nvim/feline.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
local feline = require 'feline'
local utils = require 'config.utils'
local c = utils.feline_c
local theme = utils.feline_theme
local vi_mode_colors = utils.feline_vi_mode_colors
local left = {
c.vim_mode,
-- c.gitBranch,
-- c.gitDiffAdded,
-- c.gitDiffRemoved,
-- c.gitDiffChanged,
c.file_info,
c.right_separator,
c.lsp_client_names,
c.diagnostic_errors,
c.diagnostic_warnings,
c.diagnostic_info,
c.diagnostic_hints,
}
-- local middle = {
-- c.separator,
-- }
local right = {
c.file_type,
c.search_count,
c.macro,
c.file_encoding,
c.line_percentage,
c.select_count,
c.position,
}
local components = {
active = {
left,
-- middle,
right,
},
inactive = {
left,
-- middle,
right,
},
}
feline.setup {
components = components,
theme = theme,
vi_mode_colors = vi_mode_colors,
}
end,
}

View File

@ -1,46 +0,0 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
opts = {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'selectioncount', 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
}