Closed oliv3r closed 9 months ago
14332440'
That is parsed as an hex value, which if of course invalid.
@chrisbra where is the mistake you say? It's an #RRGGBBAA
hex value, colorizer's regex seems to accept it x\{8\}
no? Ignoring the Alpha part is fine for the preview of course.
you are right. And I just tested it. It works fine for me. Are you potentially using some yml
plugin, that modified the iskeyword
setting?
If you manually search using the pattern: #\%(\x\{3}\|\x\{6}\|\x\{8\}\)\%(\>\|[-_]\)\@=
what exactly is matched/highlighted in line 57?
My file has changed since a bit, but here's what the regex copy/pasted into vim's search mode does.
As for iskeyword
, I see vim-polyglot is using it a lot; but here's all addons I currently use: https://gitlab.com/olliver/dotfiles/-/tree/master/.local/share/vim/pack?ref_type=heads
can you try with the vim-polyglot plugin disabled please? It contains a yaml
syntax script, not sure if this would cause it. I'll check it
And I still cannot reproduce. What is on line 112, column 30 Plase?
The second screenshots should show it no? It's the highlighted line. It's the first character after the quote, e.g. the #
marker
Hm, I still cannot reproduce with this specific value. Can you step through the code? Run:
:breakadd func *PreviewColorHex
:ColorHighlight
This should drop you into the internal debugger. Step through the code using n
(See also :h :debug
) and remember the line where it throws an error. Try to show the related variables using e.g. :echo var
.
That function is not that long: https://github.com/chrisbra/Colorizer/blob/2908e0683edd6a32065b4eff933623b67207ad17/autoload/Colorizer.vim#L987-L1023
I copied my original snippet to a file, and used that to debug, not sure which variable you'd like printed though :)
But E121: Undefined variable: s:colortable
looks interesting?
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 2: if <sid>IsInComment()
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 5: endif
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 6: let color = (a:match[0] == '#' ? a:match[1:] : a:match)
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 7: let pattern = color
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 8: if len(color) == 3
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 10: endif
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 11: if &t_Co == 8 && !s:HasGui()
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 21: endif
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 22: if len(split(pattern, '\zs')) == 8
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 24: let l = split(pattern, '..\zs')
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 25: call map(l, 'printf("%2d", "0x".v:val)')
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 26: let l[3] = string(str2float(l[3])/255) " normalize to 0-1
>n
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 27: let l = s:ApplyAlphaValue(l)
>n
Exception thrown: Vim(let):E121: Undefined variable: s:colortable
function Colorizer#DoColor[73]..<SNR>158_PreviewColorHex
line 27: End of function
>n
function Colorizer#DoColor
line 80: catch
>n
Exception caught: Vim(let):E121: Undefined variable: s:colortable
function Colorizer#DoColor
line 83: let error.=" Colorize: ". string(Pat)
>n
function Colorizer#DoColor
line 84: break
>n
Exception finished: Vim(let):E121: Undefined variable: s:colortable
:break made pending
function Colorizer#DoColor
line 86: finally
>n
function Colorizer#DoColor
line 87: if exists("s:extension")
>n
function Colorizer#DoColor
line 90: endif
>n
function Colorizer#DoColor
line 91: endtry
>n
:break resumed
function Colorizer#DoColor
line 93: endfor
>n
function Colorizer#DoColor
line 94: else
>n
function Colorizer#DoColor
line 98: for Pat in [ s:color_patterns_special.term, s:color_patterns_special.term_nroff ]
>n
function Colorizer#DoColor
line 99: let start = s:Reltime()
>n
function Colorizer#DoColor
line 100: if (s:CheckTimeout(Pat[0], a:force)) && !s:IsInComment()
>n
function Colorizer#DoColor
line 127: endif
>n
function Colorizer#DoColor
line 128: endfor
>n
function Colorizer#DoColor
line 98: for Pat in [ s:color_patterns_special.term, s:color_patterns_special.term_nroff ]
>n
function Colorizer#DoColor
line 99: let start = s:Reltime()
>n
function Colorizer#DoColor
line 100: if (s:CheckTimeout(Pat[0], a:force)) && !s:IsInComment()
>n
function Colorizer#DoColor
line 127: endif
>n
function Colorizer#DoColor
line 128: endfor
>n
function Colorizer#DoColor
line 98: for Pat in [ s:color_patterns_special.term, s:color_patterns_special.term_nroff ]
>n
function Colorizer#DoColor
line 128: endfor
>n
function Colorizer#DoColor
line 132: call s:SyntaxMatcher(s:color_syntax)
>n
function Colorizer#DoColor
line 133: if !exists("#FTColorizer#BufWinEnter#<buffer>") && empty(error)
>n
function Colorizer#DoColor
line 137: endif
>n
function Colorizer#DoColor
line 138: let s:relstop = s:Reltime(s:relstart)
>n
function Colorizer#DoColor
line 139: if !empty(error)
>n
function Colorizer#DoColor
line 141: call Colorizer#ColorOff()
>n
function Colorizer#DoColor
line 142: call s:Warn("Some error occurred here: ". error)
>n
Colorizer: Some error occurred here: Colorize: ['#\%(\x\{3}\|\x\{6}\|\x\{8\}\)\%(\>\|[-_]\)\@=', function('<SNR>158_PreviewColorHex'), 'colorizer_hex', 1, []]
function Colorizer#DoColor
line 143: if exists("s:position")
>n
function Colorizer#DoColor
line 144: call s:Warn("Position: ". string(s:position))
>n
Colorizer: Position: [0, 57, 21, 0]
function Colorizer#DoColor
line 145: call matchadd('Color_Error', '\%'.s:position[1].'l\%'.s:position[2].'c.*\>')
>n
function Colorizer#DoColor
line 146: endif
oh, that is interesting. What Vim version is this? And what does :set t_Co?
output?
t_Co=16777216
:version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 02 2024 18:36:25)
Compiled by Arch Linux
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +cryptv +fork() +modify_fname +persistent_undo -sun_workshop +viminfo
+arabic +cscope +gettext +mouse +popupwin +syntax +virtualedit
+autocmd +cursorbind -hangul_input +mouseshape +postscript +tag_binary +visual
+autochdir +cursorshape +iconv +mouse_dec +printer -tag_old_static +visualextra
-autoservername +dialog_con_gui +insert_expand +mouse_gpm +profile -tag_any_white +vreplace
+balloon_eval +diff +ipv6 -mouse_jsbterm -python +tcl/dyn +wildignore
+balloon_eval_term +digraphs +job +mouse_netterm +python3/dyn +termguicolors +wildmenu
+browse +dnd +jumplist +mouse_sgr +quickfix +terminal +windows
++builtin_terms -ebcdic +keymap -mouse_sysmouse +reltime +terminfo +writebackup
+byte_offset +emacs_tags +lambda +mouse_urxvt +rightleft +termresponse +X11
+channel +eval +langmap +mouse_xterm +ruby/dyn +textobjects +xattr
+cindent +ex_extra +libcall +multi_byte +scrollbind +textprop -xfontset
+clientserver +extra_search +linebreak +multi_lang +signs +timers +xim
+clipboard -farsi +lispindent -mzscheme +smartindent +title -xpm
+cmdline_compl +file_in_path +listcmds +netbeans_intg -sodium +toolbar +xsmp_interact
+cmdline_hist +find_in_path +localmap +num64 +sound +user_commands +xterm_clipboard
+cmdline_info +float +lua/dyn +packages +spell +vartabs -xterm_save
+comments +folding +menu +path_extra +startuptime +vertsplit
+conceal -footer +mksession +perl/dyn +statusline +vim9script
Hm, I cannot see, why s:colortable
wouldn't be defined. Anyway, I think I have fixed this issue now, by explicitly checking that the s:colortable
var exists. Please check it.
Did a git pull, but no banana :( I closed all my other vim windows, no vim process was running, checked the git log, redid the :so vimbal
, cause who knows`.
Entering Debug mode. Type "cont" to continue.
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 1: let s:position = getpos('.')
>n
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 2: if <sid>IsInComment()
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 5: endif
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 6: let color = (a:match[0] == '#' ? a:match[1:] : a:match)
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 7: let pattern = color
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 8: if len(color) == 3
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 10: endif
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 11: if &t_Co == 8 && !s:HasGui()
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 21: endif
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 22: if len(split(pattern, '\zs')) == 8
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 24: let l = split(pattern, '..\zs')
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 25: call map(l, 'printf("%2d", "0x".v:val)')
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 26: let l[3] = string(str2float(l[3])/255) " normalize to 0-1
>
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 27: let l = s:ApplyAlphaValue(l)
>
Exception thrown: Vim(let):E121: Undefined variable: s:colortable
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 27: End of function
>
function Colorizer#DoColor
line 80: catch
>
Exception caught: Vim(let):E121: Undefined variable: s:colortable
function Colorizer#DoColor
line 83: let error.=" Colorize: ". string(Pat)
>
function Colorizer#DoColor
line 84: break
>
Exception finished: Vim(let):E121: Undefined variable: s:colortable
:break made pending
function Colorizer#DoColor
line 86: finally
>
function Colorizer#DoColor
line 87: if exists("s:extension")
>
function Colorizer#DoColor
line 90: endif
>
function Colorizer#DoColor
line 91: endtry
>
:break resumed
function Colorizer#DoColor
line 93: endfor
>
function Colorizer#DoColor
line 94: else
>
function Colorizer#DoColor
line 98: for Pat in [ s:color_patterns_special.term, s:color_patterns_special.term_nroff ]
>
function Colorizer#DoColor
line 99: let start = s:Reltime()
>
function Colorizer#DoColor
line 100: if (s:CheckTimeout(Pat[0], a:force)) && !s:IsInComment()
>
function Colorizer#DoColor
line 127: endif
>
function Colorizer#DoColor
line 128: endfor
>
function Colorizer#DoColor
line 98: for Pat in [ s:color_patterns_special.term, s:color_patterns_special.term_nroff ]
>
function Colorizer#DoColor
line 99: let start = s:Reltime()
>
function Colorizer#DoColor
line 100: if (s:CheckTimeout(Pat[0], a:force)) && !s:IsInComment()
>
function Colorizer#DoColor
line 127: endif
>
function Colorizer#DoColor
line 128: endfor
>
function Colorizer#DoColor
line 98: for Pat in [ s:color_patterns_special.term, s:color_patterns_special.term_nroff ]
>
function Colorizer#DoColor
line 128: endfor
>
function Colorizer#DoColor
line 132: call s:SyntaxMatcher(s:color_syntax)
>
function Colorizer#DoColor
line 133: if !exists("#FTColorizer#BufWinEnter#<buffer>") && empty(error)
>
function Colorizer#DoColor
line 137: endif
>
function Colorizer#DoColor
line 138: let s:relstop = s:Reltime(s:relstart)
>
function Colorizer#DoColor
line 139: if !empty(error)
>
function Colorizer#DoColor
line 141: call Colorizer#ColorOff()
>
function Colorizer#DoColor
line 142: call s:Warn("Some error occurred here: ". error)
>
Colorizer: Some error occurred here: Colorize: ['#\%(\x\{3}\|\x\{6}\|\x\{8\}\)\%(\>\|[-_]\)\@=', function('<SNR>159_PreviewColorHex'), 'colorizer_hex', 1, []]
function Colorizer#DoColor
line 143: if exists("s:position")
>
function Colorizer#DoColor
line 144: call s:Warn("Position: ". string(s:position))
>
Colorizer: Position: [0, 57, 21, 0]
function Colorizer#DoColor
line 145: call matchadd('Color_Error', '\%'.s:position[1].'l\%'.s:position[2].'c.*\>')
>
function Colorizer#DoColor
line 146: endif
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
line 27: let l = s:ApplyAlphaValue(l)
>
Exception thrown: Vim(let):E121: Undefined variable: s:colortable
function Colorizer#DoColor[73]..<SNR>159_PreviewColorHex
I would question that the git pull was successful. The ApplyAlphaValue()
function looks like this:
https://github.com/chrisbra/Colorizer/blob/7db0e0dd8adfccab35655f5b6db805caa0fef49a/autoload/Colorizer.vim#L2175-L2214
It should not be possible, that the s:colortable
variable is undefined anymore. Can you please also check the output of :scriptnames
and check, what scripts are loaded for Colorizer
? And perhaps check:
:verbose :func <SNR>159_ApplyAlphaValue
and compare the function with the git function mentioned above.
You can also try to step into it, by :breakadd func *ApplyAlphaValue
instead of the Preview
function used before.
So this is interesting, I may have messed up my install, because it loads colorizer from /.config/vim/autoload/Colorizer.vim' instead of the
pack` folder. I'll wipe things and try again.
So that was the issue, Initially, I did git clone https://github.com/chrisbra/Colorizer ~/.vim/pack/dist/start/colorizer
, but for whatever reason I did the vimball install, but that messes things up of course, as it copies stuff into autoload, but a git pull, doesn't know and that gets loaded first, and then the git repo gets ignored. It works now!! Thank you!
ah, seems you did run the vimball install initially. you may need to clean up ~/.config/vim/autoload/Colorizer.vim
, ~/.config/vim/plugin/ColorizerPlugin.vim
and ~/.config/vim/doc/Colorizer.txt
ah perfect. Thanks for letting me know!
I was super excited to give this a go; but while 1 color sort-of, showed up; I got the following error:
on the following yaml