diff --git a/README.md b/README.md index a310a8e0..efe2875b 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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 = { diff --git a/lua/fittencode/bindings.lua b/lua/fittencode/bindings.lua index 9e548947..361888a4 100644 --- a/lua/fittencode/bindings.lua +++ b/lua/fittencode/bindings.lua @@ -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 @@ -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 @@ -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 @@ -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, { '', '', diff --git a/lua/fittencode/config.lua b/lua/fittencode/config.lua index 34e9fadb..8ea6c380 100644 --- a/lua/fittencode/config.lua +++ b/lua/fittencode/config.lua @@ -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).