wincent / base16-nvim

base16 color schemes in Lua for Neovim
MIT License
26 stars 1 forks source link

Support for 256 colorspace #2

Closed alexmakovetski closed 2 years ago

alexmakovetski commented 2 years ago

Hi @wincent, I am your big fan and your screencasts and dotfiles repo inspires me a lot :) So thank you for that!

I have a question related to your version of base16 colorschemes. It seems like Lua version of colorschemes misses the part of code responsible for supporting of 256 colorspace. If we check for example 3024 colorscheme we will notice that Lua version for some cterms looks in the following way

local cterm01 = "10"
local cterm02 = "11"
local cterm04 = "12"
local cterm06 = "13"
local cterm09 = "09"
local cterm0F = "14"

Whereas Vimscript version has a switch to adjust cterms to 256 colorspace

if exists("base16colorspace") && base16colorspace == "256"
  let s:cterm01        = "18"
  let g:base16_cterm01 = "18"
  let s:cterm02        = "19"
  let g:base16_cterm02 = "19"
  let s:cterm04        = "20"
  let g:base16_cterm04 = "20"
  let s:cterm06        = "21"
  let g:base16_cterm06 = "21"
  let s:cterm09        = "16"
  let g:base16_cterm09 = "16"
  let s:cterm0F        = "17"
  let g:base16_cterm0F = "17"
else
  let s:cterm01        = "10"
  let g:base16_cterm01 = "10"
  let s:cterm02        = "11"
  let g:base16_cterm02 = "11"
  let s:cterm04        = "12"
  let g:base16_cterm04 = "12"
  let s:cterm06        = "13"
  let g:base16_cterm06 = "13"
  let s:cterm09        = "09"
  let g:base16_cterm09 = "09"
  let s:cterm0F        = "14"
  let g:base16_cterm0F = "14"
endif

As a result when I tried to switch to Lua version I am getting weird colors in my vim. Was that part missed intentionally and I need to adjust somehow my environment to get it working as it was working with vimscript colorschemes?

wincent commented 2 years ago

Here is the initial commit that shows the actual step from Vimscript to Lua — as it says:

This is the most straightforward port of the base16-vim files I could do, to make it easier to see what changed in the move from ".vim" to ".lua".

If I recall correctly, I was thinking I could just drop the base16colorspace stuff as it didn't seem necessary — but perhaps it is. To be honest, I am not 100% sure I understand what the base16 docs mean here:

256 colorspace

If using a Base16 terminal theme designed to keep the 16 ANSI colors intact (a "256" variation) and have sucessfully modified your 256 colorspace with base16-shell you'll need to add the following to your ~/.vimrc before the colorsheme declaration.

let base16colorspace=256 " Access colors present in 256 colorspace

This will cause vim to access the colours in the modified 256 colorspace. Please do not enable this simply because you have a 256 color terminal as this will cause colors to be displayed incorrectly.

🤔

FWIW, I am using base16-shell in iTerm, but I don't think I've ever needed to set base16colorspace...

alexmakovetski commented 2 years ago

Thank for the fast reply! 😃

I also do not fully understand the difference and influence of those 16/256 colorspaces. I have a number of places where I have that magic 256 number mentioned where it is related to colors. I have 'xterm-256color' set in Terminal/Report terminal type. I changed it to get powerlevel10k theme working for zsh. I tried to change Report terminal type to other values without any luck :) Currently I switched back to Vimscript colors for Neovim and it works fine with base16colorspace set to 256.

If I understand what was the issue with Lua version of colors and how to fix it I will report in that issue

alexmakovetski commented 2 years ago

Finally I managed to get everything working without a need to set base16colorspace to 256 😀 The option that I was missing in my init.lua was

vim.opt.termguicolors   = true

After it was added I were able to use Lua bases color schemes without any issues. Thank you for the assistance!

wincent commented 2 years ago

After it was added I were able to use Lua bases color schemes without any issues.

Excellent, glad to hear you got it sorted.