diff --git a/config.org b/config.org index bb73156..ff3b9cb 100644 --- a/config.org +++ b/config.org @@ -117,11 +117,13 @@ This configuration requires the installation of : ** Garbage collection -Increase GC threshold to minimize time wasting: +Increase GC threshold to minimize time wasting on modern machines: #+BEGIN_SRC emacs-lisp (setq gc-cons-threshold 20000000) ;; 20 MB #+END_SRC +Recommendation stolen from https://github.com/lewang/flx?tab=readme-ov-file#gc-optimization . + * Base packages to install first ** Elpaca @@ -130,76 +132,43 @@ Replacement for built-in package manager package.el : https://github.com/progfolio/elpaca #+BEGIN_SRC emacs-lisp - (defvar elpaca-installer-version 0.4) - + (defvar elpaca-installer-version 0.7) (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) - (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) - (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) - (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" - - :ref nil - - :files (:defaults (:exclude "extensions")) - - :build (:not elpaca--activate-package))) - + :ref nil :depth 1 + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) (let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) - - (build (expand-file-name "elpaca/" elpaca-builds-directory)) - - (order (cdr elpaca-order)) - - (default-directory repo)) - + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) (add-to-list 'load-path (if (file-exists-p build) build repo)) - (unless (file-exists-p repo) - (make-directory repo t) - (when (< emacs-major-version 28) (require 'subr-x)) - (condition-case-unless-debug err - - (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) - - ((zerop (call-process "git" nil buffer t "clone" - - (plist-get order :repo) repo))) - - ((zerop (call-process "git" nil buffer t "checkout" - - (or (plist-get order :ref) "--")))) - - (emacs (concat invocation-directory invocation-name)) - - ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" - - "--eval" "(byte-recompile-directory \".\" 0 'force)"))) - - ((require 'elpaca)) - - ((elpaca-generate-autoloads "elpaca" repo))) - - (kill-buffer buffer) - - (error "%s" (with-current-buffer buffer (buffer-string)))) - - ((error) (warn "%s" err) (delete-directory repo 'recursive)))) - + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (apply #'call-process `("git" nil ,buffer t "clone" + ,@(when-let ((depth (plist-get order :depth))) + (list (format "--depth=%d" depth) "--no-single-branch")) + ,(plist-get order :repo) ,repo)))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) (unless (require 'elpaca-autoloads nil t) - (require 'elpaca) - (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) - (add-hook 'after-init-hook #'elpaca-process-queues) - (elpaca `(,@elpaca-order)) #+END_SRC @@ -453,6 +422,14 @@ We could use an alias (alias sudo eshell/sudo $*), but to keep things inside thi (setq password-cache-expiry 3600) ; for one hour (time in secs) #+END_SRC +** Vterm + +#+BEGIN_SRC emacs-lisp +(use-package vterm + :ensure t + ) +#+END_SRC + * Dired @@ -754,7 +731,7 @@ will the entire line including the following newline will be deleted. #+BEGIN_SRC emacs-lisp (setq kill-ring-max 5000) ; increase kill-ring capacity -(setq kill-whole-line t) +;; (setq kill-whole-line t) #+END_SRC ** Newline at end-of-file @@ -1115,6 +1092,13 @@ TODO: need to document this * Magit + +#+BEGIN_SRC emacs-lisp +(use-package transient + :ensure t + ) +#+END_SRC + #+BEGIN_SRC emacs-lisp (use-package magit :ensure t @@ -1171,6 +1155,26 @@ https://github.com/joaotavora/yasnippet *** Eglot +Eldoc complaints: + +#+BEGIN_SRC emacs-lisp +(use-package eldoc + :preface + (unload-feature 'eldoc t) + (setq custom-delayed-init-variables '()) + (defvar global-eldoc-mode nil) + :config + (global-eldoc-mode)) + + +(use-package jsonrpc + :preface + (unload-feature 'jsonrpc t) + ) + +#+END_SRC + + #+BEGIN_SRC emacs-lisp (use-package eglot :hook (prog-mode . eglot-ensure) diff --git a/config_new.org b/config_new.org new file mode 100644 index 0000000..c5dd757 --- /dev/null +++ b/config_new.org @@ -0,0 +1,299 @@ +#+STARTUP: overview +#+TITLE: My Emacs +#+CREATOR: Laurens Miers +#+LANGUAGE: en +[[./img/dash_logo.png]] + +* Elpaca + +#+begin_src emacs-lisp +(defvar elpaca-installer-version 0.7) +(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) +(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) +(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) +(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" + :ref nil :depth 1 + :files (:defaults "elpaca-test.el" (:exclude "extensions")) + :build (:not elpaca--activate-package))) +(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory)) + (build (expand-file-name "elpaca/" elpaca-builds-directory)) + (order (cdr elpaca-order)) + (default-directory repo)) + (add-to-list 'load-path (if (file-exists-p build) build repo)) + (unless (file-exists-p repo) + (make-directory repo t) + (when (< emacs-major-version 28) (require 'subr-x)) + (condition-case-unless-debug err + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (apply #'call-process `("git" nil ,buffer t "clone" + ,@(when-let ((depth (plist-get order :depth))) + (list (format "--depth=%d" depth) "--no-single-branch")) + ,(plist-get order :repo) ,repo)))) + ((zerop (call-process "git" nil buffer t "checkout" + (or (plist-get order :ref) "--")))) + (emacs (concat invocation-directory invocation-name)) + ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch" + "--eval" "(byte-recompile-directory \".\" 0 'force)"))) + ((require 'elpaca)) + ((elpaca-generate-autoloads "elpaca" repo))) + (progn (message "%s" (buffer-string)) (kill-buffer buffer)) + (error "%s" (with-current-buffer buffer (buffer-string)))) + ((error) (warn "%s" err) (delete-directory repo 'recursive)))) + (unless (require 'elpaca-autoloads nil t) + (require 'elpaca) + (elpaca-generate-autoloads "elpaca" repo) + (load "./elpaca-autoloads"))) +(add-hook 'after-init-hook #'elpaca-process-queues) +(elpaca `(,@elpaca-order)) +#+end_src + +#+begin_src emacs-lisp + ;; Install use-package support + (elpaca elpaca-use-package + ;; Enable use-package :ensure support for Elpaca. + (elpaca-use-package-mode) + ) +#+end_src + +* General config + +** Yes-or-no + +Because I'm lazy, important yes-or-no questions can be answered with y-or-n: +#+begin_src emacs-lisp +(defalias 'yes-or-no-p 'y-or-n-p) +#+end_src + +** FIDO + +Use Fake-ido as minibuffer completion system, more info here: +https://www.gnu.org/software/emacs/manual/html_node/emacs/Icomplete.html + +#+begin_src emacs-lisp +(fido-vertical-mode 1) +#+end_src + +** Switch windows + +#+begin_src emacs-lisp +(global-set-key (kbd "M-o") 'other-window) +#+end_src + +** Maximize at startup + +More info : https://www.emacswiki.org/emacs/FullScreen + +#+begin_src emacs-lisp +(push '(fullscreen . maximized) default-frame-alist) +#+end_src + +** ibuffer + +Use list-buffers bigger brother. +#+begin_src emacs-lisp +(global-set-key [remap list-buffers] 'ibuffer) +#+end_src + +** Mark + +#+begin_src emacs-lisp +(global-set-key (kbd "M-SPC") 'mark-word) +#+end_src + +** Isearch + +Display number of matches: +#+begin_src emacs-lisp +(setq-default isearch-lazy-count t) +#+end_src + +Reference that might be interesting for later: +https://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html + +** Sudo file + +#+begin_src emacs-lisp +(defun sudo () + "Use TRAMP to `sudo' the current buffer." + (interactive) + (when buffer-file-name + (find-alternate-file + (concat "/sudo:root@localhost:" + buffer-file-name) + ) + ) +) +#+end_src + +* Whole-line-or-region + +Source: +https://github.com/purcell/whole-line-or-region + +Operate on the current line if no region is active. + +#+begin_src emacs-lisp +(use-package whole-line-or-region + :ensure t + :config + (whole-line-or-region-global-mode 1) +) +#+end_src + +* imenu + +** Flatten + +#+begin_src emacs-lisp +(use-package flimenu + :ensure t + :config + (flimenu-global-mode 1) +) + +(global-set-key (kbd "M-i") 'imenu) +#+end_src + +* Terminal + +** Toggle between char- and line-mode + +Courtesy goes to https://joelmccracken.github.io/entries/switching-between-term-mode-and-line-mode-in-emacs-term/ + +#+BEGIN_SRC emacs-lisp +(require 'term) + +(defun jnm/term-toggle-mode () + "Toggles term between line mode and char mode" + (interactive) + (if (term-in-line-mode) + (term-char-mode) + (term-line-mode))) + +(define-key term-mode-map (kbd "C-c C-j") 'jnm/term-toggle-mode) +(define-key term-mode-map (kbd "C-c C-k") 'jnm/term-toggle-mode) + +(define-key term-raw-map (kbd "C-c C-j") 'jnm/term-toggle-mode) +(define-key term-raw-map (kbd "C-c C-k") 'jnm/term-toggle-mode) +#+END_SRC + +For the keybindings, we have to defien them in both raw and line mode. From the help page of term mode: + If you define custom keybindings, make sure to assign them to the + correct keymap (or to both): use ‘term-raw-map’ in raw mode and + ‘term-mode-map’ in line mode. + +* Theme + +#+BEGIN_SRC emacs-lisp +(use-package monokai-theme + :ensure t + :init + (load-theme 'monokai t) +) +#+END_SRC + +* Dashboard + +#+begin_src emacs-lisp +(use-package dashboard + :ensure t + :config + (add-hook 'elpaca-after-init-hook #'dashboard-insert-startupify-lists) + (add-hook 'elpaca-after-init-hook #'dashboard-initialize) + (dashboard-setup-startup-hook)) +#+end_src + +* Hydra + +Install and wait for hydra to be available since we are using it in this init.el : +#+begin_src emacs-lisp +(use-package hydra + :ensure (:wait t) + ) +#+end_src + +** Text zoom + +#+begin_src emacs-lisp +(defhydra hydra-zoom (global-map "") + "zoom" + ("g" text-scale-increase "in") + ("l" text-scale-decrease "out") +) +#+end_src + +* Programming + +** Eglot + +#+BEGIN_SRC emacs-lisp +(use-package eglot + :ensure t + :defer t + ;; This doesn't work for some reason, workaround below + ;;:hook (prog-mode . eglot-ensure) + ;; :config + ;; (add-hook 'prog-mode-hook 'eglot-ensure) +) +#+END_SRC + +Workaround to enable eglot in all programming modes: +#+BEGIN_SRC emacs-lisp +(add-hook 'prog-mode-hook 'eglot-ensure) +#+END_SRC + +** Yasnippet + +#+BEGIN_SRC emacs-lisp +(use-package yasnippet + :ensure t + :config + (yas-reload-all) + (add-hook 'prog-mode-hook 'yas-minor-mode) +) +#+END_SRC + +** Magit + +#+BEGIN_SRC emacs-lisp +(use-package magit + :ensure t +) +#+END_SRC + +* Multiple cursors + +#+BEGIN_SRC emacs-lisp +(use-package multiple-cursors + :ensure t +) +#+END_SRC + +* Comment-dwim-2 + +Replacement for built-in =comment-dwim=, more comment features. + +https://github.com/remyferre/comment-dwim-2 + +#+BEGIN_SRC emacs-lisp +(use-package comment-dwim-2 + :ensure t + :config + (global-set-key (kbd "M-;") 'comment-dwim-2) +) +#+END_SRC + +* Projectile + +#+BEGIN_SRC emacs-lisp +(use-package projectile + :ensure t + :hook (prog-mode . projectile-mode) +;; :config +;; (setq projectile-globally-ignored-directories (cons ".ccls-cache" projectile-globally-ignored-directories)) +;; (setq projectile-indexing-method 'alien) +;; (setq projectile-enable-caching t) +;; (projectile-mode) +) + +#+END_SRC diff --git a/early-init.el b/early-init.el index 512068a..0fe1b95 100644 --- a/early-init.el +++ b/early-init.el @@ -1 +1,9 @@ (setq package-enable-at-startup nil) + + +;; Local Variables: +;; no-byte-compile: t +;; no-native-compile: t +;; no-update-autoloads: t +;; End: + diff --git a/init.el b/init.el index 444b5ab..b25e39d 100644 --- a/init.el +++ b/init.el @@ -5,13 +5,26 @@ ;;; ... (let ((gc-cons-threshold most-positive-fixnum)) ;; This is the actual config file. It is omitted if it doesn't exist so emacs won't refuse to launch. - (defvar config-file (expand-file-name "config.org" user-emacs-directory)) - (defvar project-file (expand-file-name "project.org" user-emacs-directory)) + (defvar config-file (expand-file-name "config_new.org" user-emacs-directory)) + ;;(defvar project-file (expand-file-name "project.org" user-emacs-directory)) (when (file-readable-p config-file) (org-babel-load-file (expand-file-name config-file))) ;; If it exists, load some project-specific configurations. - (when (file-readable-p project-file) - (org-babel-load-file (expand-file-name project-file))) + ;;(when (file-readable-p project-file) + ;; (org-babel-load-file (expand-file-name project-file))) ) +(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. + '(package-selected-packages + '(flycheck-clang-tidy org-tree-slide ox-reveal writeroom-mode visual-fill-column org-present clang-format+ dash))) +(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. + )