Skip to content

Commit eb793a7

Browse files
author
wfhtqp
committedNov 21, 2023
fix: event
1 parent 4c69568 commit eb793a7

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed
 

‎lua/cmp_tabby/config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ local M = {}
33
local conf_defaults = {
44
host = 'http://localhost:5000',
55
max_lines = 100,
6+
run_on_every_keystroke = true,
67
stop = { '\n' },
78
}
89

‎lua/cmp_tabby/source.lua

+32-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Source.is_available(self)
2424
end
2525

2626
function Source.get_debug_name()
27-
return 'tabby'
27+
return 'Tabby'
2828
end
2929

3030
function Source._do_complete(self, ctx, callback)
@@ -107,7 +107,7 @@ function Source._do_complete(self, ctx, callback)
107107
}
108108

109109
local item = {
110-
label = newText,
110+
label = cur_line_before .. newText,
111111
-- removing filterText, as it interacts badly with multiline
112112
-- filterText = newText,
113113
data = {
@@ -122,7 +122,7 @@ function Source._do_complete(self, ctx, callback)
122122
sortText = newText,
123123
dup = 0,
124124
cmp = {
125-
kind_text = 'tabby',
125+
kind_text = 'Tabby',
126126
},
127127
documentation = {
128128
kind = cmp.lsp.MarkupKind.Markdown,
@@ -133,6 +133,7 @@ function Source._do_complete(self, ctx, callback)
133133
item['data']['multiline'] = true
134134
end
135135
table.insert(items, item)
136+
self:view(item)
136137
end
137138
end
138139
end
@@ -148,6 +149,34 @@ function Source._do_complete(self, ctx, callback)
148149
})
149150
end
150151

152+
--- view
153+
function Source.view(self, item)
154+
-- dump(item)
155+
local req = {
156+
type = 'view',
157+
completion_id = item.data.id,
158+
choice_index = item.data.choice,
159+
}
160+
-- dump(vim.json.encode(req))
161+
fn.jobstart({
162+
'curl',
163+
'-s',
164+
'-H',
165+
'Content-type: application/json',
166+
'-H',
167+
'Accept: application/json',
168+
'-X',
169+
'POST',
170+
'-d',
171+
vim.json.encode(req),
172+
conf:get('host') .. '/v1/events',
173+
}, {
174+
on_stdout = function(_, c, _)
175+
-- dump(c)
176+
end,
177+
})
178+
end
179+
151180
--- execute
152181
function Source.execute(self, item, callback)
153182
-- dump(item)

0 commit comments

Comments
 (0)
Please sign in to comment.