shaunsingh / nord.nvim

Neovim theme based off of the Nord Color Palette, written in lua with tree sitter support
GNU General Public License v2.0
844 stars 110 forks source link

Setting `nord_disable_background` has no effect #20

Closed jantari closed 3 years ago

jantari commented 3 years ago

Using neovim:

NVIM v0.5.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

it appears that I'm doing something wrong or the value I set for nord_disable_background does not reach the relevant code in theme.lua.

I use a vim-script config and tried setting before and after loading the plugin, but no effect:

[ ... truncated ... ]
let g:nord_disable_background = 1

" Load vim-plug plugins
call plug#begin()
Plug 'sheerun/vim-polyglot'
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/nerdtree'
Plug 'pearofducks/ansible-vim'
Plug 'Yggdroot/indentLine'
Plug 'itchyny/lightline.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'shaunsingh/nord.nvim'
call plug#end()

colorscheme nord
let g:nord_disable_background = 1
[ ... truncated ... ]

However, when I comment out the if vim.g.nord_disable_background == true then statement in theme.lua so that it unconditionally always sets the editor.Normal color to nord.none, then it works.

shaunsingh commented 3 years ago

I believe you have to set the option to let g:nord_disable_background = 0

I'll double check on my laptop though

jantari commented 3 years ago

No, but I figured it out.

I tried editing the if statement inside theme.lua, and I noticed that it would not "trigger" even if I edited it to say:

if vim.g.nord_disable_background == false then

so that made me think, the 1 I am setting probably isn't even treated as a boolean, so then I edited it to:

if vim.g.nord_disable_background == 1 then

and THEN it worked and went into that code path! It looks like you need to cast the integer that vim-script configs use to a boolean first or something before you can do a direct comparison like that (not very familiar with lua).

shaunsingh commented 3 years ago

Yup that sounds about right. I just tested it and looks like the vimscript config doesn't work. I'll fix that soon

caio commented 3 years ago

Hi, thanks a lot for this colorscheme!

Lua doesn't coerce types during comparisons. One simple way of using these on/off switches via vimscript is with v:true or v:false. So the example at the bottom of the README doesn't work, but this does:

" Example config in Vim-Script
let g:nord_contrast = v:true
let g:nord_borders = v:false
let g:nord_disable_background = v:false

" Load the colorsheme
colorscheme nord
shaunsingh commented 3 years ago

Fixed, thank you!