Emacs: Shuffle some sections around

This commit is contained in:
Joseph Ferano 2024-07-07 14:33:37 +07:00
parent c0217bf6ac
commit 7ec983116f

View File

@ -2381,6 +2381,23 @@ file."
#+end_src
** Programming Languages
*** C
Design some basic functions for compiling. There's also a hook to close the popper window if there
are no warnings or errors. It will check if we are still in the compilation buffer as well as
whether the point hasn't been moved. This way, if I switched to another popper buffer, like vterm,
it doesn't close it.
#+begin_src emacs-lisp
(require 'disaster)
(setq c-default-style "bsd")
(defun joe/c-mode-hook ()
(local-set-key (kbd "C-x c r") (defun joe/make-run () (interactive) (compile "make run")))
(local-set-key (kbd "C-x c c") (defun joe/make () (interactive) (compile "make")))
(electric-pair-local-mode t)
(c-toggle-comment-style -1))
(add-hook 'c-mode-hook #'joe/c-mode-hook)
#+end_src
*** Python
#+begin_src emacs-lisp
(require 'python)
@ -2424,6 +2441,51 @@ file."
;; (setq lsp-rust-analyzer-display-reborrow-hints t)
;; (setq lsp-rust-analyzer-cargo-watch-command "clippy"))
#+end_src
*** OCaml
#+begin_src emacs-lisp
(require 'tuareg)
(require 'dune)
(require 'utop)
(require 'merlin)
(require 'merlin-eldoc)
;; Might be worth checking out, depeding on whether we stick with flycheck or not
;; (elpaca 'flycheck-ocaml)
;; Also check this out, see if it adds anything
;; (require 'ocp-indent)
(defun opam-env ()
"Load the opam env to get the PATH variables so everything works"
(interactive nil)
(dolist (var
(car (read-from-string
(shell-command-to-string "opam config env --sexp"))))
(setenv (car var) (cadr var))))
(setq opam-share
(substring (shell-command-to-string
"opam config var share 2> /dev/null") 0 -1))
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
#+end_src
We won't use the LSP server but rather directly talk to Merlin, since I guess LSP just wraps Merlin
and there's no need for a middle-man when it's already been implemented.
#+begin_src emacs-lisp
;; (require 'utop)
;; Use the opam installed utop
(setq utop-command "opam exec -- utop -emacs")
(let ((opam-share (ignore-errors (car (process-lines "opam" "var" "share")))))
(when (and opam-share (file-directory-p opam-share))
;; Register Merlin
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
(autoload 'merlin-mode "merlin" nil t nil)
;; Automatically start it in OCaml buffers
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command 'opam)))
#+end_src
*** Elisp
#+begin_src emacs-lisp
(global-set-key (kbd "C-x C-r") 'eval-region)
@ -2503,24 +2565,7 @@ file."
(add-hook 'sql-login-hook 'joe/sql-login-hook)
#+end_src
*** C
Design some basic functions for compiling. There's also a hook to close the popper window if there
are no warnings or errors. It will check if we are still in the compilation buffer as well as
whether the point hasn't been moved. This way, if I switched to another popper buffer, like vterm,
it doesn't close it.
#+begin_src emacs-lisp
(require 'disaster)
(setq c-default-style "bsd")
(defun joe/c-mode-hook ()
(local-set-key (kbd "C-x c r") (defun joe/make-run () (interactive) (compile "make run")))
(local-set-key (kbd "C-x c c") (defun joe/make () (interactive) (compile "make")))
(electric-pair-local-mode t)
(c-toggle-comment-style -1))
(add-hook 'c-mode-hook #'joe/c-mode-hook)
#+end_src
*** Haskell
*** COMMENT Haskell
#+begin_src emacs-lisp
(require 'haskell-mode)
(setq haskell-interactive-popup-errors nil)
@ -2535,51 +2580,6 @@ it doesn't close it.
(require 'cider)
(setq cider-show-error-buffer 'only-in-repl)
#+end_src
*** COMMENT OCaml
#+begin_src emacs-lisp
(require 'tuareg)
(require 'dune)
(require 'utop)
(require 'merlin)
(require 'merlin-eldoc)
;; Might be worth checking out, depeding on whether we stick with flycheck or not
;; (elpaca 'flycheck-ocaml)
;; Also check this out, see if it adds anything
;; (require 'ocp-indent)
(defun opam-env ()
"Load the opam env to get the PATH variables so everything works"
(interactive nil)
(dolist (var
(car (read-from-string
(shell-command-to-string "opam config env --sexp"))))
(setenv (car var) (cadr var))))
(setq opam-share
(substring (shell-command-to-string
"opam config var share 2> /dev/null") 0 -1))
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
#+end_src
We won't use the LSP server but rather directly talk to Merlin, since I guess LSP just wraps Merlin
and there's no need for a middle-man when it's already been implemented.
#+begin_src emacs-lisp
;; (require 'utop)
;; Use the opam installed utop
(setq utop-command "opam exec -- utop -emacs")
(let ((opam-share (ignore-errors (car (process-lines "opam" "var" "share")))))
(when (and opam-share (file-directory-p opam-share))
;; Register Merlin
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
(autoload 'merlin-mode "merlin" nil t nil)
;; Automatically start it in OCaml buffers
(add-hook 'tuareg-mode-hook 'merlin-mode t)
(add-hook 'caml-mode-hook 'merlin-mode t)
;; Use opam switch to lookup ocamlmerlin binary
(setq merlin-command 'opam)))
#+end_src
*** COMMENT FSharp
#+begin_src emacs-lisp
(require 'fsharp-mode)