Skip to content

Error for unquoted highlight colors #109

Open

Description

@Rmano

Hi, Thanks for the plugin!

I have a little problem. In the following .vim file (excerpt from my init.vim, it fails:

"
"
hi Error guibg_"#ff0000"
lua << HERE
        color1 = "#ff0000"
        -- color1 = "#ffff00"
HERE
"
hi MarkologyHLu guifg=Black guibg=Pink

It gives the error:

Colorizer: Some error occurred here:  Colorize: ['\%(gui[fb]g\|cterm[fb]g\)\s*=\s*\<\%(\d\+\|#\x\{6}\|\w\+\)\>', function('<SNR>122_PreviewVimColors'), 'colorizer_vimcolors', '&ft ==# "vim"', []]
Colorizer: Position: [0, 9, 17, 0]

and then it will not colorize anything.

Activity

  1. chrisbra commented on Jan 7, 2025

    @chrisbra
    Owner

    I don't see this :/ Can you reproduce just with this single file? Do you have any configuration set?

    Line 9, Column 17 ist the Black, not sure why this would error out here.

  2. Rmano commented on Jan 7, 2025

    @Rmano
    Author

    Uff, yes, I have a bit of (ouch) configuration. I'll see if I can reproduce it with a minimal config.

    Thank you for your prompt answer.

  3. Rmano commented on Jan 8, 2025

    @Rmano
    Author

    I can confirm that I have no error with a minimal configuration, so it must be some clash with some other plugin.

    My init.vim is quite complex, but I can share it if you want to glance at it...

    Full `init.vim`
    " vim: set sw=4 :
    set nocompatible " vim, not vi
    set viminfo='50,<1000,s10,:100,/100,h,n~/.config/nvim/backups/viminfo
    filetype plugin on
    syntax on
    " Plugin management via https://github.com/junegunn/vim-plug
    "
    " my leader is ,
    let mapleader = ","
    " this is the default `\`
    " let maplocalleader = ","
    "
    call plug#begin('~/.config/nvim/plugged')
    " Heredoc highlighting
    let g:vimsyn_embed = 'lPr'  " support embedded lua, python and ruby
    "
    " vim-plug
    "
    let g:plug_window = 'above new'
    "
    Plug 'tpope/vim-repeat'
    "
    Plug 'tpope/vim-surround'
    "
    Plug 'tpope/vim-commentary'
    "
    Plug 'tpope/vim-characterize'
    "
    Plug 'SirVer/ultisnips'
        let g:UltiSnipsExpandTrigger="<tab>"
        let g:UltiSnipsJumpForwardTrigger="<tab>"
        let g:UltiSnipsJumpBackwardTrigger="<c-z>"
        " If you want :UltiSnipsEdit to split your window.
        let g:UltiSnipsEditSplit="vertical"
    "
    " use Plug 'lervag/vimtex', { 'branch': 'feat/context' } to test a branch
    " use Plug 'lervag/vimtex', { 'branch': 'feat/improve-main-file-detection' }
    " Plug 'lervag/vimtex', { 'tag': 'v2.15' }
    Plug 'lervag/vimtex'
        let g:tex_flavor='latex'
        let g:vimtex_fold_enabled=0
        " this two (especially the last) can create slowdows
        " read :help vimtex-af-enhanced-matchparen
        " let g:vimtex_indent_enabled=0
        " let g:vimtex_motion_matchparen = 0
        let g:vimtex_matchparen_enabled = 0
        let g:vimtex_quickfix_autoclose_after_keystrokes=5
        let g:tex_no_error=1
        " let g:vimtex_complete_img_use_tail=1
        if (executable("okular"))
            let g:vimtex_view_general_viewer = 'okular'
            " let g:vimtex_view_general_options = '--unique @pdf\#src:@line@tex'
            " let g:vimtex_view_general_options_latexmk = '--unique'
        endif
        " add pgfscope to the indent keyword
        let g:vimtex_indent_conditionals = {
          \ 'open': '\v%(\\newif)@<!\\if%(field|name|numequal|thenelse|num)@!|\\pgfscope>',
          \ 'else': '\\else\>',
          \ 'close': '\\fi\>\|\\endpgfscope\>',
          \}"
        " add item-like environment
        let g:vimtex_indent_lists = [
          \ 'itemize',
          \ 'description',
          \ 'enumerate',
          \ 'compactenum',
          \ 'thebibliography',
          \ 'multi',
          \]
    ""
    Plug 'vim-airline/vim-airline'
    Plug 'vim-airline/vim-airline-themes'
        " let g:airline_powerline_fonts = 1
        if !exists('g:airline_symbols')
            let g:airline_symbols = {}
        endif
        let g:airline_theme='light'
        set laststatus=2
        set t_Co=256
        set ttimeoutlen=50
        " unicode symbols
          let g:airline_symbols.crypt = '🔒'
          " let g:airline_symbols.linenr = '☰'
          " let g:airline_symbols.linenr = '␊'
          " let g:airline_symbols.linenr = '␤'
          " let g:airline_symbols.linenr = '¶' "this creates havoc
          " let g:airline_symbols.maxlinenr = ''
          " let g:airline_symbols.maxlinenr = '㏑'
          " let g:airline_symbols.branch = '⎇'
          " let g:airline_symbols.paste = 'ρ'
          let g:airline_symbols.paste = 'Þ'
        " let g:airline_symbols.paste = '∥'
          let g:airline_symbols.spell = 'Ꞩ'
          " let g:airline_symbols.notexists = 'Ɇ'
          " let g:airline_symbols.whitespace = 'Ξ'
    
          " " powerline symbols
          let g:airline_left_sep = ''
          " let g:airline_left_alt_sep = ''
          let g:airline_right_sep = ''
          " let g:airline_right_alt_sep = ''
          let g:airline_symbols.branch = ''
          let g:airline_symbols.readonly = ''
          let g:airline_symbols.linenr = '☰'
          let g:airline_symbols.maxlinenr = ''
          "
          let g:airline#extensions#tabline#enabled = 1
          "
          " generics see https://github.com/vim-airline/vim-airline/issues/1309
          "
          let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
          let g:airline#extensions#wordcount#enabled = 0
          "
    "
    Plug 'ntpeters/vim-better-whitespace'
        nnoremap <leader>w :ToggleWhitespace<cr>
        nnoremap <leader>W :StripWhitespace<cr>
        let g:better_whitespace_enabled = 1
    "
    Plug 'haya14busa/incsearch.vim'
        let g:incsearch#auto_nohlsearch = 1
        let g:incsearch#separate_highlight = 1
        map / <Plug>(incsearch-forward)
        map ? <Plug>(incsearch-backward)
        map g/ <Plug>(incsearch-stay)
    "
    Plug 'ervandew/supertab'
        let g:SuperTabDefaultCompletionType = "context"
        let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
        "let g:SuperTabRetainCompletionDuration = "session"
        let g:SuperTabLongestEnhanced = 1
        let g:SuperTabCrMapping = 0
        " augroup Supertab
        "     autocmd!
        "     autocmd FileType text call SuperTabSetDefaultCompletionType("<c-n>")
        "     autocmd FileType tex call SuperTabSetDefaultCompletionType("<c-n>")
        " augroup END
    "
    "Plug 'davidhalter/jedi-vim'
    "    "let g:jedi#auto_vim_configuration = 0
    "    autocmd FileType python setlocal completeopt-=preview
    "    let g:jedi#show_call_signatures = "0"
    "
    Plug 'jeetsukumaran/vim-markology'
    "
    Plug 'mbbill/undotree'
        nnoremap <F5> :UndotreeToggle<CR>
    "
    Plug 'junegunn/vim-peekaboo'
       let g:peekaboo_prefix=","
       "let g:peekaboo_ins_prefix="<C-S-R>"
    "
    Plug 'nvim-tree/nvim-web-devicons' " OPTIONAL: for file icons
    "
    " which-keys
    "
    Plug 'folke/which-key.nvim'
    "
    " let's see if we can have LSP
    "
    Plug 'williamboman/mason.nvim'
    Plug 'williamboman/mason-lspconfig.nvim'
    Plug 'neovim/nvim-lspconfig'
    Plug 'hrsh7th/nvim-cmp'
    Plug 'hrsh7th/cmp-nvim-lsp'
    Plug 'icewind/ltex-client.nvim'
    "
    " colorschenes
    "
    Plug 'catppuccin/nvim', { 'as': 'catppuccin' }
    Plug 'folke/tokyonight.nvim'
    Plug 'chrisbra/Colorizer'
        let g:colorizer_auto_map = 1 "<Leader>c
    "
    " End Plugins
    "
    call plug#end()
    "
    " Plug-ins personalizations
    "
    " COLORSCHEME
    " Error highlighting of "_" is invisible in default colorscheme (white on red!)
    " adjust spell colors for terminals too
    " colorscheme github-r
    set background=light
    lua << EOF
    -- change catpuccin to be a bit more contrasty
    require("catppuccin").setup {
        color_overrides = {
            latte = {
             --   base = "#eff1f5",
             --   blue = "#1e66f5",
             --   crust = "#dce0e8",
             --   flamingo = "#dd7878",
             --   green = "#40a02b",
             --   lavender = "#7287fd",
             --   mantle = "#e6e9ef",
             --   maroon = "#e64553",
             --   mauve = "#8839ef",
             --   overlay0 = "#9ca0b0",
             --   overlay1 = "#8c8fa1",
             --   overlay2 = "#7c7f93",
             --   peach = "#fe640b",
             --   pink = "#ea76cb",
             --   red = "#d20f39",
             --   rosewater = "#dc8a78",
             --   sapphire = "#209fb5",
             --   sky = "#04a5e5",
             --   subtext0 = "#6c6f85",
             --   subtext1 = "#5c5f77",
             --   surface0 = "#ccd0da",
             --   surface1 = "#bcc0cc",
             --   surface2 = "#acb0be",
             --   teal = "#179299",
             --   text = "#4c4f69",
                  text = "#000000",
             --   yellow = "#df8e1d"
            },
        },
        highlight_overrides = {
            latte = function(latte)
            return {
                LineNr = { bg = "#efe1e5" , fg = latte.subtext0},
                SignColumn = { bg = "#efe1e5"},
                Error = { bg = latte.yellow, fg = latte.text },
            }
            end
        },
    }
    EOF
    colorscheme catppuccin-latte
    " hi SignColumn  guibg=#efe1e5
    hi MarkologyHLu guifg=Black guibg=Pink
    hi MarkologyHLo guifg=Black guibg=Pink
    hi MarkologyHLm guifg=Black guibg=Yellow
    " hi Error guifg=black guibg=orange gui=none
    " hi spellBad   ctermfg=black ctermbg=gray
    " hi spellCap   ctermfg=black ctermbg=cyan
    " hi spellRare  ctermfg=black ctermbg=cyan
    " hi spellLocal ctermfg=black ctermbg=yellow
    " " searches in yellow bg
    " hi Search guibg=yellow guifg=black  ctermfg=black ctermbg=yellow
    " hi IncSearch guibg=red guifg=black  ctermfg=black ctermbg=red
    " " "
    " " " which-key
    " " "
    lua << EOF
    require"which-key".setup{
            preset = "helix",
            triggers = {
                 { "<auto>", mode = "nxso" },
                 { "`", mode = "i" }, -- for VimTeX, no way to put it into tex.lua
            },
    }
    EOF
    "
    " mason
    "
    lua << EOF
    require("mason").setup()
    require("mason-lspconfig").setup()
    -- After setting up mason-lspconfig you may set up servers via lspconfig
    require("lspconfig").lua_ls.setup {}
    require("lspconfig").pyright.setup {}
    -- ...
    EOF
    "
    " this is copied from
    " https://lsp-zero.netlify.app/docs/template/vimscript-config.html
    "
    function! LspAttached() abort
      nnoremap <buffer> K <cmd>lua vim.lsp.buf.hover()<cr>
      nnoremap <buffer> gd <cmd>lua vim.lsp.buf.definition()<cr>
      nnoremap <buffer> gD <cmd>lua vim.lsp.buf.declaration()<cr>
      nnoremap <buffer> gi <cmd>lua vim.lsp.buf.implementation()<cr>
      nnoremap <buffer> go <cmd>lua vim.lsp.buf.type_definition()<cr>
      nnoremap <buffer> gr <cmd>lua vim.lsp.buf.references()<cr>
      nnoremap <buffer> gs <cmd>lua vim.lsp.buf.signature_help()<cr>
      nnoremap <buffer> <C-F2> <cmd>lua vim.lsp.buf.rename()<cr>
      nnoremap <buffer> <C-F3> <cmd>lua vim.lsp.buf.format({async = true})<cr>
      xnoremap <buffer> <C-F3> <cmd>lua vim.lsp.buf.format({async = true})<cr>
      nnoremap <buffer> <C-F4> <cmd>lua vim.lsp.buf.code_action()<cr>
    endfunction
    
    autocmd LspAttach * call LspAttached()
    
    lua <<EOF
    local lspconfig_defaults = require('lspconfig').util.default_config
    lspconfig_defaults.capabilities = vim.tbl_deep_extend(
      'force',
      lspconfig_defaults.capabilities,
      require('cmp_nvim_lsp').default_capabilities()
    )
    
    require('mason').setup({})
    require('mason-lspconfig').setup({
      ensure_installed = { "lua_ls", "pyright", "ts_ls", "ltex" },
      handlers = {
        function(server_name)
          require('lspconfig')[server_name].setup({})
        end,
      }
    })
    require('ltex-client').setup {
        opts = {},
    }
    -- complete, cmp
    local cmp = require('cmp')
    
    cmp.setup({
      sources = {
        {name = 'nvim_lsp'},
      },
      snippet = {
        expand = function(args)
          vim.snippet.expand(args.body)
        end,
      },
      mapping = cmp.mapping.preset.insert({}),
    })
    EOF
    "
    " vimtex
    "
    call vimtex#imaps#add_map({
        \ 'lhs' : '<S-CR>',
        \ 'rhs' : '
    \item ',
        \ 'leader' : '',
        \ 'wrapper' : 'vimtex#imaps#wrap_environment',
        \ 'context' : ["itemize", "enumerate", "description", "compactenum"],
        \})
    "
    " Filetype-special inits
    "
    " edit xournal files (see https://vi.stackexchange.com/a/10390/854)
    "
    augroup gzip_local
        autocmd!
        autocmd BufReadPre,FileReadPre     *.xoj setlocal bin
        autocmd BufReadPost,FileReadPost   *.xoj call gzip#read("gzip -dn -S .xoj")
        autocmd BufWritePost,FileWritePost *.xoj call gzip#write("gzip -S .xoj")
        autocmd FileAppendPre              *.xoj call gzip#appre("gzip -dn -S .xoj")
        autocmd FileAppendPost             *.xoj call gzip#write("gzip -S .xoj")
    augroup END
    " edit xournalpp files (see https://vi.stackexchange.com/a/10390/854)
    augroup gzip_local2
        autocmd!
        autocmd BufReadPre,FileReadPre     *.xopp setlocal bin
        autocmd BufReadPost,FileReadPost   *.xopp call gzip#read("gzip -dn -S .xopp")
        autocmd BufWritePost,FileWritePost *.xopp call gzip#write("gzip -S .xopp")
        autocmd FileAppendPre              *.xopp call gzip#appre("gzip -dn -S .xopp")
        autocmd FileAppendPost             *.xopp call gzip#write("gzip -S .xopp")
    augroup END
    "
    " filetype settings autocmd
    "
    augroup romano_auto
        autocmd!
        " LaTeX:
        "add a % vim: set spelllang=es: to change language
        autocmd FileType tex set spell wrap linebreak showbreak=+\  conceallevel=0
        autocmd FileType tex set fdm=marker fmr=%<<<,%>>>
        autocmd FileType tex highlight  link texTitleArg Include
        " python
        autocmd FileType python set tabstop=4 shiftwidth=4 expandtab wrap linebreak  showbreak=+\
        autocmd FileType python let g:better_whitespace_enabled = 1
        autocmd FileType python let g:strip_whitespace_on_save = 0
        " JS
        autocmd FileType javascript set tabstop=4 shiftwidth=4 expandtab wrap linebreak  showbreak=+\
        autocmd FileType javascript let g:better_whitespace_enabled = 1
        autocmd FileType javascript let g:strip_whitespace_on_save = 0
        " text
        autocmd Filetype text set wrap linebreak showbreak=+\
        " html
        autocmd Filetype html set wrap linebreak showbreak=+\
        " set current dir
        autocmd Filetype markdown set spell tabstop=4 shiftwidth=4 expandtab wrap linebreak showbreak=+\
    augroup END
    "
    set completeopt=menuone,longest,preview
    set complete+=k
    set complete-=i "see https://github.com/lervag/vimtex/issues/1677
    "
    " folding
    "
    set foldmethod=marker
    ""
    " End filetype settings
    "
    "
    " Keyboard settings
    "
    " <F> keys --- redefining the ones that normally are left alone
    " by the plugins. Check them anyway.
    " F2 save and go back where we were
    nnoremap <F2> :update<CR>
    vnoremap <F2> <Esc>:update<CR>
    inoremap <F2> <Esc>:update<CR>
    " shift-F2 saves without leaving input mode
    inoremap <S-F2> <c-o>:update<CR>
    " F3 set local buffer nomodifiable
    nnoremap <F3> :setlocal nomodifiable <CR>
    nnoremap <S-F3> :setlocal modifiable <CR>
    " leader-c change current directory to the one of the current file
    noremap <silent> <F4> :noh <CR>
    " F9 toggles line numbers
    set nonumber norelativenumber
    noremap <silent> <F9> :set number! relativenumber!<cr>
    " Add an undo point before ctrl-r in input mode
    " see http://vi.stackexchange.com/questions/4556/undo-in-insert-mode
    inoremap <C-R> <C-G>u<C-R>
    " Visual movement with the arrows and End-Home
    nnoremap <Down> gj
    nnoremap <Up> gk
    vnoremap <Down> gj
    vnoremap <Up> gk
    inoremap <expr> <Down> pumvisible() ? '<C-N>' : '<C-O>gj'
    inoremap <expr> <Up> pumvisible() ? '<C-P>' : '<C-O>gk'
    inoremap <Home> <C-o>g<Home>
    inoremap <End>  <C-o>g<End>
    "
    " Settings (in general)
    "
    set history=50 " keep 50 lines of command line history
    set ruler " show the cursor position all the time
    set showcmd " Show partial commands in the last line of the screen
    set ignorecase " case insensitive search, except when using capitals
    set smartcase " case insensitive patterns, when lowercase is used
    set smarttab " smart tabulation and backspace
    set expandtab " I really prefer spaces
    set autoindent
    set breakindent
    set showmode " Show the current mode
    set showmatch " show matching braces
    set hlsearch " highlight searches
    set incsearch " find as you type
    set title " show title
    set pastetoggle=<F11> " F11 toggles indenting when pasting
    set wildmenu " make command-line completion bash like + menu
    set wildmode=longest:full
    set scrolloff=2 " see a couple of lines around top and bottom
    set display+=lastline " show partial long lines
    set lcs=trail:·,tab:»·,eol:⤶    "  listchars to be used when selecting set list
    set virtualedit=block
    set backup
    set backupdir=~/.config/nvim/backups//,/tmp
    "
    " GUI settings
    "
    set undolevels=1000 " 1000 undos
    set undoreload=10000
    set undodir=~/.config/nvim/undodir
    " persistent unod
    set undofile
    " set guifont=JetBrains\ Mono:h11,Inconsolata:h11
    if exists("g:neovide")
        "put neovide explicit things here
    else
        "in neovide the font is set by config.toml
        if hostname() == 'romano-yoga'
            set guifont=JetBrains\ Mono\ NL:h11
        else
            set guifont=JetBrains\ Mono\ NL:h10
        endif
    endif
    "
    " MACROS here
    "
    " macros for general editing:
    " c: copy all, p: para to line and copy, z: zap all and paste,
    " a: paste at the end, o: open line
    " f: para-to-line for the current paragraph
    let @c = 'ggVG"+y'
    let @p = '1G:%! para_to_line.py
    ggVG"+y'
    let @z = 'ggVGd"+p'
    let @a = 'Go�"+p'
    let @o = '0O�j'
    let @f = 'vip:! para_to_line.py
    }'
    "
    " statistics for the current paragraph
    "
    let @s = 'vip:! /home/romano/software/scripts/stat_region.py
    }'
    "
    " twiddle case from https://vim.fandom.com/wiki/Switching_case_of_characters
    " visual select and press ~
    "
    function! TwiddleCase(str)
      if a:str ==# toupper(a:str)
        let result = tolower(a:str)
      elseif a:str ==# tolower(a:str)
        let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
      else
        let result = toupper(a:str)
      endif
      return result
    endfunction
    vnoremap ~ y:call setreg('', TwiddleCase(@"), getregtype(''))<CR>gv""Pgv
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions