NvChad / nvim-colorizer.lua

Maintained fork of the fastest Neovim colorizer
Other
708 stars 47 forks source link

sass mode throwing error on virtual text mode #41

Closed jnimety closed 1 year ago

jnimety commented 1 year ago

Describe the bug

Error executing vim.schedule lua callback: ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:112: col value outside range                    
stack traceback:                                                                                                                                       
        [C]: in function 'buf_set_virtual_text'                                                                                                        
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:112: in function 'add_highlight'                                                   
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:149: in function 'highlight'                                                       
        ...packer/start/nvim-colorizer.lua/lua/colorizer/buffer.lua:259: in function 'rehighlight'                                                     
        ...k/packer/start/nvim-colorizer.lua/lua/colorizer/sass.lua:208: in function 'callback'                                                        
        .../packer/start/nvim-colorizer.lua/lua/colorizer/utils.lua:153: in function 'on_change'                                                       
        .../packer/start/nvim-colorizer.lua/lua/colorizer/utils.lua:167: in function ''                                                                
        vim/_editor.lua: in function <vim/_editor.lua:0> j

To Reproduce

I can trigger the error if I have two scss files, one referencing variables in the other (see screenshot).

  1. Open both files
  2. rename variable $foo: #fefefe; to $oo: #fefefe; and save
  3. go to the other file and :e to reload it
  4. go back to the edited file and change $oo back to $foo and save to trigger error

Expected behavior

no error :)

Screenshots

Screenshot 2023-01-03 at 8 12 41 PM

Operating System:

MacOS Ventura 13.1

Neovim Version:

$ nvim --version
NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Ventura-arm64.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.8.2/share/nvim"

Run :checkhealth for more info

Colorizer Version:

$ find ~/.local/share/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;
cddef405becd72deef72219db005a8bbf0603919

Additional context

require 'colorizer'.setup({            
  filetypes = { "css", "scss" },       
  user_default_options = {             
    RGB = true, -- #RGB hex codes      
    RRGGBB = true, -- #RRGGBB hex codes
    css = false,                       
    rgb_fn = true,                     
    hsl_fn = true,                     
    mode = "virtualtext",              
    names = false,                     
    sass = {                           
      enable = true,                   
      parsers = {                      
        RGB = true,                    
        RRGGBB = true,                 
        css = false,                   
        rgb_fn = true,                 
        hsl_fn = true,                 
        mode = "virtualtext",          
        names = false,                 
      },                               
    },                                 
    virtualtext = ""                  
  }                                    
})
Akianonymus commented 1 year ago

This should be fixed now.