1
0
mirror of https://github.com/sameer1612/.dotfiles.git synced 2025-02-22 19:38:57 +02:00

removed all comments

This commit is contained in:
Sameer Kumar 2024-10-10 19:49:25 +05:30
parent e5b41e9b42
commit f07de2d24c
2 changed files with 1 additions and 549 deletions

View File

@ -1,307 +1,37 @@
;;; init.el --- Emacs-Kick --- A feature rich Emacs config for (neo)vi(m)mers -*- lexical-binding: t; -*-
;; Author: Rahul Martim Juliato
;; Version: 0.1.0
;; Package-Requires: ((emacs "30.0"))
;; License: GPL-2.0-or-later
;;; Commentary:
;; =====================================================================
;; ==================== READ THIS BEFORE CONTINUING ====================
;; =====================================================================
;; ======== .-----. ========
;; ======== .----------------------. | === | ========
;; ======== |.-""""""""""""""""""-.| |-----| ========
;; ======== || || | === | ========
;; ======== || EMACS-KICK || |-----| ========
;; ======== || || | === | ========
;; ======== || || |-----| ========
;; ======== ||M-x || |:::::| ========
;; ======== |'-..................-'| |____o| ========
;; ======== `"")----------------(""` ___________ ========
;; ======== /::::::::::| |::::::::::\ \ no mouse \ ========
;; ======== /:::========| |==hjkl==:::\ \ required \ ========
;; ======== '""""""""""""' '""""""""""""' '""""""""""' ========
;; ======== ========
;; =====================================================================
;; =====================================================================
;; What is Emacs-Kick?
;;
;; Emacs-Kick is `not' a distribution.
;;
;; Emacs-Kick is a starting point for your own configuration. The goal
;; is that you can read every line of code, top-to-bottom, understand
;; what your configuration is doing, and modify it to suit your needs.
;;
;; Once you've done that, you can start exploring, configuring, and
;; tinkering to make Emacs your own! That might mean leaving Emacs
;; Kick just the way it is for a while or immediately breaking it into
;; modular pieces. It's up to you!
;;
;; If you don't know anything about Emacs Lisp, I recommend taking
;; some time to read through a guide.
;; One possible example which will only take 10-15 minutes:
;; - https://learnxinyminutes.com/docs/elisp/
;;
;; After understanding a bit more about Emacs Lisp, you can use `M-x
;; info RET` (info) for a reference on how Emacs integrates it.
;;
;; Emacs-Kick Guide:
;;
;; Well, this config ASSUMES you already knows (neo)vi(m) bindings,
;; and the bases of how it works. This is the `Emacs config for
;; vimmers'. So, if you're not familiar with it, go for
;; `kickstart.nvim', get used to it, and than come back.
;;
;; On Emacs help can be found multiple ways.
;; With this config, the leader key as SPC.
;; - <leader> h i opens the info (Also `M-x info RET')
;; - <leader> h v explores available variables
;; - <leader> h f explores avaliable functions
;; - <leader> h k explores avaliable keybindings
;;
;; If, at any time you need to find some functionality, Emacs `M-x'
;; (Meta is alt on most cases, option or command), works like a
;; command pallete, you can for example type `M-x quit' and be
;; presented with various options to quit Emacs.
;;
;; Once you've completed that, you can continue working through
;; `AND READING' the rest of the kickstart configuration.
;;
;; I have left several comments throughout the configuration. These
;; are hints about where to find more information about the relevant
;; settings, packages, or Emacs features used in Emacs-Kick.
;;
;; Feel free to delete them once you know what you're doing, but they
;; should serve as a guide for when you are first encountering a few
;; different constructs in your Emacs config.
;;
;; If you encounter any errors while installing Emacs-Kick,
;; check the *Messages* buffer for more information. You can switch
;; buffers using `<leader> SPC`, and all option menus can be navigated
;; with `C-p` and `C-n`.
;;
;; I hope you enjoy your Emacs journey,
;; - Rahul
;;
;; P.S. You can delete this when you're done too. It's your config
;; now! :)
;;; Code:
;; Performance Hacks
;; Emacs is an Elisp interpreter, and when running programs or packages,
;; it can occasionally experience pauses due to garbage collection.
;; By increasing the garbage collection threshold, we reduce these pauses
;; during heavy operations, leading to smoother performance.
(setq gc-cons-threshold #x40000000) (setq gc-cons-threshold #x40000000)
;; Set the maximum output size for reading process output, allowing for larger data transfers.
(setq read-process-output-max (* 1024 1024 4)) (setq read-process-output-max (* 1024 1024 4))
;; Do I really need a speedy startup?
;; Well, this config launches Emacs in about ~0.3 seconds,
;; which, in modern terms, is a miracle considering how fast it starts
;; with external packages.
;; It wasn’t until the recent introduction of tools for lazy loading
;; that a startup time of less than 20 seconds was even possible.
;; Other fast startup methods were introduced over time.
;; You may have heard of people running Emacs as a server,
;; where you start it once and open multiple clients instantly connected to that server.
;; Some even run Emacs as a systemd or sysV service, starting when the machine boots.
;; While this is a great way of using Emacs, we WON’T be doing that here.
;; I think 0.3 seconds is fast enough to avoid issues that could arise from
;; running Emacs as a server, such as 'What version of Node is my LSP using?'.
;; Again, this setup configures Emacs much like how a Vimmer would configure Neovim.
;; Emacs already comes with its on package manager.
;; Others are available, but let's stick with the defaults when it makes sense.
;;
;; Requires the Emacs default package manager, so we can set it. Kind of an 'import'.
(require 'package) (require 'package)
;; Add MELPA (Milkypostman's Emacs Lisp Package Archive) to the list of package archives.
;; This allows you to install packages from this widely-used repository, similar to how
;; pip works for Python or npm for Node.js. While Emacs comes with ELPA (Emacs Lisp
;; Package Archive) configured by default, which contains packages that meet specific
;; licensing criteria, MELPA offers a broader range of packages and is considered the
;; standard for Emacs users. You can also add more package archives later as needed.
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Initialize the package system. In Emacs, a package is a collection of Elisp code
;; that extends the functionality of the editor, similar to plugins in Neovim.
;; By calling `package-initialize', we load the list of available packages from
;; the configured archives (like MELPA) and make them ready for installation and use.
;; This process is akin to using lazy.nvim or packer.nvim in Neovim, which manage
;; plugin installations and configurations. While there are third-party package managers
;; available for Emacs, such as straight.el and use-package, we are sticking with
;; the default package manager for simplicity in this configuration.
(package-initialize) (package-initialize)
;; Define a global customizable variable `ek-use-nerd-fonts' to control the use of
;; Nerd Fonts symbols throughout the configuration. This boolean variable allows
;; users to easily enable or disable the use of symbols from Nerd Fonts, providing
;; flexibility in appearance settings. By setting it to `t', we enable Nerd Fonts
;; symbols; setting it to `nil' would disable them.
(defcustom ek-use-nerd-fonts t (defcustom ek-use-nerd-fonts t
"Configuration for using Nerd Fonts Symbols." "Configuration for using Nerd Fonts Symbols."
:type 'boolean :type 'boolean
:group 'appearance) :group 'appearance)
;; From now on, you'll see configurations using the `use-package' macro, which (load (locate-user-emacs-file "packages/emacs.el"))
;; allows us to organize our Emacs setup in a modular way. These configurations
;; look like this:
;;
;; (use-package some-package
;; :ensure t ;; Ensure the package is installed.
;; :config ;; Configuration settings for the package.
;; ;; Additional settings can go here.
;; )
;;
;; This approach simplifies package management, enabling us to easily control
;; both built-in (first-party) and external (third-party) packages. While Emacs
;; is a vast and powerful editor, using `use-package' helps streamline our
;; configuration for better organization and customization. As we proceed,
;; you'll see smaller `use-package' declarations for specific packages, which
;; will help us enable the desired features and improve our workflow.
;;; EMACS
;; This is biggest one. Keep going, plugins (oops, I mean packages) will be shorter :)
(use-package emacs
:ensure nil
:custom ;; Set custom variables to configure Emacs behavior.
(column-number-mode t) ;; Display the column number in the mode line.
(auto-save-default nil) ;; Disable automatic saving of buffers.
(create-lockfiles nil) ;; Prevent the creation of lock files when editing.
(delete-by-moving-to-trash t) ;; Move deleted files to the trash instead of permanently deleting them.
(delete-selection-mode 1) ;; Enable replacing selected text with typed text.
(display-line-numbers-type 'relative) ;; Use relative line numbering in programming modes.
(global-auto-revert-non-file-buffers t) ;; Automatically refresh non-file buffers.
(history-length 25) ;; Set the length of the command history.
(inhibit-startup-message t) ;; Disable the startup message when Emacs launches.
(initial-scratch-message "") ;; Clear the initial message in the *scratch* buffer.
(ispell-dictionary "en_US") ;; Set the default dictionary for spell checking.
(make-backup-files nil) ;; Disable creation of backup files.
(pixel-scroll-precision-mode t) ;; Enable precise pixel scrolling.
(pixel-scroll-precision-use-momentum nil) ;; Disable momentum scrolling for pixel precision.
(ring-bell-function 'ignore) ;; Disable the audible bell.
(split-width-threshold 300) ;; Prevent automatic window splitting if the window width exceeds 300 pixels.
(switch-to-buffer-obey-display-actions t) ;; Make buffer switching respect display actions.
(tab-width 2) ;; Set the tab width to 4 spaces.
(treesit-font-lock-level 2) ;; Use advanced font locking for Treesit mode.
(truncate-lines t) ;; Enable line truncation to avoid wrapping long lines.
(use-dialog-box nil) ;; Disable dialog boxes in favor of minibuffer prompts.
(use-short-answers t) ;; Use short answers in prompts for quicker responses (y instead of yes)
(warning-minimum-level :emergency) ;; Set the minimum level of warnings to display.
:hook ;; Add hooks to enable specific features in certain modes.
(prog-mode . display-line-numbers-mode) ;; Enable line numbers in programming modes.
:config
;; By default emacs gives you access to a lot of *special* buffers, while navigating with [b and ]b,
;; this might be confusing for newcomers. This settings make sure ]b and [b will always load a
;; file buffer. To see all buffers use <leader> SPC, <leader> b l, or <leader> b i.
(defun skip-these-buffers (_window buffer _bury-or-kill)
"Function for `switch-to-prev-buffer-skip'."
(string-match "\\*[^*]+\\*" (buffer-name buffer)))
(setq switch-to-prev-buffer-skip 'skip-these-buffers)
;; Configure font settings based on the operating system.
;; Ok, this kickstart is meant to be used on the terminal, not on GUI.
;; But without this, I fear you could start Graphical Emacs and be sad :(
(set-face-font 'default "VictorMono Nerd Font")
(set-face-attribute 'default nil
:family "VictorMono Nerd Font"
:weight 'regular :height 160)
(set-fontset-font "fontset-default"
nil
(font-spec :family "VictorMono Nerd Font" :height 160))
;; Save manual customizations to a separate file instead of cluttering `init.el'.
;; You can M-x customize, M-x customize-group, or M-x customize-themes, etc.
;; The saves you do manually using the Emacs interface would overwrite this file.
;; The following makes sure those customizations are in a separate file.
(setq custom-file (locate-user-emacs-file "custom-vars.el")) ;; Specify the custom file path.
(load custom-file 'noerror 'nomessage) ;; Load the custom file quietly, ignoring errors.
:init ;; Initialization settings that apply before the package is loaded.
(tool-bar-mode -1) ;; Disable the tool bar for a cleaner interface.
(menu-bar-mode -1) ;; Disable the menu bar for a more streamlined look.
(when scroll-bar-mode
(scroll-bar-mode -1)) ;; Disable the scroll bar if it is active.
(global-hl-line-mode 1) ;; Enable highlight of the current line
(global-auto-revert-mode 1) ;; Enable global auto-revert mode to keep buffers up to date with their corresponding files.
(indent-tabs-mode -1) ;; Disable the use of tabs for indentation (use spaces instead).
(recentf-mode 1) ;; Enable tracking of recently opened files.
(savehist-mode 1) ;; Enable saving of command history.
(save-place-mode 1) ;; Enable saving the place in files for easier return.
(winner-mode) ;; Enable winner mode to easily undo window configuration changes.
(xterm-mouse-mode 1) ;; Enable mouse support in terminal mode.
(file-name-shadow-mode 1) ;; Enable shadowing of filenames for clarity.
;; Set the default coding system for files to UTF-8.
(modify-coding-system-alist 'file "" 'utf-8)
;; Add a hook to run code after Emacs has fully initialized.
(add-hook 'after-init-hook
(lambda ()
(message "Emacs has fully loaded. This code runs after startup.")
;; Insert a welcome message in the *scratch* buffer displaying loading time and activated packages.
(with-current-buffer (get-buffer-create "*scratch*")
(insert (format
";; Welcome to Emacs!
;;
;; Loading time : %s
;; Packages : %s
"
(emacs-init-time)
(number-to-string (length package-activated-list))))))))
;;; WINDOW
;; This section configures window management in Emacs, enhancing the way buffers
;; are displayed for a more efficient workflow. The `window' use-package helps
;; streamline how various buffers are shown, especially those related to help,
;; diagnostics, and completion.
;;
;; Note: I have left some commented-out code below that may facilitate your
;; Emacs journey later on. These configurations can be useful for displaying
;; other types of buffers in side windows, allowing for a more organized workspace.
(use-package window (use-package window
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:custom :custom
(display-buffer-alist (display-buffer-alist
'( '(
;; ("\\*.*e?shell\\*"
;; (display-buffer-in-side-window)
;; (window-height . 0.25)
;; (side . bottom)
;; (slot . -1))
("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*" ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*"
(display-buffer-in-side-window) (display-buffer-in-side-window)
(window-height . 0.25) (window-height . 0.25)
(side . bottom) (side . bottom)
(slot . 0)) (slot . 0))
;; Example configuration for the LSP help buffer,
;; keeps it always on bottom using 25% of the available space:
("\\*\\(lsp-help\\)\\*" ("\\*\\(lsp-help\\)\\*"
(display-buffer-in-side-window) (display-buffer-in-side-window)
(window-height . 0.25) (window-height . 0.25)
(side . bottom) (side . bottom)
(slot . 0)) (slot . 0))
;; Configuration for displaying various diagnostic buffers on
;; bottom 25%:
("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)" ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
(display-buffer-in-side-window) (display-buffer-in-side-window)
(window-height . 0.25) (window-height . 0.25)
@ -310,18 +40,6 @@
))) )))
;;; DIRED
;; In Emacs, the `dired' package provides a powerful and built-in file manager
;; that allows you to navigate and manipulate files and directories directly
;; within the editor. If you're familiar with `oil.nvim', you'll find that
;; `dired' offers similar functionality natively in Emacs, making file
;; management seamless without needing external plugins.
;; This configuration customizes `dired' to enhance its usability. The settings
;; below specify how file listings are displayed, the target for file operations,
;; and associations for opening various file types with their respective applications.
;; For example, image files will open with `feh', while audio and video files
;; will utilize `mpv'.
(use-package dired (use-package dired
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:custom :custom
@ -339,18 +57,6 @@
(setq insert-directory-program gls))))) (setq insert-directory-program gls)))))
;;; ERC
;; In this section, we introduce ERC (Emacs Relay Chat), a built-in IRC client
;; that allows you to engage in real-time chat directly within Emacs. While
;; we're aiming to maintain functionality similar to Neovim, it's important to
;; recognize that Emacs is often viewed as more than just a text editor. Many
;; users leverage Emacs for a variety of tasks beyond editing text: from watching
;; videos and listening to music, to managing emails and even serving as a window
;; manager in Xorg, freeing themselves from traditional desktop environments.
;;
;; While this kickstarter focuses on essential configurations, I wanted to present
;; ERC as a glimpse into Emacs's versatility. With ERC, you can seamlessly connect
;; to IRC channels and interact with communities without leaving your editor.
(use-package erc (use-package erc
:defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET') :defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET')
:custom :custom
@ -360,14 +66,6 @@
(erc-autojoin-channels-alist '((".*\\.libera\\.chat" "#emacs"))));; Automatically join the #emacs channel on Libera.Chat. (erc-autojoin-channels-alist '((".*\\.libera\\.chat" "#emacs"))));; Automatically join the #emacs channel on Libera.Chat.
;;; ISEARCH
;; In this configuration, we're setting up isearch, Emacs's incremental search feature.
;; Since we're utilizing Vim bindings, keep in mind that classic Vim search commands
;; (like `/' and `?') are not bound in the same way. Instead, you'll need to use
;; the standard Emacs shortcuts:
;; - `C-s' to initiate a forward search
;; - `C-r' to initiate a backward search
;; The following settings enhance the isearch experience:
(use-package isearch (use-package isearch
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:config :config
@ -379,15 +77,6 @@
("C-r" . isearch-backward))) ;; Bind C-r to backward isearch. ("C-r" . isearch-backward))) ;; Bind C-r to backward isearch.
;;; VC
;; The VC (Version Control) package is included here for awareness and completeness.
;; While its support for Git is limited and generally considered subpar, it is good to know
;; that it exists and can be used for other version control systems like Mercurial,
;; Subversion, and Bazaar.
;; Magit, which is often regarded as the "father" of Neogit, will be configured later
;; for an enhanced Git experience.
;; The keybindings below serve as a reminder of some common VC commands.
;; But don't worry, you can always use `M-x command' :)
(use-package vc (use-package vc
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:defer t :defer t
@ -397,7 +86,6 @@
("C-x v D" . vc-root-diff) ;; Show differences for the entire repository. ("C-x v D" . vc-root-diff) ;; Show differences for the entire repository.
("C-x v v" . vc-next-action)) ;; Perform the next version control action. ("C-x v v" . vc-next-action)) ;; Perform the next version control action.
:config :config
;; Better colors for <leader> g b (blame file)
(setq vc-annotate-color-map (setq vc-annotate-color-map
'((20 . "#f5e0dc") '((20 . "#f5e0dc")
(40 . "#f2cdcd") (40 . "#f2cdcd")
@ -415,39 +103,12 @@
(280 . "#b4befe")))) (280 . "#b4befe"))))
;;; SMERGE
;; Smerge is included for resolving merge conflicts in files. It provides a simple interface
;; to help you keep changes from either the upper or lower version during a merge.
;; This package is built-in, so there's no need to fetch it separately.
;; The keybindings below did not needed to be setted, are here just to show
;; you how to work with it in case you are curious about it.
(use-package smerge-mode
:ensure nil ;; This is built-in, no need to fetch it.
:defer t
:bind (:map smerge-mode-map
("C-c ^ u" . smerge-keep-upper) ;; Keep the changes from the upper version.
("C-c ^ l" . smerge-keep-lower) ;; Keep the changes from the lower version.
("C-c ^ n" . smerge-next) ;; Move to the next conflict.
("C-c ^ p" . smerge-previous))) ;; Move to the previous conflict.
;;; ELDOC
;; Eldoc provides helpful inline documentation for functions and variables
;; in the minibuffer, enhancing the development experience. It can be particularly useful
;; in programming modes, as it helps you understand the context of functions as you type.
;; This package is built-in, so there's no need to fetch it separately.
;; The following line enables Eldoc globally for all buffers.
(use-package eldoc (use-package eldoc
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:init :init
(global-eldoc-mode)) (global-eldoc-mode))
;;; FLYMAKE
;; Flymake is an on-the-fly syntax checking extension that provides real-time feedback
;; about errors and warnings in your code as you write. This can greatly enhance your
;; coding experience by catching issues early. The configuration below activates
;; Flymake mode in programming buffers.
(use-package flymake (use-package flymake
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:defer t :defer t
@ -458,23 +119,6 @@
(note "»" compilation-info)))) (note "»" compilation-info))))
;;; ORG-MODE
;; Org-mode is a powerful system for organizing and managing your notes,
;; tasks, and documents in plain text. It offers features like task management,
;; outlining, scheduling, and much more, making it a versatile tool for
;; productivity. The configuration below simply defers loading Org-mode until
;; it's explicitly needed, which can help speed up Emacs startup time.
(use-package org
:ensure nil ;; This is built-in, no need to fetch it.
:defer t) ;; Defer loading Org-mode until it's needed.
;;; WHICH-KEY
;; `which-key' is an Emacs package that displays available keybindings in a
;; popup window whenever you partially type a key sequence. This is particularly
;; useful for discovering commands and shortcuts, making it easier to learn
;; Emacs and improve your workflow. It helps users remember key combinations
;; and reduces the cognitive load of memorizing every command.
(use-package which-key (use-package which-key
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
:defer t ;; Defer loading Which-Key until after init. :defer t ;; Defer loading Which-Key until after init.
@ -482,26 +126,6 @@
(after-init . which-key-mode)) ;; Enable which-key mode after initialization. (after-init . which-key-mode)) ;; Enable which-key mode after initialization.
;;; ==================== EXTERNAL PACKAGES ====================
;;
;; From this point onward, all configurations will be for third-party packages
;; that enhance Emacs' functionality and extend its capabilities.
;;; VERTICO
;; Vertico enhances the completion experience in Emacs by providing a
;; vertical selection interface for both buffer and minibuffer completions.
;; Unlike traditional minibuffer completion, which displays candidates
;; in a horizontal format, Vertico presents candidates in a vertical list,
;; making it easier to browse and select from multiple options.
;;
;; In buffer completion, `switch-to-buffer' allows you to select from open buffers.
;; Vertico streamlines this process by displaying the buffer list in a way that
;; improves visibility and accessibility. This is particularly useful when you
;; have many buffers open, allowing you to quickly find the one you need.
;;
;; In minibuffer completion, such as when entering commands or file paths,
;; Vertico helps by showing a dynamic list of potential completions, making
;; it easier to choose the correct one without typing out the entire string.
(use-package vertico (use-package vertico
:ensure t :ensure t
:hook :hook
@ -511,9 +135,6 @@
(vertico-resize nil) ;; Disable resizing of the vertico minibuffer. (vertico-resize nil) ;; Disable resizing of the vertico minibuffer.
(vertico-cycle nil) ;; Do not cycle through candidates when reaching the end of the list. (vertico-cycle nil) ;; Do not cycle through candidates when reaching the end of the list.
:config :config
;; Customize the display of the current candidate in the completion list.
;; This will prefix the current candidate with “» ” to make it stand out.
;; Reference: https://github.com/minad/vertico/wiki#prefix-current-candidate-with-arrow
(advice-add #'vertico--format-candidate :around (advice-add #'vertico--format-candidate :around
(lambda (orig cand prefix suffix index _start) (lambda (orig cand prefix suffix index _start)
(setq cand (funcall orig cand prefix suffix index _start)) (setq cand (funcall orig cand prefix suffix index _start))
@ -524,11 +145,6 @@
cand)))) cand))))
;;; ORDERLESS
;; Orderless enhances completion in Emacs by allowing flexible pattern matching.
;; It works seamlessly with Vertico, enabling you to use partial strings and
;; regular expressions to find files, buffers, and commands more efficiently.
;; This combination provides a powerful and customizable completion experience.
(use-package orderless (use-package orderless
:ensure t :ensure t
:defer t ;; Load Orderless on demand. :defer t ;; Load Orderless on demand.
@ -539,60 +155,33 @@
completion-category-overrides '((file (styles partial-completion))))) ;; Customize file completion styles. completion-category-overrides '((file (styles partial-completion))))) ;; Customize file completion styles.
;;; MARGINALIA
;; Marginalia enhances the completion experience in Emacs by adding
;; additional context to the completion candidates. This includes
;; helpful annotations such as documentation and other relevant
;; information, making it easier to choose the right option.
(use-package marginalia (use-package marginalia
:ensure t :ensure t
:hook :hook
(after-init . marginalia-mode)) (after-init . marginalia-mode))
;;; CONSULT
;; Consult provides powerful completion and narrowing commands for Emacs.
;; It integrates well with other completion frameworks like Vertico, enabling
;; features like previews and enhanced register management. It's useful for
;; navigating buffers, files, and xrefs with ease.
(use-package consult (use-package consult
:ensure t :ensure t
:defer t :defer t
:init :init
;; Enhance register preview with thin lines and no mode line.
(advice-add #'register-preview :override #'consult-register-window) (advice-add #'register-preview :override #'consult-register-window)
;; Use Consult for xref locations with a preview feature.
(setq xref-show-xrefs-function #'consult-xref (setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)) xref-show-definitions-function #'consult-xref))
;;; EMBARK
;; Embark provides a powerful contextual action menu for Emacs, allowing
;; you to perform various operations on completion candidates and other items.
;; It extends the capabilities of completion frameworks by offering direct
;; actions on the candidates.
;; Just `<leader> .' over any text, explore it :)
(use-package embark (use-package embark
:ensure t :ensure t
:defer t) :defer t)
;;; EMBARK-CONSULT
;; Embark-Consult provides a bridge between Embark and Consult, ensuring
;; that Consult commands, like previews, are available when using Embark.
(use-package embark-consult (use-package embark-consult
:ensure t :ensure t
:hook :hook
(embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode. (embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode.
;;; TREESITTER-AUTO
;; Treesit-auto simplifies the use of Tree-sitter grammars in Emacs,
;; providing automatic installation and mode association for various
;; programming languages. This enhances syntax highlighting and
;; code parsing capabilities, making it easier to work with modern
;; programming languages.
(use-package treesit-auto (use-package treesit-auto
:ensure t :ensure t
:after emacs :after emacs
@ -603,11 +192,6 @@
(global-treesit-auto-mode t)) (global-treesit-auto-mode t))
;;; MARKDOWN-MODE
;; Markdown Mode provides support for editing Markdown files in Emacs,
;; enabling features like syntax highlighting, previews, and more.
;; It’s particularly useful for README files, as it can be set
;; to use GitHub Flavored Markdown for enhanced compatibility.
(use-package markdown-mode (use-package markdown-mode
:defer t :defer t
:ensure t :ensure t
@ -615,12 +199,6 @@
:init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command. :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
;;; COMPANY
;; Company Mode provides a text completion framework for Emacs.
;; It enhances the editing experience by offering context-aware
;; suggestions as you type. With support for multiple backends,
;; Company Mode is highly customizable and can be integrated with
;; various modes and languages.
(use-package company (use-package company
:defer t :defer t
:ensure t :ensure t
@ -631,8 +209,6 @@
(company-tooltip-maximum-width 50) (company-tooltip-maximum-width 50)
:config :config
;; While using C-p C-n to select a completion candidate
;; C-y quickly shows help docs for the current candidate
(define-key company-active-map (kbd "C-y") (define-key company-active-map (kbd "C-y")
(lambda () (lambda ()
(interactive) (interactive)
@ -645,13 +221,6 @@
(after-init . global-company-mode)) ;; Enable Company Mode globally after initialization. (after-init . global-company-mode)) ;; Enable Company Mode globally after initialization.
;;; LSP
;; Emacs comes with an integrated LSP client called `eglot', which offers basic LSP functionality.
;; However, `eglot' has limitations, such as not supporting multiple language servers
;; simultaneously within the same buffer (e.g., handling both TypeScript, Tailwind and ESLint
;; LSPs together in a React project). For this reason, the more mature and capable
;; `lsp-mode' is included as a third-party package, providing advanced IDE-like features
;; and better support for multiple language servers and configurations.
(use-package lsp-mode (use-package lsp-mode
:ensure t :ensure t
:defer t :defer t
@ -706,12 +275,6 @@
(lsp-semantic-tokens-enable nil)) ;; Disable semantic tokens. (lsp-semantic-tokens-enable nil)) ;; Disable semantic tokens.
;;; LSP Additional Servers
;; You can extend `lsp-mode' by integrating additional language servers for specific
;; technologies. For example, `lsp-tailwindcss' provides support for Tailwind CSS
;; classes within your HTML files. By using various LSP packages, you can connect
;; multiple LSP servers simultaneously, enhancing your coding experience across
;; different languages and frameworks.
(use-package lsp-tailwindcss (use-package lsp-tailwindcss
:ensure t :ensure t
:defer t :defer t
@ -721,18 +284,6 @@
(setq lsp-tailwindcss-add-on-mode t)) (setq lsp-tailwindcss-add-on-mode t))
;;; Diff-HL
;; The `diff-hl' package provides visual indicators for version control changes
;; directly in the margin of the buffer, showing lines added, deleted, or changed.
;; This is useful for tracking modifications while you edit files. When enabled,
;; it automatically activates in every buffer that has a corresponding version
;; control backend, offering a seamless experience.
;;
;; In comparison, Neovim users often rely on plugins like `gitsigns.nvim' or
;; `vim-signify', which provide similar functionalities by displaying Git
;; changes in the gutter and offer additional features like highlighting
;; changed lines and displaying blame information. `diff-hl' aims to provide
;; a comparable experience in Emacs with its own set of customizations.
(use-package diff-hl (use-package diff-hl
:defer t :defer t
:ensure t :ensure t
@ -750,32 +301,6 @@
(ignored . "i")))) (ignored . "i"))))
;;; Magit
;; `magit' is a powerful Git interface for Emacs that provides a complete
;; set of features to manage Git repositories. With its intuitive interface,
;; you can easily stage, commit, branch, merge, and perform other Git
;; operations directly from Emacs. Magit’s powerful UI allows for a seamless
;; workflow, enabling you to visualize your repository's history and manage
;; changes efficiently.
;;
;; In the Neovim ecosystem, similar functionality is provided by plugins such as
;; `fugitive.vim', which offers a robust Git integration with commands that
;; allow you to perform Git operations directly within Neovim. Another popular
;; option is `neogit', which provides a more modern and user-friendly interface
;; for Git commands in Neovim, leveraging features like diff views and staging
;; changes in a visual format. Both of these plugins aim to replicate and
;; extend the powerful capabilities that Magit offers in Emacs.
(use-package magit
:ensure t
:defer t)
;;; XCLIP
;; `xclip' is an Emacs package that integrates the X Window System clipboard
;; with Emacs. It allows seamless copying and pasting between Emacs and other
;; applications using the clipboard. When `xclip' is enabled, any text copied
;; in Emacs can be pasted in other applications, and vice versa, providing a
;; smooth workflow when working across multiple environments.
(use-package xclip (use-package xclip
:ensure t :ensure t
:defer t :defer t
@ -783,12 +308,6 @@
(after-init . xclip-mode)) ;; Enable xclip mode after initialization. (after-init . xclip-mode)) ;; Enable xclip mode after initialization.
;;; INDENT-GUIDE
;; The `indent-guide' package provides visual indicators for indentation levels
;; in programming modes, making it easier to see code structure at a glance.
;; It draws vertical lines (by default, a character of your choice) at each
;; level of indentation, helping to improve readability and navigation within
;; the code.
(use-package indent-guide (use-package indent-guide
:defer t :defer t
:ensure t :ensure t
@ -798,22 +317,6 @@
(setq indent-guide-char "")) ;; Set the character used for the indent guide. (setq indent-guide-char "")) ;; Set the character used for the indent guide.
;;; ADD-NODE-MODULES-PATH
;; The `add-node-modules-path' package ensures that Emacs uses the local
;; `node_modules/.bin' for a project rather than globally installed binaries.
;; This is essential in JavaScript/TypeScript projects where different versions
;; of tools like `eslint' and `typescript-language-server' might be needed
;; per project.
;;
;; This setup helps prevent conflicts between global and local versions of
;; Node.js tools and ensures consistency across different environments.
;;
;; Example in the wild: This is an example of a real-world issue often faced
;; by developers using modern tech stacks. When working on multiple projects
;; with different dependencies, Emacs must use the correct local versions
;; instead of relying on globally installed packages. This configuration
;; ensures that the environment is accurate and project-specific tools are
;; properly utilized.
(use-package add-node-modules-path (use-package add-node-modules-path
:ensure t :ensure t
:defer t :defer t
@ -831,10 +334,6 @@
(load (locate-user-emacs-file "packages/evil.el")) (load (locate-user-emacs-file "packages/evil.el"))
;;; RAINBOW DELIMITERS
;; The `rainbow-delimiters' package provides colorful parentheses, brackets, and braces
;; to enhance readability in programming modes. Each level of nested delimiter is assigned
;; a different color, making it easier to match pairs visually.
(use-package rainbow-delimiters (use-package rainbow-delimiters
:defer t :defer t
:ensure t :ensure t
@ -842,20 +341,12 @@
(prog-mode . rainbow-delimiters-mode)) (prog-mode . rainbow-delimiters-mode))
;;; DOTENV
;; A simple major mode to provide .env files with color highlighting
(use-package dotenv-mode (use-package dotenv-mode
:defer t :defer t
:ensure t :ensure t
:config) :config)
;;; PULSAR
;; The `pulsar' package enhances the user experience in Emacs by providing
;; visual feedback through pulsating highlights. This feature is especially
;; useful in programming modes, where it can help users easily track
;; actions such as scrolling, error navigation, yanking, deleting, and
;; jumping to definitions.
(use-package pulsar (use-package pulsar
:defer t :defer t
:ensure t :ensure t
@ -879,10 +370,6 @@
(add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk)) (add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk))
;;; DOOM MODELINE
;; The `doom-modeline' package provides a sleek, modern mode-line that is visually appealing
;; and functional. It integrates well with various Emacs features, enhancing the overall user
;; experience by displaying relevant information in a compact format.
(use-package doom-modeline (use-package doom-modeline
:ensure t :ensure t
:defer t :defer t
@ -899,10 +386,6 @@
(after-init . doom-modeline-mode)) (after-init . doom-modeline-mode))
;;; NEOTREE
;; The `neotree' package provides a file tree explorer for Emacs, allowing easy navigation
;; through directories and files. It presents a visual representation of the file system
;; and integrates with version control to show file states.
(use-package neotree (use-package neotree
:ensure t :ensure t
:custom :custom
@ -916,20 +399,12 @@
(setq neo-theme 'nerd))) ;; Otherwise, fall back to the 'nerd' theme. (setq neo-theme 'nerd))) ;; Otherwise, fall back to the 'nerd' theme.
;;; NERD ICONS
;; The `nerd-icons' package provides a set of icons for use in Emacs. These icons can
;; enhance the visual appearance of various modes and packages, making it easier to
;; distinguish between different file types and functionalities.
(use-package nerd-icons (use-package nerd-icons
:if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
:ensure t ;; Ensure the package is installed. :ensure t ;; Ensure the package is installed.
:defer t) ;; Load the package only when needed to improve startup time. :defer t) ;; Load the package only when needed to improve startup time.
;;; NERD ICONS Dired
;; The `nerd-icons-dired' package integrates nerd icons into the Dired mode,
;; providing visual icons for files and directories. This enhances the Dired
;; interface by making it easier to identify file types at a glance.
(use-package nerd-icons-dired (use-package nerd-icons-dired
:if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
:ensure t ;; Ensure the package is installed. :ensure t ;; Ensure the package is installed.
@ -938,11 +413,6 @@
(dired-mode . nerd-icons-dired-mode)) (dired-mode . nerd-icons-dired-mode))
;;; NERD ICONS COMPLETION
;; The `nerd-icons-completion' package enhances the completion interfaces in
;; Emacs by integrating nerd icons with completion frameworks such as
;; `marginalia'. This provides visual cues for the completion candidates,
;; making it easier to distinguish between different types of items.
(use-package nerd-icons-completion (use-package nerd-icons-completion
:if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
:ensure t ;; Ensure the package is installed. :ensure t ;; Ensure the package is installed.
@ -952,33 +422,19 @@
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display. (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display.
;;; CATPPUCCIN THEME
;; The `catppuccin-theme' package provides a visually pleasing color theme
;; for Emacs that is inspired by the popular Catppuccin color palette.
;; This theme aims to create a comfortable and aesthetic coding environment
;; with soft colors that are easy on the eyes.
(use-package catppuccin-theme (use-package catppuccin-theme
:ensure t :ensure t
:config :config
(custom-set-faces (custom-set-faces
;; Set the color for changes in the diff highlighting to blue.
`(diff-hl-change ((t (:background unspecified :foreground ,(catppuccin-get-color 'blue)))))) `(diff-hl-change ((t (:background unspecified :foreground ,(catppuccin-get-color 'blue))))))
(custom-set-faces (custom-set-faces
;; Set the color for deletions in the diff highlighting to red.
`(diff-hl-delete ((t (:background unspecified :foreground ,(catppuccin-get-color 'red)))))) `(diff-hl-delete ((t (:background unspecified :foreground ,(catppuccin-get-color 'red))))))
(custom-set-faces (custom-set-faces
;; Set the color for insertions in the diff highlighting to green.
`(diff-hl-insert ((t (:background unspecified :foreground ,(catppuccin-get-color 'green)))))) `(diff-hl-insert ((t (:background unspecified :foreground ,(catppuccin-get-color 'green))))))
;; Load the Catppuccin theme without prompting for confirmation.
(load-theme 'catppuccin :no-confirm)) (load-theme 'catppuccin :no-confirm))
;;; UTILITARY FUNCTION TO INSTALL EMACS-KICK
(defun ek/first-install () (defun ek/first-install ()
"Install tree-sitter grammars and compile packages on first run..."
(interactive) ;; Allow this function to be called interactively. (interactive) ;; Allow this function to be called interactively.
(switch-to-buffer "*Messages*") ;; Switch to the *Messages* buffer to display installation messages. (switch-to-buffer "*Messages*") ;; Switch to the *Messages* buffer to display installation messages.
(message ">>> All required packages installed.") (message ">>> All required packages installed.")
@ -992,7 +448,6 @@
(message ">>> Native compile 3rd-party packages...\n") (message ">>> Native compile 3rd-party packages...\n")
(require 'comp) (require 'comp)
(native-compile-prune-cache) ;; Prune the native compilation cache to free up resources. (native-compile-prune-cache) ;; Prune the native compilation cache to free up resources.
;; Iterate through all directories in the user's package directory.
(dolist (dir (directory-files package-user-dir t "^[^.]" t)) (dolist (dir (directory-files package-user-dir t "^[^.]" t))
(when (file-directory-p dir) ;; Check if the current entry is a directory. (when (file-directory-p dir) ;; Check if the current entry is a directory.
(byte-recompile-directory dir 0 t) ;; Byte compile all files in the directory. (byte-recompile-directory dir 0 t) ;; Byte compile all files in the directory.
@ -1003,4 +458,3 @@
(kill-emacs)) ;; Close Emacs after installation is complete. (kill-emacs)) ;; Close Emacs after installation is complete.
(provide 'init) (provide 'init)
;;; init.el ends here

View File

@ -18,8 +18,6 @@
(evil-define-key 'normal 'global (kbd "C-d") 'scroll-up) (evil-define-key 'normal 'global (kbd "C-d") 'scroll-up)
(evil-define-key 'normal 'global (kbd "C-u") 'scroll-down) (evil-define-key 'normal 'global (kbd "C-u") 'scroll-down)
;; Keybindings for searching and finding files. ;; Keybindings for searching and finding files.
(evil-define-key 'normal 'global (kbd "<leader> f f") 'project-find-file) (evil-define-key 'normal 'global (kbd "<leader> f f") 'project-find-file)
(evil-define-key 'normal 'global (kbd "<leader> f G") 'consult-grep) (evil-define-key 'normal 'global (kbd "<leader> f G") 'consult-grep)