rust: Nicer launch-rust-analyzer signature with #:share and #:expose
This commit is contained in:
parent
b9a4a014f3
commit
c5662606df
1 changed files with 18 additions and 2 deletions
20
env/rust.scm
vendored
20
env/rust.scm
vendored
|
@ -148,9 +148,25 @@ function."
|
|||
(exec-in-rustup-environment '("/bin/sh") #:home home))
|
||||
|
||||
(define* (launch-rust-analyzer env target-name
|
||||
#:key (tag 'current) mappings)
|
||||
#:key
|
||||
(tag 'current) (share '()) (expose '()))
|
||||
(define (remap w)
|
||||
(let ((home (getenv "HOME")))
|
||||
(λ (m)
|
||||
(let loop ((m m))
|
||||
(match m
|
||||
((s t) (file-system-mapping (source s) (target t) (writable? w)))
|
||||
(s (if (file-exists? s)
|
||||
(if (string-prefix? home s)
|
||||
(loop (list s (string-replace s "rustup"
|
||||
6 (string-length home))))
|
||||
(loop (list s s)))
|
||||
(throw 'file-doesnt-exist))))))))
|
||||
|
||||
(let* ((target (string-append (@@ (env) %env-directory) "/" target-name))
|
||||
(mnt (mount-environment env #:tag tag #:target target)))
|
||||
(mnt (mount-environment env #:tag tag #:target target))
|
||||
(mappings (append (map (remap #f) expose)
|
||||
(map (remap #t) share))))
|
||||
(exec-in-rustup-environment '("./.cargo/bin/rust-analyzer")
|
||||
#:home (overlay-mount-merged mnt)
|
||||
#:mappings mappings)
|
||||
|
|
Loading…
Reference in a new issue