chrisbra / Colorizer

color hex codes and color names
547 stars 30 forks source link

ANSI coloring is carried over to other buffers #65

Closed nkakouros closed 5 years ago

nkakouros commented 5 years ago

Here are two demo files:

#!/usr/bin/env bash

if [[ "$0" =~ ^\./ ]]; then
  # if running first time
  :
elif [[ ! -v INSTALLATION_DIR && -f script ]]; then
  # if in project directory
  :
elif [[ ! -v INSTALLATION_DIR ]]; then
  # if `script` is a command, this variable ought to be set (in
  # /etc/bash.bashrc)
  echo -e "\033[0;31mINSTALLATION_DIR is unset; enter installation dir and rerun\033[0m"
  exit 1
else
  pushd "$INSTALLATION_DIR" >/dev/null || exit 1
fi

and

echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"          
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"                                    
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"
echo "$dddfffffffffffffffffffffffffffffffffffffffffffffffffffffff"

Save them, close nvim and open them the first file. Part of line 12 will be red correctly. Now, open the second file (eg nvim b.sh). Line 12 is also red (hopefully your colorscheme does not print variables red).

I use neovim.

wimstefan commented 5 years ago

Hmmmm can you make that fix a configurable option? I'm using a lot of buffers in my window open to compare colors and Colorizer makes it very easy to compare them visually. That's not possible anymore with this fix :-/

chrisbra commented 5 years ago

Yeah, I wondered why initially the BufLeave autocommand was commented out (because I don't remember the reason). How are you using the plugin, so that it is broken for you now?

wimstefan commented 5 years ago

Yeah, I wondered why initially the BufLeave autocommand was commented out (because I don't remember the reason). How are you using the plugin, so that it is broken for you now?

I'm using it a lot to manage my colorschemes (vim via lifepillar/vim-colortemplate, termite, awesomewm) and to have the same colours everywhere. So I have two or more buffers open with the colorschemes and it's easier to compare the colours in a glance with Colorizer than checking the hex-codex ...

With the latest fix the colorization is gone as soon as I switch buffers :-/

chrisbra commented 5 years ago

Okay, I made this configurable commit 8dcb8daa0b446f8115a4bda51ea72f5b4b26e1a4

If you don't want the default behaviour, use :let g:colorizer_disable_bufleave=1

wimstefan commented 5 years ago

Thank you so much! This is perfect :-D