commit bcb67d5b11bbe138203d336fca61f964e0f76fdc
parent 55919b2ab79765605850600df9ef1ae49663aaee
Author: Ethan Long <ethandavidlong@gmail.com>
Date: Sun, 1 Oct 2023 22:04:08 +1100
Updated le config
I can't be assed dealing with autosave crap anymore so all that is gone.
Diffstat:
| M | config.org | | | 102 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- |
| M | early-init.el | | | 2 | +- |
2 files changed, 75 insertions(+), 29 deletions(-)
diff --git a/config.org b/config.org
@@ -57,18 +57,6 @@ We can use ~use-package~ to configure emacs at startup. On MacOS we leave things
(global-unset-key (kbd "<C-wheel-up>"))
(global-unset-key (kbd "<C-wheel-down>")))
#+end_src
-Let's get rid of the autosave and backup crap that emacs puts into the active working directories.
-#+begin_src emacs-lisp
- ;; Put autosave files (ie #foo#) and backup files (ie foo~) in ~/.emacs.d/.
- (setq ethandl/autosave-file-directory (expand-file-name "autosaves/" user-emacs-directory))
- (setq ethandl/backups-file-directory (expand-file-name "backups/" user-emacs-directory))
- (custom-set-variables
- '(auto-save-file-name-transforms `((".*" ,ethandl/autosave-file-directory t)))
- '(backup-directory-alist '((".*" . ethandl/backups-file-directory))))
-
- ;; create the autosave dir if necessary, since emacs won't.
- (make-directory ethandl/autosave-file-directory t)
-#+end_src
** Fonts & Ligature definitions
#+begin_src emacs-lisp
;; Set the fonts
@@ -323,7 +311,8 @@ We need to configure the ~org~ package. Technically we could install the git ver
:elpaca nil
:hook ((org-mode . ethandl/org-mode-base)
(org-mode . turn-on-org-cdlatex)
- (org-mode . ethandl/org-mode-prettify)))
+ (org-mode . ethandl/org-mode-prettify))
+ )
#+end_src
Adding in the ability to seamlessly paste in images from the clipboard:
#+begin_src emacs-lisp
@@ -355,32 +344,77 @@ LSP, the Language Server Protocol. Very nice for debugging code live as you writ
*Warning:* Some LSPs are godawful slow and can chew through CPU and memory. Be careful, tinker, and don't be afraid to disable the training wheels.
#+begin_src emacs-lisp
- ;; LSP mode
- (use-package lsp
- :elpaca lsp-mode
- :init
- (setq gc-cons-threshold 100000000)
- (setq read-process-output-max (* 1024 1024))
- (setq lsp-completion-provider :none))
+ ;; LSP mode
+ (use-package lsp
+ :elpaca lsp-mode
+ :init
+ (setq gc-cons-threshold 100000000)
+ (setq read-process-output-max (* 1024 1024))
+ (setq lsp-completion-provider :none)
+ (setq lsp-eldoc-render-all t))
+#+end_src
+A longer term goal of mine is to remove the need for =lsp-mode= and instead use =eglot=, but =lsp-mode= just has such a painless setup that I would rather just use it sometimes.
+** Tree Sitter Setup
+Since Emacs 29, we don't need to install tree sitter separately anymore, it comes with Emacs!
+#+begin_src emacs-lisp
+ (setq treesit-language-source-alist
+ '((bash "https://github.com/tree-sitter/tree-sitter-bash")
+ (css "https://github.com/tree-sitter/tree-sitter-css")
+ (go "https://github.com/tree-sitter/tree-sitter-go")
+ (html "https://github.com/tree-sitter/tree-sitter-html")
+ (javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
+ (json "https://github.com/tree-sitter/tree-sitter-json")
+ (python "https://github.com/tree-sitter/tree-sitter-python")
+ (toml "https://github.com/tree-sitter/tree-sitter-toml")
+ (tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
+ (typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
+ (rust "https://github.com/tree-sitter/tree-sitter-rust")
+ (java "https://github.com/tree-sitter/tree-sitter-java")
+ ;;(haskell "https://github.com/tree-sitter/tree-sitter-haskell") ; There is no haskell-ts-mode yet
+ ;;(ocaml "https://github.com/tree-sitter/tree-sitter-ocaml" "master" "ocaml/src") ; There is no ocaml-ts-mode
+ (c "https://github.com/tree-sitter/tree-sitter-c")
+ (cpp "https://github.com/tree-sitter/tree-sitter-cpp")))
+
+ (require 'cl-lib)
+ (when (treesit-available-p)
+ (elpaca nil (mapc #'treesit-install-language-grammar (cl-remove-if #'treesit-language-available-p (mapcar #'car treesit-language-source-alist)))))
+#+end_src
+** Eldoc Setup
+I like to have eldoc appear as a box below where I'm typing, rather than having it appear in the minibuffer. This is done with =eldoc-box=:
+#+begin_src emacs-lisp
+ (use-package eldoc-box
+ :hook (eldoc-managed-mode . eldoc-box-hover-at-point-mode)
+ :hook (lsp-after-open . eldoc-box-hover-at-point-mode))
#+end_src
** C
-There is nothing to report here, yet...
+We want to use tree sitter to generate syntax highlighting, so we should change the default major mode to be the tree-sitter mode.
#+begin_src emacs-lisp
+ (push '(c-mode . c-ts-mode) major-mode-remap-alist)
#+end_src
** Haskell
This setup is just a combination of =haskell-mode= and the Haskell Language Server.
Haskell mode is really good for the indenting and overall behaviour of the editor, and the Haskell language server is definitely there... (It can be slow, so can be turned off on larger projects)
#+begin_src emacs-lisp
;; Haskell setup
+ ;; Dumb hack for emacs 30 (see https://github.com/haskell/haskell-mode/issues/1825):
+ ;;(setq flymake-allowed-file-name-masks nil)
(use-package haskell-mode)
(use-package lsp-haskell
:config
(add-hook 'haskell-mode-hook #'lsp)
(add-hook 'haskell-literate-mode-hook #'lsp))
#+end_src
+NOTE: This is not using tree sitter, as there is no haskell-ts-mode yet or probably for a while into the future.
** Rust
Rust mode alongside LSP again. The rust LSP is very good as far as LSPs go, very helpful. Though sometimes it's better to compile and see the rustc errors as they tend to be more verbose.
+/Chad =rust-ts-mode= configuration/:
#+begin_src emacs-lisp
+ (push '("\\.rs\\'" . rust-ts-mode) auto-mode-alist)
+ (add-hook 'rust-ts-mode-hook #'lsp)
+#+end_src
+
+/Legacy =rust-mode= configuration/:
+#+begin_src emacs-lisp :tangle no
;; Rust setup
(use-package rust-mode
:config
@@ -394,17 +428,31 @@ Nothing to see here, yet...
A.K.A. OO hell.
=lsp-java= is actually pretty okay, and uses the Eclipse Language Server. So basically emacs becomes eclipse but better (not hard). In general IntelliJ is probably still your best bet when it comes to Java development.
#+begin_src emacs-lisp
-;; Java setup
-(use-package lsp-java
- :config
- (add-hook 'java-mode-hook #'lsp))
+ ;; Java setup
+ (use-package lsp-java
+ :config
+ (add-hook 'java-mode-hook #'lsp))
+#+end_src
+We want to use tree sitter in our major mode:
+#+begin_src emacs-lisp
+ (push '(java-mode . java-ts-mode) major-mode-remap-alist)
+ (add-hook 'java-ts-mode #'lsp)
+#+end_src
+** JavaScript/TypeScript
+JavaScript and TypeScript are easy thanks to tree sitter!
+#+begin_src emacs-lisp
+ (push '(js-mode . js-ts-mode) major-mode-remap-alist)
+ (add-hook 'js-ts-mode-hook #'lsp)
+ (add-hook 'typescript-ts-mode #'lsp)
+ (add-hook 'tsx-ts-mode #'lsp)
#+end_src
** Python
A.K.A. the most overused and overhyped language. This language is incredibly slow, which is why its language server is not written in Python LMAO. Anywho the =pyright= LSP is made by Microshit so maybe this is proprietary software or telemetry, idk.
#+begin_src emacs-lisp
+ (push '(python-mode . python-ts-mode) major-mode-remap-alist)
;; Python setup
(use-package lsp-pyright
- :hook (python-mode . (lambda ()
+ :hook (python-ts-mode . (lambda ()
(require 'lsp-pyright)
(lsp))))
#+end_src
@@ -433,7 +481,6 @@ This is the basic OCaml config provided by opam on installation. It may be actua
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line
(require 'opam-user-setup (expand-file-name "opam-user-setup.el" user-emacs-directory))
#+end_src
-
** LaTeX
LaTeX isn't really a language, but we should set up stuff for it.
Firstly, we should get CDLaTeX:
@@ -441,7 +488,6 @@ Firstly, we should get CDLaTeX:
(use-package cdlatex
:hook ((latex-mode LaTeX-mode) . turn-on-cdlatex))
#+end_src
-
** Clojure
Firstly, we want to use clojure-mode:
#+begin_src emacs-lisp
diff --git a/early-init.el b/early-init.el
@@ -8,4 +8,4 @@
"/opt/homebrew/opt/gcc/lib/gcc/13/gcc/aarch64-apple-darwin22/13")
":"))
(setq package-enable-at-startup nil)
-(add-to-list 'default-frame-alist '(undecorated-round . t))
+;;(add-to-list 'default-frame-alist '(undecorated-round . t))