Skip to content

Commit

Permalink
Add auto_triggering_completion to config
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed May 19, 2024
1 parent b862bf6 commit d971099
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ use {
-- Disable auto completion when pressing Backspace or Delete.
---@type boolean
disable_completion_when_delete = false,
-- Auto triggering completion
---@type boolean
auto_triggering_completion = true,
},
delay_completion = {
-- Delay time for inline completion (in milliseconds).
Expand All @@ -121,8 +124,8 @@ use {
},
-- Set the mode of the completion.
-- Available options:
-- - 'inline' (default)
-- - 'source'
-- - 'inline' (VSCode style inline completion)
-- - 'source' (integrates into other completion plugins)
completion_mode = 'inline',
---@class LogOptions
log = {
Expand Down
13 changes: 11 additions & 2 deletions lua/fittencode/bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function M.setup_autocmds()
if not InlineEngine.is_inline_enabled() then
return
end
if not Config.options.inline_completion.auto_triggering_completion then
return
end
if ignore then
return
end
Expand All @@ -40,6 +43,9 @@ function M.setup_autocmds()
pattern = '*',
callback = function()
-- Log.debug('CursorMovedI')
if not Config.options.inline_completion.auto_triggering_completion then
return
end
if ignore then
return
end
Expand All @@ -55,6 +61,9 @@ function M.setup_autocmds()
pattern = '*',
callback = function()
-- Log.debug('TextChangedI')
if not Config.options.inline_completion.auto_triggering_completion then
return
end
if ignore then
return
end
Expand Down Expand Up @@ -247,8 +256,8 @@ end

-- '<80>kd', '<80>kD' in Lua
local FILTERED_KEYS = {}
vim.tbl_map(function(trigger)
FILTERED_KEYS[#FILTERED_KEYS + 1] = api.nvim_replace_termcodes(trigger, true, true, true)
vim.tbl_map(function(key)
FILTERED_KEYS[#FILTERED_KEYS + 1] = api.nvim_replace_termcodes(key, true, true, true)
end, {
'<Backspace>',
'<Delete>',
Expand Down
3 changes: 3 additions & 0 deletions lua/fittencode/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ local defaults = {
-- Disable auto completion when pressing Backspace or Delete.
---@type boolean
disable_completion_when_delete = false,
-- Auto triggering completion
---@type boolean
auto_triggering_completion = true,
},
delay_completion = {
-- Delay time for inline completion (in milliseconds).
Expand Down

0 comments on commit d971099

Please sign in to comment.