Skip to content

Commit 7f2f74f

Browse files
fix: disable blink.cmp remaps when telescope prompt is open (#104)
resolves #102 * disable blink.cmp remaps when telescope prompt is open * make it a bit cleaner * implemented iteration over exclude_filetypes table * add `exclude_filetypes` config option to disable keymaps for specific filetypes - Implemented `exclude_filetypes` as a config option with default values (`TelescopePrompt` - Improved performance by using a map for filetype lookups instead of iterating over a list - Keymaps are now disabled for buffers matching the excluded filetypes) * add dynamic plugin disabling based on file type - Implemented autocommand for BufEnter and InsertEnter events to disable the plugin dynamically for specific file types. - Added a global variable `vim.g.blinkcmp_enabled` to track whether the plugin is enabled. - Updated relevant parts of the plugin to return early if the plugin is disabled for a file type. * remove old unused code * refactor: remove blinkcmp_enabled flag and directly utilize utils.is_special_buffer() for buffer handling * refactor: remove extra calls to is_special_buffer where logic already exists --------- Co-authored-by: Scott McKendry <[email protected]>
1 parent a12617d commit 7f2f74f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lua/blink/cmp/keymap.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ function keymap.setup(opts)
4343
-- from overriding our mappings. We also use InsertEnter to avoid conflicts with keymaps
4444
-- applied on other autocmds, such as LspAttach used by nvim-lspconfig and most configs
4545
vim.api.nvim_create_autocmd('InsertEnter', {
46-
callback = function() keymap.apply_keymap_to_current_buffer(insert_keys_to_commands, snippet_keys_to_commands) end,
46+
callback = function()
47+
if utils.is_special_buffer() then return end
48+
keymap.apply_keymap_to_current_buffer(insert_keys_to_commands, snippet_keys_to_commands)
49+
end,
4750
})
4851
end
4952

lua/blink/cmp/trigger/completion.lua

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function trigger.activate_autocmds()
6161

6262
vim.api.nvim_create_autocmd({ 'CursorMovedI', 'InsertEnter' }, {
6363
callback = function(ev)
64+
if utils.is_special_buffer() then return end
65+
6466
-- we were told to ignore the cursor moved event, so we update the context
6567
-- but don't send an on_show event upstream
6668
if trigger.ignore_next_cursor_moved and ev.event == 'CursorMovedI' then

lua/blink/cmp/trigger/signature.lua

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function trigger.activate_autocmds()
6060
-- check if we've moved outside of the context by diffing against the query boundary
6161
vim.api.nvim_create_autocmd({ 'CursorMovedI', 'InsertEnter' }, {
6262
callback = function(ev)
63+
if utils.is_special_buffer() then return end
64+
6365
-- characters added so let textchanged handle it
6466
if #last_chars ~= 0 then return end
6567

0 commit comments

Comments
 (0)