olimorris / onedarkpro.nvim

🎨 Atom's iconic One Dark theme. Cacheable, fully customisable, Tree-sitter and LSP semantic token support. Comes with variants
MIT License
784 stars 42 forks source link

[Bug]: Change highlight on yank doesn't work. #232

Closed neuromaancer closed 6 months ago

neuromaancer commented 6 months ago

Your minimal.lua config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "olimorris/onedarkpro.nvim",
    opts = {
      -- Your OneDarkPro config goes here
    opts = {
            colors = {}, -- Override default colors or create your own
            highlights = {
                Visual = { fg = "#F3F8FF", bg = "#A7C010", style = "bold" },
                IncSearch = { fg = "#F3F8FF", bg = "#A7C010", style = "bold" },
            }, 
        }
    },
    config = true
  },

  { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },

  -- Delete if you do not require LSP
  {
    "VonHeikemen/lsp-zero.nvim",
    branch = "v2.x",
    dependencies = {
      -- LSP Support
      {"neovim/nvim-lspconfig"},             -- Required
      {                                      -- Optional
        "williamboman/mason.nvim",
        build = function()
          pcall(vim.cmd, "MasonUpdate")
        end,
      },
      {"williamboman/mason-lspconfig.nvim"}, -- Optional

      -- Autocompletion
      {"hrsh7th/nvim-cmp"},     -- Required
      {"hrsh7th/cmp-nvim-lsp"}, -- Required
      {"L3MON4D3/LuaSnip"},     -- Required
    },
    config = function()
      local lsp = require("lsp-zero").preset({})

      lsp.on_attach(function(client, bufnr)
        lsp.default_keymaps({buffer = bufnr})
      end)

      lsp.ensure_installed({ "lua_ls" })

      -- (Optional) Configure lua language server for neovim
      require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls())

      lsp.setup()
    end
  }

  -- add any other plugins here
{
"gbprod/yanky.nvim",
  dependencies = not jit.os:find("Windows") and { "kkharji/sqlite.lua" } or {},
  opts = {
    highlight = { timer = 250 },
    ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" },
  },
}
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- setup treesitter
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if ok then
  treesitter.setup({
    ensure_installed = "all",
    ignore_install = { "phpdoc" }, -- list of parser which cause issues or crashes
    highlight = { enable = true },
  })
end

vim.cmd("colorscheme onedark")

Error messages

No response

Describe the bug

I want to change the highlight of on_yank, but it didn't work. Use LazyVim. so the autocmd is like:

-- Highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
  group = augroup("highlight_yank"),
  callback = function()
    vim.highlight.on_yank()
  end,
})

no variables in on_yank so the default IncSearch highlight group is used. I changed the IncSearch as indicated before, but no effect taken.

Reproduce the bug

No response

Final checks

olimorris commented 6 months ago

Don't think this is an issue of the plugin as many of us overwrite highlight groups.

What if you remove config = true? As per Lazy.nvim: "To use the default implementation without opts set config to true."

neuromaancer commented 6 months ago

Oh,I didn't put 'config=true'. It still didn't work for me, I am wondering if the hanky.nvim affect the highlight group.

olimorris commented 6 months ago

I suspect that it's overwriting the highlight group.

My approach would be: Disable hanky, run :hi IncSearch observe the outputs, re-enable hanky, run :hi IncSearch observe the outputs and see if it is overwriting.

neuromaancer commented 6 months ago

You are right, when I disabled yanky.nvim it works.

olimorris commented 6 months ago

I suspect the author has probably enabled force = true in [nvim_set_hl](https://neovim.io/doc/user/api.html#nvim_set_hl()). Raise thie issue on their repo

neuromaancer commented 6 months ago

Okay, I figured it out, when I yanked, actually I used yanky.nvim, it used Search highlight group not IncSearch. Problem solved.