telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

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

Open rockyzhang24 opened this issue 3 years ago • 8 comments

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.

rockyzhang24 avatar Jan 21 '22 21:01 rockyzhang24

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

fdschmidt93 avatar Jan 21 '22 21:01 fdschmidt93

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?

rockyzhang24 avatar Jan 21 '22 21:01 rockyzhang24

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).

fdschmidt93 avatar Jan 21 '22 22:01 fdschmidt93

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.

rockyzhang24 avatar Jan 21 '22 23:01 rockyzhang24

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.

fdschmidt93 avatar Jan 22 '22 08:01 fdschmidt93

Okay, I got it. Thanks.

rockyzhang24 avatar Jan 22 '22 16:01 rockyzhang24

Is there any progress? 👀

mrbeardad avatar Dec 11 '23 05:12 mrbeardad

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

Conni2461 avatar Dec 11 '23 06:12 Conni2461