(setq user-full-name "Alessandro Corbetta")
(setq package-enable-at-startup nil)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
Need to figure out the clash between the org-mode version provided with emacs and that one needed by emacs.
The next line gets org to work, but fails in things like org-roam-ui
;; (use-package org :straight (:type built-in))
;; (straight-use-package 'org)
(setq inhibit-startup-screen t)
(tool-bar-mode -1)
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(global-set-key (kbd "C-o") 'occur)
;; window dimensions
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)
(global-set-key [(C-f5)] 'compile)
(global-set-key [(f5)] 'recompile)
;; bind compiling with get-above-makefile to f5
;; (global-set-key [f5] (lambda () (interactive) (compile (format
;; "make -f %s" (get-above-makefile)))))
;; winner
(winner-mode 1)
(global-set-key (kbd "<f7>") 'winner-undo)
(global-set-key (kbd "C-<f7>") 'winner-redo)
;; setting treemacs
(global-set-key (kbd "<f8>") 'treemacs)
;; Don’t compact font caches during GC.
(setq inhibit-compacting-font-caches t)
;; shell -- opens shell in the same buffer
(push (cons "\\*shell\\*" display-buffer--same-window-action) display-buffer-alist)
;; doc-view comes with auto-revert-mode
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
;; increases doc-view-resolution to match higher screen resolution
(setq doc-view-resolution 192)
;; (use-package ace-window
;; :straight t
;; :if (display-graphic-p)
;; )
(global-set-key (kbd "M-o") 'ace-window)
I’d like to switch to an open shell if exists
;; https://emacs.stackexchange.com/a/21154/8641
(defun my-switch-to-buffer (buffer)
"Display BUFFER in the selected window.
If BUFFER is displayed in an existing window, select that window instead."
(interactive
(list (get-buffer (read-buffer
"Switch to buffer: "
(other-buffer (current-buffer)
)
))))
(if-let ((win (get-buffer-window buffer)))
(select-window win)
(switch-to-buffer buffer)
))
;; easy access to shell
;; (global-set-key (kbd "C-x t") 'shell)
(global-set-key (kbd "C-x t") 'my-open-shell-if-closed-else-my-switch-there)
(defun my-open-shell-if-closed-else-my-switch-there ()
"Tries to move to an open shell or moves there"
(interactive)
(if (get-buffer "*shell*")
(my-switch-to-buffer "*shell*")
(shell)
)
)
Close the compilatio window if compilation suceeded
;; autocloses the compilation window after successful compilation
(defun compile-autoclose (buffer string)
(cond ((string-match "finished" string)
(bury-buffer "*compilation*")
(winner-undo)
(message "Build successful."))
(t
(message "Compilation exited abnormally: %s" string))))
(setq compilation-finish-functions 'compile-autoclose)
Use the makefile in this folder or above (disabled)
;; currently using the default behavior ;; bind compiling with get-above-makefile to f5 ;; (global-set-key [f5] (lambda () (interactive) (compile (format ;; "make -f %s" (get-above-makefile))))) ;; compile hacks -- makefile in current dir or upstaris. To be improved (defun get-above-makefile () (let ((dir (locate-dominating-file "." "Makefile"))) (when dir (concat dir "Makefile"))))
Ref: https://kristofferbalintona.me/posts/202202211546/
(use-package all-the-icons
:straight t
:if (display-graphic-p))
(use-package all-the-icons-completion
:straight t
:after (marginalia all-the-icons)
:hook (marginalia-mode . all-the-icons-completion-marginalia-setup)
:init
(all-the-icons-completion-mode))
(use-package all-the-icons-dired
:straight t
:defer t
:hook (dired-mode . all-the-icons-dired-mode)
)
(use-package dashboard
:straight t
:diminish dashboard-mode
:config
;; (setq dashboard-banner-logo-title "your custom text")
;; (setq dashboard-startup-banner "/path/to/image")
(setq dashboard-items '((recents . 10)
;; (projects . 5)
;; (bookmarks . 5)
))
(setq dashboard-icon-type 'all-the-icons)
(setq dashboard-set-heading-icons nil)
(setq dashboard-set-file-icons t)
(setq dashboard-set-navigator t)
(setq dashboard-set-footer t)
(dashboard-setup-startup-hook))
(use-package dashboard :straight t :config (dashboard-setup-startup-hook) :init (setq dashboard-items '((recents . 10) ;;(bookmarks . 5) ;; (projects . 5) ;; (agenda . 5) (registers . 5))) (setq dashboard-set-heading-icons t) (setq dashboard-set-file-icons t) (setq dashboard-icon-type 'all-the-icons) (setq dashboard-heading-icons '((recents . "history") (bookmarks . "bookmark") (agenda . "calendar") (projects . "rocket") (registers . "database"))))
(setq treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(css "https://github.com/tree-sitter/tree-sitter-css")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(go "https://github.com/tree-sitter/tree-sitter-go")
(html "https://github.com/tree-sitter/tree-sitter-html")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(json "https://github.com/tree-sitter/tree-sitter-json")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python "https://github.com/tree-sitter/tree-sitter-python")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
(use-package magit
:straight t
:bind (("C-x g" . magit-status)))
(use-package visual-fill-column
:straight t
;;:defer t
;; :config
;; (add-hook 'visual-line-mode-hook #'visual-fill-column-mode)
;;:hook visual-line-mode-hook
)
(use-package adaptive-wrap
:straight t
:defer t
)
(add-hook 'visual-line-mode-hook #'visual-fill-column-mode)
(add-hook 'visual-fill-column-mode-hook #'adaptive-wrap-prefix-mode)
(use-package highlight-indent-guides
:straight t
:hook (prog-mode . highlight-indent-guides-mode)
;; :config
;; (setq highlight-indent-guides-method 'bitmap)
)
;; hs (hideshow) native mode is really bad in python
;; (add-hook 'prog-mode-hook #'hs-minor-mode)
;; (add-hook 'prog-mode-hook
;; (lambda () (local-set-key (kbd "C-c C-<tab>") 'hs-toggle-hiding)))
;; ;; (global-set-key (kbd "C-c C-<tab>") 'hs-toggle-hiding)
(use-package origami
:straight t
:hook (prog-mode . origami-mode)
:bind (("C-c C-<tab>" . origami-toggle-node)
))
(use-package lsp-origami
:straight t
:config (add-hook 'lsp-after-open-hook #'lsp-origami-try-enable)
)
(defun my-behavior-enable-doom-theme ()
(use-package doom-themes
:straight t
:defer
:init
(progn
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
;; may have their own settings.
;; (load-theme 'doom-opera-light t)
;; (load-theme 'doom-opera-light t)
(load-theme 'doom-dark+ t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
;; (doom-themes-neotree-config)
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
;; or for treemacs users
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)
)
)
;; (use-package vscode-dark-plus-theme
;; :ensure t
;; :disabled t
;; )
)
(defun my-behavior-with-graphic ()
;; (my-behavior-enable-centaur-tabs)
(my-behavior-enable-doom-theme)
;;(treemacs)
)
(defun my-behavior-use-nano-emacs ()
(straight-use-package
'(nano :type git :host github :repo "rougier/nano-emacs"))
(setq nano-font-family-proportional nil)
(setq nano-font-size 11)
(require 'nano)
)
(defun my-behavior-without-graphic ()
(use-package zenburn-theme
:straight t
:config
(progn
(load-theme 'zenburn t)
)
)
(use-package corfu-terminal
:straight t
:config
(corfu-terminal-mode)
)
)
;; tweaks the theme in dependence on whether terminal or not.
(if (display-graphic-p)
(my-behavior-with-graphic)
;; (my-behavior-use-nano-emacs)
(my-behavior-without-graphic)
)
(use-package doom-modeline
:straight t
;; :disabled
:hook (after-init . doom-modeline-mode)
;;:defer 2
:config
(progn
(setq doom-modeline-height 25)
;; Whether display icons in mode-line or not.
(setq doom-modeline-icon (display-graphic-p))
;; Whether display the icon for major mode. It respects `doom-modeline-icon'.
(setq doom-modeline-major-mode-icon t)
;; If non-nil, a word count will be added to the selection-info modeline segment.
(setq doom-modeline-enable-word-count t)
))
From: https://github.com/minad/org-modern
;; Add frame borders and window dividers
(modify-all-frames-parameters
'((right-divider-width . 2)
(internal-border-width . 2)))
(dolist (face '(window-divider
window-divider-first-pixel
window-divider-last-pixel))
(face-spec-reset-face face)
(set-face-foreground face (face-attribute 'default :background)))
(set-face-background 'fringe (face-attribute 'default :background))
https://kristofferbalintona.me/posts/202202211546/
https://github.com/minad/marginalia
;; Enable rich annotations using the Marginalia package
(use-package marginalia
:straight t
;; Either bind `marginalia-cycle' globally or only in the minibuffer
:bind (("M-A" . marginalia-cycle)
:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; The :init configuration is always executed (Not lazy!)
:init
;; Must be in the :init section of use-package such that the mode gets
;; enabled right away. Note that this forces loading the package.
(marginalia-mode))
https://github.com/minad/vertico
;; Enable vertico
(use-package vertico
;; :straight t
;; Special recipe to load extensions conveniently
:straight (vertico :files (:defaults "extensions/*")
:includes ( ;;vertico-indexed
;;vertico-flat
;;vertico-grid
;;vertico-mouse
;;vertico-quick
vertico-buffer
;;vertico-repeat
;;vertico-reverse
vertico-directory
;;vertico-multiform
;;vertico-unobtrusive
))
:init
:custom
(vertico-count 7) ; Number of candidates to display
(vertico-resize t)
(vertico-cycle nil) ; Go from last to first candidate and first to last (cycle)
:config
(vertico-mode)
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
;; (setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer
;; (setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
;; (setq vertico-cycle t)
)
;; Configure directory extension.
(use-package vertico-directory
:after vertico
:straight t
;;:demand
;; More convenient directory navigation commands
:bind (:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word))
;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:straight t
:init
(savehist-mode))
;; Optionally use the `orderless' completion style.
(use-package orderless
:straight t
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
(defun dw/get-project-root ()
(when (fboundp 'projectile-project-root)
(projectile-project-root)))
(use-package consult
:straight t
:demand t
:bind (("C-s" . consult-line)
("C-S-s" . consult-line-multi)
("C-M-l" . consult-imenu)
("C-M-j" . persp-switch-to-buffer*)
("C-x b" . consult-buffer)
("M-g g" . consult-goto-line)
("M-y" . consult-yank-replace)
("C-x m" . consult-mark)
("C-S-x m" . consult-global-mark)
:map minibuffer-local-map
("C-r" . consult-history)
)
:custom
;; (consult-project-root-function #'dw/get-project-root)
(completion-in-region-function #'consult-completion-in-region)
;; starts the search from the top
(setq consult-line-start-from-top 't)
;; :config
;; (consult-preview-mode)
)
(use-package consult-lsp
:straight t
:demand t
)
(use-package projectile
:straight t
:init
(projectile-mode +1)
:bind (:map projectile-mode-map
("C-c p" . projectile-command-map)))
(use-package embark
:straight t
:bind (("C-S-a" . embark-act)
:map minibuffer-local-map
("C-d" . embark-act))
:config
;; Show Embark actions via which-key
(setq embark-action-indicator
(lambda (map)
(which-key--show-keymap "Embark" map nil nil 'no-paging)
#'which-key--hide-popup-ignore-command)
embark-become-indicator embark-action-indicator))
;; (use-package embark-consult
;; :straight '(embark-consult :host github
;; :repo "oantolin/embark"
;; :files ("embark-consult.el"))
;; :after (embark consult)
;; :demand t
;; :hook
;; (embark-collect-mode . embark-consult-preview-minor-mode))
(use-package embark-consult
:straight t
:hook
(embark-collect-mode . embark-consult-preview-minor-mode))
;; Configure Tempel (use-package tempel ;; Require trigger prefix before template name when completing. ;; :custom ;; (tempel-trigger-prefix "<") :straight t :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand ("M-*" . tempel-insert)) :init ;; Setup completion at point (defun tempel-setup-capf () ;; Add the Tempel Capf to `completion-at-point-functions'. ;; `tempel-expand' only triggers on exact matches. Alternatively use ;; `tempel-complete' if you want to see all matches, but then you ;; should also configure `tempel-trigger-prefix', such that Tempel ;; does not trigger too often when you don't expect it. NOTE: We add ;; `tempel-expand' *before* the main programming mode Capf, such ;; that it will be tried first. (setq-local completion-at-point-functions (cons #'tempel-expand completion-at-point-functions))) (add-hook 'prog-mode-hook 'tempel-setup-capf) (add-hook 'text-mode-hook 'tempel-setup-capf) ;; Optionally make the Tempel templates available to Abbrev, ;; either locally or globally. `expand-abbrev' is bound to C-x '. ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode) ;; (global-tempel-abbrev-mode) ) ;; Optional: Add tempel-collection. ;; The package is young and doesn't have comprehensive coverage. (use-package tempel-collection :straight t)
;; (use-package yasnippet-snippets ; Collection of snippets
;; ;; :defer 5
;; :straight t)
;; ;; an
;; yway loaded by elpy.
(use-package yasnippet
:straight t
;; :defer 3
;; :hook ('LaTeX-mode-hook 'yas-minor-mode)
;; :hook ('python-mode-hook 'yas-minor-mode)
)
:config
(use-package yasnippet-snippets ; Collection of snippets
;; :defer 5
:straight t)
(yas-global-mode t)
(yas-reload-all)
;; (progn
;; ;; (yas-global-mode 1)
;; ;; (with-eval-after-load 'yasnippet
;; ;; (validate-setq yas-snippet-dirs '(yasnippet-snippets-dir)))
;; ))
(use-package avy
:straight t
:config
(progn
(global-set-key (kbd "C-S-d") 'avy-goto-char-2)
(setq avy-all-windows 'all-frames)
) ;;-timer
)
;;ag
(use-package ag
:straight t)
(use-package minimap
:straight t)
;; howdoi
(use-package howdoi
:straight t)
(use-package undo-tree
:straight t
:config
(progn
(global-undo-tree-mode t)
(setq undo-tree-visualizer-relative-timestamps t)
(setq undo-tree-visualizer-timestamps t)
)
)
(use-package shell-pop
:straight t
:bind (("<C-M-return>" . shell-pop))
;; :config
;; (progn
;; (global-set-key (kbd "<C-M-return>") 'shell-pop)
;; )
)
(use-package which-key
:straight t
:config
(which-key-mode))
(use-package chatgpt :straight (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el")) :init (require 'python) (setq chatgpt-repo-path "~/.emacs.d/straight/repos/ChatGPT.el/") :bind ("C-c q" . chatgpt-query))
Corfu config: https://kristofferbalintona.me/posts/202202270056/
;; (use-package corfu
;; :straight t
;; ;; Optional customizations
;; :custom
;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
;; (corfu-auto t) ;; Enable auto completion
;; (corfu-separator ?\s) ;; Orderless field separator
;; ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
;; ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; ;; (corfu-preview-current nil) ;; Disable current candidate preview
;; ;; (corfu-preselect 'prompt) ;; Preselect the prompt
;; ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
;; ;; (corfu-scroll-margin 5) ;; Use scroll margin
;; ;; Enable Corfu only for certain modes.
;; ;; :hook ((prog-mode . corfu-mode)
;; ;; (shell-mode . corfu-mode)
;; ;; (eshell-mode . corfu-mode))
;; ;; Recommended: Enable Corfu globally.
;; ;; This is recommended since Dabbrev can be used globally (M-/).
;; ;; See also `corfu-excluded-modes'.
;; :init
;; (global-corfu-mode))
(use-package corfu
:straight t
:hook (lsp-completion-mode . kb/corfu-setup-lsp) ; Use corfu for lsp completion
;; :general
;; (:keymaps 'corfu-map
;; :states 'insert
;; "C-n" #'corfu-next
;; "C-p" #'corfu-previous
;; "<escape>" #'corfu-quit
;; "<return>" #'corfu-insert
;; "H-SPC" #'corfu-insert-separator
;; ;; "SPC" #'corfu-insert-separator ; Use when `corfu-quit-at-boundary' is non-nil
;; "M-d" #'corfu-show-documentation
;; "C-g" #'corfu-quit
;; "M-l" #'corfu-show-location)
:custom
;; Works with `indent-for-tab-command'. Make sure tab doesn't indent when you
;; want to perform completion
(tab-always-indent 'complete)
(completion-cycle-threshold nil) ; Always show candidates in menu
(corfu-auto t)
(corfu-auto-prefix 2)
(corfu-auto-delay 0.25)
(corfu-min-width 80)
(corfu-max-width corfu-min-width) ; Always have the same width
(corfu-count 14)
(corfu-scroll-margin 4)
(corfu-cycle t)
;; `nil' means to ignore `corfu-separator' behavior, that is, use the older
;; `corfu-quit-at-boundary' = nil behavior. Set this to separator if using
;; `corfu-auto' = `t' workflow (in that case, make sure you also set up
;; `corfu-separator' and a keybind for `corfu-insert-separator', which my
;; configuration already has pre-prepared). Necessary for manual corfu usage with
;; orderless, otherwise first component is ignored, unless `corfu-separator'
;; is inserted.
(corfu-quit-at-boundary nil)
(corfu-separator ?\s) ; Use space
(corfu-quit-no-match 'separator) ; Don't quit if there is `corfu-separator' inserted
(corfu-preview-current 'insert) ; Preview first candidate. Insert on input if only one
(corfu-preselect-first t) ; Preselect first candidate?
;; Other
(corfu-echo-documentation nil) ; Already use corfu-doc
(lsp-completion-provider :none) ; Use corfu instead for lsp completions
:init
(global-corfu-mode)
:config
;; NOTE 2022-03-01: This allows for a more evil-esque way to have
;; `corfu-insert-separator' work with space in insert mode without resorting to
;; overriding keybindings with `general-override-mode-map'. See
;; https://github.com/minad/corfu/issues/12#issuecomment-869037519
;; Alternatively, add advice without `general.el':
;; (advice-add 'corfu--setup :after 'evil-normalize-keymaps)
;; (advice-add 'corfu--teardown :after 'evil-normalize-keymaps)
;; (general-add-advice '(corfu--setup corfu--teardown) :after 'evil-normalize-keymaps)
;; (evil-make-overriding-map corfu-map)
;; Enable Corfu more generally for every minibuffer, as long as no other
;; completion UI is active. If you use Mct or Vertico as your main minibuffer
;; completion UI. From
;; https://github.com/minad/corfu#completing-with-corfu-in-the-minibuffer
(defun corfu-enable-always-in-minibuffer ()
"Enable Corfu in the minibuffer if Vertico/Mct are not active."
(unless (or (bound-and-true-p mct--active) ; Useful if I ever use MCT
(bound-and-true-p vertico--input))
(setq-local corfu-auto nil) ; Ensure auto completion is disabled
(corfu-mode 1)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
;; Setup lsp to use corfu for lsp completion
(defun kb/corfu-setup-lsp ()
"Use orderless completion style with lsp-capf instead of the
default lsp-passthrough."
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(orderless))))
;; Use Dabbrev with Corfu!
(use-package dabbrev
;; Swap M-/ and C-M-/
:straight t
:bind (("M-/" . dabbrev-completion)
("C-M-/" . dabbrev-expand))
;; Other useful Dabbrev configurations.
:custom
(dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
(use-package kind-icon
:straight t
:after corfu
:custom
(kind-icon-use-icons t)
(kind-icon-default-face 'corfu-default) ; to compute blended backgrounds correctly
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
;; Add extensions
(use-package cape
:straight t
:custom
(cape-line-buffer-function #'current-buffer)
;; Bind dedicated completion commands
;; Alternative prefix keys: C-c p, M-p, M-+, ...
:bind (("C-c e p" . completion-at-point) ;; capf
("C-c e t" . complete-tag) ;; etags
("C-c e d" . cape-dabbrev) ;; or dabbrev-completion
("C-c e h" . cape-history)
("C-c e f" . cape-file)
("C-c e k" . cape-keyword)
("C-c e s" . cape-symbol)
("C-c e a" . cape-abbrev)
("C-c e i" . cape-ispell)
("C-c e l" . cape-line)
("C-c e w" . cape-dict)
("C-c e \\" . cape-tex)
("C-c e _" . cape-tex)
("C-c e ^" . cape-tex)
("C-c e &" . cape-sgml)
("C-c e r" . cape-rfc1345))
:init
;; Add `completion-at-point-functions', used by `completion-at-point'.
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-elisp-block)
;; (add-to-list 'completion-at-point-functions #'cape-file)
;; (add-to-list 'completion-at-point-functions #'cape-dabbrev)
;; (add-to-list 'completion-at-point-functions #'cape-history)
;; (add-to-list 'completion-at-point-functions #'cape-keyword)
;; ;; (add-to-list 'completion-at-point-functions #'cape-tex)
;; (add-to-list 'completion-at-point-functions #'cape-sgml)
;; (add-to-list 'completion-at-point-functions #'cape-rfc1345)
;; (add-to-list 'completion-at-point-functions #'cape-abbrev)
;; ;; (add-to-list 'completion-at-point-functions #'cape-ispell)
;; ;; (add-to-list 'completion-at-point-functions #'cape-dict)
;; ;; (add-to-list 'completion-at-point-functions #'cape-symbol)
;; ;; (add-to-list 'completion-at-point-functions #'cape-line)
)
;; A few more useful configurations...
(use-package emacs
:straight t
:init
;; VERTICO PART
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)
;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t)
;; CORFU PART
;; TAB cycle if there are only few candidates
(setq completion-cycle-threshold 3)
;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
;; Corfu commands are hidden, since they are not supposed to be used via M-x.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)
;; Enable indentation+completion using the TAB key.
;; `completion-at-point' is often bound to M-TAB.
(setq tab-always-indent 'complete))
About the keymap: emacs-lsp/lsp-mode#1672
About integrating with formatting in python: https://slinkp.com/python-emacs-lsp-20231229.html
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(use-package lsp-mode
:init (setq lsp-keymap-prefix "C-l")
:config (define-key lsp-mode-map (kbd "C-l") lsp-command-map)
:straight t
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
;; (pyls-mode . lsp)
;;(latex-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024)) ;; 1mb
(add-hook 'LaTeX-mode-hook 'lsp)
(add-hook 'python-mode-hook 'lsp)
(add-hook 'pyls-mode-hook
(lambda ()
(local-set-key (kbd "M-q") 'lsp-format-buffer )))
;; pyright?
(use-package lsp-pyright
:straight t
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp)))) ; or lsp-deferred
(use-package python-black
:straight t
:after python
;; :hook (python-mode . python-black-on-save-mode-enable-dwim)
:bind (:map python-mode-map
("C-c C-q" . python-black-buffer))
)
(use-package dap-mode
:after lsp-mode
:straight t)
;; (use-package dap-mode
;; :after lsp-mode
;; :commands dap-debug
;; :hook ((python-mode . dap-ui-mode)
;; (python-mode . dap-mode))
;; :config
;; (eval-when-compile
;; (require 'cl))
;; (require 'dap-python)
;; (require 'dap-lldb)
;; ;; Temporal fix
;; (defun dap-python--pyenv-executable-find (command)
;; (with-venv (executable-find "python")))
;; )
(use-package lsp-ui
:straight t
:hook (lsp-mode . lsp-ui-mode)
:config
(setq lsp-ui-sideline-enable t)
(setq lsp-ui-sideline-show-diagnostics t)
(setq lsp-ui-sideline-show-hover t)
;; (setq lsp-ui-sideline-show-code-actions t)
(setq lsp-ui-peek-enable t)
(setq lsp-ui-peek-always-show t)
(setq lsp-ui-doc-enable t)
;; (setq lsp-ui-doc-delay 2)
(setq lsp-ui-doc-position 'bottom)
(setq lsp-ui-imenu-enable nil)
(lsp-ui-doc-show))
(use-package yaml-mode
:straight t
:defer t
:mode (
"\\.yaml\\'"
"\\.yml\\'"
)
)
(use-package markdown-mode
:straight t
:defer t
:mode ("\\.md\\'" "\\.MD\\'" "\\.md.template\\'")
)
(use-package julia-mode
:straight t
:defer t
:mode ("\\.jl\\'")
)
(use-package json-mode
:straight t
:mode (("\\.json\\'" . json-mode)
("\\.tmpl\\'" . json-mode)
("\\.eslintrc\\'" . json-mode))
:config (setq-default js-indent-level 4))
(use-package toml-mode
:straight t
:mode ("\\.toml\\'" . toml-mode))
(use-package dockerfile-mode
:straight t
:mode ("Dockerfile\\'" . dockerfile-mode))
(use-package rust-mode
:straight t
)
(use-package web-mode
:straight t
)
(use-package cmake-mode
:straight t
:mode "CMakeLists.txt")
(use-package gnuplot-mode
;; :defer t
:straight t
:mode ("\\.gnu\\'")
:init
(progn
(add-to-list 'auto-mode-alist '("\\.gnu\\'" . gnuplot-mode))
))
(use-package gitlab-ci-mode
:straight t
:defer t
:mode
("\\.gitlab-ci.yaml\\'"
"\\.gitlab-ci.yml\\'")
)
(use-package sphinx-doc
:straight t
;; :config
;; (add-hook 'python-mode-hook 'sphinx-doc-mode-hook)
)
config of pdftools: https://emacs.stackexchange.com/q/51283/8641
Some folding: https://staff.fnwi.uva.nl/p.vanormondt/blog/2021-02-13-emacs-init-file.html
(use-package tex-mode
:straight auctex
;; :defer t
:init
(progn
(setq TeX-auto-save t) ; Enable parse on save.
(setq TeX-parse-self t) ; Enable parse on load.
(setq-default TeX-master nil)
;; To compile documents to PDF by default
;; (setq TeX-PDF-mode t)
;; Activate folding mode
(add-hook `TeX-mode-hook (lambda ()
(TeX-fold-mode 1)))
;; getting pdftools to Preview-LaTeX
(setq TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
;; (setq TeX-view-program-selection '((output-pdf "PDF Tools")))
;; Use pdf-tools to open PDF files
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-source-correlate-start-server t)
;; Update PDF buffers after successful LaTeX runs
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
;; makefile support
(eval-after-load "tex" '(add-to-list 'TeX-command-list '("Make" "make" TeX-run-compile nil t)))
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
(setq reftex-enable-partial-scans t)
(setq reftex-save-parse-info t)
(setq reftex-use-multiple-selection-buffers t)
(setq bib-cite-use-reftex-view-crossref t)
)
;; :mode (
;; "\\.tex\\'"
;; "\\.TEX\\'"
;; "\\.bib\\'"
;; )
)
;; (use-package auctex-label-numbers
;; :straight t
;; :after latex
;; :config
;; (auctex-label-numbers-mode 1))
;; (use-package auctex-cont-latexmk
;; :after latex
;; :straight t
;; :bind
;; (:map LaTeX-mode-map
;; ("C-c k" . auctex-cont-latexmk-toggle)))
(with-eval-after-load "tex-mode"
(add-hook 'tex-mode-hook 'lsp)
(add-hook 'latex-mode-hook 'lsp))
(use-package lsp-ltex
:straight t
;; :hook (text-mode . (lambda ()
;; (require 'lsp-ltex)
;; (lsp))
;; ) ; or lsp-deferred
:init
(setq lsp-ltex-version "16.0.0") ; make sure you have set this, see below
)
;; ;; For bibtex
(with-eval-after-load "bibtex"
(add-hook 'bibtex-mode-hook 'lsp))
(use-package gscholar-bibtex
:straight t
;; :hook latex-mode
:config
(progn
(setq gscholar-bibtex-default-source "Google Scholar")
(defalias 'gbib 'gscholar-bibtex)
)
)
note: latex extra changes some default auctex shortcuts, so for the moment the hook is disabled
;; (use-package latex-extra
;; :straight t
;; ;; :hook (LaTeX-mode . latex-extra-mode)
;; )
(use-package pdf-tools
:if (memq window-system '(x))
:straight t
:magic ("%PDF" . pdf-view-mode)
:defer
:config
(progn
(pdf-tools-install :no-query) ;; :no-query
(add-hook 'pdf-view-mode-hook 'auto-revert-mode)
)
;; :mode (
;; "\\.PDF\\'"
;; "\\.pdf\\'"
;; )
)
https://github.com/minad/org-modern
(use-package org-modern
:straight t
:defer t
:init (progn
(add-hook 'org-mode-hook #'org-modern-mode)
(add-hook 'org-agenda-finalize-hook #'org-modern-agenda)
(setq
;; Edit settings
org-auto-align-tags nil
org-tags-column 0
org-catch-invisible-edits 'show-and-error
org-special-ctrl-a/e t
org-insert-heading-respect-content t
;; Org styling, hide markup etc.
org-hide-emphasis-markers t
org-pretty-entities t
org-ellipsis "…"
;; Agenda styling
org-agenda-tags-column 0
org-agenda-block-separator ?─
org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
org-agenda-current-time-string
"⭠ now ─────────────────────────────────────────────────")
)
)
(add-hook 'org-mode-hook #'visual-line-mode)
can’t get it to work with a single file yet
(use-package org-roam
:straight t
:custom
(org-roam-directory (file-truename "~/workspace/org-roam/"))
;; :hook (org-load . org-roam-mode)
;;:hook (org-roam-backlinks-mode . visual-line-mode)
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture)
;; Dailies
("C-c n j" . org-roam-dailies-capture-today))
:config
;; If you're using a vertical completion framework, you might want a more informative completion interface
(setq org-roam-node-display-template (concat "${title:*} " (propertized-buffer-identification "${tags:10}" 'face 'org-tag)))
(org-roam-db-autosync-mode)
;; If using org-roam-protocol
(require 'org-roam-protocol)
)
(use-package org-roam-ui
:straight t
:after org-roam ;; or :after org
;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have
;; a hookable mode anymore, you're advised to pick something yourself
;; if you don't care about startup time, use
;; :hook (after-init . org-roam-ui-mode)
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))
(use-package flycheck
:straight t
:defer t
:hook (lsp-mode . flycheck-mode)
)
(use-package consult-flycheck
:straight t
:defer t
;; :hook (flycheck-mode . consult-flycheck-mode)
)
(global-set-key (kbd "C-c h w") 'whitespace-mode)
(global-set-key (kbd "C-c h l") 'visual-line-mode)