Skip to content

Update zsh completion scripts #2

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6d8bf2a
zsh: update raco docs spec
benknoble Nov 24, 2024
f8154c8
zsh: require separate words in raco setup
benknoble Nov 24, 2024
2edfb30
zsh: overhaul raco setup completion
benknoble Nov 24, 2024
b1f61e7
zsh: update raco scribble completion
benknoble Nov 25, 2024
11cde17
zsh: update raco exe completion
benknoble Nov 25, 2024
1d2e4bc
zsh: update raco make completion
benknoble Nov 25, 2024
f31919f
zsh: update raco distribute completion
benknoble Nov 25, 2024
53a2c7d
zsh: update raco expand completion
benknoble Nov 25, 2024
5497abc
zsh: update raco test completion
benknoble Nov 25, 2024
e898705
zsh: update racket completion
benknoble Nov 25, 2024
91b0862
zsh: add raco pkg completion
benknoble Nov 25, 2024
cf8517c
zsh: add raco pkg install completion
benknoble Nov 25, 2024
4444b14
zsh: add raco pkg update completion
benknoble Nov 25, 2024
e516c11
zsh: add raco pkg uninstall completion
benknoble Nov 26, 2024
06a8ec6
zsh: complete installed packages in some commands
benknoble Nov 26, 2024
65c247e
zsh: add raco pkg new completion
benknoble Nov 26, 2024
5c3823b
zsh: add raco pkg show completion
benknoble Nov 26, 2024
3c1e766
zsh: add raco pkg migrate completion
benknoble Nov 26, 2024
4ebf9b3
fix unused variables/imports in main program
benknoble Nov 26, 2024
f455417
todo: note a problem with top-level collections
benknoble Nov 26, 2024
b315c8d
zsh: complete migratable versions in raco pkg migrate
benknoble Nov 27, 2024
5c98cc1
zsh: centralize --deps/--auto for raco pkg install/update/migrate
benknoble Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions list-collects.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(provide get-top-level-collection-paths)

(require racket/string racket/list racket/path setup/dirs setup/link)
(require racket/list racket/path setup/link)

(define (add-directory-collections c s)
(if (directory-exists? c)
Expand All @@ -22,7 +22,26 @@
(current-library-collection-paths))])
(add-directory-collections c s))]
[(path? l)
;; TODO: this case generates false-positives for Zsh. For example, say
;; the package named PACK is linked at ~/code/PACK as a "top-level
;; collection" (list "PACK" "~/code/PACK"); then the below code will
;; typically result in ~/code ending up in Zsh's list of prefixes to
;; complete from. But ~/code probably contains more than just Racket
;; packages! In the worst case, a package's info.rkt might specify a
;; different name for the collection than either of PACK or ~/code/PACK
;; (in which case completion can't generate matches) so that the link is,
;; e.g., (list "COLLECT" "~/code/PACK"). Ideally we'd spit out a list of
;; collection names rather than generate a list of directory prefixes for
;; Zsh and then rely on Zsh traversing the filesystem.
;;
;; "Root" collections (list 'root <path>) don't appear to have this
;; problem. See "Collection Links"
(let ([s (for*/fold ([s s]) ([c (in-list (links #:file l #:root? #f #:with-path? #t))])
;; TODO: see above. Here we throw away any root collection
;; names. Because we don't go through
;; add-directory-collections, either, we end up adding
;; ~/code/PACK to the list of candidates, which gets turned
;; into ~/code for Zsh.
(hash-set s (cdr c) #t))])
(for*/fold ([s s]) ([c (in-list (links #:file l #:root? #t))])
(add-directory-collections c s)))]
Expand All @@ -35,7 +54,7 @@
(define shell (getenv var))
(cond [(equal? shell "bash")
(for ([p (get-top-level-collection-paths)])
(define-values [base name dir?] (split-path p))
(define-values [_base name _dir?] (split-path p))
(displayln name))]
[(equal? shell "zsh")
(for-each displayln
Expand Down
Loading