1
1
local fn , health = vim .fn , vim .health
2
+ local ok , error , info = health .ok , health .error , health .info
2
3
local filetype = require (' guard.filetype' )
3
- local ok , error = health .ok , health .error
4
+ local util = require (' guard.util' )
5
+ local events = require (' guard.events' )
4
6
local M = {}
5
7
6
8
local function executable_check ()
@@ -27,19 +29,60 @@ local function executable_check()
27
29
table.insert (checked , conf .cmd )
28
30
end
29
31
end
30
- if pcall (require , ' mason' ) then
31
- health .warn (
32
- ' It seems that mason.nvim is installed,'
33
- .. ' in which case checkhealth may be inaccurate.'
34
- .. ' Please add your mason bin path to PATH to avoid potential issues.'
35
- )
36
- end
37
32
end
33
+ if pcall (require , ' mason' ) then
34
+ health .warn (
35
+ ' It seems that mason.nvim is installed,'
36
+ .. ' in which case checkhealth may be inaccurate.'
37
+ .. ' Please add your mason bin path to PATH to avoid potential issues.'
38
+ )
39
+ end
40
+ end
41
+
42
+ local function dump_settings ()
43
+ ok ((' fmt_on_save: %s' ):format (util .getopt (' fmt_on_save' )))
44
+ ok ((' lsp_as_default_formatter: %s' ):format (util .getopt (' lsp_as_default_formatter' )))
45
+ ok ((' save_on_fmt: %s' ):format (util .getopt (' save_on_fmt' )))
38
46
end
39
47
48
+ local function dump_tools (buf )
49
+ local fmtau = events .get_format_autocmds (buf )
50
+ local lintau = events .get_lint_autocmds (buf )
51
+ local ft = vim .bo [buf ].ft
52
+
53
+ ok ((' Current buffer has filetype %s:' ):format (ft ))
54
+ info ((' %s formatter autocmds attached' ):format (# fmtau ))
55
+ info ((' %s linter autocmds attached' ):format (# lintau ))
56
+
57
+ local conf = filetype [ft ] or {}
58
+ local formatters = conf .formatter or {}
59
+ local linters = conf .linter or {}
60
+
61
+ if # formatters > 0 then
62
+ info (' formatters:' )
63
+ vim .iter (formatters ):map (vim .inspect ):each (info )
64
+ end
65
+
66
+ if # linters > 0 then
67
+ info (' formatters:' )
68
+ vim .iter (linters ):map (vim .inspect ):each (info )
69
+ end
70
+ end
71
+
72
+ -- TODO: add custom autocmds info
40
73
M .check = function ()
41
74
health .start (' Executable check' )
42
75
executable_check ()
76
+
77
+ health .start (' Settings' )
78
+ dump_settings ()
79
+
80
+ local orig_bufnr = vim .fn .bufnr (' #' )
81
+ if not vim .api .nvim_buf_is_valid (orig_bufnr ) then
82
+ return
83
+ end
84
+ health .start ((' Tools registered for current buffer (bufnr %s)' ):format (orig_bufnr ))
85
+ dump_tools (orig_bufnr )
43
86
end
44
87
45
88
return M
0 commit comments