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

select breaks syntax highlighting in bash #14795

Open
DarioDarko opened this issue May 17, 2024 · 7 comments
Open

select breaks syntax highlighting in bash #14795

DarioDarko opened this issue May 17, 2024 · 7 comments
Labels

Comments

@DarioDarko
Copy link

Steps to reproduce

set filetype to sh or bash
use 'select' as a command argument without surrounding quotes
watch the syntax highlighting break

example:

while true
do
	anycommand select something
done

i randomly discovered this because copyq has a select argument, that i use in a script

Expected behaviour

'select' should not break the syntax highlighting if its used as an argument for a command. the syntax recognition logic should only trigger if its at the very beginning of the line, after && semicolon etc

Version of Vim

9.1.0408-1

Environment

EndeavourOS
Alacritty

Logs and stack traces

No response

@DarioDarko DarioDarko added the bug label May 17, 2024
@chrisbra
Copy link
Member

I don't see this. Can you please verify using vim --clean
grafik

@DarioDarko
Copy link
Author

DarioDarko commented May 18, 2024

vim --clean

image

@chrisbra
Copy link
Member

Hm, did you use bash initially? I only see this when using bash in the shebang line.
This seems to happen when the syntax script determines a bash script, because bash "knows" select name [ in word ] ; do list ; done, which the syntax script tries to match here. And since there is a missing do here, it matches the done with an error. You can workaround this by setting :let b:is_posix=1.

@DarioDarko
Copy link
Author

yes normally i use bash, but for me this happens with sh as well

btw this does not only affect select. same with while, until, for, etc

@chrisbra
Copy link
Member

btw this does not only affect select. same with while, until, for, etc

Yeah, for the same reason, you are using reserved words which the syntax script tries to match against the expected syntax.

:let b:is_posix=1

So does this help?

@DarioDarko
Copy link
Author

DarioDarko commented May 19, 2024

Yeah, for the same reason, you are using reserved words which the syntax script tries to match against the expected syntax.

yes, i understand the issue. wouldt it be pretty simple to fix that in the syntax script?

So does this help?

unfortunately no
image

@chrisbra
Copy link
Member

You need to reload the file after :let b:is_posix=1 using :e!, otherwise setting the buffer local var happens too late.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants