Skip to content

fix: disable syntax highlighting for input buffer#127

Merged
dmtrKovalenko merged 1 commit intodmtrKovalenko:mainfrom
oskarrrrrrr:fix-input-buffer-highlighting
Aug 23, 2025
Merged

fix: disable syntax highlighting for input buffer#127
dmtrKovalenko merged 1 commit intodmtrKovalenko:mainfrom
oskarrrrrrr:fix-input-buffer-highlighting

Conversation

@oskarrrrrrr
Copy link
Copy Markdown
Contributor

When syntax is enabled Neovim tries really hard to provide syntax highlighting. This is the simplest way I found to disable it for just one buffer.

Setting syntax = '' when the buffer is created is not enough, it will get overwritten on changes to the buffer and setting syntax = '' on buffer change wasn't 100% reliable for some reason.

Buffer scoped autocmds are cleaned up when the buffer is destroyed.

Fixes: #112

Comment thread lua/fff/picker_ui.lua
-- syntax highlighting. This makes sure that it's always off.
vim.api.nvim_create_autocmd('Syntax', {
buffer = M.state.input_buf,
callback = function() vim.api.nvim_buf_set_option(M.state.input_buf, 'syntax', '') end,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to do this on autocmd if we can set the option directly on a buffer when creating it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting it once is not enough. Neovim tries to guess the file type as you type and it will overwrite it.

This is what happens when you set it just once, immediately after opening the search:
Screenshot 2025-08-23 at 17 32 33

and after you type something that looks like Lua:
Screenshot 2025-08-23 at 17 32 52

We can see that Neovim overwrites the value.

@dmtrKovalenko
Copy link
Copy Markdown
Owner

with your changes I can still see the highlights in the prompt
image

@oskarrrrrrr
Copy link
Copy Markdown
Contributor Author

oskarrrrrrr commented Aug 23, 2025

I just double checked and it works for me. Can you open a new neovim instance, open fff and run :verbose set syntax? (you need to press first to escape the prompt) and then type "if" in the prompt and run the command again?

@dmtrKovalenko
Copy link
Copy Markdown
Owner

this is what I get

20:27:29 msg_show.list_cmd   verbose set syntax?   syntax=fff_input

while there is still syntax highlighting

@dmtrKovalenko
Copy link
Copy Markdown
Owner

sorry it's me being dumb

@dmtrKovalenko dmtrKovalenko merged commit fd38df7 into dmtrKovalenko:main Aug 23, 2025
7 checks passed
@oskarrrrrrr oskarrrrrrr deleted the fix-input-buffer-highlighting branch August 24, 2025 05:34
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.

Strange highlighting in prompt buffer

2 participants