add initial draft for fschl-ide (rustic)

Signed-off-by: Frieder Schlesier <frieder@fschl.de>
This commit is contained in:
Frieder Schlesier 2023-07-27 23:57:28 +02:00
parent 8740ea8854
commit 785aa0bb85
6 changed files with 225 additions and 9 deletions

View File

@ -15,7 +15,16 @@ solution, e.g. set it up to auto-tangle all .org files within/below
** Missing Features ** Missing Features
*** TODO flyspell languages *** TODO IDE
**** TODO LSP per language
**** TODO AutoComplete, easy compile, unit test
**** TODO Debugging of some sort
*** TODO flyspell languages (de, en)
is it possible to detect based on existing content?
*** TODO snippets? *** TODO snippets?
@ -62,7 +71,6 @@ e.g. HN, golem, fefe, tagesschau
** LaTeX setup ** LaTeX setup
*** TODO make letters export work *** DONE make letters export work
*** TODO make export for other texbased documents work *** TODO make export for other texbased documents work

View File

@ -25,11 +25,6 @@
(lambda () (lambda ()
(add-hook 'after-save-hook #'org-babel-tangle-config))) (add-hook 'after-save-hook #'org-babel-tangle-config)))
(defvar fschl-org-file (expand-file-name "fschl-org.el" user-emacs-directory))
(when (and fschl-org-file
(file-exists-p fschl-org-file))
(load fschl-org-file nil :nomessage))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

82
fschl-ide.el Normal file
View File

