~ruther/emacs.d

85c54a0565e3bc44307fc653b3d99fdda2ce71be — Rutherther 2 months ago 711686d
chore: cleanup
1 files changed, 80 insertions(+), 202 deletions(-)

M init.el
M init.el => init.el +80 -202
@@ 171,48 171,6 @@
    (setq-local tab-width indent))
  (setq-local evil-shift-width tab-width))

;; This doesn't work. Why?
;; it's not a good approach, but I don't understand it!
;; (defmacro my/adjust-shift-widths (variable)
;;   `(let
;;       ((shift-width ,variable))
;;     (setq-local evil-shift-width shift-width)
;;     (setq-local tab-width shift-width)))

;; (defmacro my/add-hook-adjust-shift-widths (mode variable)
;;   `(add-hook
;;     (intern (concat (symbol-name ',mode) "-hook"))
;;     (lambda (&rest args) (my/adjust-shift-widths ,variable))))

;; ENV
(my-use-package exec-path-from-shell
  :ensure t
  :demand t
  :custom
  (exec-path-from-shell-shell-name (getenv "SHELL"))
                                        ; (exec-path-from-shell-arguments "-l -i") ; Set by default for bash, zsh etc.
  (exec-path-from-shell-variables
   '("PATH"
     "MANPATH"
     "INFOPATH"
     "CXX"
     "CC"
     "XDG_CONFIG_HOME"
     "XDG_CACHE_HOME"
     "XDG_DATA_HOME"
     "NIX_PATH"
     "GUILE_LOAD_PATH"
     "GUILE_LOAD_COMPILED_PATH"))
  :config
  (setenv "SHLVL" "0")
  (unless (or (memq system-type '(windows-nt android)) (getenv "EMACS_NO_SHELL_ENV"))
    (message "Setting up environment from shell")
    (exec-path-from-shell-initialize))
  ;; This is for Matlab + my WM without reparenting.
  ;; This cannot be sourced from the env, as the script that adds
  ;; this environment, is not part of shell initialization
  (setenv "_JAVA_AWT_WM_NONREPARENTING" "1"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                            KEYS                                       ;;


@@ 1019,11 977,6 @@
   "]t" '(hl-todo-next :wk "previous TODO" :jump t)
   "[t" '(hl-todo-previous :wk "next TODO" :jump t)))

;; (my-use-package magit-todos
;;   :ensure t
;;   :after magit
;;   :config (magit-todos-mode 1))

(my-use-package git-gutter-fringe
  :ensure t
  :preface


@@ 1070,8 1023,7 @@
      [("gtb" "blame current revision" git-timemachine-blame)
        ("gtc" "show commit" git-timemachine-show-commit)
        ("?" "show help" git-timemachine-help)
        ("q" "quit" git-timemachine-quit)]])
  )
        ("q" "quit" git-timemachine-quit)]]))

;; Editing
(my-use-package flycheck


@@ 1177,27 1129,6 @@
  (:map project-prefix-map
    ("c" . projection-multi-compile)))

