-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathinit.lua
More file actions
82 lines (75 loc) · 1.95 KB
/
init.lua
File metadata and controls
82 lines (75 loc) · 1.95 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
local M = {
stl_timer = vim.uv.new_timer(),
stl_stop = false,
}
function M.set_buf_stl(buf, stl)
vim.b[buf].stl = stl
vim.cmd.redrawstatus()
end
function M.gpt_stl(buf, icon, title, usage)
if usage then
M.set_buf_stl(buf, { " %#DiagnosticInfo#", icon, " %#StatusLine#", title, " %#Comment#", usage })
else
M.set_buf_stl(buf, { " %#DiagnosticInfo#", icon, " %#StatusLine#", title })
end
end
function M.term_stl(buf, cmd)
local cmd_type = type(cmd)
local cmd_0
if cmd_type == "table" then
cmd_0 = cmd[1]
elseif cmd_type == "string" then
cmd_0 = cmd
else
vim.notify("不支持的 cmd 类型", vim.log.levels.ERROR)
return
end
if cmd_0 == "curl" then
M.set_buf_stl(buf, { " %#DiagnosticInfo#", "", " %#StatusLine#", "cURL" })
elseif cmd_0 == "mvn" then
M.set_buf_stl(buf, { " %#DiagnosticError#", "", " %#StatusLine#", "Maven (" .. table.concat(cmd, " ") .. ")" })
elseif cmd_0 == "Codex" then
M.set_buf_stl(buf, { " %#DiagnosticInfo#", "", " %#StatusLine#", "Codex" })
else
M.set_buf_stl(buf, { " %#DiagnosticInfo#", "", " %#StatusLine#", cmd_0 })
end
end
function M.lsp_stl(message)
require("kide.stl").set_lsp_status(message)
vim.cmd.redrawstatus()
M.stl_timer:stop()
M.stl_timer:start(
500,
0,
vim.schedule_wrap(function()
require("kide.stl").set_lsp_status(nil)
vim.cmd.redrawstatus()
end)
)
end
---清理全局状态
---@param id number stl id
---@param code number exit code
function M.clean_stl_status(id, code)
M.stl_stop = true
M.stl_timer:stop()
require("kide.stl").exit_status(id, code)
end
---@param title string
---@param buf? number
function M.timer_stl_status(title, buf)
local id = require("kide.stl").new_status(title)
M.stl_stop = false
M.stl_timer:stop()
M.stl_timer:start(
0,
200,
vim.schedule_wrap(function()
if not M.stl_stop then
vim.cmd.redrawstatus()
end
end)
)
return id
end
return M