Skip to content

Commit 817df65

Browse files
authored
Merge branch 'master' into fix/CI
2 parents e8765ea + 0193770 commit 817df65

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

lua/lualine/components/filename.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ local default_options = {
2121

2222
local function is_new_file()
2323
local filename = vim.fn.expand('%')
24-
return filename ~= '' and vim.bo.buftype == '' and vim.fn.filereadable(filename) == 0
24+
return filename ~= ''
25+
and filename:match('^%a+://') == nil
26+
and vim.bo.buftype == ''
27+
and vim.fn.filereadable(filename) == 0
2528
end
2629

2730
---shortens path by turning apple/orange -> a/orange

lua/lualine/extensions/trouble.lua

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
local M = {}
22

3-
local function get_trouble_mode()
4-
local opts = require('trouble.config').options
5-
6-
local words = vim.split(opts.mode, '[%W]')
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]')
78
for i, word in ipairs(words) do
89
words[i] = word:sub(1, 1):upper() .. word:sub(2)
910
end
1011

1112
return table.concat(words, ' ')
1213
end
1314

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+
1432
M.sections = {
1533
lualine_a = {
1634
get_trouble_mode,
1735
},
1836
}
1937

20-
M.filetypes = { 'Trouble' }
38+
M.filetypes = { 'trouble', 'Trouble' }
2139

2240
return M

0 commit comments

Comments
 (0)