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: highlight_on_key = true breaks clever-f.vim #11

Closed
squishram opened this issue Aug 1, 2022 · 7 comments
Closed

feature: highlight_on_key = true breaks clever-f.vim #11

squishram opened this issue Aug 1, 2022 · 7 comments

Comments

@squishram
Copy link

Hi there! Love eyeliner, it's really useful, and fantastic job adding the 'highlight_on_key' feature, it takes some of the visual load off of staring at code all day - so thanks for your work.

I also use clever-f.vim, which allows f, t to replace ; repeat and F, T to replace , repeat, and allows letter searches to traverse multiple lines. This is essential for me as I can then remap ; and , to other uses. Unfortunately, clever-f is broken by {highlight_on_key = true}.

This is kind of a (potentially difficult) feature request - are there any plans for eyeliner.nvim to add the possibility of clever-f functionality? It seems like it'd be a fantastic & complementary accompanying module. Cheers!

@jinh0
Copy link
Owner

jinh0 commented Aug 2, 2022

Hey @squishram , thanks for the issue! clever-f.vim is most likely broken since I forgot to check for previous mappings of f,F,t,T, which means that I am currently overriding any mappings you had. I'll make a fix ASAP :)

@jinh0
Copy link
Owner

jinh0 commented Aug 6, 2022

Hey @squishram sorry for taking so long! The issue seems a lot more complicated than I thought... turns out other plugins have the same issue, since all these plugins override the same f/F/t/T keys. like quick-scope.vim, (see unblevable/quick-scope#55). From what I understand, nobody has a solution to get clever-f.vim work with plugins like eyeliner.nvim or quick-scope.vim.

are there any plans for eyeliner.nvim to add the possibility of clever-f functionality

If you are talking about pressing f/F/t/T as a replacement for repeats with ;, I am interested in adding that as a feature to eyeliner.nvim, thanks for the idea!

If you're talking about how clever-f allows you to press f for lines beyond the current line, I've never had a use case for such a feature. Can you tell me a use case for pressing f for characters beyond the current one? That always seemed inefficient to me since for movement beyond the current line, movement plugins like lightspeed.nvim are more convenient / reliable.

@squishram
Copy link
Author

No worries at all! I really appreciate you looking into it. I found clever-f.vim because I migrated from lightspeed.nvim (which includes clever-f.vim-like functionality) over to leap.nvim (which doesn't) and couldn't bear to go back to using ;/,-repeat.

If you are talking about pressing f/F/t/T as a replacement for repeats with ;, I am interested in adding that as a feature to eyeliner.nvim, thanks for the idea!

This is what I was talking about - I think it's an awesome feature, as adding 2 new keys (;,) to your roster, without having to map new things to <leader>, is such a big offering. Though again, I recognize that adding such a feature would be a pretty massive undertaking. I really appreciate you considering that - I would offer to help myself, but while I have a basic understanding of Lua, I'm far from fluent and have never written a neovim plugin before, so I'm not sure how useful I'd be.

If you're talking about how clever-f allows you to press f for lines beyond the current line, I've never had a use case for such a feature.

You're absolutely right, there are no real use-cases for such a feature at all. clever-f.vim and lightspeed.nvim both have it as a default functionality, so I assume the philosophy there is simply 'why not?' - but as you say, it's not an important feature.

Thanks again for your great work! :)

@samhh
Copy link

samhh commented Sep 9, 2022

Possibly related is that I found that this plugin broke abbreviations and macros using f. Example: https://github.com/samhh/dotfiles/blob/657b128801a631779906fc289434100a40012604/headful/cfg/nvim/ftplugin/typescript.vim#L8

@jinh0
Copy link
Owner

jinh0 commented Sep 18, 2022

Hey @samhh , are you talking about if you have highlights only turned on on pressing f? Or do you mean the default mode?

I'm not sure if this will help, but I was thinking I could give the option for users to map "f" with commands to interact with eyeliner.nvim . Maybe that'll give more flexibility with working with macros and the like.

So you could just remap f/F/t/T at your liking,

nnoremap f <Plug>Eyeliner_f

with whatever customizations you would want.

(Also, I've been busy in my personal life, but I am hoping to be more active developing this plugin in the future.)

@chrisgrieser
Copy link

If you are talking about pressing f/F/t/T as a replacement for repeats with ;, I am interested in adding that as a feature to eyeliner.nvim, thanks for the idea!

I came here exactly for this request. I don't mind moving multiple lines so much, but being able to repeat with more f is really useful and also frees up ,; for other keymappings

@jinh0
Copy link
Owner

jinh0 commented Aug 4, 2024

Hi everyone, I know it's been more than a year since I've actively been developing this plugin, but I've finally come up with a solution which I think is perfect! It is now live in the latest commit of eyeliner df1a5c8 !

The New Feature

I've exposed the function in eyeliner that highlights the line, so that it can be integrated with other plugins like clever-f.vim. Here's how:

First, you need these two config options:

require("eyeliner").setup({
	highlight_on_key = true,
        default_keymaps = false -- this will disable eyeliner from hijacking the f/F/t/T keymaps
})

Then, you can use the highlight function from eyeliner freely:

require("eyeliner.on-key").highlight({ forward = true }) -- { forward = false } to go backwards (for F/T motions)

Integration with clever-f.vim

For example, to integrate with clever-f.vim, you can set it up as:

  {
    "rhysd/clever-f.vim",
    dependencies = {"eyeliner.nvim"},
    init = function()
      vim.g.clever_f_not_overwrites_standard_mappings = 1

      vim.keymap.set(
        {"n", "x", "o"},
        "f",
        function() 
          require("eyeliner.on-key").highlight({ forward = true })
          return "<Plug>(clever-f-f)"
        end,
        {expr = true}
      )
    end
  }

Thanks everyone for your feedback, I'm sorry it took so long! Let me know if there's any problems, I'll reopen this issue!

EDIT: I've added this information to the README.md

@jinh0 jinh0 closed this as completed Aug 4, 2024
@jinh0 jinh0 mentioned this issue Aug 5, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants