From d2483f19cee5234db1e010e6560d9aa9bb60bb30 Mon Sep 17 00:00:00 2001 From: Jeremy Pridemore Date: Wed, 17 Jul 2024 23:21:50 -0600 Subject: [PATCH] feat(lualine): allow for trouble_lualine to be overriden on buffer (#4096) ## Description Right now there is a default `vim.g.trouble_lualine` being set to `true`, and only that variable is being checked when deciding if the trouble output is being appended to the `lualine_c` for the lualine plugin. This is normally nice in code files, where you can get output like `packages/src/index.ts > myFunction` but in some filetypes, the user may not wish for this. In particular, I found if you have files with the `markdown` type that include long headers, then you can easily lose the file name by it trying to include the headers in this location. Considering that one of the `CONTRIBUTING.md` guidelines is `Ensure all configurations are overridable by the user, using Lazy's specs.`, I figured that allowing this to be overrideable at the user's discretion could be a valuable feature. This would allow the user to override this on file type by including an autocmd like this in their `lua/config/autocmds.lua` or equivalent: ```lua -- disable trouble symbols in lualine in text filetypes vim.api.nvim_create_autocmd("FileType", { group = vim.api.nvim_create_augroup("disable_trouble_lualine", { clear = true }), pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" }, callback = function() vim.b.trouble_lualine = false end, }) ``` ## Related Issue(s) None ## Screenshots ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: jpridemore-allegion --- lua/lazyvim/plugins/ui.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 14a77ce4..6455658d 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -198,7 +198,12 @@ return { } -- do not add trouble symbols if aerial is enabled - if vim.g.trouble_lualine and LazyVim.has("trouble.nvim") then + -- And allow it to be overriden for some buffer types (see autocmds) + if + vim.g.trouble_luline_enabed ~= false + and vim.b.trouble_lualine_enabled ~= false + and LazyVim.has("trouble.nvim") + then local trouble = require("trouble") local symbols = trouble.statusline and trouble.statusline({