Skip to content

Commit

Permalink
Merge pull request #151 from xixiaofinland/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xixiaofinland authored Jul 20, 2024
2 parents 7d6f41f + c4f4023 commit 02f78d3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
(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)

<br>

## ⚙️ Installation
Expand Down
67 changes: 67 additions & 0 deletions lua/sf/health.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 02f78d3

Please sign in to comment.