18 KiB
18 KiB
Simponic's Settings
- image-types hack (thanks macos)
- Packages
- General emacs
- Theming
- Projectile
- Swiper, Ivy
- Neotree
- Org mode
- Development
- Multiple Cursors
image-types hack (thanks macos)
(setq image-types '(svg png gif tiff jpeg xpm xbm pbg))
Packages
Melpa
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
General emacs
Evil Mode!
(use-package evil
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump t)
(setq evil-shift-width 2)
(setq evil-cross-lines t)
(setq evil-respect-visual-line-mode t)
(setq evil-vsplit-window-below t)
(setq evil-split-window-below t)
(setq evil-undo-system 'undo-redo)
:config
(evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(add-hook 'evil-visual-activate-hook #'(lambda () (global-hl-line-mode 0) (message "Hello visual!")))
(add-hook 'evil-visual-deactivate-hook #'(lambda () (global-hl-line-mode 1)))
(setq evil-want-fine-undo t)
(evil-set-initial-state 'messages-buffer-mode 'normal))
t
Ring Bell Sound
(setq ring-bell-function 'ignore)
Tab bar mode
(defun my-tabbar-buffer-groups () ;; customize to show all normal files in one group
(list (cond ((string-equal "*" (substring (buffer-name) 0 1)) "emacs")
((eq major-mode 'dired-mode) "emacs")
(t "user"))))
(setq tabbar-buffer-groups-function 'my-tabbar-buffer-groups)
(tab-bar-mode)
Indentation
(setq default-tab-width 2
tab-width 2
indent-tabs-mode nil)
Line numbers
(setq display-line-numbers-type 'relative)
(global-display-line-numbers-mode)
Filesystem stuff
(setq auto-save-default nil
make-backup-files nil
create-lockfiles nil)
(global-auto-revert-mode t) ;; Change files on disk as they are updated
Move by whole line units not visually
(setq line-move-visual nil)
GUI stuff
(menu-bar-mode -1)
(setq inhibit-startup-screen t ;; Startup screen
frame-resize-pixelwise t) ;; Use 100% of window space
(defun do-frame-config ()
(tool-bar-mode -1) ;; System bar
(add-to-list 'default-frame-alist '(undecorated . t))
(set-fringe-mode '(1 . 1)) ;; Minimize arrows before and after wrapped lines by setting fringe to 1px
(toggle-scroll-bar -1))
(defun disable-scroll-bars (frame)
(modify-frame-parameters frame
'((vertical-scroll-bars . nil)
(horizontal-scroll-bars . nil))))
(when (display-graphic-p)
(do-frame-config)
(add-hook 'after-make-frame-functions 'disable-scroll-bars))
System path (macos)
(use-package exec-path-from-shell
:ensure t
:init
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
Fuzy Wuzzy
(use-package ivy
:ensure t)
(use-package counsel
:ensure t)
(ivy-mode 1)
(counsel-mode 1)
Electric Pair Mode
(electric-pair-mode)
(electric-quote-mode)
Theming
Line spacing
(setq line-spacing 0.24)
Highlight current line
(global-hl-line-mode)
Font
(let ((font "ZedMono Nerd Font-13:style=Regular"))
(set-face-attribute 'default nil :font font)
(set-frame-font font nil t))
;; This assumes you've installed the package via MELPA.
(use-package ligature
:config
;; Enable the "www" ligature in every possible major mode
(ligature-set-ligatures 't '("www"))
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Cascadia Code ligatures in programming modes
(ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
"!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
"<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
"<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
"..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
"~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
"[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
"<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
"##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
"?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
"\\\\" "://"))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
Highlight indent guides
(use-package :highlight-indent-guides
:ensure t
:config
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode))
Catppuccin and theme notify watcher
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic nil) ; if nil, italics is universally disabled
;; (load-theme 'doom-spacegrey t)
(load-theme 'doom-oceanic-next 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)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
t
;; (use-package catppuccin-theme
;; :ensure t)
;; (require 'filenotify)
;;
;; (setq *theme-file* "~/theme")
;; (defun set-system-theme ()
;; (let ((theme
;; (with-temp-buffer
;; (insert-file-contents *theme-file*)
;; (buffer-string)))
;; (current-flavor catppuccin-flavor))
;; (setq catppuccin-flavor (if (string-prefix-p "dark" theme) 'mocha 'latte))
;; (if (not (eq catppuccin-flavor current-flavor))
;; (catppuccin-reload))))
;;
;; (set-system-theme)
;; (file-notify-add-watch *theme-file* '(change)
;; #'(lambda (event) (set-system-theme)))
Doom-modeline
(use-package doom-modeline
:ensure t
:config
(doom-modeline-mode 1))
Icons
must run (all-the-icons-install-fonts)
and (nerd-fonts-install-fonts)
(use-package all-the-icons
:ensure t)
(use-package nerd-icons
:ensure t)
Projectile
(use-package projectile
:bind ("C-c p" . 'projectile-command-map)
:init (projectile-mode +1) (setq projectile-enable-caching t)
:ensure t)
Swiper, Ivy
(use-package counsel
:ensure t
:bind
("C-s" . 'swiper-isearch)
("M-x" . 'counsel-M-x)
:init
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(ivy-mode 1))
Neotree
(use-package neotree
:ensure t
:bind ("C-c j" . 'neotree-toggle)
:init
;; slow rendering
(setq inhibit-compacting-font-caches t)
;; set icons theme
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
;; Every time when the neotree window is opened, let it find current file and jump to node
(setq neo-smart-open t)
;; When running ‘projectile-switch-project’ (C-c p p), ‘neotree’ will change root automatically
(setq projectile-switch-project-action 'neotree-projectile-action)
(setq neo-window-width 35)
;; show hidden files
(setq-default neo-show-hidden-files t))
Org mode
General
(setq org-startup-indented t
org-html-postamble nil
org-html-preamble t)
Roam
(use-package org-roam
:straight t)
Babel
Elixir
(use-package ob-elixir
:ensure t)
JS
(require 'ob-js)
Load Languages
(org-babel-do-load-languages
'org-babel-load-languages
'((lisp . t)
(elixir . t)
(emacs-lisp . t)
(js . t)
(python . t)))
org-bullets
(use-package org-bullets
:ensure t
:init
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
org-appear
(use-package org-appear
:ensure t
:init
(add-hook 'org-mode-hook 'org-appear-mode))
Presentations
(use-package org-present
:ensure t
:straight '(org-present
:type git
:host github
:repo "rlister/org-present"))
Development
Git
(use-package magit :ensure t)
Autocomplete
(use-package auto-complete :ensure t)
(ac-config-default)
Company mode
(use-package company
:ensure t
:init
(global-company-mode t)
:bind (:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous))
:config
(setq company-idle-delay 0.3))
LSP Mode
(use-package which-key
:ensure t
:init (which-key-mode))
(defun lsp-booster--advice-json-parse (old-fn &rest args)
"Try to parse bytecode instead of json."
(or
(when (equal (following-char) ?#)
(let ((bytecode (read (current-buffer))))
(when (byte-code-function-p bytecode)
(funcall bytecode))))
(apply old-fn args)))
(advice-add (if (progn (require 'json)
(fboundp 'json-parse-buffer))
'json-parse-buffer
'json-read)
:around
#'lsp-booster--advice-json-parse)
(defun lsp-booster--advice-final-command (old-fn cmd &optional test?)
"Prepend emacs-lsp-booster command to lsp CMD."
(let ((orig-result (funcall old-fn cmd test?)))
(if (and (not test?) ;; for check lsp-server-present?
(not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper
lsp-use-plists
(not (functionp 'json-rpc-connection)) ;; native json-rpc
(executable-find "emacs-lsp-booster"))
(progn
(when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH)
(setcar orig-result command-from-exec-path))
(message "Using emacs-lsp-booster for %s!" orig-result)
(cons "emacs-lsp-booster" orig-result))
orig-result)))
(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)
(use-package company-lsp
:after (lsp-mode company))
(use-package lsp-mode
:ensure t
:init
(setq lsp-keymap-prefix "C-c l")
(setq lsp-file-watch-threshold 5000)
:hook ((python-ts-mode . lsp)
(elixir-mode . lsp)
(rust-mode . lsp)
(go-ts-mode . lsp)
(php-mode . lsp)
(c-mode . lsp)
(typescript-ts-mode . lsp)
(tsx-ts-mode . lsp)
(java-ts-mode . lsp)
(kotlin-ts-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:config
(setq lsp-ui-doc-enabled nil)
(setq read-process-output-max (* 1024 1024))
(setq gc-cons-threshold 100000000)
(setq lsp-enable-file-watchers nil)
:commands lsp)
Tree-Sitter
(use-package treesit-auto
:ensure t
:custom (treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
Languages
Python
(use-package python
:config
(defun python-info-current-defun () nil))
(use-package lsp-pyright
:ensure t
:custom (lsp-pyright-langserver-command "pyright") ;; or basedpyright
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp)))) ; or lsp-deferred
Common Lisp
Rainbow Parentheses
(use-package rainbow-delimiters :ensure t)
(add-hook 'lisp-mode-hook #'rainbow-delimiters-mode)
Slime
(use-package slime
:ensure t
:init
(setq inferior-lisp-program "sbcl"))
AC-Slime
(use-package ac-slime
:ensure t
:straight '(ac-slime
:type git
:host github
:repo "purcell/ac-slime"))
(add-hook 'slime-mode-hook 'set-up-slime-ac)
(add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'slime-repl-mode))
cl-indentify
;; roswell is in the AUR
;; ros install cl-indentify
(defun on-lisp-save-cl-indentify ()
(when (eq major-mode 'lisp-mode)
(shell-command
(format "~/.roswell/bin/cl-indentify -r %s" (buffer-file-name)))))
(add-hook 'after-save-hook
#'on-lisp-save-cl-indentify)
Elixir
(use-package elixir-mode
:ensure t
:hook ((before-save .
(lambda ()
(when (eq major-mode 'elixir-mode)
(elixir-format))))))
Rust
After installing the rust-analyzer
, the following can be used:
(use-package rust-mode
:ensure t)
(setq lsp-rust-server 'rust-analyzer)
Web Stuff
astro
(use-package astro-ts-mode
:ensure t)
;; note - do treesit-install-language-grammar astro @ https://github.com/virchau13/tree-sitter-astro
#+END_SR
**** Web Mode
#+BEGIN_SRC emacs-lisp
(setq web-mode-markup-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(use-package web-mode
:ensure t
:mode (("\\.scss\\'" . web-mode)
("\\.css\\'" . web-mode)
("\\.jsx\\'" . web-mode)
("\\.tsx\\'" . web-mode)
("\\.html\\'" . web-mode))
:commands web-mode)
Prisma
(use-package prisma-mode
:ensure t
:straight '(prisma-mode
:type git
:host github
:repo "pimeys/emacs-prisma-mode"))
Svelte
(use-package svelte-mode
:ensure t
:straight '(svelte-mode
:type git
:host github
:repo "leafOfTree/svelte-mode"))
Prettier
(use-package prettier-js
:ensure t)
(add-hook 'astro-ts-mode-hook 'prettier-js-mode)
(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'typescript-mode 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
Kotlin
(add-to-list 'treesit-language-source-alist '(kotlin . ("https://github.com/fwcd/tree-sitter-kotlin")))
(use-package kotlin-ts-mode
:straight (:host gitlab :repo "bricka/emacs-kotlin-ts-mode")
:mode "\\.kt\\'")
Java
(use-package lsp-java
:ensure t
:after lsp-mode
:config
(setq lsp-java-vmargs
(list
"-Xmx4G"
"-XX:+UseG1GC"
"-XX:+UseStringDeduplication"
"-javaagent:/Users/lizhunt/.emacs.d/lombok.jar"))
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.bemol\\'")
(setq lsp-java-project-resource-filters ["node_modules" ".metadata" "archetype-resources" "META-INF/maven" "runtime" "env"]))
(add-hook 'java-ts-mode-hook (lambda ()
(setq c-basic-offset 4
tab-width 4
indent-tabs-mode nil)))
PHP
(use-package php-mode
:ensure t)
Format All The Buffers
(use-package format-all
:bind (("C-c C-f" . format-all-region))
:ensure t)
;;(add-hook 'prog-mode-hook 'format-all-mode)
(add-hook 'astro-ts-mode-hook 'format-all-mode)
(add-hook 'format-all-mode-hook 'format-all-ensure-formatter)
Multiple Cursors
(use-package multiple-cursors
:straight t
:ensure t
:bind (("H-SPC" . set-rectangular-region-anchor)
("C-M-SPC" . set-rectangular-region-anchor)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C->" . mc/mark-all-like-this)
("C-c C-SPC" . mc/edit-lines)))