telescope-live-grep-args.nvim
telescope-live-grep-args.nvim copied to clipboard
Use `rg --json` for highlighting the matches
rg
provides a --json
option that returns offsets of the matches. This can be used to highlight the matches.
It should use ~json_decode
or~ vim.json.decode
~depending on availablility where vim.json
has priority~. vim.json
is going to be shipped with nvim 0.6.
relates to https://github.com/nvim-telescope/telescope.nvim/pull/1448
Love it! Too add to that, I feel like it should have no problem highlighting more complex regex searches as well, which --json
would absolutely help with.
I'm curious how --json
would affect performance though.
Also, @TC72 had done some experimenting with highlighting on my old live_grep_raw PR as well; Posting his thoughts here in case it helps... https://github.com/nvim-telescope/telescope.nvim/pull/670#issuecomment-975341210
I have code which works thanks to @Conni2461 giving me some code to convert ansi codes to highlighting. But overall the way I implemented it was a mess.
I think we could give --json
a try, my only concern is the sheer amount of data we'll get back from it.
As @weeman1337 has already spotted, this patch should improve json parsing:
https://github.com/neovim/neovim/pull/14871
I already said it once but again vim.fn.json_decode
was never an option because we are in an fast event. You cant call viml
inside a fast event. :help api-fast
Thats why vim.json
is such a big deal not because its 2.5 times faster.
@Conni2461 thanks for explaining.
Hi, sorry but i dont understand how to use --json to highlight the matches (tried passing that in rg args but got nil:nil:nil). Is it possible to highlight matches when additional arguments are passed? Like this
Hi, sorry but i dont understand how to use --json to highlight the matches
Hi @jugarpeupv . It has not yet been implemented.