From 8c83ef6713affe696592acfb1f88ac547a200359 Mon Sep 17 00:00:00 2001 From: xi xiao Date: Sat, 20 Jul 2024 09:38:49 +0300 Subject: [PATCH 1/3] add health check --- README.md | 2 ++ lua/sf/health.lua | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 lua/sf/health.lua diff --git a/README.md b/README.md index 89e5fd7..4598616 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ (Why not telescope.nvim? Because its UI is slow) - 🔍 (Optional) [universal ctags](https://github.com/universal-ctags/ctags) is used to enhance [Apex jump](#-enhanced-jump-to-definition-apex) +💡 It comes with a health check feature. Run `:che sf` to auto-check prerequiste statistics. +
## ⚙️ Installation diff --git a/lua/sf/health.lua b/lua/sf/health.lua new file mode 100644 index 0000000..ada6c72 --- /dev/null +++ b/lua/sf/health.lua @@ -0,0 +1,67 @@ +local M = {} +local H = {} + +M.check = function() + H.check_nvim_version() + H.check_sf_cli() + H.check_tree_sitter() + H.check_fzf_lua() + H.check_ctag() +end + +-- helper; + +H.check_sf_cli = function() + if vim.fn.executable('sf') ~= 1 then + return vim.health.error("sf cli not found!") + end + + vim.health.ok("sf cli found.") +end + +H.check_tree_sitter = function() + if not pcall(require, 'nvim-treesitter') then + return vim.health.error("nvim-treesitter plugin not found!") + end + vim.health.ok("nvim-treesitter plugin found.") + + local parsers = require('nvim-treesitter.parsers').get_parser_configs() + if parsers['apex'] == nil then + return vim.health.error("apex parser not installed in nvim-treesitter!") + end + if parsers['soql'] == nil then + return vim.health.error("soql parser not installed in nvim-treesitter!") + end + if parsers['sosl'] == nil then + return vim.health.error("sosl parser not installed in nvim-treesitter!") + end + vim.health.ok("parsers found in nvim-treesitter.") +end + +H.check_nvim_version = function() + local v = vim.version() + local v_in_str = string.format("v%s.%s", v.major, v.minor) + + if v.major == 0 and v.minor < 10 then + return vim.health.error("installed Nvim version: " .. v_in_str .. ', plugin demands 0.10 or higher!') + else + vim.health.ok("nvim version ok: " .. v_in_str) + end +end + +H.check_fzf_lua = function() + if not pcall(require, 'fzf-lua') then + return vim.health.warn("Optional: fzf-lua not found. Some features for listing items won't work. You could install `ibhagwan/fzf-lua`.") + end + vim.health.ok("fzf-lua plugin found.") +end + +H.check_ctag = function() + if vim.fn.executable('ctags') ~= 1 then + return vim.health.warn("Optional: ctags command not found in the path. Enhanced apex jump-to-definition won't work. You could install `universal ctags`.") + end + + vim.health.ok("ctags command found.") +end + +return M From b108432c1c54755938558245070faff06967628f Mon Sep 17 00:00:00 2001 From: Xi Xiao Date: Sat, 20 Jul 2024 09:48:08 +0300 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4598616..0f94743 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ 💡 It comes with a health check feature. Run `:che sf` to auto-check prerequiste statistics. +![Image 019](https://github.com/user-attachments/assets/aad0ac11-f980-423b-8332-a2b4359fb4ae) +
## ⚙️ Installation From c4f40238d7181596529400df396b373580300a57 Mon Sep 17 00:00:00 2001 From: Xi Xiao Date: Sat, 20 Jul 2024 09:49:35 +0300 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0f94743..f880901 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ (Why not telescope.nvim? Because its UI is slow) - 🔍 (Optional) [universal ctags](https://github.com/universal-ctags/ctags) is used to enhance [Apex jump](#-enhanced-jump-to-definition-apex) +---- 💡 It comes with a health check feature. Run `:che sf` to auto-check prerequiste statistics. ![Image 019](https://github.com/user-attachments/assets/aad0ac11-f980-423b-8332-a2b4359fb4ae)