Comments (6)
Btw, this is not urgent for me. I was able to add a feature to yazi.nvim where I can read the last cd
DDS event and run telescope inside neovim, limiting the search to the directory. The experience is quite good.
yazi-nvim-search.mov
from yazi.
I'd like to know more about the implementation details:
- Currently, there's no saved information about the matching line numbers. Where do you plan to store them? Will it be in the file's own attributes or a separate variable?
- We need to consider the worst-case scenario: if the offset is large, for example, if the first match is the last line of a 10,000-line file, highlighting will take a long time. How will we handle this?
- Should we implement this as a unified feature, or distribute it among the Lua code for each previewer? If it's the latter, it will allow us to expand support for other file types in the future (e.g., PDF, where it would be page numbers instead of line numbers). This would make it easier to transition from rg to rga, which supports searching in file types other than just text files.
from yazi.
Currently, there's no saved information about the matching line numbers. Where do you plan to store them? Will it be in the file's own attributes or a separate variable?
Here is a sample match from rg
using the --json
flag to get machine readable output (it seems to provide line numbers already):
// $ rg "window" --files-with-matches --json
{
"type": "match",
"data": {
"path": { "text": "lua/yazi/utils.lua" },
"lines": { "text": "---@param window YaziFloatingWindow\n" },
"line_number": 195,
"absolute_offset": 5224,
"submatches": [{ "match": { "text": "window" }, "start": 10, "end": 16 }],
},
}
One possibility would store it as a new struct, composing the existing File
with additional information:
pub struct RgSearchMatch {
pub file: File,
pub line_number: u32,
}
We need to consider the worst-case scenario: if the offset is large, for example, if the first match is the last line of a 10,000-line file, highlighting will take a long time. How will we handle this?
I don't know what would be the best way to handle this.
I can think of a few approaches:
- If the file is too large, we could skip highlighting altogether. Maybe the user could configure this in some way, and yazi could provide a conservative default
- For large files, provide a faster but less accurate highlighting method. I'm not really sure about this approach since it increases the maintenance burden quite a lot.
- For all files, display the match without highlighting, but also start a background task to highlight the file. When the highlighting is done (for the area that is needed), we could update the previewer and kill the task.
Should we implement this as a unified feature, or distribute it among the Lua code for each previewer
To tell you the truth, I would personally be very happy with a super basic implementation in yazi that showed some context around the match. I would give previewer plugins the possibility of doing opt-in fancy things.
For example, a plugin could be written that applies a tree-sitter parser (I believe this is the implementation in https://github.com/nvim-telescope/telescope.nvim).
from yazi.
Looks like rg also provides a rudimentary integration with delta: https://github.com/BurntSushi/ripgrep?tab=readme-ov-file#related-tools
I tried this out and it worked.. but some files were not highlighted correctly. Also, this requires a bit of tinkering to set up, so I don't really think it's that good.
from yazi.
This task is want to make like fg.yazi to a built-in feature?
from yazi.
Hmm, conceptually they are very similar, but here are some differences:
- fg.yazi seems to use external programs - I actually meant simple highlighting in yazi's current search
- fg.yazi seems capable of showing each match as a separate result - yazi shows each matched file only once
from yazi.
Related Issues (20)
- Exit select mode after finishing renaming the files. HOT 4
- DDS static messages only work when at least two instances of Yazi are running HOT 2
- Child process hangs waiting for EOF (end fo file) when using `stdin(Command.PIPED)` HOT 2
- Extract plugin fails to work on encrypted rar and zip archives HOT 4
- Opening multiple files only hovers the first file, others are directories HOT 2
- [RFC] Replace package manager URL from `yazi-rs/plugins#full-border` to `yazi-rs/plugins:full-border` HOT 10
- view files in /proc HOT 9
- [RFC] refactor and improve shell options HOT 1
- `cd --interactive` - some dirs/files icons are small until hovered HOT 6
- Add IF patched fonts HOT 1
- parquet HOT 1
- Moving folder into itself causes frozen task HOT 3
- Glob pattern matching also includes children in filetype rules HOT 4
- Insert keymap doesnt work HOT 7
- Multiple Keymap Actions result in erroneous behaviour. HOT 1
- Export list of key bindings
- Wrong behavior on opening file that contains space on Windows HOT 1
- Plugins like zoxide don't seem to work HOT 4
- Compilation issues while building from source HOT 3
- Yazi gets stuck when hovering over a specific text file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yazi.