Mofiqul / dracula.nvim

Dracula colorscheme for neovim written in Lua
MIT License
594 stars 102 forks source link

Using `colors()` no longer seems to work #96

Closed dfsnow closed 1 year ago

dfsnow commented 1 year ago

I get the following error as of commit 2e8ce9c4b4bc160e4926f737ff0678dee0f418e6.

E5108: Error executing lua [string ":lua"]:89: attempt to index a nil value
stack traceback:
        [string ":lua"]:89: in main chunk

Here's the relevant lua config, which works fine with 52f6d1c48589479d519c1aaea93dba1dd550a7a4.

local dracula = require("dracula")
dracula.setup({
  colors = { nontext = "#474e57" }, -- default is too low contrast
  overrides = {
    WhichKeyDesc = { fg = dracula.colors().bright_white },
    WhichKeyGroup = { fg = dracula.colors().pink },
    FloatBorder = { fg = dracula.colors().bright_white },
    FoldColumn = { fg = dracula.colors().comment },
    ColorColumn = { bg = dracula.colors().black },
    CmpItemAbbr = { fg = dracula.colors().bright_white, bg = nil },
    CmpItemAbbrMatch = { fg = dracula.colors().bright_green },
    GitSignsChange = { fg = dracula.colors().orange },
    GitSignsChangeLn = { fg = dracula.colors().orange },
    TelescopePromptBorder = { fg = dracula.colors().bright_white },
    TelescopePreviewBorder = { fg = dracula.colors().bright_white },
    TelescopeResultsBorder = { fg = dracula.colors().bright_white },
    TelescopeSelection = { fg = dracula.colors().bright_white },
    TelescopeMatching = { fg = dracula.colors().bright_green }
  }
})
Mofiqul commented 1 year ago

@dfsnow - Hi, I can confirm that it's working. This the config I tried

 {
    'Mofiqul/dracula.nvim',
    config = function(self, opts)
      local dracula = require("dracula")
      dracula.setup({
        colors = {
          nontext = "red"
        },
      })
      vim.cmd.colorscheme 'dracula'
    end
  },

Result

image

dfsnow commented 1 year ago

Ah, sorry, I should have been clearer in my initial report. It's the call to colors() that is now throwing an error. Here's a minimal working example of the error using vim-plug. I copied your use of colors() right from the README.

call plug#begin("~/.vim/vim-plug")

Plug 'Mofiqul/dracula.nvim'

call plug#end()

lua << EOF

local dracula = require("dracula")
dracula.setup({
  colors = { nontext = "#474e57" },
  overrides = {
    FloatBorder = { fg = dracula.colors().bright_white }, -- this line throws the error
  }
})

EOF

colorscheme dracula " must load after the nvim plugin
AndreM222 commented 1 year ago

I can agree. All my settings which contain colors where causing problems.

image

Btw. could you consider some of my changes? I added all this changes because even though you got very nice colors there seem to be missing still some setup for others from the dracula color theme which I added. though I also got some extra ones in there.

For the transparency I made it return none in some areas because if not there is is no true transparency. As well some of the variables you used the same color and I checked the original dracula and placed does colors in there.

Some extra ones are: the highlight when searching, the number highlight from where the cursor is.

Mofiqul commented 1 year ago

@AndreM222 - I have merged the fix, please update. And for your changes, can you please make PR and share the before/after screenshot ?