Archived entries from file home/dan/repos.doom.d/README.org
Config thanks to: Configuring Emacs for Rust development | Robert Krahn
(setq rustic-lsp-client 'eglot)
(after! rustic
(map! :map rustic-mode-map
"M-j" #'lsp-ui-imenu
"M-?" #'lsp-find-references
"C-c C-c C-c" #'rustic-compile
"C-c C-c l" #'flycheck-list-errors
"C-c C-c a" #'lsp-execute-code-action
"C-c C-c r" #'lsp-rename
"C-c C-c q" #'lsp-workspace-restart
"C-c C-c Q" #'lsp-workspace-shutdown
"C-c C-c s" #'lsp-rust-analyzer-status)
;; (setq lsp-enable-symbol-highlighting nil)
(setq rustic-format-trigger nil)
(add-hook 'rustic-mode-hook 'my/rustic-mode-hook)
;; (setq lsp-rust-analyzer-server-display-inlay-hints nil)
;; (customize-set-variable 'lsp-ui-doc-enable nil)
;; (add-hook 'lsp-ui-mode-hook #'(lambda () (lsp-ui-sideline-enable nil)))
)
(after! eglot
(eglot-inlay-hints-mode nil)
(add-hook 'eglot--managed-mode-hook (lambda () (flymake-mode -1))))
(defun my/rustic-mode-hook ()
;; so that run C-c C-c C-r works without having to confirm, but don't try to
;; save rust buffers that are not file visiting. Once
;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should
;; no longer be necessary.
(when buffer-file-name
(setq-local buffer-save-without-query t)))
- cargo-edit
(use-package! selectrum
:config
(selectrum-mode +1)
(setq selectrum-max-window-height 15)
(setq selectrum-fix-vertical-window-height t)
(setq selectrum-group-format nil)
(setq magit-completing-read-function #'selectrum-completing-read))
(use-package! orderless
:custom (completion-styles '(orderless)))
(use-package! selectrum-prescient
:after (selectrum)
:config
(setq selectrum-prescient-enable-filtering nil)
(selectrum-prescient-mode +1)
(prescient-persist-mode +1))
(use-package! ctrlf
:init
(ctrlf-mode +1))
(use-package! consult
:init
(setq xref-search-program 'ripgrep
xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
(map! :localleader
:map org-mode-map
;; override default binding for org-goto
"." 'consult-outline)
:config
(setq consult-async-split-style 'nil)
(autoload 'projectile-project-root "projectile")
(setq consult-project-root-function #'projectile-project-root)
(setq consult-ripgrep-command "rg --null --ignore-case --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS")
:bind
(;; C-c bindings (mode-specific-map)
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-s l" . consult-line)
("M-s m" . consult-multi-occur)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch)
:map isearch-mode-map
("M-s e" . consult-isearch) ;; orig. isearch-edit-string
("M-s l" . consult-line)) ;; needed by consult-line to detect isearch
)
(use-package! consult-flycheck
:bind (:map flycheck-command-map
("!" . consult-flycheck)))
(use-package! consult-projectile)
;; (consult-customize
;; consult-ripgrep consult-git-grep consult-grep
;; consult-bookmark consult-recent-file consult-xref
;; consult--source-bookmark consult--source-recent-file
;; consult--source-project-recent-file
;; ;; :preview-key '(:debounce 0.2 any) ;; Option 1: Delay preview
;; :preview-key "M-.")
;; (consult-customize
;; consult--source-file consult--source-project-file consult--source-bookmark
;; :preview-key "M-.")
(add-to-dk-keymap
'(("<SPC>" . deadgrep)
;; Project content search. ripgrep automatically understands .gitignore
("g" . consult-ripgrep)
;; Project file search.
("h" . consult-projectile)
("i" . consult-imenu)
("j" . consult-buffer)))
(global-set-key [remap yank-pop] 'consult-yank-pop)
(use-package! marginalia
:init (marginalia-mode)
:bind
(("M-A" . marginalia-cycle)
:map minibuffer-local-map
("M-A" . marginalia-cycle)))
(use-package! selectrum
:config
(selectrum-mode +1)
(setq selectrum-max-window-height 15)
(setq selectrum-fix-vertical-window-height t)
(setq selectrum-group-format nil)
(setq magit-completing-read-function #'selectrum-completing-read))
(use-package! selectrum-prescient
:after (selectrum)
:config
(setq selectrum-prescient-enable-filtering nil)
(selectrum-prescient-mode +1)
(prescient-persist-mode +1))
(use-package! orderless
:custom (completion-styles '(orderless)))
(use-package! marginalia
:init (marginalia-mode)
:bind
(("M-A" . marginalia-cycle)
:map minibuffer-local-map
("M-A" . marginalia-cycle)))
Set brightness by writing directly to system brightness file.
(setq my/brightness-min 1)
(setq my/brightness-max 100)
(setq my/brightness-step 5)
(defun my/get-brightness ()
(* my/brightness-step (round (string-to-number
(shell-command-to-string "light -G"))
my/brightness-step)))
(defun my/set-brightness (level)
(interactive "nBrightness level: ")
(let ((safe-level
(cond ((< level my/brightness-min) my/brightness-min)
((> level my/brightness-max) my/brightness-max)
(t level))))
(save-window-excursion
(shell-command
(format "sudo light -S %s" safe-level) nil nil))))
(defun my/brightness-step-change (delta)
(my/set-brightness (+ delta (my/get-brightness))))
(defun my/brightness-increase ()
(interactive)
(my/brightness-step-change my/brightness-step))
(defun my/brightness-decrease ()
(interactive)
(my/brightness-step-change (- my/brightness-step)))
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)))
Elisp related to my neurosys.
(setq neurosys/base-dir "/home/dan/repos/neurosys/")
(defun neurosys/deploy-to-host (host host-home-raw)
(interactive "sHost: \nsHost home: ")
(let ((host-root (format "/ssh:%s:/" host))
;; mind the trailing slash, since we're passing it to rsync
(host-home (file-name-as-directory host-home-raw)))
(save-window-excursion
(org-babel-tangle)
(my/run-in-fresh-compilation
(format (concat neurosys/base-dir "rsync.sh %s %s") host host-home) neurosys/base-dir)
;; TODO: Is there cleaner way to compile over TRAMP?
(find-file host-root)
(compile "nixos-rebuild switch --show-trace")))
(switch-to-buffer-other-window "*compilation*"))
(defun neurosys/deploy-to-nixos-dev ()
(interactive)
(neurosys/deploy-to-host "root@nixos-dev" "/home/dan/"))
- [ ] Update channels with
nix-channel --update
- [ ] Rebuild packages with
nixos-rebuild switch
NOTE: These can be combined with nixos-rebuild switch --update
(defun neurosys/open-config-file ()
(interactive)
(find-file (concat neurosys/base-dir "README.org")))
(map!
:leader
:prefix ("j" . "neurosys")
:desc "deploy" "D" #'neurosys/deploy-to-host
:desc "deploy to nixos-dev" "d" #'neurosys/deploy-to-nixos-dev)