aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/emacs/config/development.el56
-rw-r--r--config/emacs/config/macos.el3
-rw-r--r--config/emacs/gtd.el62
-rw-r--r--config/emacs/init.el85
-rw-r--r--config/emacs/ligatures.el25
-rw-r--r--config/emacs/sanemacs.el14
-rw-r--r--config/emacs/tree-sitter.el44
7 files changed, 87 insertions, 202 deletions
diff --git a/config/emacs/config/development.el b/config/emacs/config/development.el
new file mode 100644
index 0000000..2ef26ee
--- /dev/null
+++ b/config/emacs/config/development.el
@@ -0,0 +1,56 @@
+;;; -*- lexical-binding: t -*-
+
+(use-package ligature
+ :hook
+ (prog-mode . ligature-mode)
+ :config
+ (ligature-set-ligatures
+ 'prog-mode
+ '(;; Group A
+ ".." ".=" "..." "..<" "::" ":::" ":=" "::=" ";;" ";;;" "??" "???" ".?" "?."
+ ":?" "?:" "?=" "**" "***" "/*" "*/" "/**"
+ ;; Group B
+ "<-" "->" "-<" ">-" "<--" "-->" "<<-" "->>" "-<<" ">>-" "<-<" ">->" "<-|"
+ "|->" "-|" "|-" "||-" "<!--" "<#--" "<=" "=>" ">=" "<==" "==>" "<<=" "=>>"
+ "=<<" ">>=" "<=<" ">=>" "<=|" "|=>" "<=>" "<==>" "||=" "|=" "//=" "/=" "/=="
+ ;; Group C
+ "<<" ">>" "<<<" ">>>" "<>" "<$" "$>" "<$>" "<+" "+>" "<+>" "<:" ":<" "<:<"
+ ">:" ":>" "<~" "~>" "<~>" "<<~" "<~~" "~~>" "~~" "<|" "|>" "<|>" "<||"
+ "||>" "<|||" "|||>" "</" "/>" "</>" "<*" "*>" "<*>" ":?>"
+ ;; Group D
+ "#(" "#{" "#[" "]#" "#!" "#?" "#=" "#_" "#_(" "##" "###" "####"
+ ;; Group E
+ "[|" "|]" "[<" ">]" "{!!" "!!}" "{|" "|}" "{{" "}}" "{{--" "--}}" "{!--"
+ "//" "///" "!!"
+ ;; Group F
+ "www" "@_" "&&" "&&&" "&=" "~@" "++" "+++" "/\\" "\\/" "_|_" "||"
+ ;; Group G
+ "=:" "=:=" "=!=" "==" "===" "=/=" "=~" "~-" "^=" "__" "!=" "!==" "-~" "--"
+ "---")))
+
+(use-package magit
+ :custom
+ (transient-levels-file "~/.cache/emacs/transient/levels.el")
+ (transient-values-file "~/.cache/emacs/transient/values.el")
+ (transient-history-file "~/.cache/emacs/transient/history.el"))
+
+(use-package projectile
+ :bind-keymap
+ ("C-c p" . projectile-command-map)
+ :custom
+ (projectile-known-projects-file "~/.cache/emacs/projectile-bookmarks.eld")
+ (projectile-project-search-path '(("~/Developer/" . 2)))
+ :config
+ (projectile-mode +1))
+
+;;;
+;;; Ocaml
+;;;
+
+(use-package tuareg)
+
+(use-package ocaml-eglot
+ :after (tuareg)
+ :hook
+ (tuareg-mode . ocaml-eglot)
+ (ocaml-eglot . eglot-ensure))
diff --git a/config/emacs/config/macos.el b/config/emacs/config/macos.el
new file mode 100644
index 0000000..463eec1
--- /dev/null
+++ b/config/emacs/config/macos.el
@@ -0,0 +1,3 @@
+(use-package exec-path-from-shell
+ :config
+ (exec-path-from-shell-initialize))
diff --git a/config/emacs/gtd.el b/config/emacs/gtd.el
deleted file mode 100644
index 2c910a4..0000000
--- a/config/emacs/gtd.el
+++ /dev/null
@@ -1,62 +0,0 @@
-;;; -*- lexical-binding: t -*-
-;;; GTD Org-mode Setup <https://www.labri.fr/perso/nrougier/GTD/index.html>
-;;;
-
-(require 'org)
-
-;; Configure Org-mode
-(setq org-directory "~/Documents/Org")
-
-;; Org capture templates
-(setq
- org-capture-templates `(
- ("i" "Inbox" entry (file "inbox.org")
- ,(concat "* TODO %?\n"
- "/Entered on/ %U"))))
-(defun gtd-org-capture-inbox ()
- (interactive)
- (org-capture nil "i"))
-
-;; Org agenda
-(setq
- org-agenda-files (list "inbox.org" "projects.org")
- org-agenda-hide-tags-regexp "."
- org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s")
- (todo . " ")
- (tags . " %i %-12:c")
- (search . " %i %-12:c"))
- org-agenda-custom-commands '(
- ("g" "Get Things Done (GTD)"
- ((agenda "" ((org-deadline-warning-days 0)))
- (todo "NEXT"
- ((org-agenda-skip-function '(org-agenda-skip-entry-if 'deadline))
- (org-agenda-prefix-format " %i %-12:c [%e] ")
- (org-agenda-overriding-header "\nTasks\n")))
- (tags-todo "inbox"
- ((org-agenda-prefix-format " %?-12t% s")
- (org-agenda-overriding-header "\nInbox\n")))
- (tags "CLOSED>=\"<today>\""
- ((org-agenda-overriding-header "\nCompleted today\n")))))))
-(add-hook 'org-agenda-mode-hook 'delete-other-windows)
-
-;; Org refiling
-(setq
- org-refile-targets '(("projects.org" :regexp . "\\(?:\\(?:Note\\|Task\\)s\\)"))
- org-refile-use-outline-path 'file
- org-outline-path-complete-in-steps nil)
-
-;; Org todo
-(setq
- org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "HOLD(h)" "|" "WONTFIX(x)" "DONE(d)"))
- org-log-done 'time)
-(defun gtd-log-todo-next-creation-date (&rest ignore)
- "Log NEXT creation time in the property drawer under the key 'ACTIVATED'"
- (when (and (string= (org-get-todo-state) "NEXT")
- (not (org-entry-get nil "ACTIVATED")))
- (org-entry-put nil "ACTIVATED" (format-time-string "[%Y-%m-%d]"))))
-(add-hook 'org-after-todo-state-change-hook #'gtd-log-todo-next-creation-date)
-
-;; Key bindings
-(define-key global-map (kbd "C-c c") 'org-capture)
-(define-key global-map (kbd "C-c i") 'gtd-org-capture-inbox)
-(define-key global-map (kbd "C-c a") 'org-agenda)
diff --git a/config/emacs/init.el b/config/emacs/init.el
index 9bc916d..e6ca9c3 100644
--- a/config/emacs/init.el
+++ b/config/emacs/init.el
@@ -1,80 +1,23 @@
;;; -*- lexical-binding: t -*-
;;; TODO(nlordell):
-;; 1. Update remaining init scripts:
-;; (load "~/.config/emacs/gtd.el" nil t)
-;; (load "~/.config/emacs/tree-sitter.el" nil t)
-;; 2. Emacs over devcontainers/docker with TRAMP
+;; 1. Emacs over devcontainers/docker with TRAMP
;; <https://happihacking.com/blog/posts/2023/dev-containers-emacs/>
-;; 3. Investigate other potential sane Emacs defaults
-;; <https://idiomdrottning.org/bad-emacs-defaults>
-;; 4. Setup GPTel - should be possible without FastGPT credits
+;; 2. Setup LLM coding: gptel, aidermacs
+;; 3. Try out neocaml - tree-sitter based
(load "~/.config/emacs/sanemacs.el" nil t)
-(load "~/.config/emacs/ligatures.el" nil t)
-;;;
-;;; General
-;;;
+(defcustom system-category 'plain
+ "The category of system.
-(use-package ace-window
- :bind
- (("C-x o" . ace-window)))
+ Allows initialization and customization differentiation with a
+ shared .emacs."
+ :type '(choice (const :tag "Plain" plain)
+ (const :tag "Development" development))
+ :group 'convenience)
-(use-package avy
- :bind
- (("C-:" . avy-goto-char)
- ("M-g f" . avy-goto-line)))
-
-(use-package ligature
- :config
- (ligature-set-ligatures 'prog-mode ligatures-berkeley-mono)
- (global-ligature-mode +1))
-
-(use-package magit
- :custom
- (transient-levels-file "~/.cache/emacs/transient/levels.el")
- (transient-values-file "~/.cache/emacs/transient/values.el")
- (transient-history-file "~/.cache/emacs/transient/history.el"))
-
-(use-package projectile
- :bind-keymap
- ("C-c p" . projectile-command-map)
- :custom
- (projectile-known-projects-file "~/.cache/emacs/projectile-bookmarks.eld")
- (projectile-project-search-path '(("~/Developer/" . 2)))
- :config
- (projectile-mode +1))
-
-(use-package undo-tree
- :custom
- (undo-tree-auto-save-history nil)
- :config
- (global-undo-tree-mode +1))
-
-(unless (fboundp 'which-key-mode)
- (use-package which-key
- :config
- (which-key-mode +1)))
-
-;;;
-;;; OCaml
-;;;
-
-(use-package tuareg)
-
-(use-package ocaml-eglot
- :after (tuareg)
- :hook
- (tuareg-mode . ocaml-eglot)
- (ocaml-eglot . eglot-ensure))
-
-;;;
-;;; macOS
-;;;
-
-(when (memq window-system '(mac ns))
- ;; Make the shell environement available when started on macOS Spotlight.
- (use-package exec-path-from-shell
- :config
- (exec-path-from-shell-initialize)))
+(when (eq system-category 'development)
+ (load "~/.config/emacs/config/development.el" nil t))
+(when (eq system-type 'darwin)
+ (load "~/.config/emacs/config/macos.el" nil t))
diff --git a/config/emacs/ligatures.el b/config/emacs/ligatures.el
deleted file mode 100644
index afb3d38..0000000
--- a/config/emacs/ligatures.el
+++ /dev/null
@@ -1,25 +0,0 @@
-;;; -*- lexical-binding: t -*-
-
-(defconst ligatures-berkeley-mono
- '(;; Group A
- ".." ".=" "..." "..<" "::" ":::" ":=" "::=" ";;" ";;;" "??" "???" ".?" "?."
- ":?" "?:" "?=" "**" "***" "/*" "*/" "/**"
- ;; Group B
- "<-" "->" "-<" ">-" "<--" "-->" "<<-" "->>" "-<<" ">>-" "<-<" ">->" "<-|"
- "|->" "-|" "|-" "||-" "<!--" "<#--" "<=" "=>" ">=" "<==" "==>" "<<=" "=>>"
- "=<<" ">>=" "<=<" ">=>" "<=|" "|=>" "<=>" "<==>" "||=" "|=" "//=" "/="
- ;; Group C
- "<<" ">>" "<<<" ">>>" "<>" "<$" "$>" "<$>" "<+" "+>" "<+>" "<:" ":<" "<:<"
- ">:" ":>" "<~" "~>" "<~>" "<<~" "<~~" "~~>" "~~" "<|" "|>" "<|>" "<||"
- "||>" "<|||" "|||>" "</" "/>" "</>" "<*" "*>" "<*>" ":?>"
- ;; Group D
- "#(" "#{" "#[" "]#" "#!" "#?" "#=" "#_" "#_(" "##" "###" "####"
- ;; Group E
- "[|" "|]" "[<" ">]" "{!!" "!!}" "{|" "|}" "{{" "}}" "{{--" "--}}" "{!--"
- "//" "///" "!!"
- ;; Group F
- "www" "@_" "&&" "&&&" "&=" "~@" "++" "+++" "/\\" "\\/" "_|_" "||"
- ;; Group G
- "=:" "=:=" "=!=" "==" "===" "=/=" "=~" "~-" "^=" "__" "!=" "!==" "-~" "--"
- "---")
- "Ligatures for the Berkeley Mono font.")
diff --git a/config/emacs/sanemacs.el b/config/emacs/sanemacs.el
index 222b6b8..d8df3d4 100644
--- a/config/emacs/sanemacs.el
+++ b/config/emacs/sanemacs.el
@@ -47,3 +47,17 @@
(setq package-archive-priorities '(("gnu" . 1) ("nongnu" . 1) ("melpa" . 0)))
(require 'use-package)
(setq use-package-always-ensure t)
+
+;; Install standard packages
+(use-package ace-window
+ :bind
+ (("C-x o" . ace-window)))
+(use-package avy
+ :bind
+ (("C-:" . avy-goto-char)
+ ("M-g f" . avy-goto-line)))
+(use-package undo-tree
+ :custom
+ (undo-tree-auto-save-history nil)
+ :config
+ (global-undo-tree-mode +1))
diff --git a/config/emacs/tree-sitter.el b/config/emacs/tree-sitter.el
deleted file mode 100644
index 402d15c..0000000
--- a/config/emacs/tree-sitter.el
+++ /dev/null
@@ -1,44 +0,0 @@
-(require 'treesit)
-
-(setq
- tree-sitter-install-dir "~/.cache/emacs/tree-sitter"
- tree-sitter-languages '((rust :version "v0.23.1")
- (ocaml :version "v0.23.2"
- :grammars ((ocaml :src "grammars/ocaml/src")
- (ocaml_interface :src "grammars/interface/src")
- (ocaml_type :src "grammars/type/src")))))
-
-(defun tree-sitter--install-language (lang)
- "Installs tree-sitter language grammars for LANG."
- (let* ((lconf (or (alist-get lang tree-sitter-languages)
- (error "unknown language %s" lang)))
- (url (or (plist-get lconf :url)
- (format "https://github.com/tree-sitter/tree-sitter-%s" lang)))
- (version (plist-get lconf :version))
- (grammars (or (plist-get lconf :grammars)
- `((,lang)))))
- (cl-loop for (grammar . gconf) in grammars do
- (let* ((src (or (plist-get gconf :src) "src"))
- (recipe (list "~/.cache/emacs/tree-sitter"
- grammar url version src)))
- (apply #'treesit--install-language-grammar-1 recipe)))))
-
-(defun tree-sitter--major-mode-remaps (lang)
- "Gets the remap configuration for LANG or `nil' when not available"
- (let* ((lconf (or (alist-get lang tree-sitter-languages)
- (error "unknown language %s" lang)))
- (remaps (plist-get lconf :remaps)))
- (if (treesit-language-available-p lang) remaps nil)))
-
-(defun use-tree-sitter-language (lang)
- "Installs and configures tree-sitter language grammars for LANG."
- (unless (treesit-language-available-p lang)
- (tree-sitter--install-language lang)
- (let (remaps (tree-sitter--major-mode-remaps lang))
- (append major-mode-remap-alist remaps))))
-
-(setq
- treesit-extra-load-path `(,tree-sitter-install-dir)
- major-mode-remap-alist (mapcan (lambda (lang)
- (tree-sitter--major-mode-remaps (car lang)))
- tree-sitter-languages))