-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telescope-style search box #8279
Comments
It's the main thing I'll miss from neovim Screen.Recording.2024-04-19.at.7.53.25.PM.mov |
And the grep version Screen.Recording.2024-04-19.at.8.00.28.PM.mov |
Agree completely. |
Would be the feature that makes me move from vs-code |
Please make this happen! |
This would be amazing |
absolutely, I'm on board too |
I also want this to happen, It'll speed the coding. |
This would be very nice! |
In case it helps anyone else, I was able to set up a task that uses
The preview window is specific to my layout but should be pretty easy to update ( Something built-in like telescope would be amazing |
This 🙌 I'm soooo in favor. This is the main (and atm. basically the only) missing feature that keeps me from switching to Zed from Neovim. - I don't care for tabs or clunky file trees that much but am totally content using Telescope for this. Things I'd need from that:
Bonus:
|
If this gets added to the editor along with errorlens. consider me as a loyal lifelong Zed user. |
This would be a very nice addition! Keep up the good work |
Every time I try to switch from nvim I end up just running nvim in the editor terminal to edit files this way :D |
This is the final piece to make me migrate from webstorm to zed |
Planning to move from neo vim to zed. Wish this gets implemented in zed |
I've been trying Zed for a few weeks now and the only feature that keeps me from making the switch is Telescope. Hope this gets released and keep up the good work! |
Thank you for providing the code solution. I have adjusted it to make it look even better. Everyone is welcome to give it a try. 2024-11-23.12.59.50.mp4
function search_and_edit
set -l selected_file (rg --column --hidden --line-number --no-heading --color=always --smart-case --glob '!**/.git/' --glob '!**/node_modules/' . | fzf --ansi --delimiter : --preview 'bat --style=numbers,changes,header --color=always --highlight-line {2} {1}' --preview-window 'up:60%:+{2}+3/3' --layout=reverse)
if test -n "$selected_file"
set -l file (echo $selected_file | cut -d':' -f1)
set -l line (echo $selected_file | cut -d':' -f2)
set -l col (echo $selected_file | cut -d':' -f3)
zed $file:$line:$col
end
end
{
"context": "Editor && vim_mode == normal && !VimWaiting && !menu",
"bindings": {
"space f": [
"workspace::SendKeystrokes",
": new center terminal enter search_and_edit space && space exit enter"
]
}
} |
Hey guys, I was looking at this issue too. I have an implementation of this search style in rust on my websocket ide project here on line 177. I use the crate nucleo. I will spend some time looking into the code to see if I can easily move the coded over. If someone can point to a starting point, that would be great. |
I submitted a pr for realtime search but it's kinda slow because their current search seems to lack optimizations. Waiting on their advice on how to proceed. |
Hey @GengCen-Qin Can you please help me out.. I configured fish and added the function as well and it works in the terminal when I put it manually. I have also added the keymap as you provided. But, when i press |
The I've updated and enhanced my config since my last post. I've added file search and historical search support. Sharing it here for others: In my function zed_file_search() {
local FILE
FILE=$(
rg --files --hidden --color=always \
--glob '!**/.git/' \
--glob '!**/node_modules' \
| fzf --ansi --preview 'bat --decorations=always --color=always {} --style=full --line-range :50' \
--preview-window 'up:60%:wrap' \
--layout=reverse
)
if [ -n "$FILE" ]; then
zed "$FILE"
fi
}
function zed_search() {
local query="${1:-}"
local OUT
# Run fzf in multi-selection mode with dynamic reload based on the query.
# The first line of output is the final query, followed by one or more selected results.
OUT=$(
fzf --ansi --cycle --exact --delimiter ':' --nth 4.. \
--preview 'bat --decorations=always --color=always {1} --highlight-line {2} --style=full' \
--preview-window 'up:60%:+{2}+3/3' \
--layout=reverse \
--query "$query" \
--phony \
--print-query \
--multi \
--bind 'start:reload:rg --column --hidden --line-number --no-heading --color=always --smart-case \
--colors match:fg:green --colors path:fg:white --colors path:style:nobold \
--glob "!**/.git/" --glob "!**/node_modules" {q} .' \
--bind 'change:reload:rg --column --hidden --line-number --no-heading --color=always --smart-case \
--colors match:fg:green --colors path:fg:white --colors path:style:nobold \
--glob "!**/.git/" --glob "!**/node_modules" {q} .'
)
# If nothing was selected, do nothing
if [ -z "$OUT" ]; then
return
fi
# The first line of OUT is the query used, append it to history
local FINAL_QUERY
FINAL_QUERY=$(echo "$OUT" | head -n1)
if [ -n "$FINAL_QUERY" ]; then
echo "$FINAL_QUERY" >> ~/.zed_search_history
fi
# Now extract the selected file lines (everything after the first line)
# Each line is in the format: filepath:line:col:...
echo "$OUT" | tail -n +2 | while IFS= read -r FILE_LINE; do
if [ -n "$FILE_LINE" ]; then
local LINE COL PATH
# Not sure why, but I have to use absolute paths to `cut` and `zed` here
LINE=$(echo "$FILE_LINE" | /usr/bin/cut -d':' -f2)
COL=$(echo "$FILE_LINE" | /usr/bin/cut -d':' -f3)
PATH=$(echo "$FILE_LINE" | /usr/bin/cut -d':' -f1)
/usr/local/bin/zed "$PATH:$LINE:$COL"
fi
done
}
function zed_search_history() {
# FZF to choose a past query
local HIST_QUERY=$(fzf --prompt="History> " < ~/.zed_search_history)
if [ -n "$HIST_QUERY" ]; then
# Run zed_search again with the chosen query
zed_search "$HIST_QUERY"
fi
} My global {
"label": "search:files",
"command": "zed_file_search",
"env": {},
"cwd": "${ZED_WORKTREE_ROOT}",
"allow_concurrent_runs": false,
"use_new_terminal": false,
"reveal": "always",
"hide": "always",
"show_command": true,
"show_summary": true,
"reveal_target": "center"
},
{
"label": "search:project",
"command": "zed_search ${ZED_SELECTED_TEXT:-}",
"env": {},
"cwd": "${ZED_WORKTREE_ROOT}",
"allow_concurrent_runs": false,
"use_new_terminal": false,
"reveal": "always",
"hide": "always",
"show_command": true,
"show_summary": true,
"reveal_target": "center"
},
{
"label": "search:history",
"command": "zed_search_history",
"env": {},
"cwd": "${ZED_WORKTREE_ROOT}",
"allow_concurrent_runs": false,
"use_new_terminal": false,
"reveal": "always",
"hide": "always",
"show_command": true,
"show_summary": true,
"reveal_target": "center"
}, I then have some keybindings that fire these tasks. Here is a quick demo of how it works/looks: Kapture.2024-12-23.at.09.41.53.mp4I recently came across this TUI tool for general-purpose fuzzy finding inspired by Telescope - https://github.com/alexpasmantier/television. Integrating this as a center terminal task might be a better approach but I haven't gotten around to it yet |
@vjdhanota - Nice work on that and good find for
{
"label": "File Finder",
"command": "zed \"$(tv files)\"",
"hide": "always",
"allow_concurrent_runs": true,
"use_new_terminal": true
},
{
"label": "Find in Files",
"command": "zed \"$(tv text)\"",
"hide": "always",
"allow_concurrent_runs": true,
"use_new_terminal": true
},
"cmd-p": [
"task::Spawn",
{ "task_name": "File Finder", "reveal_target": "center" }
],
"cmd-f": [
"task::Spawn",
{ "task_name": "Find in Files", "reveal_target": "center" }
], |
Hi @baldwindavid Thanks for your help! Merry Christmas! |
@LogicKahanHai The feature to run a task in the center terminal is currently only in the preview release. The next stable release will include it. |
Posted a discussion of the drop-in replacement leveraging television with a video in #22581. This is effectively a solved issue for me at this point though I know popping into a TUI is not everyone's bag. |
Check for existing issues
Describe the feature
In (neo)vim I'm able to search for file names and contents using telescope. This has the following advantages:
If applicable, add mockups / screenshots to help present your vision of the feature
The text was updated successfully, but these errors were encountered: