Skip to content

Commit f75d777

Browse files
polish: add health check, LuaCATS annotations, drop deprecated compat
- Add lua/pytrize/health.lua for :checkhealth pytrize support. Checks Neovim version (>= 0.9), Python treesitter parser, grep availability, and configured highlight group existence. - Add LuaCATS @param/@return doc annotations to api.lua, marks.lua, and init.lua for better lua-language-server discoverability. - Remove deprecated ts_query.parse_query compatibility shim in call_spec.lua; use vim.treesitter.query.parse directly (requires Neovim >= 0.9).
1 parent 0df39da commit f75d777

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

lua/pytrize/api.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
local M = {}
22

3+
--- Clear pytrize virtual text from buffer.
4+
---@param bufnr? integer Buffer number (0 or nil for current buffer)
35
M.clear = function(bufnr)
46
local marks = require("pytrize.marks")
57
marks.clear(bufnr or 0)
68
end
79

10+
--- Set pytrize virtual text for parametrize entries in buffer.
11+
---@param bufnr? integer Buffer number (0 or nil for current buffer)
812
M.set = function(bufnr)
913
local cs = require("pytrize.call_spec")
1014
local marks = require("pytrize.marks")
@@ -38,24 +42,28 @@ M.set = function(bufnr)
3842
end
3943
end
4044

45+
--- Jump to the parametrize entry declaration under cursor.
4146
M.jump = function()
4247
local jump = require("pytrize.jump")
4348

4449
jump.to_param_declaration()
4550
end
4651

52+
--- Jump to fixture definition under cursor.
4753
M.jump_fixture = function()
4854
local jump = require("pytrize.jump")
4955

5056
jump.to_fixture_declaration()
5157
end
5258

59+
--- Rename fixture under cursor across the project.
5360
M.rename_fixture = function()
5461
local rename = require("pytrize.rename")
5562

5663
rename.rename_fixture()
5764
end
5865

66+
--- Show all usages of fixture under cursor in quickfix list.
5967
M.fixture_usages = function()
6068
local usages = require("pytrize.usages")
6169

lua/pytrize/call_spec.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
local M = {}
22

33
local ts = vim.treesitter
4-
local ts_query = ts.query
5-
local parse_query = ts_query.parse or ts_query.parse_query
4+
local parse_query = vim.treesitter.query.parse
65

76
local warn = require("pytrize.warn").warn
87
local tbls = require("pytrize.tables")

lua/pytrize/health.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
local M = {}
2+
3+
M.check = function()
4+
vim.health.start("pytrize")
5+
6+
-- Check Neovim version
7+
if vim.fn.has("nvim-0.9.0") == 1 then
8+
vim.health.ok("Neovim >= 0.9.0")
9+
else
10+
vim.health.error("Neovim >= 0.9.0 required")
11+
end
12+
13+
-- Check Python treesitter parser
14+
local ok = pcall(vim.treesitter.language.inspect, "python")
15+
if ok then
16+
vim.health.ok("Python treesitter parser installed")
17+
else
18+
vim.health.error("Python treesitter parser not found", {
19+
"Install with :TSInstall python (nvim-treesitter) or compile manually",
20+
})
21+
end
22+
23+
-- Check for grep (used by fixture rename/usages)
24+
if vim.fn.executable("grep") == 1 then
25+
vim.health.ok("grep command available")
26+
else
27+
vim.health.warn("grep not found — fixture rename and usages features will not work")
28+
end
29+
30+
-- Check highlight group
31+
local settings = require("pytrize.settings").settings
32+
if vim.fn.hlexists(settings.highlight) == 1 then
33+
vim.health.ok(string.format("Highlight group '%s' exists", settings.highlight))
34+
else
35+
vim.health.warn(string.format("Highlight group '%s' not found — virtual text may be invisible", settings.highlight))
36+
end
37+
end
38+
39+
return M

lua/pytrize/init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ local function setup_commands()
2323
end, { desc = "Show fixture usages in quickfix list" })
2424
end
2525

26+
--- Configure the pytrize plugin.
27+
---@param opts? PytrizeSettings
2628
M.setup = function(opts)
2729
opts = opts or {}
2830
settings.update(opts)

0 commit comments

Comments
 (0)