Skip to content

Commit

Permalink
fix: check enabled before showing trigger and on mapping
Browse files Browse the repository at this point in the history
Closes #716
  • Loading branch information
Saghen committed Dec 24, 2024
1 parent b3822b5 commit e670720
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lua/blink/cmp/completion/trigger/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ function trigger.show_if_on_trigger_character(opts)
end

function trigger.show(opts)
if not require('blink.cmp.config').enabled() then return trigger.hide() end

opts = opts or {}

-- already triggered at this position, ignore
Expand Down
4 changes: 4 additions & 0 deletions lua/blink/cmp/keymap/apply.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function apply.keymap_to_current_buffer(keys_to_commands)

local fallback = require('blink.cmp.keymap.fallback').wrap('i', key)
apply.set('i', key, function()
if not require('blink.cmp.config').enabled() then return fallback() end

for _, command in ipairs(commands) do
-- special case for fallback
if command == 'fallback' then
Expand Down Expand Up @@ -45,6 +47,8 @@ function apply.keymap_to_current_buffer(keys_to_commands)

local fallback = require('blink.cmp.keymap.fallback').wrap('s', key)
apply.set('s', key, function()
if not require('blink.cmp.config').enabled() then return fallback() end

for _, command in ipairs(keys_to_commands[key] or {}) do
-- special case for fallback
if command == 'fallback' then
Expand Down
4 changes: 3 additions & 1 deletion lua/blink/cmp/keymap/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function keymap.setup()
-- This is not called when the plugin loads since it first checks if the binary is
-- installed. As a result, when lazy-loaded on InsertEnter, the event may be missed
if vim.api.nvim_get_mode().mode == 'i' and require('blink.cmp.config').enabled() then
require('blink.cmp.keymap.apply').keymap_to_current_buffer(mappings)
if require('blink.cmp.config').enabled() then

This comment has been minimized.

Copy link
@Kaiser-Yang

Kaiser-Yang Dec 25, 2024

Contributor

Line 62 has checke the enable status, there is no need to check in line 63.

require('blink.cmp.keymap.apply').keymap_to_current_buffer(mappings)
end
end

-- Apply cmdline keymaps since they're global, if any sources are defined
Expand Down

0 comments on commit e670720

Please sign in to comment.