Skip to content

Instantly share code, notes, and snippets.

@joseche
Created November 5, 2025 14:46
Show Gist options
  • Select an option

  • Save joseche/848cc859d212e1c68a53bc8330c6b93c to your computer and use it in GitHub Desktop.

Select an option

Save joseche/848cc859d212e1c68a53bc8330c6b93c to your computer and use it in GitHub Desktop.
;;; init.el --- My customisations of emacs -*- lexical-binding: t; mode: emacs-lisp; -*-
;;; Commentary:
;; This is the new version in 2025
;;; Code:
;; Initialize package sources
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;; Disable the startup screen, toolbar and menubar
(setq inhibit-startup-message t)
(tool-bar-mode t)
(menu-bar-mode t)
;; Enable mouse
(xterm-mouse-mode 1)
;; avoid sounds when moving the mouse
(setq visible-bell t)
;; Follow symlinks
(setq vc-follow-symlinks t)
;; Save the last place in file
(save-place-mode 1)
;; Highlight matching parentheses
(show-paren-mode 1)
;; Show line numbers and column numbers
(global-display-line-numbers-mode 1)
(column-number-mode 1)
;; Use y/n instead of yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;; Highlight current line
(global-hl-line-mode 1)
;; Show trailing whitespace (useful for code hygiene)
(setq-default show-trailing-whitespace t)
;; Set a better default font
(set-face-attribute 'default nil :font "Fira Code Retina" :height 120)
(set-face-attribute 'font-lock-comment-face nil :slant 'italic)
(set-face-attribute 'font-lock-comment-delimiter-face nil :slant 'italic)
;; Disable backup~ and #autosave# files cluttering directories
(setq make-backup-files nil)
(setq auto-save-default nil)
;; Delete selection when typing
(delete-selection-mode 1)
;; Use spaces instead of tabs
(setq-default indent-tabs-mode nil)
;; Set tab width to 4
(setq-default tab-width 4)
;; Automatically reload files changed on disk
(global-auto-revert-mode t)
;; Auto-close brackets and quotes
(electric-pair-mode 1)
;; Navigate between windows easily
(global-set-key (kbd "M-o") 'other-window)
;; Easier buffer switching
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; Quickly open init file
(defun open-init-file ()
"Open this init.el quickly."
(interactive)
(find-file user-init-file))
(global-set-key (kbd "C-c e") 'open-init-file)
;; Display time and date
(display-time-mode 1)
(pixel-scroll-precision-mode 1)
;; Keep a few lines visible above/below the cursor when scrolling
(setq scroll-margin 5) ;; number of context lines
(setq scroll-conservatively 101) ;; smooth scrolling, don’t recenter
(setq scroll-step 1) ;; scroll one line at a time
;;; ----------------------------
;;; Useful Packages
;;; ----------------------------
;; which-key shows available keybindings dynamically
(use-package which-key
:init
(which-key-mode)
:config
(setq which-key-idle-delay 0.1))
;; ivy + counsel + swiper for modern completion and search
(use-package ivy
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t
ivy-count-format "(%d/%d) "))
(use-package counsel
:after ivy
:config (counsel-mode 1))
(use-package swiper
:after ivy
:bind (("C-s" . swiper)
("C-r" . swiper)))
;; magit for git integration
(use-package magit
:commands magit-status
:bind (("C-x g" . magit-status)))
;; projectile for project navigation
(use-package projectile
:config
(projectile-mode +1)
(setq projectile-project-search-path '("~/git"))
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
;; flycheck for on-the-fly syntax checking
(use-package flycheck
:init (global-flycheck-mode))
;; set env vars from term
;;(use-package exec-path-from-shell
;; :config
;; (exec-path-from-shell-initialize)
;; (exec-path-from-shell-copy-envs '("PATH" "TERM" "VIRTUAL_ENV")))
;; Python
(use-package python-mode)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
;;(when (executable-find "python")
;; (setq python-shell-interpreter "python"))
;;(when (executable-find "ipython")
;; (setq python-shell-interpreter "ipython"))
(setq python-interpreter "~/py3.13/bin/python3")
(setq python-shell-interpreter "~/py3.13/bin/python3")
;; (setq python-shell-interpreter-args "--simple-prompt")
;; Git gutter
(use-package git-gutter
:ensure t
:diminish
:hook (prog-mode . git-gutter-mode)
:config
(global-git-gutter-mode +1)
(setq git-gutter:update-interval 5))
;; Lsp mode
(use-package lsp-mode
:commands
(lsp lsp-deferred)
:hook ((python-mode . lsp-deferred)) ;; enable LSP automatically for Python
:init
(setq lsp-keymap-prefix "C-c l") ;; common LSP prefix
:custom
(lsp-prefer-flymake nil)
(lsp-completion-provider :capf)
:config
(setq
lsp-enable-snippet t
lsp-enable-symbol-highlighting t
lsp-idle-delay 0.5))
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode
:after lsp-mode
:hook (lsp-mode . lsp-ui-mode)
:config
(setq lsp-ui-sideline-enable t
lsp-ui-doc-use-childframe t
lsp-ui-sideline-show-diagnostics t
lsp-ui-doc-enable nil
))
(use-package lsp-pyright
:ensure t
:after lsp-mode
:hook (python-mode . (lambda () (require 'lsp-pyright) (lsp-deferred))))
;(use-package company
; :ensure t
; :config
; (global-company-mode))
(use-package corfu
:init
(global-corfu-mode))
(use-package powerline)
(powerline-center-theme)
(use-package dired-sidebar
:bind (("C-x f" . dired-sidebar-toggle-sidebar))
:ensure t
:commands (dired-sidebar-toggle-sidebar))
(use-package nerd-icons :defer t)
(use-package nerd-icons-dired
:commands (nerd-icons-dired-mode)
:config
(setq dired-sidebar-theme 'nerd-icons)
:hook
(dired-mode . nerd-icons-dired-mode))
(use-package dashboard
:config
(dashboard-setup-startup-hook))
;; Org mode
(use-package org
:ensure nil
:hook
((org-mode . visual-line-mode)
(org-mode . org-indent-mode))
:config
(setq org-hide-emphasis-markers t ;; Hide *bold*, /italic/ markers for cleaner look
org-tags-column -80
org-startup-indented t ;; Indent text according to outline structure
org-ellipsis " ▼ " ;; Pretty symbol for folded sections
org-log-done 'time ;; Add timestamp when marking a task DONE
org-log-into-drawer t ;; Store logs (like timestamps) inside a LOGBOOK drawer
org-src-tab-acts-natively t ;; Make TAB work as expected inside code blocks
org-src-fontify-natively t ;; Highlight syntax in code blocks
org-confirm-babel-evaluate nil ;; Don’t ask for confirmation when running code blocks
org-image-actual-width '(300)) ;; Set default width for displayed inline images
;; --- File locations ---
(setq org-directory "~/org" ;; Base directory for all Org files
org-agenda-files '("~/org/agenda.org")
org-default-notes-file (concat org-directory "/agenda.org")) ;; Default file for org-capture
;; --- Keybindings ---
:bind
(("C-c a" . org-agenda) ;; Open agenda view
("C-c c" . org-capture) ;; Capture a quick note or task
))
(use-package org-modern
:ensure t
:hook (org-mode . org-modern-mode)
:config
(setq org-modern-star '("◉" "○" "●" "◆" "◇" "▶"))
(setq org-modern-hide-stars t))
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(shell . t)))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment