1-- Command to check if you have the required dependencies to use NormalNvim.
2--
3-- DESCRIPTION:
4-- To use it run the command :healthcheck base
5
6local M = {}
7
8local health = {
9 start = vim.health.start or vim.health.report_start,
10 ok = vim.health.ok or vim.health.report_ok,
11 warn = vim.health.warn or vim.health.report_warn,
12 error = vim.health.error or vim.health.report_error,
13 info = vim.health.info or vim.health.report_info,
14}
15
16function M.check()
17 health.start "NormalNvim"
18
19 health.info(
20 "NormalNvim Version: " .. require("distroupdate.utils.updater").version(true)
21 )
22 health.info(
23 "Neovim Version: v"
24 .. vim.fn.matchstr(vim.fn.execute "version", "NVIM v\\zs[^\n]*")
25 )
26
27 if vim.version().prerelease then
28 health.warn "Neovim nightly is not officially supported and may have breaking changes"
29 elseif vim.fn.has "nvim-0.9" == 1 then
30 health.ok "Using stable Neovim >= 0.9.0"
31 else
32 health.error "Neovim >= 0.9.0 is required"
33 end
34
35 -- Checks to perform.
36 local programs = {
37 {
38 cmd = { "git" },
39 type = "error",
40 msg = "Used for core functionality such as updater and plugin management.",
41 },
42 {
43 cmd = { "luarocks" },
44 type = "error",
45 msg = "Used for core functionality such as updater and plugin management.",
46 },
47 {
48 cmd = { "node" },
49 type = "error",
50 msg = "Used for core functionality such as updater and plugin management.",
51 },
52 {
53 cmd = { "yarn" },
54 type = "error",
55 msg = "Used for core functionality such as updater and plugin management.",
56 },
57 {
58 cmd = { "cargo" },
59 type = "error",
60 msg = "Used by nvim-spectre to install oxi. Also by dooku.nvim to generate rust html docs.",
61 },
62 {
63 cmd = { "markmap" },
64 type = "warn",
65 msg = "Used by markmap.nvim. Make sure yarn is in your PATH. To learn how check markmap.nvim github page.",
66 },
67 {
68 cmd = { "fd" },
69 type = "error",
70 msg = "Used for nvim-spectre to find using fd.",
71 },
72 {
73 cmd = { "lazygit" },
74 type = "warn",
75 msg = "Used for mappings to pull up git TUI (Optional)",
76 },
77 {
78 cmd = { "gitui" },
79 type = "warn",
80 msg = "Used for mappings to pull up git TUI (Optional)",
81 },
82 {
83 cmd = { "pynvim" },
84 type = "warn",
85 msg =
86 "Used to enable ranger file browser (optional)\nNOTE: checkhealth won't detect this correctly, but you can ensure it is installed with 'pip list | grep pynvim'.",
87 },
88 {
89 cmd = { "ranger" },
90 type = "warn",
91 msg = "Used to enable ranger file browser (Optional)",
92 },
93 {
94 cmd = { "delta" },
95 type = "warn",
96 msg = "Used by undotree to show a diff (Optional)",
97 },
98 {
99 cmd = { "grcov" },
100 type = "warn",
101 msg = "Used to show code coverage (Optional)",
102 },
103 {
104 cmd = { "grcov" },
105 type = "warn",
106 msg = "Used to show code coverage (Optional)",
107 },
108 {
109 cmd = { "jest" },
110 type = "warn",
111 msg = "Used to run typescript and javascript tests (Optional)",
112 },
113 {
114 cmd = { "pytest" },
115 type = "warn",
116 msg = "Used to run python tests (Optional)",
117 },
118 {
119 cmd = { "cargo nextest" },
120 type = "warn",
121 msg =
122 "Used to run rust tests (optional)\nNOTE: checkhealth won't detect this correctly, but you can confirm it works correctly with 'cargo nextest'.",
123 },
124 {
125 cmd = { "nunit" },
126 type = "warn",
127 msg =
128 "Used to run C# tests (optional)\nNOTE: There is no way to install this system wide. To use it you must add it to your dotnet C# project: 'dotnet add package NUnit NUnit3TestAdapter'.",
129 },
130 {
131 cmd = { "csc" },
132 type = "warn",
133 msg = "Used by compiler.nvim to compile non dotnet C# files (Optional)",
134 },
135 {
136 cmd = { "mono" },
137 type = "warn",
138 msg = "Used by compiler.nvim to run non dotnet C# files. (Optional)",
139 },
140 {
141 cmd = { "dotnet" },
142 type = "warn",
143 msg =
144 "Used by compiler.nvim and DAP to operate with dotnet projects (optional)\nNOTE: Make sure you also have the system package dotnet-sdk installed.",
145 },
146 {
147 cmd = { "java" },
148 type = "warn",
149 msg = "Used by compiler.nvim and dap to operate with java (Optional)",
150 },
151 {
152 cmd = { "javac" },
153 type = "warn",
154 msg = "Used by compiler.nvim to compile java (Optional)",
155 },
156 {
157 cmd = { "nasm" },
158 type = "warn",
159 msg = "Used by compiler.nvim to compile assembly x86_64 (Optional)",
160 },
161
162 {
163 cmd = { "gcc" },
164 type = "warn",
165 msg = "Used by compiler.nvim to compile C (Optional)",
166 },
167 {
168 cmd = { "g++" },
169 type = "warn",
170 msg = "Used by compiler.nvim to compile C++ (Optional)",
171 },
172 {
173 cmd = { "elixir" },
174 type = "warn",
175 msg = "Used by compiler.nvim to compile elixir (optional)",
176 },
177 {
178 cmd = { "Rscript" },
179 type = "warn",
180 msg = "Used by compiler.nvim to interpretate R (Optional)",
181 },
182 {
183 cmd = { "python" },
184 type = "warn",
185 msg = "Used by compiler.nvim to interpretate python (Optional)",
186 },
187 {
188 cmd = { "nuitka3" },
189 type = "warn",
190 msg = "Used by compiler.nvim to compile python to machine code (Optional)",
191 },
192 {
193 cmd = { "pyinstaller" },
194 type = "warn",
195 msg = "Used by compiler.nvim to compile python to bytecode (Optional)",
196 },
197 {
198 cmd = { "ruby" },
199 type = "warn",
200 msg = "Used by compiler.nvim to interpretate ruby (optional)",
201 },
202 {
203 cmd = { "perl" },
204 type = "warn",
205 msg = "Used by compiler.nvim to interpretate perl (optional)",
206 },
207 {
208 cmd = { "swiftc" },
209 type = "warn",
210 msg = "Used by compiler.nvim to compile swift (optional)",
211 },
212 {
213 cmd = { "swift" },
214 type = "warn",
215 msg = "Used by compiler.nvim to compile swift (optional)",
216 },
217 {
218 cmd = { "gfortran" },
219 type = "warn",
220 msg = "Used by compiler.nvim to compile fortran (optional)"
221 },
222 {
223 cmd = { "fpm" },
224 type = "warn",
225 msg = "Used by compiler.nvim to compile fortran (optional)"
226 },
227 {
228 cmd = { "go" },
229 type = "warn",
230 msg = "Used by compiler.nvim to compile go (optional)",
231 },
232 {
233 cmd = { "godoc" },
234 type = "warn",
235 msg =
236 "Used by dooku.nvim to generate go html docs\nNOTE: If you have it installed but you can't run it on the terminal, ensure you have added 'go' to your OS path (optional)",
237 },
238 {
239 cmd = { "doxygen" },
240 type = "warn",
241 msg = "Used by dooku.nvim to generate c/c++/python/java html docs (optional)",
242 },
243 }
244
245 -- Actually perform the checks we defined above.
246 for _, program in ipairs(programs) do
247 if type(program.cmd) == "string" then program.cmd = { program.cmd } end
248 local name = table.concat(program.cmd, "/")
249 local found = false
250 for _, cmd in ipairs(program.cmd) do
251 if vim.fn.executable(cmd) == 1 then
252 name = cmd
253 found = true
254 break
255 end
256 end
257
258 if found then
259 health.ok(("`%s` is installed: %s"):format(name, program.msg))
260 else
261 health[program.type](
262 ("`%s` is not installed: %s"):format(name, program.msg)
263 )
264 end
265 end
266 health.info("")
267 health.info("Write `:bw` to close `:checkhealth` gracefully.")
268end
269
270return M