From ff861b8d480be03bcd3aa8d80d32f54391019718 Mon Sep 17 00:00:00 2001 From: NTBBloodbath Date: Fri, 26 Mar 2021 05:02:58 -0400 Subject: [PATCH] health: basic checkhealth integration --- autoload/{doom/health.vim => health/doom.vim} | 5 +- lua/doom/health.lua | 76 +++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) rename autoload/{doom/health.vim => health/doom.vim} (55%) create mode 100644 lua/doom/health.lua diff --git a/autoload/doom/health.vim b/autoload/health/doom.vim similarity index 55% rename from autoload/doom/health.vim rename to autoload/health/doom.vim index 004a913..3424ae9 100644 --- a/autoload/doom/health.vim +++ b/autoload/health/doom.vim @@ -4,6 +4,7 @@ " License: MIT "================================================ -function! doom#health() abort - call doom#logging#message('+', 'Checking health', 2) +function! health#doom#check() abort + call doom#logging#message('+', 'Checking Doom health ...', 2) + lua require('doom.health').checkhealth() endfunction diff --git a/lua/doom/health.lua b/lua/doom/health.lua new file mode 100644 index 0000000..d9d817b --- /dev/null +++ b/lua/doom/health.lua @@ -0,0 +1,76 @@ +---[[----------]]--- +-- Wrappers -- +---]]----------[[--- +local fn = vim.fn +local api = vim.api + +-- Health status +local health_start = vim.fn['health#report_start'] +local health_ok = vim.fn['health#report_ok'] +local health_error = vim.fn['health#report_error'] +local health_warn = vim.fn['health#report_warn'] + +local M = {} + +-- Installation health +local function install_health() + health_start('Installation') + + ---[[-----------------------]]--- + -- REQUIRED DEPENDENCIES -- + ---]]-----------------------[[--- + -- Check Git + if fn.executable('git') == 0 then + health_error('`git` executable not found.', { + 'Install it with your package manager.', + 'Check that your `$PATH` is set correctly.' + }) + else + health_ok('`git` executable found.') + end + + ---[[-----------------------]]--- + -- OPTIONAL DEPENDENCIES -- + ---]]-----------------------[[--- + -- Ripgrep and fd + if fn.executable('rg') == 0 then + health_warn('`rg` executable not found.', { + 'Required to improve file indexing performance for some commands', + 'Ignore this message if you have `fd` installed.' + }) + else + health_ok('`rg` executable found.') + end + if fn.executable('fd') == 0 then + health_warn('`fd` executable not found.', { + 'Required to improve file indexing performance for some commands', + 'Ignore this message if you have `rg` installed.' + }) + else + health_ok('`fd` executable found.') + end + + -- Check NodeJS and NPM + if fn.executable('node') == 0 then + health_warn('`node` executable not found.', { + 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.' + }) + else + health_ok('`node` executable found.') + end + if fn.executable('npm') == 0 then + health_warn('`npm` executable not found.', { + 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.', + 'If node is installed but npm is not, you should need to install it with your package manager' + }) + else + health_ok('`npm` executable found.') + end +end + +function M.checkhealth() + -- Installation checks + install_health() +end + +return M