EdenEast / nightfox.nvim

🦊A highly customizable theme for vim and neovim with support for lsp, treesitter and a variety of plugins.
MIT License
3.11k stars 144 forks source link

Highlighted text when substituting is too dark #73

Closed eggbean closed 2 years ago

eggbean commented 2 years ago

Great theme. I'm using nordfox, but highlighting of matches when doing a substitution (:%s/FOO/BAR/) makes every instance of FOO black (or very dark grey) which makes it impossible to read on a dark background colour. I don't know if this is intentional or if it something in my config, but it makes it hard to see the matches as they could be whitespace. I would prefer the matches to be highlighted grey, like when searching.

What's the setting for this?

EdenEast commented 2 years ago

Here are two examples of what the default highlight should look like:

bug-search-nordfox bug-sub-nordfox

There are three highlight groups that deal with searching and substitution. These are:

You can check the help for more information on these highlight groups.

You can customize these hlgroups in nightfox's config.

require('nightfox').setup({
  hlgroups = {
    Search = { fg = "${fg}", bg = "${fg_gutter}" },
    IncSearch = { fg = "${bg}", bg = "${cyan}" },
    Substitute = { fg = "${bg}", bg = "${red}" },
  }
})

In this example I am setting the search background to be the same color as the line number.

If you have a specific color instead that you would like to use you can define it as well.

require('nightfox').setup({
  hlgroups = {
    Search = { fg = "${fg}", bg = "#123456" },
  }
})
eggbean commented 2 years ago

Thank you. I had to change it to a hex value, as red does not seem to be defined on my setup for some reason (the same happens if I put in nonsense colour name). Any idea what could be going on? Where are these colours defined?

EdenEast commented 2 years ago

Did you use the template format ${red}? Also you can find the color definitions for all the colorscheme's here. Do you have an example of your config? or a minimal_init.lua file that I can reproduce your issues? Also seeing a screenshot might better help me understand your issue.

eggbean commented 2 years ago

My vim config is a spread over a lot of files and I've set it up so that most files are shared between vim, nvim, gvim and gvim for Windows, so it's difficult to show. The only lua part of the config is this theme in init.vim for nvim. Is there a way I can make a dumpfile or something?

But in any case it doesn't really matter now, as the problem has been fixed by me adding the same red colour hex code from the files you linked to, so they appear the same as in your screenshots. What I will do at some point is find the problem through the process of elimination by disabling plugins and parts of the config. You can close this issue, and I will post if I find the problem in my config. Thanks.

eggbean commented 2 years ago

This is the order of all the files that are loaded from :scriptnames: https://termbin.com/2lhq, if that is any use. I do plan on removing a few the plugins which I don't really need.

EdenEast commented 2 years ago

Nightfox has recently been rewritten does your issue still persist after the rewrite?

eggbean commented 2 years ago

I have not updated the plugins, so I am still using the previous version. I deleted the Substitute = { fg = "${bg}", bg = "#bf616a" }, line from my config, but then when I open the file again in vim and try a substitution it's red, as it should be.

So I am confused about why the colour is correct while I have deleted the line while not having updated the plugin.

eggbean commented 2 years ago

I can't figure out what I am doing wrong. I have this at the end of my init.vim file: lua require('config') and in ./lua/config.lua I have:

require('nightfox').setup({
  options = {
    compile_path = util.join_paths(vim.fn.stdpath("cache"), "nightfox"),
    compile_file_suffix = "_compiled", -- Compiled file suffix
    transparent = false,     -- Disable setting background
    terminal_colors = false, -- Set terminal colors (vim.g.terminal_color_*)
    dim_inactive = false,    -- Non focused panes set to alternative background
    styles = {               -- Style to be applied to different syntax groups
      comments = "italic",
      functions = "italic,bold",
      keywords = "bold",
      numbers = "NONE",
      strings = "NONE",
      types = "NONE",
      variables = "NONE",
    },
    inverse = {             -- Inverse highlight for different types
      match_paren = false,
      visual = false,
      search = false,
    },
    modules = {             -- List of various plugins and additional options
      -- ...
    },
  }
})

vim.cmd("colorscheme nightfox")
require('lualine').setup()

But on startup I get this error:

Error detected while processing /home/jason/.dotfiles/config/.config/nvim/init.vim:
line   27:
E5108: Error executing lua /home/jason/.dotfiles/config/.config/nvim/lua/config.lua:3: attempt to index global 'util' (a nil value)
stack traceback:
        /home/jason/.dotfiles/config/.config/nvim/lua/config.lua:3: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk
Press ENTER or type command to continue
EdenEast commented 2 years ago

For config options you do not have to set any values if you are not changing them from the default. In the readme it looks like when I copied the defaults section I left in my util function that joins the paths for both windows and unix platforms. In the readme I will change that to make that more clear and so ppl dont call util. Looking at the above example here this would be:

require("nightfox").setup({
  options = {
    terminal_colors = false, -- do not define colors for neovim's builtin terminal
    styles = {
      comments = "italic",
      functions = "italic,bold",
      keywords = "bold",
    },
  },
})

vim.cmd("colorscheme nightfox")
require('lualine').setup()
eggbean commented 2 years ago

Thanks, everything seems to be working fine, including the previous issue with the substitution highlighting.

I did know that defaults don't need to be included, but I added them so that it would be easier to make further changes to my config, at least until the time I am quite sure that it is how I want it to be. It's easier to see what changes can be made at a glance. Cheers.

eggbean commented 2 years ago

One more thing - I use gitgutter and barbar plugins. Do I need to add them as modules in the configuration above, or do they get detected automatically? I don't understand the reason for the modules section in the configuration.

Currently I think the current tab highlight colour in barbar is too light when using nordfox.

EdenEast commented 2 years ago

Nightfox is built to be very configurable. Modules are used as a mechanizem for additional option per plugin or area (diagnostics, lsp, treesitter, etc...). Currently they are just booleans that say that they are enabled. If for some reason you do not want nightfox to define highlight groups for a certain plugin you could set the module to false. By default all nightfox's modules are enabled.

In the future I can see people wanting to add options for certain plugins and this is a way of implementing them. Currently they are mostly just booleans.

Also as a side note modules make contributing to nightfox easier as they are self contained examples of how a plugin is added.