File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ local default_options = {
21
21
22
22
local function is_new_file ()
23
23
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
25
28
end
26
29
27
30
--- shortens path by turning apple/orange -> a/orange
Original file line number Diff line number Diff line change 1
1
local M = {}
2
2
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]' )
7
8
for i , word in ipairs (words ) do
8
9
words [i ] = word :sub (1 , 1 ):upper () .. word :sub (2 )
9
10
end
10
11
11
12
return table.concat (words , ' ' )
12
13
end
13
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
+
14
32
M .sections = {
15
33
lualine_a = {
16
34
get_trouble_mode ,
17
35
},
18
36
}
19
37
20
- M .filetypes = { ' Trouble' }
38
+ M .filetypes = { ' trouble ' , ' Trouble' }
21
39
22
40
return M
You can’t perform that action at this time.
0 commit comments