276 lines
9.0 KiB
EmacsLisp
276 lines
9.0 KiB
EmacsLisp
;;;; Appearance
|
|
|
|
(defun apply-appearance ()
|
|
;; Set theme
|
|
(load-theme 'my-theme +1)
|
|
;; Hide GTK scroll bar
|
|
(toggle-scroll-bar -1))
|
|
|
|
(apply-appearance)
|
|
(add-hook 'after-make-frame-functions
|
|
(lambda (frame)
|
|
(with-selected-frame frame
|
|
(apply-appearance))))
|
|
|
|
;; Hide ribbon, menu bar
|
|
(menu-bar-mode -1)
|
|
(tool-bar-mode -1)
|
|
|
|
;; Show colum number in status bar
|
|
(column-number-mode +1)
|
|
|
|
;; Show line numbers
|
|
(global-display-line-numbers-mode +1)
|
|
|
|
;; Highlight current line
|
|
(global-hl-line-mode +1)
|
|
|
|
;; Replace yes/no prompts with y/n prompts
|
|
(fset #'yes-or-no-p #'y-or-n-p)
|
|
|
|
;; Fix jumpy scrolling
|
|
(setq mouse-wheel-scroll-amount '(3 ((shift) . 1))
|
|
mouse-wheel-progressive-speed nil
|
|
mouse-wheel-follow-mouse +1
|
|
scroll-step 1) ;; C-n C-p scroll step
|
|
|
|
;; Tabs
|
|
(setq custom-tab-width 2)
|
|
|
|
;; Highlight matching parens faster
|
|
(setq show-paren-delay 0)
|
|
|
|
(defun disable-tabs ()
|
|
(indent-tabs-mode -1))
|
|
(defun enable-tabs ()
|
|
(local-set-key (kbd "TAB") 'tab-to-tab-stop)
|
|
(indent-tabs-mode +1)
|
|
(setq tab-width custom-tab-width))
|
|
|
|
(add-hook 'prog-mode-hook 'enable-tabs)
|
|
(add-hook 'lisp-mode-hook 'disable-tabs)
|
|
(add-hook 'emacs-lisp-mode-hook 'disable-tabs)
|
|
|
|
;;;; Packages (straight.el)
|
|
|
|
(defvar bootstrap-version)
|
|
(let ((bootstrap-file
|
|
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
|
|
(bootstrap-version 6))
|
|
(unless (file-exists-p bootstrap-file)
|
|
(with-current-buffer
|
|
(url-retrieve-synchronously
|
|
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
|
|
'silent 'inhibit-cookies)
|
|
(goto-char (point-max))
|
|
(eval-print-last-sexp)))
|
|
(load bootstrap-file nil 'nomessage))
|
|
|
|
(setq straight-disable-native-compile t)
|
|
|
|
;; Use-Package
|
|
(straight-use-package 'use-package)
|
|
(setq straight-use-package-by-default t)
|
|
|
|
;; Avy (jump to char)
|
|
(use-package avy
|
|
:bind (("C-;" . avy-goto-char)
|
|
("C-:" . avy-goto-word-1)
|
|
("M-g g" . avy-goto-line)))
|
|
|
|
;; Magit (git frontend)
|
|
(use-package magit)
|
|
|
|
;; Rainbow-Mode (show hex strings in color)
|
|
(use-package rainbow-mode)
|
|
|
|
;; Vertico (completion helper)
|
|
(use-package vertico
|
|
:config
|
|
(vertico-mode))
|
|
|
|
;; Editorconfig support
|
|
(use-package editorconfig
|
|
:config
|
|
(editorconfig-mode 1))
|
|
|
|
;; Remove trailing whitespace
|
|
(use-package ws-butler
|
|
:config
|
|
(add-hook 'prog-mode-hook #'ws-butler-mode))
|
|
|
|
;; Code folding
|
|
(use-package ts-fold
|
|
:straight (ts-fold :type git :host github :repo "emacs-tree-sitter/ts-fold"))
|
|
|
|
;; Markdown
|
|
(use-package markdown-mode
|
|
:init
|
|
(setq markdown-fontify-code-blocks-natively t))
|
|
|
|
;; Treesitter
|
|
(use-package tree-sitter
|
|
:config
|
|
(use-package tree-sitter-langs
|
|
:config
|
|
(tree-sitter-require 'rust)
|
|
(tree-sitter-require 'java)
|
|
(tree-sitter-require 'nix))
|
|
(add-hook 'tree-sitter-after-on-hook #'ts-fold-mode)
|
|
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
|
|
(global-tree-sitter-mode +1))
|
|
|
|
;; Rust support
|
|
(use-package rustic)
|
|
|
|
;; Nix support
|
|
(use-package nix-mode
|
|
:mode "\\.nix\\'")
|
|
|
|
;; Evil (Vim Emulation)
|
|
(use-package evil
|
|
:init
|
|
(setq evil-want-C-u-scroll t
|
|
evil-mode-beyond-eol t
|
|
evil-mode-fine-undo t
|
|
evil-default-state 'emacs
|
|
evil-undo-system 'undo-redo)
|
|
:config
|
|
(add-hook 'evil-local-mode-hook (lambda ()
|
|
(setq-local interprogram-cut-function nil)
|
|
(setq-local interprogram-paste-function nil)))
|
|
(evil-set-initial-state 'prog-mode 'normal)
|
|
(evil-set-initial-state 'text-mode 'normal)
|
|
(evil-mode +1))
|
|
|
|
;; Treesitter based navigation
|
|
(use-package evil-textobj-tree-sitter
|
|
:config
|
|
(let ((define-scope (lambda (key outer inner)
|
|
(define-key evil-outer-text-objects-map key outer)
|
|
(define-key evil-inner-text-objects-map key inner)))
|
|
(define-jumps (lambda (key name)
|
|
(let ((key key) (name name))
|
|
(define-key evil-normal-state-map (kbd (concat "]" key))
|
|
`(lambda () (interactive)
|
|
(evil-textobj-tree-sitter-goto-textobj (concat ',name ".outer"))))
|
|
(define-key evil-normal-state-map (kbd (concat "[" key))
|
|
`(lambda () (interactive)
|
|
(evil-textobj-tree-sitter-goto-textobj (concat ',name ".outer") t)))
|
|
(define-key evil-normal-state-map (kbd (concat "]" (upcase key)))
|
|
`(lambda () (interactive)
|
|
(evil-textobj-tree-sitter-goto-textobj (concat ',name ".outer") nil t)))
|
|
(define-key evil-normal-state-map (kbd (concat "[" (upcase key)))
|
|
`(lambda () (interactive)
|
|
(evil-textobj-tree-sitter-goto-textobj (concat ',name ".outer") t t)))))
|
|
))
|
|
;; Define new scope symbols for use with i and a
|
|
(funcall define-scope "c"
|
|
(evil-textobj-tree-sitter-get-textobj "class.outer")
|
|
(evil-textobj-tree-sitter-get-textobj "class.inner"))
|
|
(funcall define-scope "f"
|
|
(evil-textobj-tree-sitter-get-textobj "function.outer")
|
|
(evil-textobj-tree-sitter-get-textobj "function.inner"))
|
|
|
|
;; Define jumps with ] and [
|
|
(funcall define-jumps "c" "class")
|
|
(funcall define-jumps "f" "function")))
|
|
|
|
;; Highlight operations
|
|
(use-package evil-goggles
|
|
:init
|
|
(setq evil-goggles-duration 0.15)
|
|
:config
|
|
(evil-goggles-mode +1))
|
|
|
|
;; Project
|
|
(use-package projectile
|
|
:config
|
|
(define-key prog-mode-map (kbd "C-c p") 'projectile-command-map)
|
|
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
|
|
(projectile-mode +1))
|
|
|
|
;; File tree (+ related integrations)
|
|
(use-package treemacs
|
|
:init
|
|
(setq treemacs-tag-follow-delay 0.5)
|
|
:config
|
|
(treemacs-resize-icons 15)
|
|
(treemacs-follow-mode +1)
|
|
(treemacs-tag-follow-mode +1)
|
|
(treemacs-project-follow-mode +1))
|
|
(use-package treemacs-evil)
|
|
(use-package treemacs-projectile)
|
|
(use-package treemacs-magit)
|
|
|
|
;; Explanations for keybindings
|
|
(use-package which-key
|
|
:config
|
|
(which-key-mode +1))
|
|
|
|
;; On the fly syntax checking
|
|
(use-package flycheck)
|
|
|
|
;; Completions
|
|
(use-package company
|
|
:init
|
|
(setq company-minimum-prefix-length 1
|
|
company-idle-delay 0
|
|
company-selection-wrap-around t
|
|
company-tooltip-align-annotations t
|
|
company-tooltip-flip-when-above t
|
|
company-tooltip-margin 0
|
|
company-show-quick-access 'right)
|
|
:config
|
|
(setq company-transformers '(delete-consecutive-dups
|
|
company-sort-prefer-same-case-prefix
|
|
company-sort-by-backend-importance
|
|
company-sort-by-occurrence))
|
|
(define-key company-active-map (kbd "<return>") nil)
|
|
(define-key company-active-map (kbd "RET") nil)
|
|
(define-key company-active-map (kbd "M-`") #'company-complete-selection)
|
|
(define-key company-active-map (kbd "M-n") #'company-select-next)
|
|
(define-key company-active-map (kbd "M-p") #'company-select-previous)
|
|
(define-key company-active-map (kbd "M-j") #'company-select-next)
|
|
(define-key company-active-map (kbd "M-k") #'company-select-previous)
|
|
(global-company-mode +1))
|
|
|
|
;; Fuzzy forawrd search in completions
|
|
(setq completion-styles '(flex basic))
|
|
|
|
;; Lsp
|
|
(use-package lsp-mode
|
|
:init
|
|
(setq lsp-headerline-breadcrumb-enable nil
|
|
lsp-signature-auto-activate nil
|
|
lsp-signature-doc-lines 0)
|
|
:config
|
|
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
|
|
(add-hook 'evil-insert-state-entry-hook #'lsp-signature-activate)
|
|
(add-hook 'evil-insert-state-exit-hook #'lsp-signature-stop))
|
|
(use-package lsp-ui
|
|
:init
|
|
(setq lsp-ui-doc-show-with-cursor t
|
|
lsp-ui-doc-position 'top
|
|
lsp-ui-doc-delay 0.5)
|
|
:config
|
|
(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
|
|
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)
|
|
(define-key evil-normal-state-map (kbd "SPC l d") #'lsp-ui-peek-find-definitions)
|
|
(define-key evil-normal-state-map (kbd "SPC l u") #'lsp-ui-peek-find-references)
|
|
(define-key evil-normal-state-map (kbd "SPC l r") #'lsp-rename)
|
|
(define-key evil-normal-state-map (kbd "SPC l a") #'lsp-execute-code-action)
|
|
(define-key evil-normal-state-map (kbd "SPC l = =") #'lsp-format-buffer)
|
|
(define-key evil-normal-state-map (kbd "SPC l = r") #'lsp-format-region)
|
|
(define-key evil-normal-state-map (kbd "SPC l s q") #'lsp-workspace-shutdown)
|
|
(define-key evil-normal-state-map (kbd "SPC l s r") #'lsp-workspace-restart)
|
|
;; Controls inside references popup
|
|
(define-key lsp-ui-peek-mode-map (kbd "j") #'lsp-ui-peek--select-next)
|
|
(define-key lsp-ui-peek-mode-map (kbd "k") #'lsp-ui-peek--select-prev)
|
|
(define-key lsp-ui-peek-mode-map (kbd "J") #'lsp-ui-peek--select-next-file)
|
|
(define-key lsp-ui-peek-mode-map (kbd "K") #'lsp-ui-peek--select-prev-file)
|
|
(define-key lsp-ui-peek-mode-map (kbd "o") #'lsp-ui-peek--goto-xref))
|
|
(use-package lsp-treemacs)
|
|
(setq gc-cons-threshold (* 1024 1024 100)
|
|
read-process-output-max (* 1024 1024))
|