From 942142357bbe40bc94006df3370ada35b5d7e857 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Fri, 18 Aug 2023 21:08:26 +0200 Subject: [PATCH] vim/lualine: don't show trailing whitespace for help files --- config/nvim/lua/fschauen/plugins/lualine.lua | 39 ++++++++++++-------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/config/nvim/lua/fschauen/plugins/lualine.lua b/config/nvim/lua/fschauen/plugins/lualine.lua index 3016cc9..04c14ac 100644 --- a/config/nvim/lua/fschauen/plugins/lualine.lua +++ b/config/nvim/lua/fschauen/plugins/lualine.lua @@ -108,21 +108,8 @@ M.config = function() return C end)() - local trailing_whitespace = function() - local trailing = [[\s\+$]] - local lineno = vim.fn.search(trailing, 'nwc') - if lineno == 0 then return '' end - - local result = ' ' .. lineno - - local total = vim.fn.searchcount({ pattern = trailing }).total - if total > 1 then result = result .. string.format(' (%d total)', total) end - - return result - end - local colored_if_focused = function(component) - if type(component) == 'string' then + if type(component) == 'string' then local C = require('lualine.components.' .. component):extend() function C:update_status(is_focused) @@ -149,6 +136,28 @@ M.config = function() end end + local trailing_whitespace = { + colored_if_focused(function() + local trailing = [[\s\+$]] + local lineno = vim.fn.search(trailing, 'nwc') + if lineno == 0 then return '' end + + local result = ' ' .. lineno + + local total = vim.fn.searchcount({ pattern = trailing }).total + if total > 1 then result = result .. string.format(' (%d total)', total) end + + return result + end), + + color = { bg = orange }, + + cond = function() + return vim.bo.filetype ~= 'help' + end, + } + + local paste = { colored_if_focused(function(has_focus) return has_focus and '' or ' ' end), color = { @@ -192,7 +201,7 @@ M.config = function() }, lualine_z = { 'location', - { colored_if_focused(trailing_whitespace), color = { bg = orange } }, + trailing_whitespace, }, }