-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoderabbit.lua
More file actions
94 lines (86 loc) · 2.38 KB
/
coderabbit.lua
File metadata and controls
94 lines (86 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
if vim.g.loaded_coderabbit then
return
end
vim.g.loaded_coderabbit = true
local function ensure_setup()
if not require("coderabbit.config")._current then
require("coderabbit").setup({})
end
end
vim.api.nvim_create_user_command("CodeRabbitReview", function(args)
ensure_setup()
local opts = {}
if args.fargs[1] then
opts.type = args.fargs[1]
end
require("coderabbit").review(opts)
end, {
nargs = "?",
complete = function()
return { "all", "committed", "uncommitted" }
end,
desc = "Run CodeRabbit code review",
})
vim.api.nvim_create_user_command("CodeRabbitStop", function()
require("coderabbit").stop()
end, {
desc = "Cancel running CodeRabbit review",
})
vim.api.nvim_create_user_command("CodeRabbitClear", function()
require("coderabbit").clear()
end, {
desc = "Clear CodeRabbit diagnostics",
})
vim.api.nvim_create_user_command("CodeRabbitShow", function(args)
ensure_setup()
local id = args.fargs[1] and tonumber(args.fargs[1]) or nil
require("coderabbit").show(id)
end, {
nargs = "?",
complete = function()
return require("coderabbit.storage").ids()
end,
desc = "Show CodeRabbit review results in a buffer (optional: review ID)",
})
vim.api.nvim_create_user_command("CodeRabbitRestore", function(args)
ensure_setup()
local id = nil
if args.fargs[1] then
id = tonumber(args.fargs[1])
if not id then
vim.notify("CodeRabbitRestore: invalid review ID: " .. args.fargs[1], vim.log.levels.ERROR)
return
end
end
require("coderabbit").restore(id)
end, {
nargs = "?",
complete = function()
return require("coderabbit.storage").ids()
end,
desc = "Restore diagnostics from a previous CodeRabbit review (default: most recent)",
})
vim.api.nvim_create_user_command("CodeRabbitHistory", function()
ensure_setup()
require("coderabbit").history()
end, {
desc = "Browse CodeRabbit review history",
})
vim.api.nvim_create_user_command("CodeRabbitQuickfix", function(args)
ensure_setup()
local id = nil
if args.fargs[1] then
id = tonumber(args.fargs[1])
if not id then
vim.notify("CodeRabbitQuickfix: invalid review ID: " .. args.fargs[1], vim.log.levels.ERROR)
return
end
end
require("coderabbit").quickfix(id)
end, {
nargs = "?",
complete = function()
return require("coderabbit.storage").ids()
end,
desc = "Populate quickfix list with CodeRabbit findings (optional: review ID)",
})