chadtree icon indicating copy to clipboard operation
chadtree copied to clipboard

Missing documentation for theme.discrete_colour_map?

Open adriantrunzo opened this issue 3 years ago • 1 comments

I had a similar issue to #139, only I am new to chadtree so instead of losing colors they just didn't appear as expected. Please let me know if I am misreading the documentation or interpreting the comments in the other issue incorrectly. This is a great project, by the way. I am quite happy I found it.

For context, I use macOS at work. With kitty and nvim I use the Dracula theme, so the terminal blue is more of a purple (relevant to my examples below, by default it seems like the blue color is used for directories in ls):

Screen Shot 2021-05-25 at 7 06 59 PM

As noted in the other issue, there is by default a dark blue color for the directories in chadtree:

default

After reading the theme documentation and about the text_colour_set property, I spent some quality time reading about how LS_COLORS works, how the the .dircolors files are structured, and how this project bundles a few dircolors files that can be selected via text_colour_set. After learning that BSD, and thus macOS, uses a different LSCOLORS implementation, I decided to add a simple LS_COLORS definition to my profile for the benefit of chadtree:

export LS_COLORS="di=34:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"

( I also learned that you can install GNU command line tools on Mac and make them the defaults to use GNU LS_COLORS, but it looks like chadtree just parses the environment variable so I didn't need to install anything).

To my surprise the chadtree colors changed:

Screen Shot 2021-05-25 at 7 25 06 PM

I was surprised because LS_COLORS doesn't define the colors, just how to apply them to the file tree. After more digging, I found the new colors were being defined in the default config file with the discrete_colour_map key. So, I defined discrete_colour_map in my nvim config file and got the expected result:

let g:chadtree_settings = { "theme.discrete_colour_map": {
      \ "black": "#21222c",
      \ "red": "#ff5555",
      \ "green": "#50fa7b",
      \ "yellow": "#f1fa8c",
      \ "blue": "#bd93f9",
      \ "magenta": "#ff79c6",
      \ "cyan": "#8be9fd",
      \ "white": "#f8f8f2",
      \ "bright_black": "#6272a4",
      \ "bright_red": "#ff6e6e",
      \ "bright_green": "#69ff94",
      \ "bright_yellow": "#ffffa5",
      \ "bright_blue": "#d6acff",
      \ "bright_magenta": "#ff92df",
      \ "bright_cyan": "#a4ffff",
      \ "bright_white": "#ffffff"
\ }}
Screen Shot 2021-05-25 at 7 27 04 PM

I don't see discrete_colour_map in the documentation, should it be added? As well, setting discrete_colour_map won't work unless you also have a valid LS_COLORS environment variable, because by default solarized will be used. I would suggest making these two points clear in the documentation:

  • Without LS_COLORS defined, the solarized theme is used, which is why you probably see the dark blue at first.
  • Mac does not use LS_COLORS, but you can add it to your profile for using chadtree.

Getting my expected colors here was a great learning experience. I think the documentation would be outstanding if it also had more background about LS_COLORS. Specifically, how it does not define the color palette, just how the colors will be used. I think it is a great idea for chadtree to reuse the existing LS_COLORS variable. Again, let me know if I am doing something silly in my configuration. Conversely, if contributing to the documentation would be helpful, I am happy to give it a try.

adriantrunzo avatar May 26 '21 21:05 adriantrunzo

Thanks @adriantrunzo! I could change the colors to my vim-deus theme!

IMO it would be better if the LS_COLORS variable wouldn't have to be set at all (at least on OSX). I would like all the necessary configuration of Neovim to remain in only one file. Would that be possible?

npielawski avatar Aug 15 '21 10:08 npielawski