From 571cecaf3f13514030c87f07d4f6b9488038b303 Mon Sep 17 00:00:00 2001 From: Andrew Conlin <andrew@andrewconl.in> Date: Fri, 10 May 2024 14:19:52 +0100 Subject: [PATCH] [2024-05-09] Updated nvim feline config --- nvim/init.vim | 4 +- nvim/lua/init.lua | 1 + nvim/lua/plugins/feline.lua | 174 ++++++++++++++++++++++++++++++------ 3 files changed, 150 insertions(+), 29 deletions(-) diff --git a/nvim/init.vim b/nvim/init.vim index 50add24..bbcee3d 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -8,7 +8,7 @@ Plug 'ellisonleao/gruvbox.nvim' "Plug 'vim-airline/vim-airline' "Plug 'vim-airline/vim-airline-themes' Plug 'ghifarit53/tokyonight-vim' -Plug 'airblade/vim-gitgutter' +"Plug 'airblade/vim-gitgutter' Plug 'folke/tokyonight.nvim' Plug 'nvim-lua/plenary.nvim' Plug 'nvim-tree/nvim-web-devicons' @@ -16,7 +16,7 @@ Plug 'MunifTanjim/nui.nvim' Plug 'nvim-neo-tree/neo-tree.nvim', { 'branch': 'v3.x' } Plug 'lewis6991/gitsigns.nvim' " OPTIONAL: for git status Plug 'nvim-tree/nvim-web-devicons' " OPTIONAL: for file icons -Plug 'romgrk/barbar.nvim' +"Plug 'romgrk/barbar.nvim' Plug 'freddiehaddad/feline.nvim' "Plug 'epwalsh/obsidian.nvim' "Plug 'hrsh7th/nvim-cmp' diff --git a/nvim/lua/init.lua b/nvim/lua/init.lua index 48545d6..b65bc0f 100644 --- a/nvim/lua/init.lua +++ b/nvim/lua/init.lua @@ -1,2 +1,3 @@ require('plugins.gruvbox') require('plugins.feline') +require('gitsigns').setup() diff --git a/nvim/lua/plugins/feline.lua b/nvim/lua/plugins/feline.lua index 3e0cecc..3dce911 100644 --- a/nvim/lua/plugins/feline.lua +++ b/nvim/lua/plugins/feline.lua @@ -1,53 +1,173 @@ --- Initialize the components table -local components = { +-- Common function used by the git providers +local function git_diff(type) + ---@diagnostic disable-next-line: undefined-field + local b = vim.b + local gsd = b.gitsigns_status_dict + + if gsd and gsd[type] then + return tostring(gsd[type]) + end + + return '' +end +-- Initialize the status_components table +local status_components = { active = {}, inactive = {} } -local config = {} +local status_config = {} -- Insert three sections (left, mid and right) for the active statusline -table.insert(components.active, {}) -table.insert(components.active, {}) -table.insert(components.active, {}) -components.active[1][1] = { +table.insert(status_components.active, {}) +table.insert(status_components.active, {}) +table.insert(status_components.active, {}) +status_components.active[1][1] = { provider = 'vi_mode', hl = function() return { - name = require('feline.providers.vi_mode').get_mode_highlight_name(), - fg = require('feline.providers.vi_mode').get_mode_color(), + name = (require('feline.providers.vi_mode').get_mode_highlight_name()) .. " ", + bg = require('feline.providers.vi_mode').get_mode_color(), + fg = 'bg', style = 'bold' } end, - right_sep = { - str = 'right', - hl = { - fg = 'fg', - bg = 'bg' - } + left_sep = { + str = "block" }, - - -- Uncomment the next line to disable icons for this component and use the mode name instead + right_sep = { + { str='block' }, + { + str = 'right_filled', + hl = function() + return { + fg = require('feline.providers.vi_mode').get_mode_color(), + bg = 'bg' + } + end + } + }, + -- Use the name of the mode instead of the icon icon = '' } -components.active[1][2] = { + +status_components.active[3][1] = { + provider = { + name = 'position', + opts = { + padding = true + } + } +} +status_components.active[3][2] = { provider = 'line_percentage', hl = { - fg = 'blue', + fg = 'blue', }, left_sep = { - str = 'vertical_bar' + str = 'block' + }, + right_sep = { + str = 'block' } - } -components.active[3][1] = { - provider = 'time' +status_components.active[3][3] = { + provider = 'scroll_bar' } local custom_providers = { time = function() - return tostring(vim.fn.strftime('%c')) + return tostring(vim.fn.strftime('%H:%M')) + end, + git_add = function() + return git_diff('added'), ' ' + end, + git_remove = function() + return git_diff('removed'), ' ' + end, + git_change = function() + return git_diff('changed'), ' ' end } -config.components = components -config.custom_providers = custom_providers +status_config.components = status_components +status_config.custom_providers = custom_providers +require('feline').setup(status_config) +-- Initialize the win_components table +local win_components = { + active = {}, + inactive = {} +} +local win_config = {} +-- Insert three sections (left, mid and right) for the active winbar +table.insert(win_components.active, {}) +table.insert(win_components.active, {}) +table.insert(win_components.active, {}) +win_components.active[1][1] = { + provider = { + name = 'file_info', + opts = { + type = 'relative' + } + }, + hl = { fg = 'bg', bg = 'fg' }, + left_sep = { + str = 'block' + }, + right_sep = { + { + str = 'block' + }, + { + str = 'right_filled' + } + } +} +win_components.active[1][2] = { + provider = 'file_size', + left_sep = 'block', + right_sep = { + str = 'block', + hl = { fg = 'bg' } + } +} +win_components.active[1][3] = { + provider = 'file_encoding', + right_sep = { + str = 'block', + hl = { fg = 'bg' } + } +} +win_components.active[1][4] = { + provider = 'file_format', + right_sep = { + str = 'block', + hl = { fg = 'bg' } + } +} +win_components.active[3][1] = { + provider = 'git_add', + hl = { fg = 'fg', bg = 'blue' }, + left_sep = 'left_rounded' +} +win_components.active[3][2] = { + provider = 'git_remove', + hl = { fg = 'fg', bg = 'blue' } +} +win_components.active[3][3] = { + provider = 'git_change', + hl = { fg = 'fg', bg = 'blue' }, + right_sep = { 'block' } +} +win_components.active[3][4] = { + provider = 'git_branch', + hl = { fg = 'fg', bg = 'blue' }, + right_sep = 'right_rounded' +} +win_components.active[3][5] = { + provider = 'time', + left_sep = { + str = 'block' + } +} +win_config.components = win_components +require('feline').winbar.setup(win_config) local theme = require('themes.gruvbox') -require('feline').setup(config) require('feline').use_theme(theme) +