Skip to content

Telescope magic picker

Federico Mengozzi edited this page Mar 8, 2026 · 3 revisions

This document describes the custom magic picker implemented in fnl/mods/tools/telescope.fnl.

Entry Points

  • Normal mode:
    • <C-f> -> full-height magic picker (themed_magic)
    • F -> magic picker with count-based height
      • default F = 40%
      • 3F = 30%, 7F = 70%, 9F = 90%
  • Grep shortcuts:
    • fs (normal) -> grep current word
    • fs (visual) -> grep selected text

What It Does

The magic picker combines file finding and live grep in one picker and lets you change context without closing it.

  • Starts in files mode by default
  • Root starts at current buffer directory (utils.buffer_dir())
  • Search depth starts at 4
  • Uses a dynamic previewer:
    • text/code files -> Telescope file preview
    • media files (png, jpg, gif, mp4, webm, pdf, epub, ...) -> terminal preview script

Prompt Title Format

Prompt title is updated live:

<mode> [d:<depth>] [h:<on|off>] <cwd>

Example:

find [d:4] [h:off] $HOME/projects/myrepo

In-Picker Controls

  • S (normal mode): decrease depth (fcmd_depth - 1, minimum 1)
  • D (normal mode): increase depth (fcmd_depth + 1)
  • <C-h> (insert/normal): toggle hidden files
  • <C-g> (insert/normal): toggle mode files <-> grep
  • <C-e> (insert/normal): cd into first directory segment from selected entry
  • <Tab> (insert/normal): cd into full directory of selected entry
  • <S-Tab> (insert/normal): go to parent directory

All of these refresh the current picker in place.

Finder Backend

  • files mode:
    • command: fd --type f --color never --follow --max-results 5000 --max-depth <d> [--hidden]
  • grep mode:
    • command base: rg --color=never --no-heading --with-filename --line-number --column --smart-case --max-depth <d> [--hidden]
    • query is passed dynamically as you type

Behavior Notes

  • In grep mode, selected entry paths come from entry.filename when available.
  • Directory jumps only happen when target is an existing directory and differs from current cwd.
  • Picker cache is disabled (cache_picker = false) so refresh always reflects current state.

Clone this wiki locally