tmux-plugins/vim-tmux

Numers in option names highlighted wrong

y opened this issue · 8 comments

y commented

The numbers in option names are highlighted differently than the rest of the option name. Examples: prefix2, utf8, status-utf8, mouse-utf8.

Hey, are you sure you're using this plugin when you get the above described result?

I can reproduce what you're saying with the tmux syntax highlighting that comes default with vim.
I think syntax highlithing in this plugin is much more sophisticated (and also up to date it seems).

When I use syntax highlighting from this plugin I'm NOT getting the behavior when you're describing. All those keywords are correctly registered as vim keywords and are highlighted properly.

Please reopen the issue if I got something wrong..

y commented

Tested on Vim 8.0.0596 with pathogen. This definitely is a syntax issue with this plugin. But all other available tmux syntaxes, including the official one, appear to suffer from this. I did find the fix for this plugin's syntax:

diff --git a/syntax/tmux.vim b/syntax/tmux.vim
index 8f4acf2..02772ed 100644
--- a/syntax/tmux.vim
+++ b/syntax/tmux.vim
@@ -161,7 +161,7 @@ syn keyword tmuxTodo FIXME NOTE TODO XXX todo contained
syn match tmuxURL `\v<(((https?|ftp|gopher)://|(mailto|file|news):)[^'  <>"]+|(www|web|w3)[a-z0-9_-]*\.[a-z0-9._-]+\.[^'  <>"]+)[a-zA-Z0-9/]` contained

syn match tmuxKey               /\(C-\|M-\|\^\)\+\S\+/  display
-syn match tmuxNumber            /[+-]\?\d\+/            display
+syn match tmuxNumber            /[+-]\?\d\+/            contained display
syn match tmuxSelWindowOption   /:[!+-]\?/              display
syn match tmuxOptions           /\s-\a\+/               display
syn match tmuxVariable          /\w\+=/                 display

Hi,
I tried your patch but that one messes highlighting for regular numbers on a line like this set -g history-limit 5000. 5000 is a standalone, non-contained word that needs to be highlighted on its own.

Also I'm still not able to reproduce the original issue. I have 2 suggestions:

  • would you mind pasting minimal .vimrc where this is occurring for you? I imagine it would be something like an empty .vimrc with just pathogen loading this plugin.

  • can you try manually changing the tmuxNumber line to this and see if it fixes the issue? syn match tmuxNumber /\<[+-]\?\d\+/ display (there's a small addition \< near the start of regex)

y commented

I finally tracked down the offending cause; this was contained in a system file:

syn match unprintableASCII '[^\x9\x20-\x7e]\+' containedin=ALL

I'm not sure why this causes tmuxNumber to match the 8 in set -g status-utf8 on, but it does.

Your suggested change to tmuxNumber does fix this problem. Thanks!

Hm.. If your find with unprintableASCII causes the issue, why would changing tmuxNumber fix it?

I committed that tmuxNumber change in this commit d8ef7af

I think this is finally solved.