From 47ac7803898958050d0dc49d8fed5f7d2b53eb1d Mon Sep 17 00:00:00 2001 From: Mike Fikes Date: Sun, 12 May 2019 07:59:01 -0400 Subject: [PATCH] Auto complete for #queue, #inst, etc. (#927) Fixes #926 --- CHANGELOG.md | 1 + planck-cljs/src/planck/repl.cljs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f1bf975..28e0382c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. This change - Add -keep-gcl option to the clean script - Ignore `*.swp` files - Support [`NO_COLOR`](https://no-color.org) ([#923](https://github.com/planck-repl/planck/issues/923)) +- Auto complete for `#queue`, `#inst`, _etc_. ([#926](https://github.com/planck-repl/planck/issues/926)) ### Changed - Re-enable FTL JIT on macOS ([#820](https://github.com/planck-repl/planck/issues/820)) diff --git a/planck-cljs/src/planck/repl.cljs b/planck-cljs/src/planck/repl.cljs index 4a97f94b..9d775cf1 100644 --- a/planck-cljs/src/planck/repl.cljs +++ b/planck-cljs/src/planck/repl.cljs @@ -657,6 +657,9 @@ :req :req-un :opt :opt-un :args :ret :fn]) +(def ^:private tagged-literal-completions + ["#uuid" "#inst" "#queue" "#js"]) + (def ^:private namespace-completion-exclusions '[planck.from.io.aviso.ansi planck.pprint.code @@ -728,6 +731,7 @@ (completion-candidates-for-ns (add-macros-suffix expanded-ns) false))) (concat (map str keyword-completions) + tagged-literal-completions (namespace-completions) (map #(str % "/") (keys (current-alias-map))) (completion-candidates-for-ns 'cljs.core false) @@ -786,7 +790,7 @@ (local-keyword-completions kw-name) (let [top-form? (re-find #"^\s*\(\s*[^()\s]*$" buffer) typed-ns (second (re-find #"\(*(\b[a-zA-Z0-9-.<>*=&?]+)/[a-zA-Z0-9-]*$" buffer))] - (let [buffer-match-suffix (first (re-find #":?([a-zA-Z0-9-.<>*=&?]*|^\(/)$" buffer)) + (let [buffer-match-suffix (first (re-find #"[#:]?([a-zA-Z0-9-.<>*=&?]*|^\(/)$" buffer)) completions (sort (filter (partial is-completion? buffer-match-suffix) (completion-candidates top-form? typed-ns))) common-prefix (longest-common-prefix completions)]