;; (my-use-package run-command
;;   :ensure t
;;   :custom
;;   (run-command-default-runner 'run-command-runner-eat)
;;   :general
;;   (my-leader
;;     "c" '(run-command :wk "Run command"))
;;   :config
;;   (defun run-command-recipe-example ()
;;   (list
;;    ;; Run A simple command
;;    (list :command-name "say-hello"
;;          :command-line "echo Hello, World!"))))


;; MMM mode
;; (my-use-package mmm-mode
;;   :ensure t
;;   :config
;;   (setq mmm-global-mode 'maybe))

(my-use-package corfu
  :ensure t
  :demand t


@@ 1267,31 1198,6 @@
  :config
  (yas-global-mode))

(my-use-package gendoxy
  :ensure (gendoxy :type git :host gitlab :repo "mp81ss_repo/gendoxy")
  :custom
  (cc-search-directories '("." "../src" "../include" "/usr/include" "/usr/local/include/*"))
  :general
  ;; TODO: figure out how to merge these into one call
  (my-local-leader c-ts-mode-map
    "d h" '(gendoxy-tag :wk "Gendoxy header")
    "d t" '(gendoxy-tag :wk "Gendoxy tag")
    "d T" '(gendoxy-tag-header :wk "Gendoxy tag header")
    "d g" '(gendoxy-group :wk "Gendoxy group")
    "d G" '(gendoxy-group-header :wk "Gendoxy group header")
    "d s" '(gendoxy-group-start :wk "Gendoxy group start")
    "d e" '(gendoxy-group-end :wk "Gendoxy group end")
    "o"   '(ff-find-related-file :wk "Find other file"))
  (my-local-leader c-mode-map
    "d h" '(gendoxy-tag :wk "Gendoxy header")
    "d t" '(gendoxy-tag :wk "Gendoxy tag")
    "d T" '(gendoxy-tag-header :wk "Gendoxy tag header")
    "d g" '(gendoxy-group :wk "Gendoxy group")
    "d G" '(gendoxy-group-header :wk "Gendoxy group header")
    "d s" '(gendoxy-group-start :wk "Gendoxy group start")
    "d e" '(gendoxy-group-end :wk "Gendoxy group end")
    "o"   '(ff-find-related-file :wk "Find other file")))

(my-use-package jsonrpc
  :ensure t)



@@ 1346,7 1252,7 @@
  (agent-shell-prefer-viewport-interaction t)
  ;; Command setup
  (agent-shell-google-gemini-command
   '("~/.local/bin/gemini" "--experimental-acp" "--model" "gemini-2.5-pro"))
   '("~/.local/bin/gemini" "--experimental-acp" "--model" "gemini-3.1-pro"))
  (agent-shell-anthropic-claude-command
   '("~/.local/bin/claude-agent-acp"))
  ;; Auth


@@ 1357,11 1263,6 @@
  (agent-shell-openai-authentication
   (agent-shell-openai-make-authentication :login t)))

(my-use-package agent-review
  :ensure (agent-review :type git
                        :host github
                        :repo "nineluj/agent-review"))

(my-use-package lsp-mode
  :ensure t
  :commands (lsp lsp-mode)


@@ 1493,18 1394,6 @@
  (org-log-into-drawer t)
  (org-todo-keywords '((sequence "TODO(t)" "|" "CANCEL(c!)" "DONE(d!)"))))

;; PDF tools
(my-use-package pdf-tools
  :ensure nil ;; TODO: how to manage this?
              ;; I have this package installed via
              ;; my distribution. To get the executables
              ;; properly
  :hook
  (doc-view-mode . (lambda () (display-line-numbers-mode -1)))
  (pdf-view-mode . (lambda () (display-line-numbers-mode -1)))
  :mode ("\\.pdf\\'" . pdf-view-mode)
  :commands pdf-view-mode)

;; Treesit langs
(use-package ts-fold
  :ensure (ts-fold :type git :host github :repo "emacs-tree-sitter/ts-fold"))


@@ 1664,49 1553,38 @@ minibuffer, even without explicitly focusing it."
  (my/indent-variable-mode-alist-add python-mode python-indent-offset)
  (my/indent-variable-mode-alist-add python-ts-mode python-indent-offset))

;; Julia
(my-use-package julia-mode
  :ensure t)

(use-package julia-snail
  :ensure t
  :custom
  (julia-snail-terminal-type :eat)
  :hook
  (julia-mode . julia-snail-mode))

(my-use-package vhdl-mode
  :ensure nil
  :commands vhdl-mode
  :after lsp-mode
  ;; :mode
  ;; Use vhdl-ts-mode instead
  ;; ("\\.vhdl?\\'" . vhdl-mode)
  :general
  (my-local-leader vhdl-mode-map
    "a" '(nil :wk "Alignment")
    "a a" '(vhdl-align-group :wk "Align group")
    "a c" '(vhdl-align-inline-comment-group :wk "Align comment group"))
  :hook
   ((vhdl-mode . vhdl-electric-mode)
    (vhdl-mode . vhdl-stutter-mode))
  :custom
  (vhdl-clock-edge-condition 'function)
  (vhdl-clock-name "clk_i")
  (vhdl-reset-kind 'sync)
  (vhdl-reset-name "rst_in")
  (vhdl-basic-offset 2)
  (vhdl-end-comment-column 300)
  :config
  (my/indent-variable-mode-alist-add vhdl-mode vhdl-basic-offset)
;; (my-use-package vhdl-mode
;;   :ensure nil
;;   :commands vhdl-mode
;;   :after lsp-mode
;;   ;; :mode
;;   ;; Use vhdl-ts-mode instead
;;   ;; ("\\.vhdl?\\'" . vhdl-mode)
;;   :general
;;   (my-local-leader vhdl-mode-map
;;     "a" '(nil :wk "Alignment")
;;     "a a" '(vhdl-align-group :wk "Align group")
;;     "a c" '(vhdl-align-inline-comment-group :wk "Align comment group"))
;;   :hook
;;    ((vhdl-mode . vhdl-electric-mode)
;;     (vhdl-mode . vhdl-stutter-mode))
;;   :custom
;;   (vhdl-clock-edge-condition 'function)
;;   (vhdl-clock-name "clk_i")
;;   (vhdl-reset-kind 'sync)
;;   (vhdl-reset-name "rst_in")
;;   (vhdl-basic-offset 2)
;;   (vhdl-end-comment-column 300)
;;   :config
;;   (my/indent-variable-mode-alist-add vhdl-mode vhdl-basic-offset)


  (defun my/electric-space-not-in-strings (fun &rest args)
    (if (vhdl-in-string-p)
        (apply 'self-insert-command args)
      (apply fun args)))
;;   (defun my/electric-space-not-in-strings (fun &rest args)
;;     (if (vhdl-in-string-p)
;;         (apply 'self-insert-command args)
;;       (apply fun args)))

  (advice-add 'vhdl-electric-space :around #'my/electric-space-not-in-strings))
;;   (advice-add 'vhdl-electric-space :around #'my/electric-space-not-in-strings))

(my-use-package slint-mode
  :ensure t


@@ 1719,55 1597,55 @@ minibuffer, even without explicitly focusing it."
  ("\\.tsx\\'" . tsx-ts-mode)
  ("\\.ts\\'" . typescript-mode))

(my-use-package vhdl-ts-mode
  :ensure (:host github :repo "gmlarumbe/vhdl-ts-mode")
  :demand t
  ;; :after vhdl-mode
  :general
  (my-local-leader vhdl-ts-mode-map
    "f" '(nil :wk "Formatting")
    "f f" '(my/vhdl-ts/beautify-block-at-point :wk "Beautify block at point")
    "f b" '(my/vhdl-ts/beautify-buffer :wk "Beautify buffer"))
  :custom
  (vhdl-ts-indent-level tab-width)
  :mode
  ("\\.vhdl?\\'" . vhdl-ts-mode)
  :init
  (defun my/vhdl-ts/beautify-block-at-point ()
    (interactive)
    (vhdl-align-group)
    (vhdl-ts-beautify-block-at-point))

  (defun my/vhdl-ts/beautify-buffer ()
    (interactive)
    (vhdl-align-buffer)
    (vhdl-ts-beautify-block-at-point))
  :config
  (my/indent-variable-mode-alist-add vhdl-ts-mode vhdl-ts-indent-level)

  (defun my/vhdl-ts-special-node-identifier-name (node)
    "Return identifier name of NODE."
    (let (temp-node)
      (when node
        (cond ((string-match vhdl-ts-instance-re (treesit-node-type node))
              (cond ((setq temp-node (treesit-search-subtree node "\\_<component_instantiation\\_>"))
                      (treesit-node-text (treesit-node-child-by-field-name temp-node "component") :no-prop))
                    ((setq temp-node (treesit-search-subtree node "entity_instantiation"))
                      (treesit-search-subtree node "entity_instantiation")
                      (treesit-node-text (treesit-node-child temp-node 1) :no-props))
                    (t (error "Unexpected component_instantiation_statement subnode!"))))
              (t nil)))))

  (defun my/vhdl-ts-node-identifier-name (orig node)
    (when-let ((original-identifier-name (orig node)))
      (let* ((special-identifier-name (my/vhdl-ts-special-node-identifier-name node))
            (concat-identifier-name
              (when special-identifier-name
                (concat ": " special-identifier-name))))
        (concat original-identifier-name concat-identifier-name))))

  ;; (advice-add 'vhdl-ts--node-identifier-name :around #'my/vhdl-ts-node-identifier-name)
  )
;; (my-use-package vhdl-ts-mode
;;   :ensure (:host github :repo "gmlarumbe/vhdl-ts-mode")
;;   :demand t
;;   ;; :after vhdl-mode
;;   :general
;;   (my-local-leader vhdl-ts-mode-map
;;     "f" '(nil :wk "Formatting")
;;     "f f" '(my/vhdl-ts/beautify-block-at-point :wk "Beautify block at point")
;;     "f b" '(my/vhdl-ts/beautify-buffer :wk "Beautify buffer"))
;;   :custom
;;   (vhdl-ts-indent-level tab-width)
;;   :mode
;;   ("\\.vhdl?\\'" . vhdl-ts-mode)
;;   :init
;;   (defun my/vhdl-ts/beautify-block-at-point ()
;;     (interactive)
;;     (vhdl-align-group)
;;     (vhdl-ts-beautify-block-at-point))

;;   (defun my/vhdl-ts/beautify-buffer ()
;;     (interactive)
;;     (vhdl-align-buffer)
;;     (vhdl-ts-beautify-block-at-point))
;;   :config
;;   (my/indent-variable-mode-alist-add vhdl-ts-mode vhdl-ts-indent-level)

;;   (defun my/vhdl-ts-special-node-identifier-name (node)
;;     "Return identifier name of NODE."
;;     (let (temp-node)
;;       (when node
;;         (cond ((string-match vhdl-ts-instance-re (treesit-node-type node))
;;               (cond ((setq temp-node (treesit-search-subtree node "\\_<component_instantiation\\_>"))
;;                       (treesit-node-text (treesit-node-child-by-field-name temp-node "component") :no-prop))
;;                     ((setq temp-node (treesit-search-subtree node "entity_instantiation"))
;;                       (treesit-search-subtree node "entity_instantiation")
;;                       (treesit-node-text (treesit-node-child temp-node 1) :no-props))
;;                     (t (error "Unexpected component_instantiation_statement subnode!"))))
;;               (t nil)))))

;;   (defun my/vhdl-ts-node-identifier-name (orig node)
;;     (when-let ((original-identifier-name (orig node)))
;;       (let* ((special-identifier-name (my/vhdl-ts-special-node-identifier-name node))
;;             (concat-identifier-name
;;               (when special-identifier-name
;;                 (concat ": " special-identifier-name))))
;;         (concat original-identifier-name concat-identifier-name))))

;;   ;; (advice-add 'vhdl-ts--node-identifier-name :around #'my/vhdl-ts-node-identifier-name)
;;   )

;; (my-use-package hydra
;;   :ensure t)