From 30a1ccc89b374d67caadc2d831c6d4cb0b239fb3 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Mon, 26 Feb 2024 08:55:52 -0500 Subject: [PATCH] health check --- init.lua | 6 ++--- lua/kickstart/health.lua | 48 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 lua/kickstart/health.lua diff --git a/init.lua b/init.lua index cf320ac..72231f9 100644 --- a/init.lua +++ b/init.lua @@ -542,12 +542,12 @@ require('lazy').setup({ -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- - -- If you use something like typescript, where the tooling is as bad as the language, - -- then you might need to install and configure something like this: + -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- - -- If you only have simple needs for typescript, then you can probably just use tsserver + -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, + -- lua_ls = { -- cmd = {...}, diff --git a/lua/kickstart/health.lua b/lua/kickstart/health.lua new file mode 100644 index 0000000..9547c3a --- /dev/null +++ b/lua/kickstart/health.lua @@ -0,0 +1,48 @@ +--[[ +-- +-- This file is not required for your own configuration, +-- but helps people determine if their system is setup correctly. +-- +--]] + +local check_version = function() + if not vim.version.cmp then + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", tostring(vim.version()))) + return + end + + if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then + vim.health.ok(string.format("Neovim version is: '%s'", tostring(vim.version()))) + else + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", tostring(vim.version()))) + end +end + +local check_external_reqs = function() + -- Basic utils: `git`, `make`, `unzip` + for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do + local is_executable = vim.fn.executable(exe) == 1 + if is_executable then + vim.health.ok(string.format("Found executable: '%s'", exe)) + else + vim.health.warn(string.format("Could not find executable: '%s'", exe)) + end + end + + return true +end + +return { + check = function() + vim.health.start 'kickstart.nvim' + + vim.health.info [[You don't have to fix every 'WARNING' you see in checkheath." + Just fix the ones for the plugins and languages you intend to use.' + For example, in Mason, you may see warnings about several language runtimes' + but if you are not planning on developing in those languages, you do not have' + to fix those at this time']] + + check_version() + check_external_reqs() + end, +}