Code Monkey home page Code Monkey logo

Comments (7)

purpleP avatar purpleP commented on August 25, 2024

Oh, and in case you're wondering why not just add what user searched for to the / register - because this wouldn't work with regex searches.

from vim-grepper.

mhinz avatar mhinz commented on August 25, 2024

Do you know that there's simple highlighting support already? It's enabled by :Greppers -highlight flag. (See :h :Grepper.)

Simple because it indeed uses the / register, although it should handle simple cases of .* and a few other patterns just fine. It's a "good enough" approach that doesn't rely on external tools.

Put this in your vimrc to turn on highlighting for :Ag:

command! -nargs=* -complete=file Ag Grepper -noprompt -highlight -tool ag -query <args>

As for the other suggestions:

  • Way 1: But how do you "search" the output line to even get the starting column when using regexp? To get an exact answer, you'd have to use the same tool again. And then you have the same problem again: no ending column. (Some tools don't even report the starting column.)
  • Way 2: No, just no. :-) Parsing ANSI escape sequences only leads into a deep, deep rabbit hole. Some tools might not even provide coloured output.

from vim-grepper.

purpleP avatar purpleP commented on August 25, 2024

@mhinz First of all I've tried enable highlight via g:grepper, but it didn't work out for some reason.

About the first way. Ag can report starting column. You don't need to search for it youself. Then, as I've said - you can make Ag output match only and from that you can get the length of match. Start column + length = end column. And there it is - you arguments for the matchpos ready.
Unfortunately I know only basics of vimscript, so most of you code is mumbo jumbo to me, so I can't add this myself in any reasonable time, but this shouldn't be hard to do, right?

What's harder to do is display the whole line in quick fix with this approach. I don't really need that myself, but other people probably would prefer this. This is also achievable. We can just take line numbers from ag output and get this lines manually from all files with matches.

I sense that you will say something like "this is too much work", "no one really needs this", so would you at least accept pull request with this feature sometime?

And I don't like things that's "good enough" when there's clearly a way to make them better. Never settle on the mediocracy.

from vim-grepper.

mhinz avatar mhinz commented on August 25, 2024

First of all I've tried enable highlight via g:grepper, but it didn't work out for some reason.

What was the exact line? A quick test with let g:grepper = { 'highlight': 1 } and searching for "foo" afterwards worked just fine.

And I don't like things that's "good enough" when there's clearly a way to make them better. Never settle on the mediocracy.

Well, this misses the point. The approach wasn't chosen because it's easier to implement, but because it works the same for all supported tools and tools added by the user. It's the best approach given a certain design and has nothing to do with mediocracy.

Ag can report starting column. You don't need to search for it youself. Then, as I've said - you can make Ag output match only and from that you can get the length of match.

And as I've said, that might not work for other tools, which is my main grief, since I don't like adding too much tool-specific code.

Nevertheless I'm open to adding "exact highlighting". Let me play around with this idea for a bit and see if I encounter any technical problems.

from vim-grepper.

purpleP avatar purpleP commented on August 25, 2024

@mhinz Thanks, will be glad if this would be added.

from vim-grepper.

mhinz avatar mhinz commented on August 25, 2024

I played around with the idea for a bit, but all solutions seem quite flakey to me.

Nevertheless I let the issue open in case someone wants to have a try on it.

from vim-grepper.

mhinz avatar mhinz commented on August 25, 2024

I'm closing this since I'm going into maintenance mode for this plugin. I'll still fix bugs but I won't add new features on my own.

from vim-grepper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.