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

feature: Double-character labels for features like jump to line #106

Closed
1 task done
mystilleef opened this issue Jul 1, 2023 · 4 comments
Closed
1 task done

feature: Double-character labels for features like jump to line #106

mystilleef opened this issue Jul 1, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@mystilleef
Copy link

Did you check the docs?

  • I have read all the flash.nvim docs

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

HopLine is the last feature I need from Hop to completely ditch it. At the moment Flash does not support double-character labels, so it cannot label the beginning of all lines in a document.

Describe the solution you'd like

Maybe provide a way to temporarily override the labels list to allow double characters for certain jumps, like jump-to-line.

It doesn't even have to be supported by default. It should just exist for edge cases for users who want to do weird stuff, like implementing jump-to-line in Flash.

Alternatively, you could just implement FlashLine as an edge-case solution. That way you can restrict double-character labels to just FlashLine until double-characters can be available universally, if possible.

Describe alternatives you've considered

The jump-to-line example works but does not label all the visible lines in documents due to the limited number of single-character labels.

The only alternative so far is to use HopLine from Hop or a similar feature from other jump plugins.

Additional context

Screenshot of flash jump-to-line just labeling a few lines.

flashhopbug

@mystilleef mystilleef added the enhancement New feature or request label Jul 1, 2023
@folke
Copy link
Owner

folke commented Jul 1, 2023

You disabled lower-case labels? Something must be off with your config of flash.

You should at least get 52 labels with that code

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2023
@mystilleef
Copy link
Author

Interesting. I had set uppercase to false because I was formatting labels with opts.match.label:upper() and I assumed that would conflict with uppercase if it were set to true.

After enabling uppercase and disabling my custom formatting, I get more labels. Unfortunately, still not enough. Also, it looks like folds might be consuming some of the labels. I've attached my config below.

{
    "folke/flash.nvim",
    opts = {
      label = {
        uppercase = true,
        -- format = function(opts)
        --   return { { opts.match.label:upper(), opts.hl_group } }
        -- end,
      },
      modes = { treesitter = { highlight = { backdrop = true } } },
      jump = { autojump = true, nohlsearch = true },
    },
    keys = {
      ...
      {
        "<leader>l",
        mode = { "n", "x", "o" },
        function()
          require("flash").jump({
            search = { mode = "search", max_length = 0 },
            label = { after = { 0, 0 } },
            pattern = "^",
          })
          -- vim.schedule(require("user.utils").schedule_command)
        end,
        desc = "Label beginning of line",
      },
      ...
    },
  }

Screenshot of labels with unfolded code

flash_unfolded

Screenshot of labels with folded code

flash_folded

@folke
Copy link
Owner

folke commented Jul 2, 2023

@mystilleef I've added better handling of folds so that labels won't be callculated for folded lines

@mystilleef
Copy link
Author

Excellent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants