commit 90d2d5984c28b9954fbf3f00547dd97af83fb267
parent f133860f09ed2f0b84f467eab27b9bd98da77321
Author: Ethan Long <ethandavidlong@gmail.com>
Date: Fri, 22 Dec 2023 00:02:45 +1100
Added support for systems that suck
Windows can't use tree-sitter easily, as that would involve being able
to compile C... Imagine...
Anyway I've changed the config slightly to let emacs work without
tree-sitter whenever possible, though I refuse to add dependencies to
the config just to get some modes that aren't reliant on tree-sitter.
Perhaps there is a solution to this but it seems kinda bad.
Diffstat:
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/config.org b/config.org
@@ -418,7 +418,11 @@ Since Emacs 29, we don't need to install tree sitter separately anymore, it come
(c "https://github.com/tree-sitter/tree-sitter-c")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp")))
- (elpaca nil (ethandl/install-treesit-grammars treesit-language-source-alist))
+ ;; 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
** 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=:
@@ -430,7 +434,8 @@ I like to have eldoc appear as a box below where I'm typing, rather than having
** C
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)
+ (when treesit-enabled
+ (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.
@@ -456,6 +461,9 @@ NOTE: This is not using tree sitter, as there is no haskell-ts-mode yet or proba
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 with eglot:/
#+begin_src emacs-lisp
+ (unless treesit-enabled
+ (print "Cannot use rust without tree-sitter!"))
+
(use-package eglot
:elpaca nil
:hook (rust-ts-mode . eglot-ensure)
@@ -470,6 +478,9 @@ Rust mode alongside LSP again. The rust LSP is very good as far as LSPs go, very
** Go
This basic LSP setup is based on the golang guide: https://cs.opensource.google/go/x/tools/+/refs/tags/gopls/v0.14.2:gopls/doc/emacs.md
#+begin_src emacs-lisp
+ (unless treesit-enabled
+ (print "Cannot use go without tree-sitter!"))
+
(push '("\\.go\\'" . go-ts-mode) auto-mode-alist)
(push '("\\.mod\\'" . go-mod-ts-mode) auto-mode-alist)
(defun golang/project-find-go-module (dir)
@@ -500,12 +511,17 @@ Using the Eclipse JDT Language Server:
#+begin_src emacs-lisp
;; Java setup
(use-package eglot-java
- :hook (java-ts-mode . eglot-java-mode)
- :config (push '(java-mode . java-ts-mode) major-mode-remap-alist))
+ :hook ((java-mode java-ts-mode) . eglot-java-mode)
+ :config
+ (when treesit-enabled
+ (push '(java-mode . java-ts-mode) major-mode-remap-alist)))
#+end_src
** JavaScript/TypeScript
JavaScript and TypeScript are easy thanks to tree sitter!
#+begin_src emacs-lisp
+ (unless treesit-enabled
+ (print "Cannot use JS/TS without tree-sitter!"))
+
(use-package eglot
:elpaca nil
:hook
@@ -523,11 +539,14 @@ A.K.A. the most overused and overhyped language. This language is incredibly slo
#+begin_src emacs-lisp
(use-package eglot
:elpaca nil
- :hook (python-ts-mode . eglot-ensure)
+ :hook ((python-mode python-ts-mode) . eglot-ensure)
:config
(add-to-list 'eglot-server-programs
+ `(python-mode . ("pyright-langserver" "--stdio")))
+ (add-to-list 'eglot-server-programs
`(python-ts-mode . ("pyright-langserver" "--stdio")))
- (push '(python-mode . python-ts-mode) major-mode-remap-alist))
+ (when treesit-enabled
+ (push '(python-mode . python-ts-mode) major-mode-remap-alist)))
#+end_src
** OCaml
This is the basic OCaml config provided by opam on installation. It may be actually better to just use the language server that OCaml installed...