343 lines
13 KiB
EmacsLisp
343 lines
13 KiB
EmacsLisp
;;; init.el --- config file for emacs
|
|
|
|
;;; Commentary:
|
|
|
|
;; -*- lexical-binding: t -*-
|
|
|
|
;;; Code:
|
|
|
|
(require 'package)
|
|
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
|
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
|
|
;; and `package-pinned-packages`. Most users will not need or want to do this.
|
|
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
|
(package-initialize)
|
|
|
|
;; Ensure package-list has been fetched
|
|
(when (not package-archive-contents)
|
|
(package-refresh-contents))
|
|
|
|
;; We want to use use-package, not the default emacs behavior
|
|
(setq package-enable-at-startup nil)
|
|
|
|
;; Install use-package if it hasn't been installed
|
|
(when (not (package-installed-p 'use-package)) (package-install 'use-package))
|
|
(require 'use-package)
|
|
|
|
;; ido-mode provides a better file/buffer-selection interface
|
|
;; But fido vertical mode is better
|
|
(use-package ido
|
|
:ensure t
|
|
:config (fido-vertical-mode t))
|
|
|
|
;; ido for M-x
|
|
(use-package smex
|
|
:ensure t
|
|
:config
|
|
(progn
|
|
(smex-initialize)
|
|
(global-set-key (kbd "M-x") 'smex)
|
|
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
|
|
;; This is your old M-x.
|
|
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)))
|
|
|
|
;; Directional windown selection
|
|
;; Shift + Arrows to point to the next window
|
|
(windmove-default-keybindings)
|
|
|
|
;; Provides all the racket support
|
|
(use-package racket-mode
|
|
:ensure t)
|
|
|
|
;; Syntax checking
|
|
(use-package flycheck
|
|
:ensure t
|
|
:config
|
|
(global-flycheck-mode))
|
|
|
|
;; Autocomplete popups
|
|
(use-package company
|
|
:ensure t
|
|
:config
|
|
(progn
|
|
(setq company-idle-delay 0.2
|
|
;; min prefix of 2 chars
|
|
company-minimum-prefix-length 2
|
|
company-selection-wrap-around t
|
|
company-echo-delay 0
|
|
company-tooltip-limit 20
|
|
company-transformers '(company-sort-by-occurrence)
|
|
company-begin-commands '(self-insert-command)
|
|
)
|
|
(global-company-mode))
|
|
)
|
|
|
|
;; Lots of parenthesis and other delimiter niceties
|
|
(use-package paredit
|
|
:ensure t
|
|
:config
|
|
(add-hook 'racket-mode-hook #'enable-paredit-mode))
|
|
|
|
;; Colorizes delimiters so they can be told apart
|
|
(use-package rainbow-delimiters
|
|
:ensure t
|
|
:config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
|
|
;; Make buffer names unique
|
|
;; buffernames that are foo<1>, foo<2> are hard to read. This makes them foo|dir foo|otherdir
|
|
(use-package uniquify
|
|
:config (setq uniquify-buffer-name-style 'post-forward))
|
|
|
|
;; ligature fonts
|
|
;; https://github.com/mickeynp/ligature.el
|
|
(use-package ligature
|
|
:config
|
|
;; Enable all Iosevka ligatures in programming modes
|
|
(ligature-set-ligatures 'prog-mode '("<---" "<--" "<<-" "<-" "->" "-->" "--->" "<->" "<-->" "<--->" "<---->" "<!--"
|
|
"<==" "<===" "<=" "=>" "=>>" "==>" "===>" ">=" "<=>" "<==>" "<===>" "<====>" "<!---"
|
|
"<~~" "<~" "~>" "~~>" "::" ":::" "==" "!=" "===" "!=="
|
|
":=" ":-" ":+" "<*" "<*>" "*>" "<|" "<|>" "|>" "+:" "-:" "=:" "<******>" "++" "+++"))
|
|
;; Enables ligature checks globally in all buffers. You can also do it
|
|
;; per mode with `ligature-mode'.
|
|
(global-ligature-mode t))
|
|
|
|
;; Highlight matching parenthesis
|
|
(show-paren-mode 1)
|
|
(setq show-paren-delay 0)
|
|
|
|
;; Allows moving through wrapped lines as they appear
|
|
(setq line-move-visual t)
|
|
|
|
(custom-set-variables
|
|
;; custom-set-variables was added by Custom.
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
;; Your init file should contain only one such instance.
|
|
;; If there is more than one, they won't work right.
|
|
'(ac-use-fuzzy nil)
|
|
'(backup-directory-alist '(("." . "~/.local/share/emacs/backups")))
|
|
'(column-number-mode t)
|
|
'(compilation-context-lines 2)
|
|
'(compilation-error-screen-columns nil)
|
|
'(compilation-scroll-output t)
|
|
'(compilation-search-path '(nil "src"))
|
|
'(custom-enabled-themes '(misterioso))
|
|
'(electric-indent-mode nil)
|
|
'(indent-tabs-mode nil)
|
|
'(ledger-default-date-format "%Y/%m/%d")
|
|
'(ledger-reports
|
|
'(("reg" "ledger [[ledger-mode-flags]] -f /home/haqadosch/Documents/Accounting/ledger.dat reg")
|
|
("bal" "ledger [[ledger-mode-flags]] -f /home/haqadosch/Documents/Accounting/ledger.dat bal")
|
|
("payee" "%(binary) -f %(ledger-file) reg @%(payee)")
|
|
("account" "%(binary) -f %(ledger-file) reg %(account)")))
|
|
'(line-move-visual t)
|
|
'(next-error-highlight t)
|
|
'(next-error-highlight-no-select t)
|
|
'(next-line-add-newlines nil)
|
|
'(org-agenda-files '("~/Documents/agenda.org"))
|
|
'(package-selected-packages
|
|
'(ligature yaml-mode flycheck-ocaml ocamlformat tuareg utop eglot dune dune-format merlin merlin-ac merlin-company merlin-eldoc merlin-iedit gptel company-ledger flycheck-ledger ledger-mode ellama 0blayout magit magit-annex magit-commit-mark magit-delta magit-diff-flycheck magit-filenotify magit-find-file magit-gerrit magit-gh-pulls magit-gitflow magit-imerge magit-lfs magit-org-todos magit-p4 magit-patch-changelog magit-popup magit-rbr magit-reviewboard magit-stats magit-stgit magit-svn magit-tbdiff magit-todos magit-topgit magit-vcsh magithub mermaid-mode mermaid-ts-mode ob-mermaid rust-mode company-web company elfeed-autotag elfeed-curate elfeed-dashboard elfeed-goodies elfeed-org elfeed-protocol elfeed-score elfeed-summary elfeed-tube-mpv elfeed-web elfeed-webkit smex typescript-mode deno-fmt flycheck-deno ob-deno flycheck emms racket-mode pdf-tools))
|
|
'(require-final-newline t)
|
|
'(safe-local-variable-values '((my-variables . value)))
|
|
'(sentence-end-double-space nil)
|
|
'(show-trailing-whitespace t)
|
|
'(tab-bar-mode t)
|
|
'(visible-bell t)
|
|
'(warning-suppress-log-types '((comp))))
|
|
'(warning-suppress-types '((comp) (comp) (comp)))
|
|
(custom-set-faces
|
|
;; custom-set-faces was added by Custom.
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
;; Your init file should contain only one such instance.
|
|
;; If there is more than one, they won't work right.
|
|
'(default ((t (:family "Fira Code" :foundry "CTDB" :slant normal :weight light :height 128 :width normal)))))
|
|
|
|
;; Specify mmdc path for org-babel with mermaid
|
|
(setq ob-mermaid-cli-path "/home/haqadosch/.nvm/versions/node/v20.10.0/bin/mmdc")
|
|
|
|
;; active Babel languages
|
|
(org-babel-do-load-languages
|
|
'org-babel-load-languages
|
|
'((js . t)
|
|
(shell . t)))
|
|
|
|
;; Based on the doc https://www.gnu.org/software/emacs/manual/html_mono/eglot.html
|
|
;; (with-eval-after-load 'eglot
|
|
;; (add-to-list 'eglot-server-programs
|
|
;; '((js-mode typescript-mode) . (eglot-deno "deno" "lsp"))))
|
|
|
|
;; Deno config with eglot
|
|
;; (add-to-list 'eglot-server-programs '((js-mode typescript-mode) . (eglot-deno "deno" "lsp")))
|
|
|
|
;; (defclass eglot-deno (eglot-lsp-server) ()
|
|
;; :documentation "A custom class for deno lsp.")
|
|
|
|
;; (cl-defmethod eglot-initialization-options ((server eglot-deno))
|
|
;; "Passes through required deno initialization options to the SERVER."
|
|
;; (list :enable t
|
|
;; :lint t))
|
|
|
|
;; Based on the bash-language-server doc for eglot
|
|
;; https://github.com/bash-lsp/bash-language-server?tab=readme-ov-file#emacs
|
|
(use-package eglot
|
|
:config
|
|
(add-to-list 'eglot-server-programs
|
|
'((sh-mode bash-ts-mode) . ("bash-language-server" "start"))
|
|
;; '((typescript-mode javascript-mode) . ("typescript-language-server" "--stdio"))
|
|
)
|
|
|
|
:hook
|
|
(sh-mode . eglot-ensure)
|
|
(bash-ts-mode . eglot-ensure)
|
|
;; (typescript-mode . eglot-ensure)
|
|
;; (javascript-mode . eglot-ensure)
|
|
)
|
|
|
|
|
|
;; Tree sitter config for TSX JSX mode
|
|
(use-package jtsx
|
|
:ensure t
|
|
:mode (("\\.jsx?\\'" . jtsx-jsx-mode)
|
|
("\\.tsx?\\'" . jtsx-tsx-mode))
|
|
:commands jtsx-install-treesit-language
|
|
:hook ((jtsx-jsx-mode . hs-minor-mode)
|
|
(jtsx-tsx-mode . hs-minor-mode))
|
|
:custom
|
|
;; Optional customizations
|
|
;; (js-indent-level 2)
|
|
;; (typescript-ts-mode-indent-offset 2)
|
|
;; (jtsx-switch-indent-offset 0)
|
|
;; (jtsx-indent-statement-block-regarding-standalone-parent nil)
|
|
;; (jtsx-jsx-element-move-allow-step-out t)
|
|
;; (jtsx-enable-jsx-electric-closing-element t)
|
|
;; (jtsx-enable-electric-open-newline-between-jsx-element-tags t)
|
|
;; (jtsx-enable-jsx-element-tags-auto-sync nil)
|
|
(jtsx-enable-all-syntax-highlighting-features t)
|
|
:config
|
|
(defun jtsx-bind-keys-to-mode-map (mode-map)
|
|
"Bind keys to MODE-MAP."
|
|
(define-key mode-map (kbd "C-c C-j") 'jtsx-jump-jsx-element-tag-dwim)
|
|
(define-key mode-map (kbd "C-c j o") 'jtsx-jump-jsx-opening-tag)
|
|
(define-key mode-map (kbd "C-c j c") 'jtsx-jump-jsx-closing-tag)
|
|
(define-key mode-map (kbd "C-c j r") 'jtsx-rename-jsx-element)
|
|
(define-key mode-map (kbd "C-c <down>") 'jtsx-move-jsx-element-tag-forward)
|
|
(define-key mode-map (kbd "C-c <up>") 'jtsx-move-jsx-element-tag-backward)
|
|
(define-key mode-map (kbd "C-c C-<down>") 'jtsx-move-jsx-element-forward)
|
|
(define-key mode-map (kbd "C-c C-<up>") 'jtsx-move-jsx-element-backward)
|
|
(define-key mode-map (kbd "C-c C-S-<down>") 'jtsx-move-jsx-element-step-in-forward)
|
|
(define-key mode-map (kbd "C-c C-S-<up>") 'jtsx-move-jsx-element-step-in-backward)
|
|
(define-key mode-map (kbd "C-c j w") 'jtsx-wrap-in-jsx-element)
|
|
(define-key mode-map (kbd "C-c j u") 'jtsx-unwrap-jsx)
|
|
(define-key mode-map (kbd "C-c j d") 'jtsx-delete-jsx-node))
|
|
|
|
(defun jtsx-bind-keys-to-jtsx-jsx-mode-map ()
|
|
(jtsx-bind-keys-to-mode-map jtsx-jsx-mode-map))
|
|
|
|
(defun jtsx-bind-keys-to-jtsx-tsx-mode-map ()
|
|
(jtsx-bind-keys-to-mode-map jtsx-tsx-mode-map))
|
|
|
|
(add-hook 'jtsx-jsx-mode-hook 'jtsx-bind-keys-to-jtsx-jsx-mode-map)
|
|
(add-hook 'jtsx-tsx-mode-hook 'jtsx-bind-keys-to-jtsx-tsx-mode-map))
|
|
|
|
;; Remap list buffers =C-x C-b= with the ibuffer command
|
|
(global-set-key [remap list-buffers] 'ibuffer)
|
|
|
|
;; Highlight lines that go beyond the 80 char limit
|
|
(require 'whitespace)
|
|
(setq whitespace-style '(face empty tabs lines-tail trailing))
|
|
(global-whitespace-mode t)
|
|
|
|
;; Shows the column number in the modline
|
|
(setq column-number-mode t)
|
|
|
|
;; OPAM set up for ocp-ident
|
|
(add-to-list 'load-path "/home/haqadosch/.opam/ocaml-book/share/emacs/site-lisp")
|
|
(require 'ocp-indent)
|
|
|
|
(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)
|
|
;; To easily change opam switches within a given Emacs session, you can
|
|
;; install the minor mode https://github.com/ProofGeneral/opam-switch-mode
|
|
;; and use one of its "OPSW" menus.
|
|
))
|
|
|
|
; Make company aware of merlin
|
|
(with-eval-after-load 'company
|
|
(add-to-list 'company-backends 'merlin-company-backend))
|
|
; Enable company on merlin managed buffers
|
|
(add-hook 'merlin-mode-hook 'company-mode)
|
|
|
|
;; Ocaml formatting using ocamlformat
|
|
(use-package ocamlformat
|
|
:custom (ocamlformat-enable 'enable-outside-detected-project)
|
|
:hook (before-save . ocamlformat-before-save)
|
|
)
|
|
|
|
;; GPTel with Llamafile config
|
|
;; Llama.cpp offers an OpenAI compatible API
|
|
;; See https://github.com/karthink/gptel?tab=readme-ov-file#llamacpp-or-llamafile
|
|
;; (gptel-make-openai "Llamafile"
|
|
;; :stream t
|
|
;; :host "127.0.0.1:8080"
|
|
;; :protocol "http"
|
|
;; :key "no-key"
|
|
;; :models '("local"))
|
|
|
|
;; (setq gptel-default-mode 'org-mode)
|
|
;; (setq-default gptel-backend (gptel-make-openai "Llamafile"
|
|
;; :stream t
|
|
;; :host "127.0.0.1:8080"
|
|
;; :protocol "http"
|
|
;; :key "no-key"
|
|
;; :models '("local"))
|
|
;; gptel-model "local")
|
|
|
|
;; Basic .emacs with a good set of defaults, to be used as template for usage
|
|
;; with OCaml and OPAM
|
|
;;
|
|
;; Author: Louis Gesbert <louis.gesbert@ocamlpro.com>
|
|
;; Released under CC0
|
|
|
|
;; Generic, recommended configuration options
|
|
|
|
|
|
|
|
;; ANSI color in compilation buffer
|
|
(require 'ansi-color)
|
|
(defun colorize-compilation-buffer ()
|
|
(toggle-read-only)
|
|
(ansi-color-apply-on-region (point-min) (point-max))
|
|
(toggle-read-only))
|
|
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
|
|
|
|
;; Some key bindings
|
|
|
|
(global-set-key [f3] 'next-match)
|
|
(defun prev-match () (interactive nil) (next-match -1))
|
|
(global-set-key [(shift f3)] 'prev-match)
|
|
(global-set-key [backtab] 'auto-complete)
|
|
;; OCaml configuration
|
|
;; - better error and backtrace matching
|
|
|
|
(defun set-ocaml-error-regexp ()
|
|
(set
|
|
'compilation-error-regexp-alist
|
|
(list '("[Ff]ile \\(\"\\(.*?\\)\", line \\(-?[0-9]+\\)\\(, characters \\(-?[0-9]+\\)-\\([0-9]+\\)\\)?\\)\\(:\n\\(\\(Warning .*?\\)\\|\\(Error\\)\\):\\)?"
|
|
2 3 (5 . 6) (9 . 11) 1 (8 compilation-message-face)))))
|
|
|
|
(add-hook 'tuareg-mode-hook 'set-ocaml-error-regexp)
|
|
(add-hook 'caml-mode-hook 'set-ocaml-error-regexp)
|
|
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line
|
|
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el")
|
|
;; ## end of OPAM user-setup addition for emacs / base ## keep this line
|
|
|
|
|
|
|
|
;;; init.el ends here
|