Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Vim syntax
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 522

PostPosted: Sat Jun 22, 2024 9:32 am    Post subject: Vim syntax Reply with quote

Hi folks

I've noticed that after installing the Gentoo syntax extension for Vim, Vim shows lines beginning with spaces with a red background, as if to indicate some kind of error. This seems to happen with .ebuild files, and files in /etc/init.d. I'm not sure about other files, but I know that my source code is generally note affected.

If this is intentional (and I can't see why it should be, since spaces are fine there) is there a way to turn off the Gentoo syntax highlighting, without breaking anything?

BR, Lars.
Back to top
View user's profile Send private message
Banana
Moderator
Moderator


Joined: 21 May 2004
Posts: 1739
Location: Germany

PostPosted: Sat Jun 22, 2024 9:40 am    Post subject: Reply with quote

I'm currrently not sure about the colors and if it is correct but this package does provide the plugin: https://packages.gentoo.org/packages/app-vim/gentoo-syntax
The wiki has more information about plugins and syntax highlight: https://wiki.gentoo.org/wiki/Vim
_________________
Forum Guidelines

PFL - Portage file list - find which package a file or command belongs to.
My delta-labs.org snippets do expire
Back to top
View user's profile Send private message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 522

PostPosted: Sat Jun 22, 2024 12:48 pm    Post subject: Reply with quote

Thanks. But do you know a way to turn it off? Or, better still, fix it? There's not much in the documentation except 'it exists'.

BR, Lars.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22684

PostPosted: Sat Jun 22, 2024 2:31 pm    Post subject: Reply with quote

I never noticed this, but looked into it due to your post. Ebuild files routinely have indents in their functions, and are not impacted. Examining the syntax file reveals this is because /usr/share/vim/vimfiles/syntax/ebuild.vim loads /usr/share/vim/vimfiles/syntax/gentoo-common.vim. The latter includes:
/usr/share/vim/vimfiles/syntax/gentoo-common.vim:
" bad space
syn region  GentooError start=/^ / end=/$/
This causes leading space characters to be flagged as an error. It does not flag leading tabs as an error, which is why ebuild functions are not flagged. They use tabs for indenting. If I were to guess why this syntax rule exists, I would guess it is because the coding standard is to use tabs, and this rule warns people who try to use spaces there. You can avoid it by using tabs. You could add a Vim local rule to cancel that specific syntax match.
Back to top
View user's profile Send private message
lars_the_bear
Guru
Guru


Joined: 05 Jun 2024
Posts: 522

PostPosted: Sat Jun 22, 2024 5:36 pm    Post subject: Reply with quote

Hu wrote:
I would guess it is because the coding standard is to use tabs, and this rule warns people who try to use spaces there. You can avoid it by using tabs. You could add a Vim local rule to cancel that specific syntax match.


Thanks. I prefer spaces but, of course, I wouldn't want to inflict my odd ways on other people ;)

BR, Lars.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum