mirror of https://github.com/Chizi123/.emacs.d.git

Joel Grunbaum
2024-02-14 46132dcf362f3da63ffa1d8573dc5995d8e7e767
config.org
@@ -22,48 +22,36 @@
Theme switcher, using a cond allows loading of many preconfigured themes which can be switched between easily.
Zenburn theme is my default.
#+BEGIN_SRC emacs-lisp
  (setq emacs-theme 'zenburn)
  (defun disable-all-themes ()
    (dolist (i custom-enabled-themes)
      (disable-theme i)))
  (cond ((eq emacs-theme 'zenburn)
         (use-package zenburn-theme
           :init
           (disable-all-themes)
           :config
           (load-theme 'zenburn t)))
        ((eq emacs-theme 'doom-one)
         (use-package doom-themes
           :init
           (disable-all-themes)
           :config
           (setq doom-themes-enable-bolt t
                 doom-themes-enable-italic t)
           (load-theme 'doom-one t)
           (doom-themes-visual-bell-config)
           (doom-themes-org-config)))
        ((eq emacs-theme 'nord)
         (use-package nord-theme
           :init
           (disable-all-themes)
           :config
           (load-theme 'nord t)))
        ((eq emacs-theme 'solarized)
         (use-package solarized-theme
           :init
           (disable-all-themes)
           :config
           (load-theme 'solarized-dark t)))
        ((eq emacs-theme 'jetbrains-darcula)
         (use-package jetbrains-darcula-theme
           :init
           (disable-all-themes)
           :config
           (load-theme 'jetbrains-darcula t)))
        ((eq emacs-theme 'none)
         (disable-all-themes)))
  (defun set-theme (theme)
    "Set the theme with theme downloading"
    (interactive "SWhat theme to load? ")
    (cond ((eq theme 'zenburn)
           (use-package zenburn-theme))
          ((string-match-p "^doom" "doom-one")
           (use-package doom-themes
             :config
             (setq doom-themes-enable-bolt t
                   doom-themes-enable-italic t)
             (doom-themes-visual-bell-config)
             (doom-themes-org-config)))
          ((eq theme 'nord)
           (use-package nord-theme))
          ((eq theme 'solarized)
           (use-package solarized-theme))
          ((eq theme 'jetbrains-darcula)
           (use-package jetbrains-darcula-theme))
          ((eq theme 'none)
           (disable-all-themes)))
    (setq emacs-theme theme)
    (when (not (eq theme 'none))
      (load-theme theme t))
    (message (format "Theme set to: %s" theme)))
  (set-theme 'zenburn)
#+END_SRC
** Default font
@@ -104,25 +92,16 @@
Use aspell for spellchecking. 
Auto-enable in latex and org as they're the main writing modes.
#+BEGIN_SRC emacs-lisp
  ;; (require 'ispell)
  ;; (setq-default ispell-program-name "aspell")
  ;; (setq-default ispell-local-dictionary "en_AU")
  ;; (add-hook 'tex-mode-hook 'flyspell-mode)
  ;; (add-hook 'latex-mode-hook 'flyspell-mode)
  ;; (add-hook 'TeX-mode-hook 'flyspell-mode)
  ;; (add-hook 'LaTeX-mode-hook 'flyspell-mode)
  ;; (add-hook 'latex-mode-hook 'flyspell-buffer)
  ;; (add-hook 'org-mode-hook 'flyspell-mode)
  ;; (add-hook 'org-mode-hook 'flyspell-buffer)
  ;; (diminish 'flyspell-mode)
  (use-package flyspell
    :hook (tex-mode latex-mode TeX-mode LaTeX-mode org-mode)
    :hook ((tex-mode latex-mode TeX-mode LaTeX-mode org-mode text-mode) . flyspell-mode)
    :diminish flyspell-mode
    :init
    (require 'ispell)
    :config
    (setq-default ispell-program-name "aspell")
    (setq-default ispell-local-dictionary "en_AU"))
#+END_SRC
** COMMENT Language Tool
** Language Tool
Language tool is an open source grammar checker.
#+BEGIN_SRC emacs-lisp
  (use-package langtool
@@ -178,23 +157,23 @@
** Helm core
Helm aids the user interface for emacs. Adds visual and auto-complete feedback for emacs commands.
#+BEGIN_SRC emacs-lisp
  (use-package helm-config
    :ensure helm
  (use-package helm
    :bind (("M-x" . helm-M-x)
           ("C-x C-f" . helm-find-files)
           ("M-y" . helm-show-kill-ring)
           ("C-x b" . helm-mini)
           ("C-c h o" . helm-occur))
    :diminish helm-mode
    :config
    (setq helm-M-x-fuzzy-match t)
    (setq helm-buffers-fuzzy-matching t
          helm-recentf-fuzzy-match    t)
    (setq helm-split-window-in-side-p           t ; open helm buffer inside current window, not occupy whole other window
    (setq helm-mode-fuzzy-match                 t
          helm-completion-in-regionfuzzy-match  t
          helm-split-window-inside-p            t ; open helm buffer inside current window, not occupy whole other window
          helm-move-to-line-cycle-in-source     t ; move to end or beginning of source when reaching top or bottom of source.
          helm-ff-search-library-in-sexp        t ; search for library in `require' and `declare-function' sexp.
          helm-scroll-amount                    8 ; scroll 8 lines other window using M-<next>/M-<prior>
          helm-ff-file-name-history-use-recentf t
          helm-echo-input-in-header-line t)
          helm-echo-input-in-header-line        t
          completion-styles                     '(flex))
    (defun spacemacs//helm-hide-minibuffer-maybe ()
      "Hide minibuffer in Helm session if we use the header line as input field."
      (when (with-helm-buffer helm-echo-input-in-header-line)
@@ -208,7 +187,12 @@
              'spacemacs//helm-hide-minibuffer-maybe)
    (helm-mode 1))
#+END_SRC
*** Helm git
Give helm git awareness.
#+BEGIN_SRC emacs-lisp
  (use-package helm-ls-git
    :bind (("C-x C-d" . helm-browse-project)))
#+END_SRC
** Projectile
Projectile is project management framework for emacs.
Helps in navigation and management of projects.
@@ -421,6 +405,14 @@
  (global-set-key (kbd "C-c e i") 'init-visit)
#+END_SRC
*** Go to early-init.el
#+BEGIN_SRC emacs-lisp
  (defun early-init-visit ()
    (interactive)
    (find-file "~/.emacs.d/early-init.el"))
  (global-set-key (kbd "C-c e e") 'early-init-visit)
#+END_SRC
*** Reload configuration
#+BEGIN_SRC emacs-lisp
  (defun config-reload ()
@@ -519,6 +511,8 @@
  (use-package undo-tree
    :diminish undo-tree-mode
    :config
    (setq-default undo-tree-auto-save-history t)
    (add-to-list 'undo-tree-incompatible-major-modes 'archive-mode)
    (global-undo-tree-mode))
#+END_SRC
@@ -567,7 +561,9 @@
** Line numbers
Everyone needs line numbers when programming.
#+BEGIN_SRC emacs-lisp
  (add-hook 'prog-mode-hook 'linum-mode)
  (if (version<= "26.0.50" emacs-version)
      (add-hook 'prog-mode-hook 'display-line-numbers-mode)
    (add-hook 'prog-mode-hook 'linum-mode))
#+END_SRC
** Garbage collection
@@ -714,6 +710,12 @@
  (use-package highlight-indentation
    :hook (prog-mode . highlight-indentation-mode))
#+END_SRC
** Auto revert mode
Update unchanged buffers if underlying file changes.
#+BEGIN_SRC emacs-lisp
  (global-auto-revert-mode)
#+END_SRC
* Mode line tweaks
Diminish is used but is included in init.el such that it can be used throughout this document
** Spaceline
@@ -724,7 +726,6 @@
    (require 'spaceline-config)
    (setq spaceline-buffer-encoding-abbrev-p t)
    (setq spaceline-line-column-p t)
    (setq spaceline-line-p t)
    (setq powerline-default-separator (quote arrow))
    (spaceline-spacemacs-theme)
    (spaceline-helm-mode))
@@ -800,7 +801,8 @@
             rust-mode
             sh-mode
             ;; verilog-mode
             go-mode) . lsp))
             go-mode
             python-mode) . lsp))
    :init
    (setq lsp-keymap-prefix "C-c l")
    :commands lsp
@@ -809,7 +811,8 @@
    (setq read-process-output-max (* 1024 1024))
    (setq lsp-completion-provider :capf)
    (setq lsp-keep-workspace-alive 'nil)
    (add-to-list 'exec-path "~/.cargo/bin"))
    (add-to-list 'exec-path "~/.cargo/bin")
    (add-to-list 'exec-path "~/.local/bin"))
  (use-package lsp-ui
    :commands lsp-ui-mode)
@@ -905,7 +908,7 @@
  (add-hook 'magit-process-prompt-functions
            #'magit-process-general-yn-prompt-hook)
#+END_SRC
*** Gerrit integration
*** COMMENT Gerrit integration
Gerrit takes ~origin:refs/for/master~ as a destination.
Enable magit to work with its oddities.
#+BEGIN_SRC emacs-lisp
@@ -958,6 +961,18 @@
           ("M-RET" . 'srefactor-refactor-at-point)
           :map c++-mode-map
           ("M-RET" . 'srefactor-refactor-at-point)))
#+END_SRC
** Tree sitter
Parser library.
Provides better syntax highlighting and some other neat features.
#+BEGIN_SRC emacs-lisp
  (use-package tree-sitter
    :diminish t)
  (use-package tree-sitter-langs
    :config
    (global-tree-sitter-mode)
    (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
#+END_SRC
** Language specific configs
@@ -1027,16 +1042,20 @@
        (setq-local clang-format-style nil)
      (setq-local clang-format-style (concat "{BasedOnStyle: LLVM,"
                                             "IndentWidth: " (format "%s" tab-width) ","
                                             "TabWidth: " (format "%s" tab-width) ","
                                             "UseTab: " (if (eq indent-tabs-mode nil)
                                                            "Never"
                                                          "AlignWithSpaces")
                                             ","
                                             "BreakBeforeBraces: Linux,"
                                             "AllowShortIfStatementsOnASingleLine: false,"
                                             "IndentCaseLabels: false}"))))
                                             "PointerAlignment: Left,"
                                             "IndentCaseBlocks: true,"
                                             "IndentCaseLabels: false,"
                                             "SortUsingDeclarations: true}"))))
  (add-hook 'c-mode-common-hook 'set-clang-format-style)
  (use-package clang-format
    :hook (c-mode-common . (set-clang-format-style)))
  (use-package clang-format)
  ;;   (defun clang-format-on-save ()
  ;;     (add-hook 'before-save-hook 'clang-format-buffer nil t))
@@ -1076,6 +1095,7 @@
#+BEGIN_SRC emacs-lisp
  (use-package tex
    :ensure auctex
    :straight auctex
    :config
    (setq TeX-auto-save t
          TeX-parse-self t
@@ -1153,11 +1173,11 @@
    (cond ((eq system-type 'windows-nt)
           (when (file-exists-p "c:/ProgramData/chocolatey/lib/plantuml/tools/plantuml.jar")
             (setq plantuml-jar-path "c:/ProgramData/chocolatey/lib/plantuml/tools/plantuml.jar")
             (setq planuml-default-exec-mode 'jar)))
             (setq plantuml-default-exec-mode 'jar)))
          ((eq system-type 'gnu/linux)
           (when (file-exists-p "/usr/share/java/plantuml/plantuml.jar")
             (setq plantuml-jar-path "/usr/share/java/plantuml/plantuml.jar")
             (setq planuml-default-exec-mode 'jar)))))
             (setq plantuml-default-exec-mode 'jar)))))
#+END_SRC
*** COMMENT Racket
@@ -1206,12 +1226,34 @@
                  verilog-indent-level-directive 4
                  verilog-indent-level-module 4))
#+END_SRC
**** FPGA
#+BEGIN_SRC emacs-lisp
  (use-package fpga
    :init
    (setq fpga-feature-list '(xilinx)))
#+END_SRC
*** COMMENT MATLAB
**** Run and test
Run the open buffer and display the output in a new buffer.
#+BEGIN_SRC emacs-lisp
  (defun run-verilator ()
    (interactive)
    (save-buffer)
    (if (not (eq (shell-command (concat "verilator --binary -j 0 " (buffer-file-name)) "*verilator output*") 0))
        (display-buffer "*verilator output*" 'display-buffer-reuse-window)
      (shell-command (concat (file-name-directory (buffer-file-name))
                             '"obj_dir/V"
                             (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))
                     "*test output*")
      (display-buffer "*test output*" 'display-buffer-reuse-window))
    t)
  (define-key verilog-mode-map (kbd "C-c c") 'run-verilator)
#+END_SRC
*** MATLAB
Mode for editing MATLAB m-files.
#+BEGIN_SRC emacs-lisp
  (use-package matlab
    :ensure matlab-mode
    :straight matlab-mode
    :config
    (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
    (add-to-list
@@ -1219,7 +1261,8 @@
     '("\\.m$" . matlab-mode))
    (setq matlab-indent-function t)
    (setq matlab-shell-command "matlab")
    (matlab-cedet-setup))
    (matlab-cedet-setup)
    (add-to-list 'company-backends 'company-matlab-shell))
#+END_SRC
*** COMMENT MIPS
@@ -1279,14 +1322,16 @@
#+BEGIN_SRC emacs-lisp
  (use-package company-go)
#+END_SRC
* Org mode
** Up to date org
Pull the latest org mode from the repository, rather than the org which comes with emacs.
*** Python
**** LSP server
Use pyright, idk why.
#+BEGIN_SRC emacs-lisp
  (use-package org
    :ensure org-contrib)
  (use-package lsp-pyright
    :config
    (add-to-list 'lsp-disabled-clients 'pyls)
    (add-to-list 'lsp-enabled-clients 'jedi))
#+END_SRC
* Org mode
** Small tweaks
Small quality of life changes to org-mode.
#+BEGIN_SRC emacs-lisp
@@ -1367,7 +1412,8 @@
Call pandoc on org buffer from org export.
Need to add ~#+OPTIONS: H:99~ to enable large level header exports.
#+BEGIN_SRC emacs-lisp
  (use-package ox-pandoc)
  (when (executable-find "pandoc")
    (use-package ox-pandoc))
#+END_SRC
*** COMMENT Dokuwiki Wiki
@@ -1382,6 +1428,7 @@
#+BEGIN_SRC emacs-lisp
  (use-package emms-setup
    :ensure emms
    :straight emms
    :init
    (add-to-list 'load-path "~/elisp/emms/")
    :config