Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(setq-default c-basic-offset 8
c-default-style "k&r"
tab-width 8
indent-tabs-mode t)
(setq-default python-basic-offset 8
tab-width 8
indent-tabs-mode nil)
(add-hook 'html-mode-hook
(lambda ()
;; Default indentation is usually 2 spaces, changing to 4.
(set (make-local-variable 'sgml-basic-offset) 4)))
(defun html-show-toc ()
"Shows a TOC based on headings tags <H[1-6]>"
(interactive)
(if sgml-tags-invisible
(error "SGML tags are invisible")
(occur "<h[1-6]>")
(pop-to-buffer "*Occur*")
(vc-toggle-read-only)
(goto-char (point-min))
(replace-string "<h1>" "")
(goto-char (point-min))
(replace-string "<h2>" " ")
(goto-char (point-min))
(replace-string "<h3>" " ")
(goto-char (point-min))
(replace-string "<h4>" " ")
(goto-char (point-min))
(replace-string "<h5>" " ")
(goto-char (point-min))
(replace-string "<h6>" " ")
(goto-char (point-min))
(replace-regexp "</h[1-6]>" "")
(goto-char (point-min))
(toggle-read-only 1)))
(defun html-end-of-line ()
"If there is an HTML tag at the end of the line, then go to start of tag.
Otherwise go to the real end of the line."
(interactive)
(if (or (looking-at ".*>$") ; if we're on a line that ends with a tag
(and (= (char-before) 62)
(= (point) (save-excursion
(end-of-line)
(point))))) ; or we're at the end of a line
; with a tag
(let ((where-now (point)))
(narrow-to-region
(save-excursion
(beginning-of-line)
(point))
(save-excursion
(end-of-line)
(point)))
(end-of-line)
(re-search-backward "<" nil t)
(if (= (point) where-now)
(end-of-line))
(widen))
(end-of-line)))
(add-hook 'html-helper-mode-hook
(lambda ()
(define-key html-helper-mode-map "\C-e" 'html-end-of-line)))
;; Instea of putting *~ backups in current directory,
;; put them in local .saves
(setq backup-directory-alist `(("." . ".saves")))
;; Just to stop spamming backup files
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(menu-bar-mode -1)
;; (menu-bar--display-line-numbers-mode-visual) ; <- relative
;; (menu-bar--display-line-numbers-mode-relative) ; <- relative
(menu-bar--display-line-numbers-mode-absolute)
;; This fixes an annoying issue of the left line number
;; sliding right when we get into bigger digits. Let's hope
;; I don't open a file with >99,999 lines.
(setq display-line-numbers-width-start 5)
(setq display-line-numbers-grow-only t)
(setq display-line-numbers-minor-tick 100)
;; enable the line mode globally
(global-display-line-numbers-mode)
(setq redisplay-dont-pause t
scroll-margin 1
scroll-step 1
scroll-conservatively 10000
scroll-preserve-screen-position 1)
(setq ring-bell-function 'ignore)
(add-hook 'org-mode-hook '(lambda () (setq fill-column 80)))
(add-hook 'org-mode-hook 'turn-on-auto-
9E88
fill)
(require 'autopair)
(autopair-global-mode)
(global-set-key (kbd "<f1>") 'shell)
(show-paren-mode 1)
(setq show-paren-delay 0)
(setq org-html-validation-link nil)
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <left>") 'windmove-left)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key [remap goto-line] 'goto-line-preview)
(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.
'(company-tooltip ((t (:background "black" :foreground "white"))))
'(company-tooltip-selection ((t (:background "plum1" :foreground "black"))))
'(highlight ((t (:background "plum1" :foreground "black"))))
'(italic ((t (:slant italic)))))
;; Give emacs some RAW power, yes
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024)) ;; 1mb
(setq lsp-log-io nil) ; if set to true can cause a performance hit
;; don't want to have copilot mode enabled by default
(setq lsp-copilot-enabled nil)
;; (setq lsp-copilot-applicable-fn nil)
;; (setq lsp-copilot-applicable-fn (-const nil)) ;; doesn't work
(setq lsp-copilot-applicable-fn (lambda (&rest _) lsp-copilot-enabled))
;; Configure LSP-UI by https://emacs-lsp.github.io/lsp-ui/
;; Optional - provides fancier overlays.
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode)
;; Sideline options
(setq lsp-ui-sideline-show-diagnostics t)
(setq lsp-ui-sideline-show-hover nil)
(setq lsp-ui-sideline-show-code-actions t)
(setq lsp-ui-sideline-update-mode nil)
(setq lsp-clients-clangd-args '("--header-insertion-decorators=0"))
(require 'rjsx-mode)
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . rjsx-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . rjsx-mode))
(use-package lsp-mode
:hook ((go-mode . lsp)
(rust-mode . lsp)
(c++-mode . lsp)
(c-mode . lsp)
(js-mode . lsp)
(html-mode . lsp)
(python-mode . lsp)
(haskell-mode . lsp)
(elm-mode . lsp)
(js-mode . lsp)
(ruby-mode . lsp)
;; (sh-mode . lsp)
(rjsx-mode . lsp)
(zig-mode . lsp)
(css-mode . lsp)
(java-mode . lsp)
(css-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
(use-package lsp-pyright
:ensure t
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp)))) ; or lsp-deferred
(setq lsp-keymap-prefix "C-c l")
(global-set-key (kbd "C-c f") 'lsp-find-definition)
(global-set-key (kbd "C-c b") 'lsp-find-references)
;; Optional - provides snippet support.
(use-package yasnippet
:ensure t
:commands yas-minor-mode
:hook ((go-mode . yas-minor-mode)
(css-mode . yas-minor-mode)
(c++-mode . yas-minor-mode)))
;; Set up before-save hooks to format buffer and add/delete imports.
;; Make sure you don't have other gofmt/goimports hooks enabled.
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
(lsp-register-custom-settings
'(("gopls.completeUnimported" t t)
("gopls.staticcheck" t t)))
;;Company mode is a standard completion package that works well with lsp-mode.
;;company-lsp integrates company mode completion with lsp-mode.
;;completion-at-point also works out of the box but doesn't support snippets.
(use-package company
:ensure t
:config
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 1)
:bind ("M-<tab>" . company-complete))
(use-package company-lsp
:ensure t
:commands company-lsp)
;; (require 'company-box)
;; (add-hook 'company-mode-hook 'company-box-mode)
;; Set the python interpreter right to ARM python3
;; (setq python-shell-interpreter "/opt/homebrew/Caskroom/miniconda/base/envs/naked-snake/bin/python3.9")
;; (setq lsp-pyright-python-executable-cmd python-shell-interpreter)
(lsp-register-custom-settings
`(("python.pythonPath" "/opt/homebrew/bin/python3")))
(setq lsp-ui-doc-enable t)
(setq lsp-ui-doc-delay 0.1)
(setq lsp-ui-doc-header nil)
(setq lsp-ui-doc-show-with-cursor t)
(setq lsp-ui-doc-show-with-mouse t)
;; Add the zig lsp mode executable path for zls
(setq lsp-zig-zls-executable "/Users/thecsw/gits/zls/zig-out/bin/zls")
;; Enable dashboard
(require 'dashboard)
;; Add the hook
(dashboard-setup-startup-hook)
;; Set the dashboard as the default buffer
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
;; Set the title
(setq dashboard-banner-logo-title "Sandy's Emacs")
;; Set the banner
(setq dashboard-startup-banner 'logo)
(setq dashboard-show-shortcuts nil)
(setq dashboard-week-agenda nil)
(setq dashboard-items '((recents . 5)
(projects . 5)))
(setq dashboard-set-heading-icons t)
Press C-x g
to open magit
(global-set-key (kbd "C-x g") 'magit-status)
;; Default to ssh when using tramp
(setq tramp-default-method "ssh")
;; I like lush and use it by default
(load-theme 'lush t)
(setq org-capture-templates
'(("c" "Cookbook" entry (file "~/org/cookbook.org")
"%(org-chef-get-recipe-from-url)"
:empty-lines 1)
("m" "Manual Cookbook" entry (file "~/org/cookbook.org")
"* %^{Recipe title: }\n :PROPERTIES:\n :source-url:\n :servings:\n :prep-time:\n :cook-time:\n :ready-in:\n :END:\n** Ingredients\n %?\n** Directions\n\n")))
(setq org-startup-folded t)
;; Add the Unicode bullets package
(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
;; Add timestamp when marked DONE
(setq org-log-done 'time)
;; Use org-ref
(setenv "PATH" (
F438
concat (getenv "PATH") ":/Library/TeX/texbin"))
(setenv "PATH" (concat (getenv "PATH") ":/Users/thecsw/Library/Python/3.9/bin"))
(setenv "PATH" (concat (getenv "PATH") ":/Users/thecsw/.nvm/versions/node/v22.13.1/bin"))
(require 'org)
(require 'ox-latex)
(define-key org-mode-map (kbd "C-c ]") 'org-ref-insert-cite-link)
(require 'bibtex)
(setq bibtex-autokey-year-length 4
bibtex-autokey-name-year-separator "-"
bibtex-autokey-year-title-separator "-"
bibtex-autokey-titleword-separator "-"
bibtex-autokey-titlewords 2
bibtex-autokey-titlewords-stretch 1
bibtex-autokey-titleword-length 5
org-ref-bibtex-hydra-key-binding (kbd "H-b"))
(define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-hydra/body)
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)
(setq org-latex-custom-lang-environments
'(
(emacs-lisp "common-lispcode")
))
(setq org-latex-minted-options
'(("frame" "lines")
("fontsize" "\\footnotesize")
;; ("linenos" "")
("obeytabs" "")
("mathescape" "")
("numbersep" "5pt")
("numbersep" "2mm")
("xleftmargin" "0.25in")))
;; Build nonstopmode with xelatex
(setq org-latex-pdf-process
'("xelatex -shell-escape -8bit -interaction nonstopmode -output-directory %o %b %f"
"bibtex %b"
"makeindex %b"
"xelatex -shell-escape -8bit -interaction nonstopmode -output-directory %o %b %f"
"xelatex -shell-escape -8bit -interaction nonstopmode -output-directory %o %b %f"))
(setq org-src-fontify-natively t)
(org-babel-do-load-languages
'org-babel-load-languages
'((R . t)
(latex . t)))
(setf (nth 4 org-emphasis-regexp-components) 10)
(load-library "org")
;; Press C-c c to open git-messenge
(global-set-key (kbd "C-c c") 'git-messenger:popup-message)
(custom-set-variables
'(git-messenger:use-magit-popup t))
(setq olivetti-body-width 80)
; (add-hook 'after-init-hook #'global-emojify-mode)
(global-set-key (kbd "<f5>") #'deadgrep)
(global-anzu-mode +1)
(put 'narrow-to-region 'disabled nil)
(which-key-mode)
(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(add-hook 'gemini-mode-hook '(lambda () (setq fill-column 80)))
(add-hook 'gemini-mode-hook 'turn-on-auto-fill)
(setq org-highlight-latex-and-related '(latex script entities))
(add-to-list 'org-latex-classes
'("sandy-article"
"\\documentclass[12pt]{article}
\\usepackage{graphicx}
\\usepackage{grffile}
\\usepackage{longtable}
\\usepackage{wrapfig}
\\usepackage{rotating}
\\usepackage[normalem]{ulem}
\\usepackage{amsmath}
\\usepackage{textcomp}
\\usepackage{amssymb}
\\usepackage{capt-of}
\\usepackage{hyperref}
\\usepackage{minted}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{setspace}
\\usepackage{subcaption}
\\usepackage{mathtools}
\\usepackage{xfrac}
%\\usepackage{geometry}
\\usepackage[left=1.4in, right=1.4in, bottom=1in]{geometry}
\\usepackage{marginnote}
\\usepackage[utf8]{inputenc}
\\usepackage{color}
\\usepackage{epsf}
\\usepackage{tikz}
\\usepackage{graphicx}
\\usepackage{pslatex}
\\usepackage{hyperref}
%\\usepackage{beton}
%\\usepackage{euler}
%\\usepackage[OT1]{fontenc}
%\\usepackage[T1]{fontenc}
%\\usepackage{newpxtext,eulerpx}
\\usepackage[p]{scholax}
\\usepackage[scaled=1.075,ncf,vvarbb]{newtxmath}
% this fixes wack monospace fonts and issues
\\usepackage[nomath,variablett]{lmodern}
\\usepackage{textgreek}
\\renewcommand*{\\textgreekfontmap}{%
{phv/*/*}{LGR/neohellenic/*/*}%
{*/b/n}{LGR/artemisia/b/n}%
{*/bx/n}{LGR/artemisia/bx/n}%
{*/*/n}{LGR/artemisia/m/n}%
{*/b/it}{LGR/artemisia/b/it}%
{*/bx/it}{LGR/artemisia/bx/it}%
{*/*/it}{LGR/artemisia/m/it}%
{*/b/sl}{LGR/artemisia/b/sl}%
{*/bx/sl}{LGR/artemisia/bx/sl}%
{*/*/sl}{LGR/artemisia/m/sl}%
{*/*/sc}{LGR/artemisia/m/sc}%
{*/*/sco}{LGR/artemisia/m/sco}%
}
\\makeatletter
\\newcommand*{\\rom}[1]{\\expandafter\\@slowromancap\\romannumeral #1@}
\\makeatother
\\DeclarePairedDelimiterX{\\infdivx}[2]{(}{)}{%
#1\\;\\delimsize\\|\\;#2%
}
\\newcommand{\\infdiv}{D\\infdivx}
\\DeclarePairedDelimiter{\\norm}{\\left\\lVert}{\\right\\rVert}
\\DeclarePairedDelimiter{\\ceil}{\\left\\lceil}{\\right\\rceil}
\\DeclarePairedDelimiter{\\floor}{\\left\\lfloor}{\\right\\rfloor}
\\def\\Z{\\mathbb Z}
\\def\\R{\\mathbb R}
\\def\\C{\\mathbb C}
\\def\\N{\\mathbb N}
\\def\\Q{\\mathbb Q}
\\def\\noi{\\noindent}
\\onehalfspace
\\usemintedstyle{bw}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
;;;(set-frame-font "InputMono 10" nil t)
(set-face-attribute 'default nil :height 130)
(add-hook 'after-init-hook 'global-color-identifiers-mode)
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
;; ---------------------------------------------------------------------
;; GNU Emacs / N Λ N O - Emacs made simple
;; Copyright (C) 2020 - N Λ N O developers
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; ---------------------------------------------------------------------
(setq default-frame-alist
(append (list
'(font . "MonacoB:size=13")
;; '(font . "Roboto Mono Emacs Regular:size=14")
'(min-height . 1) '(height . 40)
'(min-width . 1) '(width . 95)
'(vertical-scroll-bars . nil)
'(internal-border-width . 30)
'(left-fringe . 0)
'(right-fringe . 0)
'(tool-bar-lines . 0)
'(menu-bar-lines . 0))))
;; on OSX, type the line below (in terminal) to get a 1 pixel border
;; defaults write com.apple.universalaccess increaseContrast -bool YES
;; To control anti-aliasing on OSX:
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 0 (none)
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 1 (light)
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 2 (medium)
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 3 (strong)
;; Fix bug on OSX in term mode & zsh (spurious % after each command)
(add-hook 'term-mode-hook
(lambda () (setq buffer-display-table (make-display-table))))
(setq inhibit-startup-screen t
inhibit-startup-message t
inhibit-startup-echo-area-message t
initial-scratch-message nil)
(tool-bar-mode 0)
(tooltip-mode 0)
(menu-bar-mode 0)
;; (global-hl-line-mode 1)
(setq x-underline-at-descent-line t)
;; Vertical window divider
(setq window-divider-default-right-width 3)
(setq window-divider-default-places 'right-only)
(window-divider-mode 1)
;; No ugly button for checkboxes
(setq widget-image-enable nil)
;; Hide org markup for README
(setq org-hide-emphasis-markers t)
(add-hook 'org-mode-hook 'org-fragtog-mode)
(ctrlf-mode +1)
(global-hl-line-mode +1)
(setq package-native-compile t)
;;(native-compile-async "~/.emacs.d/elpa" 'recursively) ;; <-- danger zone
(require 'telephone-line)
(setq telephone-line-primary-left-separator 'telephone-line-cubed-left
telephone-line-secondary-left-separator 'telephone-line-cubed-hollow-left
telephone-line-primary-right-separator 'telephone-line-cubed-right
telephone-line-secondary-right-separator 'telephone-line-cubed-hollow-right)
(setq telephone-line-primary-right-separator 'telephone-line-abs-left
telephone-line-secondary-right-separator 'telephone-line-abs-hollow-left)
(setq telephone-line-height 20
telephone-line-evil-use-short-tag t)
(telephone-line-mode 1)
;; (powerline-nano-theme)
(setq neo-smart-open t)
(global-set-key [f8] 'neotree-toggle)
(setq neo-global--do-autorefresh t)
(setq neo-window-width 37)
(setq neo-window-fixed-size nil)
(setq neo-smart-open t)
(setq neo-window-position 'right)
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
;; Enable richer annotations using the Marginalia package
(use-package marginalia
;; 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))
(all-the-icons-completion-mode)
;; Use https://github.com/iyefrat/all-the-icons-completion for icons
(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)
;; Enable Vertico.
(use-package vertico
:custom
(vertico-scroll-margin 0) ;; Different scroll margin
(vertico-count 7) ;; Show more candidates
;; (vertico-resize t) ;; Grow and shrink the Vertico minibuffer
(vertico-cycle t) ;; Enable cycling for `vertico-next/previous'
:init
(vertico-mode))
;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))
;; Emacs minibuffer configurations.
(use-package emacs
:custom
;; Support opening new minibuffers from inside existing minibuffers.
(enable-recursive-minibuffers t)
;; Hide commands in M-x which do not work in the current mode. Vertico
;; commands are hidden in normal buffers. This setting is useful beyond
;; Vertico.
(read-extended-command-predicate #'command-completion-default-include-p)
;; Do not allow the cursor in the minibuffer prompt
(minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt)))
(require 'centaur-tabs)
(centaur-tabs-mode t)
(global-set-key (kbd "C-<prior>") 'centaur-tabs-backward)
(global-set-key (kbd "C-<next>") 'centaur-tabs-forward)
(centaur-tabs-headline-match)
(setq centaur-tabs-style "box")
(setq centaur-tabs-height 20)
(setq centaur-tabs-set-icons t)
(setq centaur-tabs-set-bar 'under)
(setq x-underline-at-descent-line t)
(setq centaur-tabs-set-modified-marker t)
(setq centaur-tabs-show-navigation-buttons t)
(setq centaur-tabs-set-modified-marker t)
(setq centaur-tabs-modified-marker "*")
(setq centaur-tabs-close-button " ×")
(global-set-key (kbd "C-/") 'undo-only)
(global-set-key (kbd "C-?") 'undo-redo)
;; (global-undo-tree-mode)
;; (add-to-list 'load-path (expand-file-name "/Users/thecsw/.emacs.d/elpa/origami-20200331.1019/origami.el/"))
(global-origami-mode)
(bind-key "C-c g" 'origami-open-all-nodes)
(bind-key "C-c r" 'origami-close-all-nodes)
(bind-key "C-c t" 'origami-recursively-toggle-node)
(bind-key "C-c n" 'origami-next-fold)
(bind-key "C-c u" 'origami-previous-fold)
(setq max-lisp-eval-depth 10000)
(setq max-specpdl-size 10000)
;; We use copilot.el and not the LSP-provided one.
(setq lsp-copilot-enabled nil)
(global-set-key (kbd "M-RET") 'copilot-accept-completion)
(global-set-key (kbd "M-]") 'copilot-next-completion)
(global-set-key (kbd "M-[") 'copilot-previous-completion)
(define-key dired-mode-map (kbd "h") #'dired-gitignore-mode)
;; (add-hook 'dired-mode-hook 'dired-gitignore-mode)
(require 'difftastic)
;; Add commands to a `magit-difftastic'
(eval-after-load 'magit-diff
'(transient-append-suffix 'magit-diff '(-1 -1)
[("D" "Difftastic diff (dwim)" difftastic-magit-diff)
("S" "Difftastic show" difftastic-magit-show)]))
(add-hook 'magit-blame-read-only-mode-hook
(lambda ()
(keymap-set magit-blame-read-only-mode-map
"D" #'difftastic-magit-show)
(keymap-set magit-blame-read-only-mode-map
"S" #'difftastic-magit-show)))
(global-set-key (kbd "C-x c") 'writegood-mode)