Skip to content

Commit 805cd3a

Browse files
committed
improv(leap): targets callback can return custom error message
1 parent 3170bf6 commit 805cd3a

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

fnl/leap/main.fnl

+10-5
Original file line numberDiff line numberDiff line change
@@ -464,16 +464,21 @@ char separately.
464464
(or targets (set st.errmsg (.. "not found: " in1 (or ?in2 ""))))))
465465

466466
(fn get-user-given-targets [targets]
467-
(local targets* (if (= (type targets) :function) (targets) targets))
468-
(if (and targets* (> (length targets*) 0))
467+
(local default-errmsg "no targets")
468+
(local (targets* errmsg) (if (= (type targets) :function) (targets) targets))
469+
(if (not targets*)
470+
(set st.errmsg (or errmsg default-errmsg))
471+
472+
(= (length targets*) 0)
473+
(set st.errmsg default-errmsg)
474+
469475
(do
470476
; Fill wininfo-s when not provided.
471-
(local wininfo (. (vim.fn.getwininfo curr-winid) 1))
472477
(when-not (. targets* 1 :wininfo)
478+
(local wininfo (. (vim.fn.getwininfo curr-winid) 1))
473479
(each [_ t (ipairs targets*)]
474480
(set t.wininfo wininfo)))
475-
targets*)
476-
(set st.errmsg "no targets")))
481+
targets*)))
477482

478483
; Sets `autojump` and `label_set` attributes for the target list, plus
479484
; `label` and `group` attributes for each individual target.

lua/leap/main.lua

+12-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)