mirror of
https://codeberg.org/andyscott/dotfiles.git
synced 2024-11-13 15:50:50 -05:00
330 lines
8.4 KiB
EmacsLisp
330 lines
8.4 KiB
EmacsLisp
;; No thanks
|
|
(setq inhibit-startup-message t) ; Disable startup message
|
|
(scroll-bar-mode -1) ; Disable visible scrollbar
|
|
(tool-bar-mode -1) ; Disable the toolbar
|
|
(tooltip-mode -1) ; Disable tooltips
|
|
(set-fringe-mode 10) ; Give some breathing room
|
|
(menu-bar-mode -1) ; Disable the menu bar
|
|
(setq-default custom-file null-device) ; Write customizations not in this file to the null device (AKA stop littering in my init.el)
|
|
|
|
;; Visible bell
|
|
(setq visible-bell t)
|
|
|
|
; Font
|
|
(set-face-attribute 'default nil :font "Hack" :height 120)
|
|
|
|
;; Make ESC quit prompts
|
|
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
|
|
|
|
;; paren/bracket pairs
|
|
(show-paren-mode t)
|
|
(setq-default show-paren-style 'parenthesis)
|
|
(electric-pair-mode 1)
|
|
|
|
;; Profile emacs startup
|
|
(add-hook 'emacs-startup-hook
|
|
(lambda ()
|
|
(message "*** Emacs loaded in %s with %d garbage collections."
|
|
(format "%.2f seconds"
|
|
(float-time
|
|
(time-subtract after-init-time before-init-time)))
|
|
gcs-done)))
|
|
|
|
;; Change the user-emacs-directory to keep ~/.emacs.d clean
|
|
(setq user-emacs-directory (expand-file-name "~/.cache/emacs/")
|
|
url-history-file (expand-file-name "url/history" user-emacs-directory))
|
|
|
|
;; No annoying Windows errors
|
|
(set-default-coding-systems 'utf-8)
|
|
|
|
;; Improved scrolling
|
|
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
|
|
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
|
|
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
|
|
(setq scroll-step 1) ;; keyboard scroll one line at a time
|
|
|
|
;; Tabs
|
|
(setq-default indent-tabs-mode nil)
|
|
(setq-default tab-width 4)
|
|
(setq indent-line-function 'insert-tab)
|
|
|
|
;;Line numbers
|
|
(setq column-number-mode t)
|
|
(dolist (mode '(text-mode-hook
|
|
prog-mode-hook
|
|
conf-mode-hook))
|
|
(add-hook mode (lambda () (display-line-numbers-mode 1))))
|
|
|
|
;; Show vertical line at column 80 to keep code clean in prog-mode
|
|
(setq-default fill-column 80)
|
|
(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)
|
|
|
|
; Override some modes which derive from the above
|
|
(dolist (mode '(org-mode-hook))
|
|
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
|
|
|
;; Initialize package sources
|
|
(require 'package)
|
|
|
|
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
|
("org" . "https://orgmode.org/elpa/")
|
|
("elpa" . "https://elpa.gnu.org/packages/")))
|
|
|
|
(package-initialize)
|
|
(unless package-archive-contents
|
|
(package-refresh-contents))
|
|
|
|
;; Initialize use-package on non-Linux platforms
|
|
(unless (package-installed-p 'use-package)
|
|
(package-install 'use-package))
|
|
|
|
(require 'use-package)
|
|
(setq use-package-always-ensure t)
|
|
|
|
;;; Packages
|
|
|
|
;; Theme
|
|
(setq custom-safe-themes t)
|
|
|
|
(use-package doom-themes
|
|
:config
|
|
(setq doom-themes-enable-bold t
|
|
doom-themes-enable-italic t)
|
|
(load-theme 'doom-gruvbox)
|
|
(doom-themes-visual-bell-config)
|
|
(setq doom-themes-treemacs-theme "doom-colors")
|
|
(doom-themes-treemacs-config)
|
|
(doom-themes-org-config))
|
|
|
|
;(use-package gruvbox-theme
|
|
; :init
|
|
; (load-theme 'gruvbox-dark-medium t))
|
|
|
|
;; Make grey look nicer
|
|
(use-package solaire-mode
|
|
:diminish
|
|
:init
|
|
(solaire-global-mode))
|
|
|
|
;; Icons
|
|
(use-package all-the-icons)
|
|
|
|
;; Modeline
|
|
(use-package minions
|
|
:hook (doom-modeline-mode . minions-mode))
|
|
|
|
(use-package doom-modeline
|
|
:init (doom-modeline-mode)
|
|
:custom-face
|
|
(mode-line ((t (:height 0.8))))
|
|
(mode-line-inactive ((t (:height 0.75))))
|
|
:custom
|
|
(doom-modeline-height 30)
|
|
(doom-modeline-bar-width 4)
|
|
(doom-modeline-window-width-limit fill-column)
|
|
(doom-modeline-lsp t)
|
|
(doom-modeline-minor-modes t)
|
|
(doom-modeline-persp-name nil)
|
|
(doom-modeline-buffer-file-name-style 'truncate-upto-project)
|
|
(doom-modeline-major-mode-icon t)
|
|
(doom-modeline-major-mode-color-icon t)
|
|
(doom-modeline-enable-word-count t)
|
|
(doom-modeline-env-version t)
|
|
(doom-modeline-env-load-string "..."))
|
|
|
|
;; Don't remind me about some minor modes
|
|
(use-package diminish)
|
|
|
|
;; Automatically set paths to the new user-emacs-directory
|
|
(use-package no-littering)
|
|
|
|
;; Automatically clean whitespace
|
|
(use-package ws-butler
|
|
:diminish
|
|
:hook ((text-mode . ws-butler-mode)
|
|
(prog-mode . ws-butler-mode)))
|
|
|
|
;; Overview of keybindings available based on prefix keys
|
|
(use-package which-key
|
|
:init (which-key-mode)
|
|
:config
|
|
(setq which-key-idle-delay 0.3))
|
|
|
|
;; Navigation: Ivy/Counsel/Swiper
|
|
(use-package ivy
|
|
:init
|
|
(ivy-mode 1)
|
|
:config
|
|
(setq ivy-use-virtual-buffers t)
|
|
(setq ivy-wrap t)
|
|
(setq ivy-count-format "(%d/%d) ")
|
|
(setq enable-recursive-minibuffers t))
|
|
|
|
(use-package ivy-rich
|
|
:after ivy
|
|
:hook (counsel-mode . ivy-rich-mode)
|
|
:config
|
|
(setq ivy-rich-parse-remote-buffer nil))
|
|
|
|
(use-package counsel
|
|
:after ivy
|
|
:config
|
|
(counsel-mode 1)
|
|
(setq ivy-initial-inputs-alist nil))
|
|
|
|
(use-package swiper
|
|
:after ivy
|
|
:bind (("C-s" . swiper)))
|
|
|
|
(use-package treemacs
|
|
:defer t
|
|
:bind
|
|
(:map global-map
|
|
("M-0" . treemacs-select-window)
|
|
("C-x t 1" . treemacs-delete-other-windows)
|
|
("C-x t t" . treemacs)
|
|
("C-x t B" . treemacs-bookmark)
|
|
("C-x t C-t" . treemacs-find-file)
|
|
("C-x t M-t" . treemacs-find-tag)))
|
|
|
|
(use-package lsp-treemacs
|
|
:defer t
|
|
:config
|
|
(lsp-treemacs-sync-mode 1))
|
|
|
|
;; Git
|
|
(use-package magit
|
|
:bind ("C-M-;" . magit-status)
|
|
:commands (magit-status magit-get-current-branch)
|
|
:custom
|
|
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
|
|
|
|
;; LSP & debugging
|
|
|
|
(use-package lsp-mode
|
|
:init
|
|
(setq lsp-keymap-prefix "C-c l")
|
|
:commands (lsp lsp-deferred)
|
|
:hook
|
|
((c-mode . lsp)
|
|
(c++-mode . lsp)
|
|
(java-mode . lsp)
|
|
(python-mode . lsp)
|
|
(rust-mode . lsp)
|
|
(tex-mode . lsp)
|
|
(latex-mode . lsp)
|
|
(zig-mode . lsp)
|
|
(lsp-mode . lsp-enable-which-key-integration))
|
|
:config
|
|
(setq lsp-prefer-flymake nil)) ;; prefer lsp-ui (flycheck) to flymake
|
|
; :bind
|
|
; (:map lsp-mode-map
|
|
; ("TAB" . completion-at-point)))
|
|
|
|
(use-package lsp-ui
|
|
:requires lsp-mode flycheck
|
|
:hook (lsp-mode . lsp-ui-mode)
|
|
:commands lsp-ui-mode
|
|
:config
|
|
(setq lsp-ui-doc-enable t)
|
|
(setq lsp-ui-doc-use-childframe t)
|
|
(setq lsp-ui-doc-position 'bottom-and-right)
|
|
(setq lsp-ui-doc-include-signature t)
|
|
(setq lsp-ui-sideline-enable t)
|
|
(setq lsp-ui-sideline-show-hover nil)
|
|
(setq lsp-ui-flycheck-enable t)
|
|
(setq lsp-ui-flycheck-list-position 'right)
|
|
(setq lsp-ui-flycheck-live-reporting t)
|
|
(setq lsp-ui-peek-enable t)
|
|
(setq lsp-ui-peek-list-width 60)
|
|
(setq lsp-ui-peek-peek-height 25)
|
|
(lsp-ui-doc-show))
|
|
|
|
(use-package dap-mode
|
|
:config
|
|
(dap-ui-mode 1)
|
|
(dap-tooltip-mode 1))
|
|
|
|
(use-package company
|
|
:config
|
|
(global-company-mode 1)
|
|
:custom
|
|
(company-idle-delay 0)
|
|
(company-minimum-prefix-length 1)
|
|
(company-tooltip-align-annotations t)
|
|
:bind
|
|
(:map company-active-map
|
|
("RET" . nil)
|
|
("[return]" . nil)
|
|
("TAB" . company-complete-selection)
|
|
("<tab>" . company-complete-selection)
|
|
("C-n" . company-select-next)
|
|
("C-p" . company-select-previous)))
|
|
|
|
;; Full terminal applications within Emacs
|
|
(use-package vterm
|
|
:commands vterm
|
|
:config
|
|
(setq vterm-max-scrollback 10000))
|
|
|
|
;;; Languages
|
|
|
|
;; C/C++
|
|
(setq-default c-default-style "k&r")
|
|
(setq-default c-basic-offset 2)
|
|
|
|
;(use-package ccls
|
|
; :hook ((c-mode c++-mode objc-mode cuda-mode) .
|
|
; (lambda () (require 'ccls) (lsp))))
|
|
|
|
;(use-package modern-cpp-font-lock
|
|
; :config
|
|
; (modern-c++-font-lock-global-mode))
|
|
|
|
;; Java
|
|
|
|
;(use-package lsp-java)
|
|
|
|
;; LaTeX
|
|
|
|
(use-package lsp-latex)
|
|
|
|
(setq lsp-tex-server 'digestif)
|
|
|
|
;; Python
|
|
(use-package lsp-pyright
|
|
:hook (python-mode . (lambda ()
|
|
(require 'lsp-pyright)
|
|
(lsp)))) ; or lsp-deferred
|
|
|
|
;; Rust
|
|
|
|
;(use-package rust-mode)
|
|
|
|
;; Zig
|
|
|
|
;(use-package zig-mode
|
|
; :custom (zig-format-on-save nil)
|
|
; :config
|
|
; (add-to-list 'lsp-language-id-configuration '(zig-mode . "zig"))
|
|
; (make-lsp-client
|
|
; :new-connection (lsp-stdio-connection "/usr/bin/zls")
|
|
; :major-modes '(zig-mode)
|
|
; :server-id 'zls))
|
|
|
|
;; Syntax checking
|
|
(use-package flycheck
|
|
:hook (lsp-mode . flycheck-mode))
|
|
|
|
;; Templating
|
|
(use-package yasnippet
|
|
:bind
|
|
("C-c y s" . yas-insert-snippet)
|
|
("C-c y v" . yas-visit-snippet-file)
|
|
:config
|
|
(add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets")
|
|
(yas-reload-all)
|
|
(yas-global-mode))
|
|
|
|
(use-package yasnippet-snippets)
|
|
;;; End init.el
|