Skip to content

Commit

Permalink
feat: autocomplete with trigger chars after confirm
Browse files Browse the repository at this point in the history
fixes #115
  • Loading branch information
max397574 committed Oct 22, 2024
1 parent a47b3f8 commit 5df526c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lua/care/menu/confirm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ return function(entry)
entry.source:execute(entry)
end
unblock()
vim.schedule(function()
require("care").core.context = require("care.context").new(require("care").core.context)
require("care").core:complete(3)
end)
end
14 changes: 13 additions & 1 deletion lua/care/sources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,24 @@ function care_sources.complete(context, source, callback)
callback(require("care.matcher").match(source.entries, prefix))
return
end
elseif context.reason == 3 then
print(last_char)
vim.print(source:get_trigger_characters())
if vim.tbl_contains(source:get_trigger_characters(), last_char) then
completion_context = {
triggerKind = 2,
triggerCharacter = last_char,
}
else
callback({})
return
end
else
completion_context = {
triggerKind = 1,
}
end
if source.incomplete then
if source.incomplete and not context.reason == 3 then
completion_context = {
triggerKind = 3,
}
Expand Down
1 change: 1 addition & 0 deletions lua/care/types/misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
---@alias care.completionReason
---| 1 # Auto
---| 2 # Manual
---| 3 # TriggerOnly

--- The icons used for the different completion item types
---@alias care.config.ui.type_icons table<string, string>

0 comments on commit 5df526c

Please sign in to comment.