commit 096973bc12a3943b6372381252252645d79f8339
parent dd1d5f6133585cea4dcac26b044da92029c24f2d
Author: Ethan Long <ethandavidlong@gmail.com>
Date: Wed, 27 Mar 2024 16:23:35 +1100
I've forgotten what I changed lol
Diffstat:
| M | config.org | | | 61 | ++++++++++++++++++++++++++++++++++++++++++++++++++----------- |
| M | init.el | | | 2 | +- |
2 files changed, 51 insertions(+), 12 deletions(-)
diff --git a/config.org b/config.org
@@ -182,7 +182,7 @@ We can use ~use-package~ to configure emacs at startup. On MacOS we leave things
#+begin_src emacs-lisp
;; Emacs init config
(use-package emacs
- :elpaca nil
+ :ensure nil
:hook
(prog-mode . display-line-numbers-mode)
(display-line-numbers-mode . ethandl/line-nums-cfg)
@@ -202,6 +202,7 @@ We can use ~use-package~ to configure emacs at startup. On MacOS we leave things
(column-number-mode 1) ;; Col. no.
;; Indentation
(setq-default indent-tabs-mode nil)
+ (setq-default tab-width 4)
(setq ring-bell-function 'ignore) ;; Get rid of the bell
;; Fuck Control+Scroll to zoom, that's terrible and seems to be bound by something in emacs-plus?
(global-unset-key (kbd "<C-wheel-up>"))
@@ -276,6 +277,7 @@ Fix my ineptitude in this chord hell that is emacs. I mean seriously, chords jus
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
(setq evil-undo-system 'undo-redo)
+ (setq evil-ex-search-case 'sensitive)
:config
(evil-mode t)
;; Enabling C-g to exit from normal mode, and C-h to do what it normally does in emacs
@@ -358,7 +360,7 @@ HACK fix for the catppuccin theme: (https://github.com/catppuccin/emacs/issues/6
The org configuration uses a lot of custom functions, see the
#+begin_src emacs-lisp
(use-package org
- :elpaca nil ;; Can be removed after 9.7 is released
+ :ensure nil ;; Can be removed after 9.7 is released
:hook
(org-mode . ethandl/org-base)
(org-mode . ethandl/org-font)
@@ -396,7 +398,7 @@ We use the built-in package eglot (requires emacs 29) if possible as there seems
#+begin_src emacs-lisp
(if (>= emacs-major-version 29)
(use-package eglot
- :elpaca nil)
+ :ensure nil)
(use-package eglot))
(use-package markdown-mode) ; needed for formatting the stuff in the eldoc buffers
#+end_src
@@ -411,6 +413,7 @@ Since Emacs 29, we don't need to install tree sitter separately anymore, it come
(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")
+ (yaml "https://github.com/ikatyang/tree-sitter-yaml")
(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")
@@ -424,7 +427,7 @@ Since Emacs 29, we don't need to install tree sitter separately anymore, it come
;; Fuck windows, compiling C on Windows is a joke.
(setq treesit-enabled (not (eq system-type 'windows-nt)))
-
+
(when treesit-enabled
(elpaca nil (ethandl/install-treesit-grammars treesit-language-source-alist)))
#+end_src
@@ -448,7 +451,7 @@ Haskell mode is really good for the indenting and overall behaviour of the edito
;; Haskell setup
(use-package haskell-mode)
(use-package eglot
- :elpaca nil
+ :ensure nil
:after eglot
:hook (haskell-mode . eglot-ensure)
:config
@@ -470,7 +473,7 @@ Rust mode alongside LSP again. The rust LSP is very good as far as LSPs go, very
(print "Cannot use rust without tree-sitter!"))
(use-package eglot
- :elpaca nil
+ :ensure nil
:after eglot
:hook (rust-ts-mode . eglot-ensure)
:config
@@ -496,12 +499,12 @@ This basic LSP setup is based on the golang guide: https://cs.opensource.google/
(cdr project))
(use-package project
- :elpaca nil
+ :ensure nil
:config
(add-hook 'project-find-functions #'golang/project-find-go-module))
(use-package eglot
- :elpaca nil
+ :ensure nil
:after eglot
:hook (go-ts-mode . eglot-ensure)
:config
@@ -518,7 +521,7 @@ If you want a language server, maybe just use IntelliJ? I don't use Java and the
#+begin_src emacs-lisp
;; Java setup
(use-package emacs
- :elpaca nil
+ :ensure nil
:config
(when treesit-enabled
(push '(java-mode . java-ts-mode) major-mode-remap-alist)))
@@ -530,13 +533,14 @@ JavaScript and TypeScript are easy thanks to tree sitter!
(print "Cannot use JS/TS without tree-sitter!"))
(use-package eglot
- :elpaca nil
+ :ensure nil
:after eglot
:hook
(js-ts-mode . eglot-ensure)
(typescript-ts-mode . eglot-ensure)
(tsx-ts-mode . eglot-ensure)
:config
+ (setq typescript-ts-mode-indent-offset tab-width)
(push '(js-mode . js-ts-mode) major-mode-remap-alist)
(push '(javascript-mode . js-ts-mode) major-mode-remap-alist)
(push '("\\.ts\\'" . typescript-ts-mode) auto-mode-alist)
@@ -546,7 +550,7 @@ JavaScript and TypeScript are easy thanks to tree sitter!
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
(use-package eglot
- :elpaca nil
+ :ensure nil
:after eglot
:hook ((python-mode python-ts-mode) . eglot-ensure)
:config
@@ -554,9 +558,44 @@ A.K.A. the most overused and overhyped language. This language is incredibly slo
`(python-mode . ("pyright-langserver" "--stdio")))
(add-to-list 'eglot-server-programs
`(python-ts-mode . ("pyright-langserver" "--stdio")))
+ (push ".dir-locals.el" project-vc-extra-root-markers)
(when treesit-enabled
(push '(python-mode . python-ts-mode) major-mode-remap-alist)))
#+end_src
+The following lets me set up a venv for use with pyright (https://robbmann.io/posts/emacs-eglot-pyrightconfig/):
+#+begin_src emacs-lisp
+ (defun pyrightconfig-write (virtualenv)
+ (interactive "DEnv: ")
+
+ (let* (;; file-truename and tramp-file-local-name ensure that neither `~' nor
+ ;; the Tramp prefix (e.g. "/ssh:my-host:") wind up in the final
+ ;; absolute directory path.
+ (venv-dir (tramp-file-local-name (file-truename virtualenv)))
+
+ ;; Given something like /path/to/.venv/, this strips off the trailing `/'.
+ (venv-file-name (directory-file-name venv-dir))
+
+ ;; Naming convention for venvPath matches the field for
+ ;; pyrightconfig.json. `file-name-directory' gets us the parent path
+ ;; (one above .venv).
+ (venvPath (file-name-directory venv-file-name))
+
+ ;; Grabs just the `.venv' off the end of the venv-file-name.
+ (venv (file-name-base venv-file-name))
+
+ ;; Eglot demands that `pyrightconfig.json' is in the project root
+ ;; folder.
+ (base-dir (vc-git-root default-directory))
+ (out-file (expand-file-name "pyrightconfig.json" base-dir))
+
+ ;; Finally, get a string with the JSON payload.
+ (out-contents (json-encode (list :venvPath venvPath :venv venv))))
+
+ ;; Emacs uses buffers for everything. This creates a temp buffer, inserts
+ ;; the JSON payload, then flushes that content to final `pyrightconfig.json'
+ ;; location
+ (with-temp-file out-file (insert out-contents))))
+#+end_src
** LaTeX
LaTeX isn't really a language, but we should set up stuff for it.
Firstly, we should get CDLaTeX:
diff --git a/init.el b/init.el
@@ -48,7 +48,7 @@
;; There are many reasons you might want to do this, but the git version is quite unstable as well
;;(elpaca (org :host "git.tecosaur.net" :repo "tec/org-mode"))
(use-package org
- :elpaca (:host "git.tecosaur.net" :repo "tec/org-mode"))
+ :ensure (:host "git.tecosaur.net" :repo "tec/org-mode"))
;; We then need to wait for the download of org to complete before we can use org.
(elpaca-wait)
(setq ethandl/config-fname (expand-file-name "config.org" user-emacs-directory))