Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable blink.cmp remaps when telescope prompt is open #104

Conversation

Jezda1337
Copy link
Contributor

close #102

@pappasam
Copy link
Contributor

Confirmed that this resolves the issue for me!

@sjava
Copy link

sjava commented Oct 12, 2024

Hope to add ignore_buffer_type to the configuration options

@simifalaye
Copy link

Could be a good idea to also make the excluded file types be configurable by the user?

@Rentib
Copy link

Rentib commented Oct 12, 2024

@Jezda1337 won't it be better to make a map: filetype -> bool instead of iterating over excluded filetypes?

… 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)
@Jezda1337
Copy link
Contributor Author

Thank you for the suggestions. I have implemented them as you suggested. Cheers!

@scottmckendry
Copy link
Collaborator

My only qualm with this is that the config option gives the impression the plugin will be disabled for the file types inside the table. This might cause some confusion.

Does it make more sense to turn off blink entirely than just the keymaps?

@Saghen
Copy link
Owner

Saghen commented Oct 12, 2024

Thanks for the PR! Like Scott said, the triggers should also be disabled and the table should be array-like instead of a key = true

@Saghen
Copy link
Owner

Saghen commented Oct 12, 2024

Seems like utils.is_special_buffer() would handle this case without a dedicated blocklist fyi

@scottmckendry
Copy link
Collaborator

This would have the added benefit of closing #52. Probably out of scope for this PR, but we should also think about extending this functionality with user commands like :blink status, :blink toggle, :blink enable and :blink disable.

Exposing these via lua APIs would also be useful for custom user functionality for the plugin too.

scottmckendry added a commit to scottmckendry/blink.cmp that referenced this pull request Oct 12, 2024
potential approach for Saghen#104
- 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.
@Jezda1337
Copy link
Contributor Author

@scottmckendry @Saghen I have updated PR based on Scott's example. Since utils.is_sepcial_buffer() covers all cases I think we don't need an additional config list for the same purpose, wdyt?

@scottmckendry
Copy link
Collaborator

@Jezda1337 great stuff! That approach made more sense when used with the exclude_filetypes approach. However, now that I've thought about it some more, it may make more sense to use is_special_buffer() directly inside the trigger logic.

This would remove the need to set a global variable for buffer-specific logic as well as the extra autocmd in init.lua.

lua/blink/cmp/keymap.lua Outdated Show resolved Hide resolved
lua/blink/cmp/init.lua Outdated Show resolved Hide resolved
lua/blink/cmp/trigger/completion.lua Outdated Show resolved Hide resolved
lua/blink/cmp/trigger/signature.lua Outdated Show resolved Hide resolved
@Jezda1337
Copy link
Contributor Author

@scottmckendry Hey, thanks for the suggestions. I have applied them all. Please feel free to check and ask for additional changes if you need them. I have tested and everything works as before. Cheers!

@scottmckendry scottmckendry merged commit 7f2f74f into Saghen:main Oct 13, 2024
@scottmckendry
Copy link
Collaborator

@Jezda1337 thanks for your efforts! I've merged with a couple of minor changes.

eero-lehtinen pushed a commit to eero-lehtinen/blink.cmp that referenced this pull request Oct 13, 2024
resolves Saghen#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Turn off cmp when in Telescope buffer
7 participants