Compare commits

...

8 Commits

3 changed files with 86 additions and 63 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "chatgpt-shell"]
path = chatgpt-shell
url = https://github.com/xenodium/chatgpt-shell

@ -1 +0,0 @@
Subproject commit f7a53903ebedb1bd67dc9dea6ae9893fb70d4d49

View File

@ -119,7 +119,7 @@
#+begin_src emacs-lisp #+begin_src emacs-lisp
(let ((font-height (let ((font-height
(pcase hostname (pcase hostname
("eagle" 100) ("zora" 100)
("eddie" 100) ("eddie" 100)
("mandarax" 115) ("mandarax" 115)
("valis" 80) ("valis" 80)
@ -609,11 +609,10 @@
(setq-default basic-offset 4) (setq-default basic-offset 4)
#+end_src #+end_src
And generally indenting with spaces is more common, so make that Use tabs as god intended:
the default:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq-default indent-tabs-mode nil) (setq-default indent-tabs-mode t)
#+end_src #+end_src
*** Language Server Protocol *** Language Server Protocol
@ -674,15 +673,7 @@
#+end_src #+end_src
** C ** C
For C there is =clangd= implementing LSP. Assuming that's For indenting style, I like BSD-style but with 4-char-wide indents
installed and on the =PATH=, we can just hook =lsp-mode= into the
default mode and there will be much rejoicing.
#+begin_src emacs-lisp
(add-hook 'c-mode-hook #'lsp-deferred)
#+end_src
As for indenting style, I like BSD-style but with 4-char-wide indents
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-hook 'c-mode-hook (lambda () (add-hook 'c-mode-hook (lambda ()
@ -699,8 +690,7 @@
There's a lot of boilerplate in C, so I want YASnippet enabled. There's a lot of boilerplate in C, so I want YASnippet enabled.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(add-hook 'c-mode-hook (lambda () (add-hook 'c-mode-hook (lambda () (yas-minor-mode)))
(yas-minor-mode)))
#+end_src #+end_src
** C++ ** C++
@ -929,26 +919,6 @@
(add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode)) (add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))
#+end_src #+end_src
** Java
[[https://github.com/jdee-emacs/jdee][JDEE]] provides a whole bunch of tooling for Java. It requires the
[[https://github.com/jdee-emacs/jdee-server][JDEE server]] to work properly, which has to be built seperately
(this requires JDK and Maven):
#+begin_src shell :tangle no
cd ~/src
git clone https://github.com/jdee-emacs/jdee-server.git
cd jdee-server
mvn -Dmaven.test.skip=true package
#+end_src
With that built, we can install JDEE, pointing at the built server:
#+begin_src emacs-lisp
(use-package jdee
:config
(setq jdee-server-dir "~/src/jdee-server/target"))
#+end_src
** Dockerfiles ** Dockerfiles
Grab =dockerfile-mode= for syntax highlighting etc in Dockerfiles: Grab =dockerfile-mode= for syntax highlighting etc in Dockerfiles:
@ -1048,22 +1018,6 @@
(add-hook 'python-mode-hook #'lsp-deferred) (add-hook 'python-mode-hook #'lsp-deferred)
#+end_src #+end_src
** C#
I hate the .NET ecosystem quite a lot, but alas: sometimes I have
to use it at work.
Using =csharp-mode= for basic support:
#+begin_src emacs-lisp
(use-package csharp-mode)
#+end_src
And =lsp-mode= for the rest (using the omnisharp server):
#+begin_src emacs-lisp
(add-hook 'csharp-mode-hook #'lsp-deferred)
#+end_src
** Ada ** Ada
*** Old ada-mode *** Old ada-mode
Unfortunately, the =ada-mode= on ELPA is hot garbage. It requires Unfortunately, the =ada-mode= on ELPA is hot garbage. It requires
@ -1224,11 +1178,69 @@
#+end_src #+end_src
** Lua ** Lua
Using a pretty standard LSP setup for Lua: Just using basic =lua-mode= package:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lua-mode) (use-package lua-mode)
(add-hook 'lua-mode-hook #'lsp-deferred) #+end_src
I want to indent with tabs (set to 4 characters wide):
#+begin_src emacs-lisp
(setq lua-indent-level 4)
#+end_src
I also want to be able to run =lua-format= on files with =C-c f=
like I have with =clang-format=. The first step for this is to make
an interactive function to run the formatter; this can be done with
[[help:call-process-region][call-process-region]].
#+begin_src emacs-lisp
(defvar lua-format-binary "lua-format")
(defun lua-format ()
(interactive)
(if (executable-find lua-format-binary)
(let ((start (if (region-active-p) (region-beginning) (point-min)))
(end (if (region-active-p) (region-end) (point-max))))
(call-process-region start end lua-format-binary t '(t nil)))
(error "%s" (concat lua-format-binary " not found."))))
#+end_src
This then needs to be assigned to the keybinding:
#+begin_src emacs-lisp
(add-hook
'lua-mode-hook
(lambda () (define-key lua-mode-map (kbd "C-c f") 'lua-format)))
#+end_src
** BASIC
=basic-mode= provides syntax highlighting and a few nice features:
#+begin_src emacs-lisp
(use-package basic-mode)
#+end_src
As well as =.bas= files, I want to open all =.bbc= files in
=basic-mode=:
#+begin_src emacs-lisp
(add-to-list 'auto-mode-alist '("\\.bbc\\'" . basic-mode))
#+end_src
** Nix
Basic editing support comes from =nix-mode=:
#+begin_src emacs-lisp
(use-package nix-mode)
#+end_src
And =nix-update= provides a convenient way to update ~fetch~
blocks:
#+begin_src emacs-lisp
(use-package nix-update)
#+end_src #+end_src
* Tool Integrations * Tool Integrations
@ -1341,14 +1353,11 @@
#+end_src #+end_src
** ChatGPT ** ChatGPT
The =chatpt-shell= package is in a git submodule, so this has to be The =chatpt-shell= package provides a shell-like interface for
added to the [[help:load-path][load-path]] and ~require~'d: ChatGPT.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(let ((path (concat (getenv "HOME") (use-package chatgpt-shell)
"/.emacs.d/chatgpt-shell")))
(add-to-list 'load-path path))
(require 'chatgpt-shell)
#+end_src #+end_src
[[help:chatgpt-shell-openai-key][chatgpt-shell-openai-key]] must also be set to a function that [[help:chatgpt-shell-openai-key][chatgpt-shell-openai-key]] must also be set to a function that
@ -1530,6 +1539,14 @@
(global-set-key (kbd "C-.") #'god-mode-all) (global-set-key (kbd "C-.") #'god-mode-all)
#+end_src #+end_src
I find it jarring and confusing to have it on and off in different
types of buffers, so will just disable the exemptions:
#+begin_src emacs-lisp
(setq god-exempt-major-modes nil)
(setq god-exempt-predicates nil)
#+end_src
** Case-flipping ** Case-flipping
Want to be able to toggle the 'shiftedness' of a selected region, Want to be able to toggle the 'shiftedness' of a selected region,
that is, map uppercase to lowercase and vice versa, but also map that is, map uppercase to lowercase and vice versa, but also map
@ -1621,3 +1638,13 @@
#+begin_src emacs-lisp #+begin_src emacs-lisp
(global-set-key (kbd "C-~") 'flip-region-case) (global-set-key (kbd "C-~") 'flip-region-case)
#+end_src #+end_src
* Fin
Now that start-up is finished, [[help:gc-cons-threshold][gc-cons-threshold]] and
[[help:gc-cons-percentage][gc-cons-percentage]] need to be set back to reasonable values to avoid
memory usage getting too high.
#+begin_src emacs-lisp
(setq gc-cons-threshold 1000000)
(setq gc-cons-percentage 0.2)
#+end_src