Skip to content

Instantly share code, notes, and snippets.

@mateusfccp
Last active May 29, 2025 17:41
Show Gist options
  • Save mateusfccp/63bfd981ae801d981b678fbfd8f60849 to your computer and use it in GitHub Desktop.
Save mateusfccp/63bfd981ae801d981b678fbfd8f60849 to your computer and use it in GitHub Desktop.
init.el
;;; init.el --- My personal, self-containted init.el
;;; Commentary:
;; This is my personal init.el file. It is self-contained and does not depend
;; on any external configuration files. It uses straight.el as a package
;; manager and use-package to configure packages.
;;
;; This should work out of the box. Tested with Emacs 29 to 31. If any other
;; external dependencies are needed, they will be mentioned in the respective
;; package configuration.
;;; Code:
;;;; Style
(set-frame-font "Fira Code 12" nil t)
;;;; straight.el bootstrap
(defvar bootstrap-version)
(defvar straight-use-package-by-default t)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(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))
(straight-use-package 'use-package)
;;;; General
(add-hook 'prog-mode-hook 'display-line-numbers-mode) ; Enable line numbers on prog mode
(add-hook 'prog-mode-hook 'display-fill-column-indicator-mode) ; Enable fill column indicator on prog mode
(add-hook 'prog-mode-hook 'column-number-mode) ; Show line and column in on prog mode
(setq ring-bell-function 'ignore) ; Prevent annoying sound when something happens
(tool-bar-mode -1) ; Hide toolbar
(menu-bar-mode -1) ; Hide menu bar
(scroll-bar-mode -1) ; Hide scrol bar
(setq-default truncate-lines t) ; Truncate lines by default
(setq-default fill-column 80) ; Set default fill column to 80
(setq native-comp-async-report-warnings-errors nil)
;;;; Backup files
(setq backup-directory-alist `(("." . "~/.emacs.d/backup")) ; Set backup directory
backup-by-copying t ; Copy files instead of renaming them
delete-old-versions t ; Delete old versions silently
kept-new-versions 6 ; Keep 6 newest versions
kept-old-versions 2 ; Keep 2 oldest versions
version-control t) ; Use version numbers on backup files
;;;; Elcord (Discord integration)
(use-package elcord
:config (elcord-mode))
;;;; Avy (Jump to visible text)
(use-package avy
:bind (("C-c C-j" . avy-goto-char-2)))
;;;; Guru mode
(use-package guru-mode
:config (guru-global-mode +1))
;;;; Dashboard
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title "Welcome to Emacs!"
dashboard-startup-banner 'logo
dashboard-icon-type 'all-the-icons
dashboard-projects-backend 'projectile
dashboard-items '((recents . 5)
(projects . 5)
(agenda . 5))))
;;;; Projectile
(use-package projectile
:init (projectile-mode +1)
:bind (("s-p" . projectile-command-map)
:map projectile-mode-map))
;;;; visual-regexp-search
;; You have to have the `python` executable in your PATH. If you are using
;; macOS, you have to make an alias to the `python3` executable.
(use-package visual-regexp-steroids
:bind (("C-c r" . vr/replace)
("C-c q" . vr/query-replace)
("C-c m" . vr/mc-mark)
("C-r" . vr/isearch-backward)
("C-s" . vr/isearch-forward)))
;;;; ag
(use-package ag)
;;;; diff-hl
(use-package diff-hl
:config (global-diff-hl-mode))
;;;; Smartparens
(use-package smartparens
:hook (prog-mode text-mode markdown-mode)
:config
;; Default configuration
(require 'smartparens-config))
;;;; Theme
(use-package catppuccin-theme
:config (load-theme 'catppuccin t)
:init (setq catppuccin-flavor 'macchiato))
;;;; Magit
(use-package magit)
;;;; Dart
(use-package dart-mode)
;;;; Json
(use-package json-mode)
;;;; Markdown
(use-package markdown-mode
:hook (markdown-mode . lsp)
:config
(require 'lsp-marksman))
;;;; Toml
(use-package toml-mode
:hook (toml-mode . lsp-mode))
;;;; Yaml
(use-package yaml-mode)
;;;; Yasnippet
(use-package yasnippet
:config (yas-global-mode))
;;;; HTML, Javascript and CSS
(use-package web-mode
:mode ("\\.phtml\\'"
"\\.tpl\\.php\\'"
"\\.[agj]sp\\'"
"\\.as[cp]x\\'"
"\\.erb\\'"
"\\.mustache\\'"
"\\.djhtml\\'"
"\\.html?\\'"))
;;;; Company
(use-package company
:config
(setq company-minimum-prefix-length 1)
(setq company-idle-delay 0.0))
;;;; Flycheck
(use-package flycheck
:config
(global-flycheck-mode)
(setq flycheck-checker-error-threshold nil))
;;;; BNF
(use-package bnf-mode)
;;;; Groovy
(use-package groovy-mode)
;;;; Basic custom mode for pint°
(define-abbrev-table 'pinto-mode-abbrev-table
'(("\\top" "" )
("\\bot" "" ))
"Abbrev table for `pinto'")
(define-derived-mode pinto-mode prog-mode "pint°"
"pint° mode is a basic mode for editing ° scripts."
(setq-local comment-start "//")
(setq-local comment-end "")
(abbrev-mode 1))
(add-to-list 'auto-mode-alist '("\\.pinto\\'" . pinto-mode))
;;;; Language Server Protocol
(use-package lsp-mode
:hook ((dart-mode . lsp)
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp
:config
(setq gc-cons-threshold (* 100 1024 1024))
;; lsp-lens-enable nil
(setq lsp-ui-doc-show-with-mouse nil)
(setq lsp-ui-sideline-show-code-actions nil)
;; lsp-signature-auto-activate nil
(setq read-process-output-max (* 2 1024 1024)))
(use-package lsp-ui :commands lsp-ui-mode)
(use-package lsp-dart)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(use-package dap-mode)
(use-package which-key
:config (which-key-mode))
;;;; ligatures.el
(use-package ligature
:ensure t
:config
;; Enable all Iosevka ligatures in programming modes
(ligature-set-ligatures 'prog-mode '("<---" "<--" "<<-" "<-" "->" "-->" "--->" "<->" "<-->" "<--->" "<---->" "<!--" "<==" "<===" "<=" "=>" "=>>" "==>" "===>" ">=" "<=>" "<==>" "<===>" "<====>" "<!---" "<~~" "<~" "~>" "~~>" "::" ":::" "==" "!=" "===" "!==" ":=" ":-" ":+" "<*" "<*>" "*>" "<|" "<|>" "|>" "+:" "-:" "=:" "<******>" "++" "+++"))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
;;;; Multiple cursors
(use-package multiple-cursors
:config
(global-set-key (kbd "C-s-n") 'mc/mark-next-like-this)
(global-set-key (kbd "C-s-p") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-s-a") 'mc/mark-all-like-this)
(global-set-key (kbd "C-s-r") 'mc/edit-lines))
;;;; Icons
;; Remember to install the fonts with the `all-the-icons-install-fonts` command.
(use-package all-the-icons
:if (display-graphic-p))
;; Needed for Doom Modeline
;;
;; Remember to install the fonts with the `nerd-icons-install-fonts` command.
(use-package nerd-icons)
;;;; Copilot
(defun copilot-m-ret ()
"Open the Copilot overlay or accept the current suggestion."
(interactive)
(if (copilot--overlay-visible)
(copilot-accept-completion)
(copilot-complete)))
(use-package copilot
:straight (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))
:ensure t
:hook (prog-mode . copilot-mode)
:bind (:map copilot-mode-map ("M-RET" . copilot-m-ret))
:config
(add-to-list 'copilot-indentation-alist '(dart-mode 2))
(add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))
(add-to-list 'copilot-indentation-alist '(lisp-mode 2))
(add-to-list 'copilot-indentation-alist '(prog-mode 2))
(add-to-list 'copilot-disable-predicates #'(lambda () t))
(setq copilot-max-char-warning-disable t))
;;;; Doom Modeline
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode)
;; Show point value in the modeline
:config
(doom-modeline-def-segment point
"Shows the point value."
(format "(%d)" (1- (point))))
(doom-modeline-def-modeline 'custom-modeline
'(bar matches buffer-info remote-host buffer-position point parrot selection-info)
'(misc-info minor-modes input-method buffer-encoding major-mode process vcs check))
;; Set default mode-line
(add-hook 'doom-modeline-mode-hook
(lambda ()
(doom-modeline-set-modeline 'custom-modeline 'default))))
;; Dependency of Doom Modeline
(use-package shrink-path
:ensure t
:demand t)
;;;; Highlight Indentation
(use-package highlight-indent-guides
:hook (prog-mode . highlight-indent-guides-mode)
:config
(setq highlight-indent-guides-method 'column)
(setq highlight-indent-guides-responsive 'top))
(provide 'init)
;;; init.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment