refactor(lualine): move lualine config to a new file

- Add a function for the word counter
This commit is contained in:
Fabrice Mouhartem 2025-05-06 16:49:38 +02:00
parent e934e38bd0
commit aa829327b5
Signed by: fmouhart
GPG Key ID: 2C5033B228CFE4E7
3 changed files with 53 additions and 52 deletions

View File

@ -62,6 +62,9 @@ require('complete')
-- [[ Configure neorg ]]
require('neorg-configure')
-- [[ Configure status line ]]
require('statusline')
-- Customizations
require('restore-position')
require('autocommands')

View File

@ -161,58 +161,8 @@ require('lazy').setup({
end,
},
{
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = true,
theme = 'rose-pine',
component_separators = '|',
section_separators = '',
},
sections = {
lualine_c = {
{
'filename',
path = 1,
}
},
lualine_y = {
{
-- Character, word and line counts
-- https://www.reddit.com/r/neovim/comments/1130kh5/comment/j8navg6/
function()
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
local wordcount = vim.fn.wordcount()
return tostring(wordcount.visual_words) ..
"W " .. tostring(wordcount.visual_chars) .. "C " .. tostring(lines) .. "L"
end
},
'progress'
}
},
inactive_sections = {
lualine_c = {
{
'filename',
path = 1,
}
},
},
symbols = {
error = "",
warn = "",
info = "",
hint = "",
}
},
},
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
{
-- Add indentation guides even on blank lines

48
lua/statusline.lua Normal file
View File

@ -0,0 +1,48 @@
-- Character, word and line counts
-- https://www.reddit.com/r/neovim/comments/1130kh5/comment/j8navg6/
local function counters()
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
local wordcount = vim.fn.wordcount()
return tostring(wordcount.visual_words) ..
"W " .. tostring(wordcount.visual_chars) .. "C " .. tostring(lines) .. "L"
end
-- See `:help lualine.txt`
require('lualine').setup({
options = {
icons_enabled = true,
theme = 'rose-pine',
component_separators = '|',
section_separators = '',
},
sections = {
lualine_c = {
{
'filename',
path = 1,
}
},
lualine_y = {
{ counters },
'progress'
}
},
inactive_sections = {
lualine_c = {
{
'filename',
path = 1,
}
},
},
symbols = {
error = "",
warn = "",
info = "",
hint = "",
}
})