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

feature: Add multi-line = false option for single line search based jumps #308

Open gerazov opened 5 months ago

gerazov commented 5 months ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

Let me start off by saying that flash.nvim is really awesome :sunglasses:

I've been using hop.nvim for a long time, and it seems that all the hickups I had with hop are solved out of the box with flash, specifically keymap (Cyrillic) based jumps and line jumping on folded lines which I really need for orgmode (https://github.com/smoka7/hop.nvim/issues/62). So kudos :muscle:

One thing I'm missing is the option to jump to a word forward/backward in a line. I work with long lines of text and this is an essential way for me to move, as well as delete/cut parts of the line.

Here's my keymap for jumping forward:

    {
      "<leader>l", mode = { "n", "x", "o" }, 
      function()
        require("flash").jump({
          search = {
            mode = "search",
            max_length = 0,
            forward = true,
            wrap = false,
            multi_line = false,
          },
          label = { after = { 0, 0 } },
          pattern = [[\<]],
          jump = { inclusive = false },
        })
      end,
      desc = "Flash jump word forward"
    },

This produces hints up to some point on the current line but then continues on the next line: image

Describe the solution you'd like

Currently the multi-line option only works for char based jumps as discussed in #179 and fixed via #283. If this option could be added to search based jumps that would be awesome :+1:

Describe alternatives you've considered

Hop.nvim supports this. The mapping there is:

    vim.keymap.set({'n', 'v'}, '<leader>l', function()
      hop.hint_words({ direction = directions.AFTER_CURSOR, current_line_only = true  })
    end, {desc = "Hop to begining of word to the right"})
    vim.keymap.set('o', '<leader>l', function()
      hop.hint_words({ direction = directions.AFTER_CURSOR, current_line_only = true, hint_offset=-1 })
    end, {desc = "Execute to begining of word to the right"})

Additional context

No response