Skip to content

Commit 37c5d15

Browse files
committed
simplify H resizing
1 parent 44f38c4 commit 37c5d15

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

fnl/mods/tools/telescope.fnl

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,11 @@
8989
:results [""]
9090
:preview ["" "" "" "" "" "" "" ""]}
9191
:shorten_path true
92-
:layout_config {:height height
93-
:preview_width 0.65
94-
}}))
95-
;:preview_title ""}))
92+
:layout_config {: height :preview_width 0.7}}))
93+
94+
;:preview_title ""}))
9695

9796
(local ivy_config (gen_ivy_config 0.7))
98-
(local small_ivy_config (gen_ivy_config 0.4))
9997

10098
(local fzf_opts_theme (merge-table ivy_config fuzzy_search_opts))
10199

@@ -145,7 +143,6 @@
145143
(map [:n] :fr (bindf builtin.resume {:initial_mode :normal})
146144
{:desc "Resume last search"})
147145

148-
(map [:n] :ff themed_count_find_files {:desc "Find files"})
149146
(map [:n] :fa (bindf themed_count_find_files {:hidden true})
150147
{:desc "Find all files [hidden]"})
151148

@@ -328,7 +325,15 @@
328325
(var mode (if (= (. opts :mode) :grep) :grep :find))
329326
(var cwd (. opts :cwd))
330327
(var relcwd (cwd:gsub (os.getenv :HOME) :$HOME))
331-
(tset opts :prompt_title (.. mode " [d:" (. opts :fcmd_depth) "] " relcwd)))
328+
(var hidden? (if (. opts :hidden) :on :off))
329+
(tset opts :prompt_title
330+
(.. mode
331+
" [d:"
332+
(. opts :fcmd_depth)
333+
"] [h:"
334+
hidden?
335+
"] "
336+
relcwd)))
332337

333338
(fn refresh [picker opts popts]
334339
"Refresh the picker with new options"
@@ -446,8 +451,16 @@
446451
true)}))
447452
(p.find p)))
448453

454+
(fn themed_magic_height [height]
455+
(bindf magic (gen_ivy_config height)))
449456
(local themed_magic (bindf magic ivy_config))
450-
(local small_themed_magic (bindf magic small_ivy_config))
457+
458+
(fn count_themed_magic []
459+
(let [n (. vim.v :count)
460+
n (if (> n 0) n 4)
461+
n (math.max 1 (math.min n 9))
462+
height (/ n 10)]
463+
((themed_magic_height height))))
451464

452465
(fn magic-grep-cword []
453466
(magic (merge-table ivy_config
@@ -459,7 +472,7 @@
459472
(vim.fn.setreg :v [])
460473
(magic (merge-table ivy_config {:mode :grep :default_text text})))
461474

462-
(map [:n] :F small_themed_magic {:desc "Find and move around"})
475+
(map [:n] :F count_themed_magic {:desc "Find and move around [count height]"})
463476
(map [:n] :<C-f> themed_magic {:desc "Find and move around"})
464477
(map [:n] :fs magic-grep-cword {:desc "Find string [magic grep]"})
465478
(map [:v] :fs magic-grep-visual {:desc "Find selection [magic grep]"})

0 commit comments

Comments
 (0)