nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.48k stars 824 forks source link

[live_grep] no highlights in results window for a regex query #1708

Open rockyzhang24 opened 2 years ago

rockyzhang24 commented 2 years ago

Description

In live_grep, when I type a regex string as query after the prompt, no highlight for the matching in the results window.

Neovim version

NVIM v0.7.0-dev+797-gb218d02c4
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

macOS 12.1 (the latest)

checkhealth telescope

telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.3.1

## ===== Installed extensions =====

## Telescope Extension: `fzf`
  - INFO: No healthcheck provided

Steps to reproduce

  1. launch live_grep
  2. type a string not containing regex, in the results window all the matching will be highlighted
  3. type a regex string, in the result window no highlight for all the matching

Expected behavior

All the matching should be highlighted as well when the query is regex.

Actual behavior

Screen Shot 2022-01-21 at 13 14 05

However, if I type a normal string as a query, all the matching will be highlighted

Screen Shot 2022-01-21 at 13 15 28

Minimal config

The default config.

fdschmidt93 commented 2 years ago

Highlighting in the results window is actually performed by a fzy sorter.

Essentially, somebody would have to pick up https://github.com/nvim-telescope/telescope.nvim/pull/1448

rockyzhang24 commented 2 years ago

Thanks. Btw, I installed fzf extension as the sorter. I know that find_files will use fzf, how about live_grep and grep_string?

Should I try telescope-rg.nvim?

fdschmidt93 commented 2 years ago

Ah, I was too brief. The fzy sorter for highlighting pretty much only gets the offsets of matched prompts for highlighting but does not perform any sorting per se.

live_grep therefore doesn't practically speaking have any sorter. grep_string passes the string (also possibly an empty string) onto rg and then filters that one using your sorter.

Should I try telescope-rg.nvim?

I think the author originally planned on picking up the PR but never came around. That's why I mentioned somebody has to pick it up :) in the long run, in open source people ideally implement the features they want to see implemented (or generally have fun implementing stuff, of course).

rockyzhang24 commented 2 years ago

Thank you @fdschmidt93 so much for your clear explanation.

On more question (or issue) here still for live_grep highlight. When I type a query string, say main, only the files containing main xxx will be listed and main should be highlighted. However, if a file has name like main.go and its content has main xxx, highlight will be misplaced, i.e., main in the filename will be highlighted instead of the actual content. Is this a bug?

Screen Shot 2022-01-21 at 15 45 34

@fdschmidt93 I am not sure whether this problem is related to this issue, do I need to open another issue? Thank you very much.

fdschmidt93 commented 2 years ago

It's pretty much the same issue. If we got our highlighting from rg directly that issue would be fixed. I'd say you're happy to open another issue for that, though in practice would have the same solution I guess.

rockyzhang24 commented 2 years ago

Okay, I got it. Thanks.

mrbeardad commented 9 months ago

Is there any progress? 👀

Conni2461 commented 9 months ago

Yes there is progress here. One of our team members made a wip pr https://github.com/nvim-telescope/telescope.nvim/pull/2536

I hope we can finish this one soon