@ -0,0 +1,82 @@
;;; fschl-ide.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*-
;; This file is generated from the .org-file with the same name. If you want to edit the
;; configuration, DO NOT edit this .el-file, edit .org, instead.
(add-to-list 'package-selected-packages 'cargo)
(add-to-list 'package-selected-packages 'rustic)
(add-to-list 'package-selected-packages 'ob-rust)
(add-to-list 'package-selected-packages 'ob-rust)
(package-install-selected-packages :noconfirm)
(use-package rustic
:ensure
:bind (:map rustic-mode-map
("M-j" . lsp-ui-imenu)
("M-ö" . lsp-find-references)
("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))
:config
;; uncomment for less flashiness
;; (setq lsp-eldoc-hook nil)
;; (setq lsp-enable-symbol-highlighting nil)
;; (setq lsp-signature-auto-activate nil)
;; comment to disable rustfmt on save
(setq rustic-format-on-save t)
(add-hook 'rustic-mode-hook 'rk/rustic-mode-hook))
(defun rk/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))
(add-hook 'before-save-hook 'lsp-format-buffer nil t))
(use-package lsp-mode
:ensure
:commands lsp
:custom
;; what to use when checking on-save. "check" is default, I prefer clippy
(lsp-rust-analyzer-cargo-watch-command "clippy")
(lsp-eldoc-render-all t)
(lsp-idle-delay 0.6)
;; enable / disable the hints as you prefer:
(lsp-inlay-hint-enable t)
;; These are optional configurations. See https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-analyzer/#lsp-rust-analyzer-display-chaining-hints for a full list
(lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
(lsp-rust-analyzer-display-chaining-hints t)
(lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
(lsp-rust-analyzer-display-closure-return-type-hints t)
(lsp-rust-analyzer-display-parameter-hints nil)
(lsp-rust-analyzer-display-reborrow-hints nil)
:config
(add-hook 'lsp-mode-hook 'lsp-ui-mode))
(use-package lsp-ui
:ensure
:commands lsp-ui-mode
:custom
(lsp-ui-peek-always-show t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-doc-enable nil))
(use-package company
:ensure
:custom
(company-idle-delay 0.5) ;; how long to wait until popup
;; (company-begin-commands nil) ;; uncomment to disable popup
:bind
(:map company-active-map
("C-n". company-select-next)
("C-p". company-select-previous)
("M-<". company-select-first)
("M->". company-select-last)))
(use-package flycheck :ensure)
(setq lsp-inlay-hint-enable t)

108
fschl-ide.org Normal file
View File

@ -0,0 +1,108 @@
#+title: Setup Fschl Ide Configuration
#+PROPERTY: header-args:emacs-lisp :tangle ./fschl-ide.el :mkdirp yes
* Basic configuration
** Additional Packages
#+begin_src emacs-lisp
;;; fschl-ide.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*-
;; This file is generated from the .org-file with the same name. If you want to edit the
;; configuration, DO NOT edit this .el-file, edit .org, instead.
(add-to-list 'package-selected-packages 'cargo)
(add-to-list 'package-selected-packages 'rustic)
(add-to-list 'package-selected-packages 'ob-rust)
(add-to-list 'package-selected-packages 'ob-rust)
(package-install-selected-packages :noconfirm)
#+end_src
** Setup Rustic
This is borrowed from https://robert.kra.hn/posts/rust-emacs-setup/
#+begin_src emacs-lisp
(use-package rustic
:ensure
:bind (:map rustic-mode-map
("M-j" . lsp-ui-imenu)
("M-ö" . lsp-find-references)
("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))
:config
;; uncomment for less flashiness
;; (setq lsp-eldoc-hook nil)
;; (setq lsp-enable-symbol-highlighting nil)
;; (setq lsp-signature-auto-activate nil)
;; comment to disable rustfmt on save
(setq rustic-format-on-save t)
(add-hook 'rustic-mode-hook 'rk/rustic-mode-hook))
(defun rk/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))
(add-hook 'before-save-hook 'lsp-format-buffer nil t))
#+end_src
** Setup LSP-mode and LSP-ui
#+begin_src emacs-lisp
(use-package lsp-mode
:ensure
:commands lsp
:custom
;; what to use when checking on-save. "check" is default, I prefer clippy
(lsp-rust-analyzer-cargo-watch-command "clippy")
(lsp-eldoc-render-all t)
(lsp-idle-delay 0.6)
;; enable / disable the hints as you prefer:
(lsp-inlay-hint-enable t)
;; These are optional configurations. See https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-analyzer/#lsp-rust-analyzer-display-chaining-hints for a full list
(lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
(lsp-rust-analyzer-display-chaining-hints t)
(lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
(lsp-rust-analyzer-display-closure-return-type-hints t)
(lsp-rust-analyzer-display-parameter-hints nil)
(lsp-rust-analyzer-display-reborrow-hints nil)
:config
(add-hook 'lsp-mode-hook 'lsp-ui-mode))
(use-package lsp-ui
:ensure
:commands lsp-ui-mode
:custom
(lsp-ui-peek-always-show t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-doc-enable nil))
#+end_src
** Auto-completion
lsp-mode integrates with company mode
#+begin_src emacs-lisp
(use-package company
:ensure
:custom
(company-idle-delay 0.5) ;; how long to wait until popup
;; (company-begin-commands nil) ;; uncomment to disable popup
:bind
(:map company-active-map
("C-n". company-select-next)
("C-p". company-select-previous)
("M-<". company-select-first)
("M->". company-select-last)))
#+end_src
** Inline stuff
hints and errors
#+begin_src emacs-lisp
(use-package flycheck :ensure)
(setq lsp-inlay-hint-enable t)
#+end_src

10
init.el
View File

@ -31,3 +31,13 @@
(unless crafted-startup-inhibit-splash (unless crafted-startup-inhibit-splash
(setq initial-buffer-choice #'crafted-startup-screen)) (setq initial-buffer-choice #'crafted-startup-screen))
(defvar fschl-org-file (expand-file-name "fschl-org.el" user-emacs-directory))
(when (and fschl-org-file
(file-exists-p fschl-org-file))
(load fschl-org-file nil :nomessage))
(defvar fschl-ide-file (expand-file-name "fschl-ide.el" user-emacs-directory))
(when (and fschl-ide-file
(file-exists-p fschl-ide-file))
(load fschl-ide-file nil :nomessage))

View File

@ -45,3 +45,16 @@
(unless crafted-startup-inhibit-splash (unless crafted-startup-inhibit-splash
(setq initial-buffer-choice #'crafted-startup-screen)) (setq initial-buffer-choice #'crafted-startup-screen))
#+end_src #+end_src
** Load my custom files
#+begin_src emacs-lisp
(defvar fschl-org-file (expand-file-name "fschl-org.el" user-emacs-directory))
(when (and fschl-org-file
(file-exists-p fschl-org-file))
(load fschl-org-file nil :nomessage))
(defvar fschl-ide-file (expand-file-name "fschl-ide.el" user-emacs-directory))
(when (and fschl-ide-file
(file-exists-p fschl-ide-file))
(load fschl-ide-file nil :nomessage))
#+end_src