- Emacs version: 28.2
function ne
emacsclient -ncu -a "" $argv &
end
;;==============;;
;; Melpa config ;;
;;==============;;
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
;; Update packages
(use-package auto-package-update
:ensure t
:init
(setq auto-package-update-delete-old-versions t
auto-package-update-interval 4)
(auto-package-update-maybe))
;; Save backups inside a unique folder
(let ((backup-dir "~/.emacs/.backups")
(auto-saves-dir "~/.emacs/.backups"))
(dolist (dir (list backup-dir auto-saves-dir))
(when (not (file-directory-p dir))
(make-directory dir t)))
(setq backup-directory-alist `(("." . ,backup-dir))
auto-save-file-name-transforms `((".*" ,auto-saves-dir t))
auto-save-list-file-prefix (concat auto-saves-dir ".saves-")
tramp-backup-directory-alist `((".*" . ,backup-dir))
tramp-auto-save-directory auto-saves-dir))
(setq backup-by-copying t ; Don't delink hardlinks
delete-old-versions t ; Clean up the backups
version-control t ; Use version numbers on backups,
kept-new-versions 10 ; keep some new versions
kept-old-versions 5) ; and some old ones, too
;; Use so long mode to avoid slowing down emacs when file is big
(global-so-long-mode 1) ; Emacs >= 27
;; Emacs server
(require 'server)
(server-start)
; (setq server-use-tcp t)
; (setq server-host "10.0.1.169")
; (setq server-port 6363)
;; Garbage collection
(use-package gcmh
:ensure t
:config
(setq gcmh-idle-delay 10 ; garbage collect after 10s of idle time
gcmh-high-cons-threshold 16777216) ; 16mb
(setq gc-cons-threshold 16777216
gc-cons-percentage 0.1)
(gcmh-mode +1))
;;=============;;
;; EMACS THEME ;;
;;=============;;
;; Camron theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/camron-theme.el")
(load-theme 'camron t)
;; Remove menu, tool and scroll bars
(menu-bar-mode -1)
(tool-bar-mode -1)
(add-hook 'after-make-frame-functions
(lambda (frame)
(modify-frame-parameters frame
'((vertical-scroll-bars . nil)
(horizontal-scroll-bars . nil)))))
;; Line number mode
(global-display-line-numbers-mode t)
(setq-default display-line-numbers-width 4)
;; (setq linum-format "%4d ") ; TODO: Find an alternative for this
;; Setup font
(add-to-list 'default-frame-alist '(font . "Hasklug Nerd Font 12"))
;; Icons mode
(use-package all-the-icons
:if (display-graphic-p)
:config
(setq all-the-icons-color-icons 11)
(setq inhibit-compacting-font-caches t))
;; Spaceline
(use-package spaceline
:ensure t
:config
(use-package spaceline-config
:config
(spaceline-spacemacs-theme)
(column-number-mode)))
;; Pretty mode
(use-package pretty-mode :ensure t)
;; Rainbow
(use-package rainbow-mode
:ensure t
:config
(define-globalized-minor-mode global-rainbow-mode rainbow-mode
(lambda () (rainbow-mode t)))
(global-rainbow-mode t))
;;=============;;
;; WHITESPACES ;;
;;=============;;
(require 'whitespace)
(setq whitespace-display-mappings
'((space-mark ?\ [?.] [?.])
(newline-mark ?\n [?◀ ?\n])
(tab-mark ?\t [?\u2502 ?\t] [?\\ ?\t])))
(setq whitespace-style '(face trailing tabs newline tab-mark newline-mark))
(global-whitespace-mode t)
(add-hook 'before-save-hook 'whitespace-cleanup)
;;=============;;
;; TABS ;;
;;=============;;
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(defvaralias 'c-basic-offset 'tab-width)
(use-package ligature
:ensure t
:config
;(ligature-set-ligatures '(web-mode) '("<!--" "-->" "</>" "</" "/>" "://"))
;(ligature-set-ligatures '(typescript-mode js2-mode) '("=>" "==" "===" "!=" "!==" "??" "||" "&&" "..." ">=" "<="))
(ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
"!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
"<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
"<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
"..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
"~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
"[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
"<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
"##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
"?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
"\\\\" "://"))
(global-ligature-mode))
(use-package flycheck
:ensure t
:config
(global-flycheck-mode))
(use-package company
:ensure t
:config
(add-hook 'after-init-hook 'global-company-mode)
(setq lsp-completion-provider :capf))
;; Trigger completion immediately.
(setq company-idle-delay 0)
;; Number the candidates (use M-1, M-2 etc to select completions).
(setq company-show-numbers t)
;;==========;;
;; LSP MODE ;;
;;==========;;
(use-package lsp-mode
:ensure t
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(web-mode . lsp)
(js2-mode . lsp)
(sh-mode . lsp)
(typescript-mode . lsp)
(rust-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
;; lsp ui
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode)
;; Front end modes
(use-package web-mode
:ensure t
:mode ("\\.html\\'"
"\\.css\\'"
"\\.vue\\'"
"\\.tsx\\'"
"\\.jsx\\'"
"\\.cjs\\'"
"\\.svelte\\'"))
;; Javascript
(use-package js2-mode
:ensure t
:mode "\\.js\\'"
:config
(setq js2-include-node-externs t)
(add-hook 'js2-mode-hook 'lsp)
)
;; Typescript
(use-package typescript-mode
:ensure t
:mode "\\.ts\\'")
(use-package json-mode
:ensure t
:mode "\\.json\\'"
:hook (json-mode . json-pretty-print-buffer))
(use-package fish-mode
:ensure t
:mode "\\.fish\\'")
(use-package rust-mode
:ensure t
:mode "\\.rs\\'")