Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: rainbow labels color wont work if they are placed on word under cursor #109

Closed
3 tasks done
JoseConseco opened this issue Jul 1, 2023 · 4 comments · Fixed by #116
Closed
3 tasks done

bug: rainbow labels color wont work if they are placed on word under cursor #109

JoseConseco opened this issue Jul 1, 2023 · 4 comments · Fixed by #116
Labels
bug Something isn't working

Comments

@JoseConseco
Copy link

Did you check docs and existing issues?

  • I have read all the flash.nvim docs
  • I have searched the existing issues of flash.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0-dev-537+gdcf8a71b8

Operating system/version

Manjaro

Describe the bug

As mentioned in #74 (comment)
The rainbow colors wont be colored, if label is placed on top of word under cursor.
The commit that broke the colors: 56531ee

Steps To Reproduce

use

{
  "u", -- unit textobject
  mode = { "o", "x" },
  function()
    require("flash").treesitter {
      label = {
        rainbow = {
          enabled = true,
        },
      },
    }
  end,
},  
  1. Use u motion, to select TSitter range in visual mode.
  2. Some labels wont be colored

Expected Behavior

All labels should be colored

Repro

-- DO NOT change the paths and don't remove the colorscheme
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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/flash.nvim", opts = {} },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@JoseConseco JoseConseco added the bug Something isn't working label Jul 1, 2023
@folke
Copy link
Owner

folke commented Jul 2, 2023

Should be fixed now!

@folke folke closed this as completed Jul 2, 2023
@JoseConseco
Copy link
Author

Something is still of for me. Here is how the rainbow labels looked before the commit that 'broke' them:
image

Here is the latest flash.nivm:
image

In both cases word under cursor gets highlighted, but as u can see in first image labels colors are ok. @folke

my config:

  {
    "folke/flash.nvim",
    cond = true,
    -- commit="13022c09fa30fb03d14110a380238f6a75b42ab4", -- correct colors under cword
    event = "VeryLazy",
    opts = {},
    keys = {
      {
        ",",
        mode = { "n", "x", "o" },
        function()
          -- default options: exact mode, multi window, all directions, with a backdrop
          require("flash").jump()
        end,
      },
      {
        "u", -- unit textobject
        mode = { "o", "x" },
        function()
          require("flash").treesitter {
            label = {
              rainbow = {
                enabled = true,
              },
            },
          }
        end,
      },

      {
        "gl",
        mode = { "n", "x", "o" },
        function()
          require("flash").jump {
            search = { mode = "search", max_length = 0 }, -- len == 0  so all labels will be used and skips won't be calculated
            label = { after = { 0, 0 } },
            matches = false, -- to hide the whitespace match
            pattern = "^\\s*\\S", -- match non-whitespace at start plus any character (ignores empty lines), add \\? to match empty lines too
          }
          vim.cmd [[normal! ^]]
        end,
      },
    },

    config = function()
      require("flash").setup {
        -- labels = "ASDFGHJKLQWERTYUIOPZXCVBNM",
        label = {
          rainbow = {
            enabled = false,
          },
        },
        highlight = {
          priority = 9900,
        },
        modes = {
          char = { -- `f`, `F`, `t`, `T`, `;` and `,` motions
            enabled = true,
            jump_labels = function(motion)
              -- never show jump labels by default
              -- return false
              -- Always show jump labels for ftFT
              return vim.v.count == 0 and motion:find("[ftFT]")
              -- Show jump labels for ftFT in operator-pending mode
              -- return vim.v.count == 0 and motion:find("[ftFT]") and vim.fn.mode(true):find("o")
            end,
          },
        },
      }

    end,
  },

Stesp to reproduce:

  1. pres: vu v[isual] u(nit)
  2. Same thing for non visual work motion (eg . cu - change unit)

@folke folke reopened this Jul 2, 2023
@folke folke closed this as completed in edb82f7 Jul 2, 2023
@folke
Copy link
Owner

folke commented Jul 2, 2023

Should be fixed again :)

@JoseConseco
Copy link
Author

it works great now. Guy who thought of this rainbow feature is genius.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants