Debian Codegraph @

lua/lualine/extensions/trouble.lua

raw
1 local M = {}
2
3 ---Format mode, eg: lsp_document_symbols -> Lsp Document Symbols
4 ---@param mode string
5 ---@return string
6 local function _format_mode(mode)
7 local words = vim.split(mode, '[%W]')
8 for i, word in ipairs(words) do
9 words[i] = word:sub(1, 1):upper() .. word:sub(2)
10 end
11
12 return table.concat(words, ' ')
13 end
14
15 local function get_trouble_mode()
16 local opts = require('trouble.config').options
17 if opts ~= nil and opts.mode ~= nil then
18 return _format_mode(opts.mode)
19 end
20
21 local win = vim.api.nvim_get_current_win()
22 if vim.w[win] ~= nil then
23 local trouble = vim.w[win].trouble
24 if trouble ~= nil and trouble.mode ~= nil then
25 return _format_mode(trouble.mode)
26 end
27 end
28
29 return ''
30 end
31
32 M.sections = {
33 lualine_a = {
34 get_trouble_mode,
35 },
36 }
37
38 M.filetypes = { 'trouble', 'Trouble' }
39
40 return M