feat: add straight package manager

This commit is contained in:
Rahul Martim Juliato
2025-04-05 21:39:35 -03:00
parent 3d83c32e19
commit ebfab32d5c
4 changed files with 367 additions and 326 deletions

516
init.el
View File

@@ -1,7 +1,8 @@
;;; init.el --- Emacs-Kick --- A feature rich Emacs config for (neo)vi(m)mers -*- lexical-binding: t; -*-
;; Author: Rahul Martim Juliato
;; Version: 0.1.3
;; Package-Requires: ((emacs "30.0"))
;; Version: 0.2.0
;; Package-Requires: ((emacs "30.1"))
;; License: GPL-2.0-or-later
;;; Commentary:
@@ -82,7 +83,7 @@
;;
;; 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
;; buffers using `<leader> SPC`, and all option menus can be navigated
;; with `C-p` and `C-n`.
;;
;; I hope you enjoy your Emacs journey,
@@ -119,13 +120,38 @@
;; 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 default Emacs package manager, similar to an 'import' in other languages.
;; Emacs comes with a built-in package manager (`package.el'), and we'll use it
;; when it makes sense. However, `straight.el' is a bit more user-friendly and
;; reproducible, especially for newcomers and shareable configs like emacs-kick.
;; So we bootstrap it here.
(setq package-enable-at-startup nil) ;; Disables the default package manager.
;; Bootstraps `straight.el'
(setq straight-check-for-modifications nil)
(defvar bootstrap-version)
(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 '(project :type built-in))
(straight-use-package 'use-package)
;; In Emacs, a package is a collection of Elisp code that extends the editor's functionality,
;; much like plugins do in Neovim.
;; much like plugins do in Neovim. We need to import this package to add package archives.
(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
@@ -134,11 +160,10 @@
;; 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)
;; 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
;; 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
"Configuration for using Nerd Fonts Symbols."
@@ -146,28 +171,30 @@
:group 'appearance)
;; From now on, you'll see configurations using the `use-package' macro, which
;; allows us to organize our Emacs setup in a modular way. These configurations
;; From now on, you'll see configurations using the `use-package` macro, which
;; 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.
;; :ensure t ;; Ensure the package is installed (used with package.el).
;; :straight t ;; Use straight.el to install and manage this package.
;; :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.
;; 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`—especially in combination
;; with `straight.el`—helps streamline our configuration for better organization,
;; reproducibility, 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
: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.
@@ -202,8 +229,8 @@
;; 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)))
"Function for `switch-to-prev-buffer-skip'."
(string-match "\\*[^*]+\\*" (buffer-name buffer)))
(setq switch-to-prev-buffer-skip 'skip-these-buffers)
@@ -232,7 +259,7 @@
(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-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.
@@ -247,41 +274,41 @@
;; 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.")
(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!
;; 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))))))))
(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,
;; 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
;; 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
:ensure nil ;; This is built-in, no need to fetch it.
:custom
(display-buffer-alist
'(
;; ("\\*.*e?shell\\*"
;; ("\\*.*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.*\\)\\*"
(display-buffer-in-side-window)
(window-height . 0.25)
@@ -295,7 +322,7 @@
(window-height . 0.25)
(side . bottom)
(slot . 0))
;; Configuration for displaying various diagnostic buffers on
;; bottom 25%:
("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
@@ -303,20 +330,20 @@
(window-height . 0.25)
(side . bottom)
(slot . 1))
)))
)))
;;; 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
;; 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
;; 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
:ensure nil ;; This is built-in, no need to fetch it.
@@ -336,16 +363,16 @@
;;; 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.
;; 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
;; 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
:defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET')
@@ -357,10 +384,10 @@
;;; 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:
;; 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:
@@ -377,10 +404,10 @@
;;; 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,
;; 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
;; 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' :)
@@ -393,7 +420,7 @@
("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.
:config
;; Better colors for <leader> g b (blame file)
;; Better colors for <leader> g b (blame file)
(setq vc-annotate-color-map
'((20 . "#f5e0dc")
(40 . "#f2cdcd")
@@ -412,7 +439,7 @@
;;; SMERGE
;; Smerge is included for resolving merge conflicts in files. It provides a simple interface
;; 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
@@ -428,21 +455,21 @@
;;; ELDOC
;; Eldoc provides helpful inline documentation for functions and variables
;; in the minibuffer, enhancing the development experience. It can be particularly useful
;; 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
:ensure nil ;; This is built-in, no need to fetch it.
: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 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
:ensure nil ;; This is built-in, no need to fetch it.
@@ -451,14 +478,14 @@
:custom
(flymake-margin-indicators-string
'((error "" compilation-error) (warning "»" compilation-warning)
(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
;; 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.
@@ -466,10 +493,10 @@
;;; 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
;; `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
:ensure nil ;; This is built-in, no need to fetch it.
@@ -484,22 +511,23 @@
;; that enhance Emacs' functionality and extend its capabilities.
;;; VERTICO
;; Vertico enhances the completion experience in Emacs by providing a
;; 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
;; 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
;; 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
;; 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
:ensure t
:straight t
:hook
(after-init . vertico-mode) ;; Enable vertico after Emacs has initialized.
:custom
@@ -511,22 +539,23 @@
;; 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
(lambda (orig cand prefix suffix index _start)
(setq cand (funcall orig cand prefix suffix index _start))
(concat
(if (= vertico--index index)
(propertize "» " 'face '(:foreground "#80adf0" :weight bold))
" ")
cand))))
(lambda (orig cand prefix suffix index _start)
(setq cand (funcall orig cand prefix suffix index _start))
(concat
(if (= vertico--index index)
(propertize "» " 'face '(:foreground "#80adf0" :weight bold))
" ")
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.
;; 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
:ensure t
:straight t
:defer t ;; Load Orderless on demand.
:after vertico ;; Ensure Vertico is loaded before Orderless.
:init
@@ -536,23 +565,25 @@
;;; 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
;; 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
:ensure t
:straight t
:hook
(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
;; 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
:ensure t
:straight t
:defer t
:init
;; Enhance register preview with thin lines and no mode line.
@@ -564,33 +595,36 @@
;;; 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
;; 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
:ensure t
:straight t
:defer t)
;;; EMBARK-CONSULT
;; Embark-Consult provides a bridge between Embark and Consult, ensuring
;; Embark-Consult provides a bridge between Embark and Consult, ensuring
;; that Consult commands, like previews, are available when using Embark.
(use-package embark-consult
:ensure t
:straight t
:hook
(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
;; 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
:ensure t
:straight t
:after emacs
:custom
(treesit-auto-install 'prompt)
@@ -600,39 +634,41 @@
;;; MARKDOWN-MODE
;; Markdown Mode provides support for editing Markdown files in Emacs,
;; enabling features like syntax highlighting, previews, and more.
;; Its particularly useful for README files, as it can be set
;; Markdown Mode provides support for editing Markdown files in Emacs,
;; enabling features like syntax highlighting, previews, and more.
;; Its particularly useful for README files, as it can be set
;; to use GitHub Flavored Markdown for enhanced compatibility.
(use-package markdown-mode
:defer t
:defer t
:straight t
:ensure t
:mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files.
: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
;; 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
:defer t
:defer t
:straight t
:ensure t
:custom
(company-tooltip-align-annotations t) ;; Align annotations with completions.
(company-minimum-prefix-length 1) ;; Trigger completion after typing 1 character
(company-idle-delay 0.2) ;; Delay before showing completion (adjust as needed)
(company-tooltip-maximum-width 50)
(company-tooltip-maximum-width 50)
: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")
(lambda ()
(interactive)
(company-show-doc-buffer)))
(lambda ()
(interactive)
(company-show-doc-buffer)))
(define-key company-active-map [tab] 'company-complete-selection)
(define-key company-active-map (kbd "TAB") 'company-complete-selection)
(define-key company-active-map [ret] 'company-complete-selection)
@@ -642,11 +678,11 @@
;;; 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
;; 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
;; 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.
;;
;; NOTE: To install or reinstall an LSP server, use `M-x install-server RET`.
@@ -657,6 +693,7 @@
;; https://emacs-lsp.github.io/lsp-mode/
(use-package lsp-mode
:ensure t
:straight t
:defer t
:hook (;; Replace XXX-mode with concrete major mode (e.g. python-mode)
(bash-ts-mode . lsp) ;; Enable LSP for Bash
@@ -710,13 +747,14 @@
;;; 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
;; 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
:ensure t
:straight t
:defer t
:config
(add-to-list 'lsp-language-id-configuration '(".*\\.erb$" . "html")) ;; Associate ERB files with HTML.
@@ -725,19 +763,20 @@
;;; 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
;; 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
;; 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
:defer t
:straight t
:ensure t
:hook
(find-file . (lambda ()
@@ -747,53 +786,56 @@
:custom
(diff-hl-side 'left) ;; Set the side for diff indicators.
(diff-hl-margin-symbols-alist '((insert . "") ;; Customize symbols for each change type.
(delete . "-")
(change . "")
(unknown . "?")
(ignored . "i"))))
(delete . "-")
(change . "")
(unknown . "?")
(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. Magits powerful UI allows for a seamless
;; workflow, enabling you to visualize your repository's history and manage
;; `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. Magits 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
;; 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
:straight 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
;; `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
:ensure t
:straight t
:defer t
:hook
(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 `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
:defer t
:straight t
:ensure t
:hook
(prog-mode . indent-guide-mode) ;; Activate indent-guide in programming modes.
@@ -802,35 +844,36 @@
;;; 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
;; 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
;; 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
;; 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
:ensure t
:straight t
:defer t
:custom
;; Makes sure you are using the local bin for your
;; node project. Local eslint, typescript server...
(eval-after-load 'typescript-ts-mode
'(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
'(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
(eval-after-load 'tsx-ts-mode
'(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
'(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
(eval-after-load 'typescriptreact-mode
'(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
'(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
(eval-after-load 'js-mode
'(add-hook 'js-mode-hook #'add-node-modules-path)))
'(add-hook 'js-mode-hook #'add-node-modules-path)))
;; EVIL
@@ -840,6 +883,7 @@
;; experience.
(use-package evil
:ensure t
:straight t
:defer t
:hook
(after-init . evil-mode)
@@ -856,8 +900,8 @@
(setq evil-want-fine-undo t) ;; Evil uses finer grain undoing steps
;; Define the leader key as Space
(evil-set-leader 'normal (kbd "SPC"))
(evil-set-leader 'visual (kbd "SPC"))
(evil-set-leader 'normal (kbd "SPC"))
(evil-set-leader 'visual (kbd "SPC"))
;; Keybindings for searching and finding files.
(evil-define-key 'normal 'global (kbd "<leader> s f") 'consult-find)
@@ -933,29 +977,29 @@
;; Custom example. Formatting with prettier tool.
(evil-define-key 'normal 'global (kbd "<leader> m p")
(lambda ()
(interactive)
(shell-command (concat "prettier --write " (shell-quote-argument (buffer-file-name))))
(revert-buffer t t t)))
(evil-define-key 'normal 'global (kbd "<leader> m p")
(lambda ()
(interactive)
(shell-command (concat "prettier --write " (shell-quote-argument (buffer-file-name))))
(revert-buffer t t t)))
;; LSP commands keybindings
(evil-define-key 'normal lsp-mode-map
;; (kbd "gd") 'lsp-find-definition ;; evil-collection already provides gd
(kbd "gr") 'lsp-find-references ;; Finds LSP references
(kbd "<leader> c a") 'lsp-execute-code-action ;; Execute code actions
(kbd "<leader> r n") 'lsp-rename ;; Rename symbol
(kbd "gI") 'lsp-find-implementation ;; Find implementation
(kbd "<leader> l f") 'lsp-format-buffer) ;; Format buffer via lsp
;; (kbd "gd") 'lsp-find-definition ;; evil-collection already provides gd
(kbd "gr") 'lsp-find-references ;; Finds LSP references
(kbd "<leader> c a") 'lsp-execute-code-action ;; Execute code actions
(kbd "<leader> r n") 'lsp-rename ;; Rename symbol
(kbd "gI") 'lsp-find-implementation ;; Find implementation
(kbd "<leader> l f") 'lsp-format-buffer) ;; Format buffer via lsp
(defun ek/lsp-describe-and-jump ()
"Show hover documentation and jump to *lsp-help* buffer."
(interactive)
(lsp-describe-thing-at-point)
(let ((help-buffer "*lsp-help*"))
"Show hover documentation and jump to *lsp-help* buffer."
(interactive)
(lsp-describe-thing-at-point)
(let ((help-buffer "*lsp-help*"))
(when (get-buffer help-buffer)
(switch-to-buffer-other-window help-buffer))))
(switch-to-buffer-other-window help-buffer))))
;; Open hover documentation
(evil-define-key 'normal 'global (kbd "K") 'ek/lsp-describe-and-jump)
;; Yeah, on terminals, Emacs doesn't support (YET), the use of floating windows,
@@ -966,16 +1010,16 @@
;; Commenting functionality for single and multiple lines
(evil-define-key 'normal 'global (kbd "gcc")
(lambda ()
(interactive)
(if (not (use-region-p))
(comment-or-uncomment-region (line-beginning-position) (line-end-position)))))
(lambda ()
(interactive)
(if (not (use-region-p))
(comment-or-uncomment-region (line-beginning-position) (line-end-position)))))
(evil-define-key 'visual 'global (kbd "gc")
(lambda ()
(interactive)
(if (use-region-p)
(comment-or-uncomment-region (region-beginning) (region-end)))))
(lambda ()
(interactive)
(if (use-region-p)
(comment-or-uncomment-region (region-beginning) (region-end)))))
;; Enable evil mode
(evil-mode 1))
@@ -988,6 +1032,7 @@
;; commands to fit the `evil' style.
(use-package evil-collection
:defer t
:straight t
:ensure t
:custom
(evil-collection-want-find-usages-bindings t)
@@ -1008,6 +1053,7 @@
;; - https://github.com/emacs-evil/evil-surround?tab=readme-ov-file#examples
(use-package evil-surround
:ensure t
:straight t
:after evil-collection
:config
(global-evil-surround-mode 1))
@@ -1021,6 +1067,7 @@
;; Just use % for jumping between matching structures to check it out.
(use-package evil-matchit
:ensure t
:straight t
:after evil-collection
:config
(global-evil-matchit-mode 1))
@@ -1034,6 +1081,7 @@
(use-package undo-tree
:defer t
:ensure t
:straight t
:hook
(after-init . global-undo-tree-mode)
:init
@@ -1058,6 +1106,7 @@
;; a different color, making it easier to match pairs visually.
(use-package rainbow-delimiters
:defer t
:straight t
:ensure t
:hook
(prog-mode . rainbow-delimiters-mode))
@@ -1067,18 +1116,20 @@
;; A simple major mode to provide .env files with color highlighting
(use-package dotenv-mode
:defer t
:straight t
:ensure t
: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
;; 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
:defer t
:straight t
:ensure t
:hook
(after-init . pulsar-global-mode)
@@ -1106,6 +1157,7 @@
;; experience by displaying relevant information in a compact format.
(use-package doom-modeline
:ensure t
:straight t
:defer t
:custom
(doom-modeline-buffer-file-name-style 'buffer-name) ;; Set the buffer file name style to just the buffer name (without path).
@@ -1126,6 +1178,7 @@
;; and integrates with version control to show file states.
(use-package neotree
:ensure t
:straight t
:custom
(neo-show-hidden-files t) ;; By default shows hidden files (toggle with H)
(neo-theme 'nerd) ;; Set the default theme for Neotree to 'nerd' for a visually appealing look.
@@ -1138,35 +1191,38 @@
;;; 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
;; 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
: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.
:straight t
: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
;; 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
: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.
:straight t
:defer t ;; Load the package only when needed to improve startup time.
:hook
(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,
;; 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
: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.
:straight t
:after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration.
:config
(nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces.
@@ -1174,25 +1230,26 @@
;;; 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
;; 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
:ensure t
:straight t
:config
(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))))))
(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))))))
(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))))))
;; Load the Catppuccin theme without prompting for confirmation.
(load-theme 'catppuccin :no-confirm))
@@ -1210,16 +1267,7 @@
(message ">>> Configuring Nerd Fonts...")
(require 'nerd-icons)
(nerd-icons-install-fonts) ;; Install all available nerd-fonts
(message ">>> Native compile 3rd-party packages...\n")
(require 'comp)
(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))
(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.
(native-compile-async dir 'recursively))) ;; Asynchronously compile the directory and its subdirectories.
(message ">>> Emacs-Kick installed!!! Press any key to close the installer and open Emacs normally.") ;; Notify the user that the installation is complete.
(message ">>> Emacs-Kick installed! Press any key to close the installer and open Emacs normally. First boot will compile some extra stuff :)")
(read-key) ;; Wait for the user to press any key.
(kill-emacs)) ;; Close Emacs after installation is complete.