folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.22k stars 27 forks source link

bug: Unexpected behaviour of / #337

Closed nshern closed 1 month ago

nshern commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.5

Operating system/version

MacOS 14.4.1

Describe the bug

When entering a document for the first time, typing / will act as / does without flash.nvim installed. After making a search using s, / will work seemingly as intended.

Steps To Reproduce

  1. from command line open blank file `nvim foo.txt'
  2. type 'hello hello world world'
  3. type / and wo and see that flash is not activated. Escape this.
  4. type s and wo. Escape this.
  5. type / and see that flash is activated

Expected Behavior

flash is activated first time pressing / without doing a s

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 = {},
 keys = {
    { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
    { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
    { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
    { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
    { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
  },
 },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 1 month ago

That's because you're lazy-loading on keys, so it will only load when one of those keys was used