@@ -5,62 +5,64 @@ M.namespace = vim.api.nvim_create_namespace("Trouble")
5
5
--- @class Options
6
6
--- @field buf number | nil
7
7
--- @field win number | nil
8
+ -- TODO: make some options configurable per mode
9
+ -- TODO: make it possible to have multiple trouble lists open at the same time
8
10
local defaults = {
9
- debug = false ,
10
- position = " bottom" , -- position of the list can be: bottom, top, left, right
11
- height = 10 , -- height of the trouble list when position is top or bottom
12
- width = 50 , -- width of the list when position is left or right
13
- icons = true , -- use devicons for filenames
14
- mode = " lsp_workspace_diagnostics" , -- "lsp_workspace_diagnostics", "lsp_document_diagnostics", "quickfix", "lsp_references", "loclist"
15
- fold_open = " " , -- icon used for open folds
16
- fold_closed = " " , -- icon used for closed folds
17
- action_keys = { -- key mappings for actions in the trouble list
18
- close = " q" , -- close the list
19
- cancel = " <esc>" , -- cancel the preview and get back to your last window / buffer / cursor
20
- refresh = " r" , -- manually refresh
21
- jump = {" <cr>" , " <tab>" }, -- jump to the diagnostic or open / close folds
22
- jump_close = {" o" }, -- jump to the diagnostic and close the list
23
- toggle_mode = " m" , -- toggle between "workspace" and "document" mode
24
- toggle_preview = " P" , -- toggle auto_preview
25
- hover = " K" , -- opens a small poup with the full multiline message
26
- preview = " p" , -- preview the diagnostic location
27
- close_folds = {" zM" , " zm" }, -- close all folds
28
- open_folds = {" zR" , " zr" }, -- open all folds
29
- toggle_fold = {" zA" , " za" }, -- toggle fold of current file
30
- previous = " k" , -- preview item
31
- next = " j" -- next item
32
- },
33
- indent_lines = true , -- add an indent guide below the fold icons
34
- auto_open = false , -- automatically open the list when you have diagnostics
35
- auto_close = false , -- automatically close the list when you have no diagnostics
36
- auto_preview = true , -- automatyically preview the location of the diagnostic. <esc> to close preview and go back to last window
37
- auto_fold = false , -- automatically fold a file trouble list at creation
38
- signs = {
39
- -- icons / text used for a diagnostic
40
- error = " " ,
41
- warning = " " ,
42
- hint = " " ,
43
- information = " " ,
44
- other = " "
45
- },
46
- use_lsp_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
11
+ debug = false ,
12
+ position = " bottom" , -- position of the list can be: bottom, top, left, right
13
+ height = 10 , -- height of the trouble list when position is top or bottom
14
+ width = 50 , -- width of the list when position is left or right
15
+ icons = true , -- use devicons for filenames
16
+ mode = " lsp_workspace_diagnostics" , -- "lsp_workspace_diagnostics", "lsp_document_diagnostics", "quickfix", "lsp_references", "loclist"
17
+ fold_open = " " , -- icon used for open folds
18
+ fold_closed = " " , -- icon used for closed folds
19
+ action_keys = { -- key mappings for actions in the trouble list
20
+ close = " q" , -- close the list
21
+ cancel = " <esc>" , -- cancel the preview and get back to your last window / buffer / cursor
22
+ refresh = " r" , -- manually refresh
23
+ jump = { " <cr>" , " <tab>" }, -- jump to the diagnostic or open / close folds
24
+ jump_close = { " o" }, -- jump to the diagnostic and close the list
25
+ toggle_mode = " m" , -- toggle between "workspace" and "document" mode
26
+ toggle_preview = " P" , -- toggle auto_preview
27
+ hover = " K" , -- opens a small poup with the full multiline message
28
+ preview = " p" , -- preview the diagnostic location
29
+ close_folds = { " zM" , " zm" }, -- close all folds
30
+ open_folds = { " zR" , " zr" }, -- open all folds
31
+ toggle_fold = { " zA" , " za" }, -- toggle fold of current file
32
+ previous = " k" , -- preview item
33
+ next = " j" , -- next item
34
+ },
35
+ indent_lines = true , -- add an indent guide below the fold icons
36
+ auto_open = false , -- automatically open the list when you have diagnostics
37
+ auto_close = false , -- automatically close the list when you have no diagnostics
38
+ auto_preview = true , -- automatyically preview the location of the diagnostic. <esc> to close preview and go back to last window
39
+ auto_fold = false , -- automatically fold a file trouble list at creation
40
+ signs = {
41
+ -- icons / text used for a diagnostic
42
+ error = " " ,
43
+ warning = " " ,
44
+ hint = " " ,
45
+ information = " " ,
46
+ other = " " ,
47
+ },
48
+ use_lsp_diagnostic_signs = false , -- enabling this will use the signs defined in your lsp client
47
49
}
48
50
49
51
--- @type Options
50
52
M .options = {}
51
53
52
54
--- @return Options
53
55
function M .setup (options )
54
- M .options = vim .tbl_deep_extend (" force" , {}, defaults , options or {})
55
- M .fix_mode (M .options )
56
+ M .options = vim .tbl_deep_extend (" force" , {}, defaults , options or {})
57
+ M .fix_mode (M .options )
56
58
end
57
59
58
60
function M .fix_mode (opts )
59
- if opts .mode == " workspace" then
60
- opts .mode = " lsp_workspace_diagnostics"
61
- elseif opts .mode == " document" then
62
- opts .mode = " lsp_document_diagnostics"
63
- end
61
+ if opts .mode == " workspace" then
62
+ opts .mode = " lsp_workspace_diagnostics"
63
+ elseif opts .mode == " document" then
64
+ opts .mode = " lsp_document_diagnostics"
65
+ end
64
66
end
65
67
66
68
M .setup ()
0 commit comments