(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;; Don't launch startup menu
(setq inhibit-startup-message t)
;; Visible bell (mute alert sounds)
(setq visible-bell t)
;; Hide menus
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
;; Don't save backups
(setq make-backup-files nil)
(setq auto-save-defaul nil)
(kill-buffer "*scratch*")
;; Highlights focused line
(global-hl-line-mode t)
;; Set Transparency
(set-frame-parameter (selected-frame) 'alpha '(90 90))
(add-to-list 'default-frame-alist '(alpha 90 90))
;; Display column number
(setq column-number-mode t)
;; Display line numbers
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
;; Highlight Matching Parentheses
(show-paren-mode 1)
;; Theme
;(use-package spacemacs-theme
; :ensure t
; :init (load-theme 'spacemacs-dark t))
(use-package nerd-icons
:ensure t)
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1))
(use-package doom-themes
:ensure t
:config
(load-theme 'doom-one t))
(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(setq org-startup-folded t)
(setq org-support-shift-select t)
;; Set a custom font for headings
(set-face-attribute 'org-level-1 nil :weight 'bold :height 1.5)
(set-face-attribute 'org-level-2 nil :weight 'bold :height 1.2)
(set-face-attribute 'org-level-3 nil :weight 'bold :height 1.1)
;; Set a custom font for regular text (non-code blocks)
(set-face-attribute 'default nil :height 110)
`which-key` is a minor mode for Emacs that displays the key bindings following your currently entered incomplete command (a prefix) in a popup. For example, after enabling the minor mode if you enter C-x and wait for the default of 1 second the minibuffer will expand with all of the available key bindings that follow C-x (or as many as space allows given your settings).
(use-package which-key
:ensure t
:init
(which-key-mode))
Whenever the window scrolls a light will shine on top of your cursor so you know where it is.
(use-package beacon
:ensure t
:config
(beacon-mode 1)
(setq beacon-color "#FF13F0"))
Swiper is an alternative to isearch that uses Ivy to show an overview of all matches.
(use-package swiper
:ensure t)
Ivy is a generic completion mechanism for Emacs. While it operates similarly to other completion schemes such as icomplete-mode, Ivy aims to be more efficient, smaller, simpler, and smoother to use yet highly customizable.
(use-package ivy
:diminish
:bind (("C-s" . swiper)
:map ivy-minibuffer-map
("TAB" . ivy-alt-done)
("C-l" . ivy-alt-done)
("C-j" . ivy-next-line)
("C-k" . ivy-previous-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line)
("C-l" . ivy-done)
("C-d" . ivy-switch-buffer-kill)
:map ivy-reverse-i-search-map
("C-k" . ivy-previous-line)
("C-d" . ivy-reverse-i-search-kill))
:config
(ivy-mode 1))
(ivy-mode 1)
(use-package magit
:ensure t)
Projectile is a project interaction library for Emacs. Its goal is to provide a nice set of features operating on a project level without introducing external dependencies (when feasible).
Common shortcuts:
C-c p f to find files within a project. C-c p p to switch between projects. C-c p s g to search for text using grep.
(use-package projectile
:ensure t
:bind-keymap ("C-c p" . projectile-command-map)
:config (projectile-mode +1))
Company is a text and code completion framework for Emacs. The name stands for “complete anything”. It uses pluggable back-ends and front-ends to retrieve and display completion candidates.
(use-package company
:ensure t
:config
(setq company-minimum-prefix-length 1)
(define-key company-active-map (kbd "TAB") 'company-complete-selection)
(define-key company-active-map (kbd "<tab>") 'company-complete-selection)
(global-company-mode))
(use-package company-box
:ensure t
:hook (company-mode . company-box-mode))
(use-package tree-sitter
:ensure t
:hook ((python-mode . tree-sitter-mode))
:config
(use-package tree-sitter-langs
:ensure t))
(use-package tree-sitter-langs
:ensure t
:after tree-sitter
:config
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
Common shortcuts:
M-. - Jump to definition M-, - Jump backwards from definition M-x RET lsp-find-references - Find all references to a particular function/class/variable M-x RET lsp-rename - Rename symbol and update all occurrences in project M-x RET lsp-rename-and-save - Rename symbol, update occurrences, then save buffers (see `Custom Functions`) M-x RET lsp-format-buffer - Autoformat file
(use-package lsp-mode
:ensure t
:hook ((python-mode . lsp)
(lsp-mode . lsp-ui-mode))
:commands lsp
:config
(setq lsp-completion-provider :capf))
;; Python LSP (Pyright)
(use-package lsp-pyright
:ensure t
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp))))
;; UI tooltip
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode
:config
(setq lsp-ui-doc-delay 0.0)
(setq lsp-ui-sideline-show-hover t)
(setq lsp-ui-sideline-show-code-actions t))
(defun lsp-rename-and-save ()
"Perform `lsp-rename` and then save all modified buffers."
(interactive)
(call-interactively 'lsp-rename)
(save-some-buffers t))
Common `use-package` keywords: :ensure – Automatically installs the package if missing. :init – Code that runs before the package is loaded. :config – Code that runs after the package is loaded. :bind – Binds specific commands to keybindings. :bind-keymap – Binds keymaps to commands (for packages with many commands). :custom – Configures variables using Emacs’ customization system. :defer – Delays package loading until it’s needed. :after – Ensures one package is loaded after another. :hook – Automatically enables the package for certain modes or events. :commands – Specifies which commands to autoload.