Add rust config
This commit is contained in:
parent
5279873a2f
commit
f402179eeb
@ -262,6 +262,29 @@
|
||||
:command-line (format "mvn test -Dtest=%s" test-method)
|
||||
:working-dir project-dir)))))
|
||||
|
||||
(defun get-cargo-commands (dir)
|
||||
(when (executable-find "cargo")
|
||||
(with-temp-buffer
|
||||
(cd dir)
|
||||
(-as-> (shell-command-to-string "cargo --list") v
|
||||
(split-string v "\n")
|
||||
(cdr v)
|
||||
(-filter (-not (-partial 's-contains-p "alias")) v)
|
||||
(-map 's-trim v)
|
||||
(-map (-partial 's-split " ") v)
|
||||
(-map 'car v)
|
||||
(-filter (-not 's-blank?) v)))))
|
||||
|
||||
(defun run-command-recipe-cargo ()
|
||||
(when-let* ((project-dir (locate-dominating-file default-directory "Cargo.toml"))
|
||||
(cargo-cmds (get-cargo-commands project-dir)))
|
||||
(-map
|
||||
(lambda (cmd)
|
||||
(list :command-name cmd
|
||||
:command-line (format "cargo %s" cmd)
|
||||
:working-dir project-dir))
|
||||
cargo-cmds)))
|
||||
|
||||
:general
|
||||
(leader-map "\"" #'run-command)
|
||||
:custom
|
||||
@ -280,6 +303,7 @@
|
||||
run-command-recipe-nosetests
|
||||
run-command-recipe-web-ext
|
||||
run-command-recipe-pip
|
||||
run-command-recipe-maven)))
|
||||
run-command-recipe-maven
|
||||
run-command-recipe-cargo)))
|
||||
|
||||
(provide 'init-run-command)
|
||||
|
8
emacs/.emacs.d/config/init-rust.el
Normal file
8
emacs/.emacs.d/config/init-rust.el
Normal file
@ -0,0 +1,8 @@
|
||||
;; -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package rust-mode
|
||||
:mode (("\\.rs\\'" . rust-mode))
|
||||
:config
|
||||
(add-hook 'rust-mode-hook 'lsp-deferred))
|
||||
|
||||
(provide 'init-rust)
|
@ -92,6 +92,7 @@
|
||||
(require 'init-java)
|
||||
(require 'init-scala)
|
||||
(require 'init-js)
|
||||
(require 'init-rust)
|
||||
(require 'init-web)
|
||||
(require 'init-xml)
|
||||
(require 'init-yaml)
|
||||
|
@ -1,5 +1,5 @@
|
||||
typeset -U path
|
||||
path=(~/bin ~/.local/bin ~/.gem/ruby/2.6.0/bin ~/go/bin /opt/local/bin ~/.cargo/bin /usr/local/opt/make/libexec/gnubin $path)
|
||||
path=(~/bin ~/.local/bin ~/.gem/ruby/2.6.0/bin ~/go/bin /opt/local/bin /usr/local/opt/make/libexec/gnubin $path)
|
||||
|
||||
export INFOPATH="$HOME/info:/opt/homebrew/share/info:"
|
||||
|
||||
@ -8,8 +8,6 @@ export LEDGER_FILE="$HOME/journal.ledger"
|
||||
EDITOR="$(which emacsclient)"
|
||||
export EDITOR
|
||||
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
|
||||
export WORKON_HOME="$HOME/.local/share/virtualenvs"
|
||||
@ -34,3 +32,4 @@ fi
|
||||
export SDKMAN_DIR="$HOME/.sdkman"
|
||||
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
path=("$SDKMAN_DIR/candidates/java/current/bin" "$path[@]")
|
||||
[[ -e "$HOME/.cargo/env" ]] && . "$HOME/.cargo/env"
|
||||
|
Loading…
Reference in New Issue
Block a user