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

3
.gitignore vendored
View File

@@ -55,4 +55,5 @@ history
ielm-history.eld ielm-history.eld
p/.extension/ p/.extension/
savehist savehist
var/ straight/
var/

172
README.md
View File

@@ -6,7 +6,6 @@ setup, you don't need to leave behind your favorite terminal or tools
like `yazi`, `starship`, `lazygit`, and `lazydocker` just to like `yazi`, `starship`, `lazygit`, and `lazydocker` just to
give Emacs a try. give Emacs a try.
Use Emacs the same way you'd use `Neovim`, seamlessly integrating it Use Emacs the same way you'd use `Neovim`, seamlessly integrating it
into your workflow inside terminal multiplexers like `tmux` or into your workflow inside terminal multiplexers like `tmux` or
`Zellij`, while also enjoying modern features such as `treesitter` `Zellij`, while also enjoying modern features such as `treesitter`
@@ -14,13 +13,11 @@ and `LSP`—no hassle.
![Demo](doc/demo01.png) ![Demo](doc/demo01.png)
**Emacs-Kick** isnt a full-fledged distribution but rather a **Emacs-Kick** isnt a full-fledged distribution but rather a
**starting point** for building your own Emacs configuration. Its **starting point** for building your own Emacs configuration. Its
designed to be especially accessible for Vim/Neovim users, letting you designed to be especially accessible for Vim/Neovim users, letting you
explore the power of Emacs without committing to its entire ecosystem. explore the power of Emacs without committing to its entire ecosystem.
You can take advantage of Emacs features without needing to master You can take advantage of Emacs features without needing to master
every Emacs-specific workflow right away. And if you find yourself every Emacs-specific workflow right away. And if you find yourself
enjoying it, you can: enjoying it, you can:
@@ -32,15 +29,13 @@ enjoying it, you can:
OR... OR...
- Just keep using it on TUI, it is all up to you! - Just keep using it on TUI, it is all up to you!
With Emacs-Kick, the goal is to empower you to explore Emacs at your With Emacs-Kick, the goal is to empower you to explore Emacs at your
own pace. The sky's the limit! 🌟 own pace. The sky's the limit! 🌟
## Minimum Requirements ## Minimum Requirements
- Emacs version **>=30** - Emacs version **>=30.1**
- You can verify your version by running: - You can verify your installed Emacs version by running:
```bash ```bash
emacs --version emacs --version
@@ -54,7 +49,6 @@ emacs --version
`~/.emacs.d`, please back it up before proceeding. You can do this `~/.emacs.d`, please back it up before proceeding. You can do this
by renaming the directory: by renaming the directory:
```bash ```bash
mv ~/.emacs.d ~/.emacs.d.backup mv ~/.emacs.d ~/.emacs.d.backup
``` ```
@@ -65,7 +59,6 @@ files such as `~/.emacs.d`, `~/.emacs`, `~/.emacs~`,
`~/.config/emacs`, `~/.config/doom`, `~/.config/cache/emacs` and `~/.config/emacs`, `~/.config/doom`, `~/.config/cache/emacs` and
any other related files. any other related files.
After deleting/backing up, clone the repository: After deleting/backing up, clone the repository:
```bash ```bash
@@ -74,7 +67,7 @@ git clone https://github.com/LionyxML/emacs-kick.git ~/.emacs.d
2. **Run the setup**: 2. **Run the setup**:
After cloning, install the configuration by running: After cloning, install the configuration by running:
```bash ```bash
emacs -nw --eval="(ek/first-install)" emacs -nw --eval="(ek/first-install)"
@@ -90,13 +83,15 @@ cd ~/.emacs.d/ && ./ek-reinstall.sh
Both methods will install all necessary packages and apply the Both methods will install all necessary packages and apply the
configuration. configuration.
**NOTE**: During the initial setup, you'll be prompted to install Tree-sitter
**NOTE**: You will be prompted to install Tree-sitter grammars and grammars and download some fonts. This configuration uses **Nerd Fonts** by
download some fonts (this configuration uses Nerd Fonts by default, so installing them now is highly recommended for the best experience.
default). While you can choose to do this later, it is highly On first launch, Emacs will also **native compile some external packages**,
recommended to complete these steps during the installation process which may take a little time. Additionally, the first time you perform certain
for the best experience! actions—like opening the tree explorer, Emacs may compile related components in
the background. This is completely normal and only happens once per feature.
You might notice a brief moment of sluggish performance during this initial
compilation.
3. **Set terminal mode by default**: 3. **Set terminal mode by default**:
@@ -131,87 +126,87 @@ emacs
``` ```
**Usage Tips**: **Usage Tips**:
- **Leader Key**: The leader key is set to `SPC` (spacebar), - **Leader Key**: The leader key is set to `SPC` (spacebar),
`which-key` is there to help you discover keybindings. `which-key` is there to help you discover keybindings.
- **Help Commands**: - **Help Commands**:
- `SPC h i` opens the Emacs info documentation (`M-x info`). - `SPC h i` opens the Emacs info documentation (`M-x info`).
- `SPC h v` allows you to explore available variables. - `SPC h v` allows you to explore available variables.
- `SPC h f` lets you explore functions. - `SPC h f` lets you explore functions.
- `SPC h k` displays keybindings. - `SPC h k` displays keybindings.
**Troubleshooting**: **Troubleshooting**:
- If you encounter any issues during installation, check the
`*Messages*` buffer for more information. You can switch between
buffers with `SPC SPC`, and navigate options using `C-p` and `C-n`.
- If you encounter any issues during installation, check the
`*Messages*` buffer for more information. You can switch between
buffers with `SPC SPC`, and navigate options using `C-p` and `C-n`.
## Available Commands ## Available Commands
| Keybinding | Action | | Keybinding | Action |
|---------------------|-------------------------------------------| | -------------- | ----------------------------------------- |
| `SPC` | Leader key | | `SPC` | Leader key |
| `C-d` | Scroll down | | `C-d` | Scroll down |
| `C-u` | Scroll up | | `C-u` | Scroll up |
| `<leader> s f` | Find file | | `<leader> s f` | Find file |
| `<leader> s g` | Grep | | `<leader> s g` | Grep |
| `<leader> s G` | Git grep | | `<leader> s G` | Git grep |
| `<leader> s r` | Ripgrep | | `<leader> s r` | Ripgrep |
| `<leader> s h` | Consult info | | `<leader> s h` | Consult info |
| `<leader> /` | Consult line | | `<leader> /` | Consult line |
| `<leader> x x` | Consult Flymake | | `<leader> x x` | Consult Flymake |
| `] d` | Next Flymake error | | `] d` | Next Flymake error |
| `[ d` | Previous Flymake error | | `[ d` | Previous Flymake error |
| `<leader> x d` | Dired | | `<leader> x d` | Dired |
| `<leader> x j` | Dired jump | | `<leader> x j` | Dired jump |
| `<leader> x f` | Find file | | `<leader> x f` | Find file |
| `] c` | Next diff hunk | | `] c` | Next diff hunk |
| `[ c` | Previous diff hunk | | `[ c` | Previous diff hunk |
| `<leader> e e` | Toggle NeoTree | | `<leader> e e` | Toggle NeoTree |
| `<leader> g g` | Open Magit status | | `<leader> g g` | Open Magit status |
| `<leader> g l` | Show current log | | `<leader> g l` | Show current log |
| `<leader> g d` | Show diff for current file | | `<leader> g d` | Show diff for current file |
| `<leader> g D` | Show diff for hunk | | `<leader> g D` | Show diff for hunk |
| `<leader> g b` | Annotate buffer with version control info | | `<leader> g b` | Annotate buffer with version control info |
| `] b` | Switch to next buffer | | `] b` | Switch to next buffer |
| `[ b` | Switch to previous buffer | | `[ b` | Switch to previous buffer |
| `<leader> b i` | Consult buffer list | | `<leader> b i` | Consult buffer list |
| `<leader> b b` | Open Ibuffer | | `<leader> b b` | Open Ibuffer |
| `<leader> b d` | Kill current buffer | | `<leader> b d` | Kill current buffer |
| `<leader> b k` | Kill current buffer | | `<leader> b k` | Kill current buffer |
| `<leader> b x` | Kill current buffer | | `<leader> b x` | Kill current buffer |
| `<leader> b s` | Save buffer | | `<leader> b s` | Save buffer |
| `<leader> b l` | Consult buffer | | `<leader> b l` | Consult buffer |
| `<leader>SPC` | Consult buffer | | `<leader>SPC` | Consult buffer |
| `<leader> p b` | Consult project buffer | | `<leader> p b` | Consult project buffer |
| `<leader> p p` | Switch project | | `<leader> p p` | Switch project |
| `<leader> p f` | Find file in project | | `<leader> p f` | Find file in project |
| `<leader> p g` | Find regexp in project | | `<leader> p g` | Find regexp in project |
| `<leader> p k` | Kill project buffers | | `<leader> p k` | Kill project buffers |
| `<leader> p D` | Dired for project | | `<leader> p D` | Dired for project |
| `P` | Yank from kill ring | | `P` | Yank from kill ring |
| `<leader> P` | Yank from kill ring | | `<leader> P` | Yank from kill ring |
| `<leader> .` | Embark act | | `<leader> .` | Embark act |
| `<leader> u` | Undo tree visualize | | `<leader> u` | Undo tree visualize |
| `<leader> h m` | Describe current mode | | `<leader> h m` | Describe current mode |
| `<leader> h f` | Describe function | | `<leader> h f` | Describe function |
| `<leader> h v` | Describe variable | | `<leader> h v` | Describe variable |
| `<leader> h k` | Describe key | | `<leader> h k` | Describe key |
| `] t` | Go to next tab | | `] t` | Go to next tab |
| `[ t` | Go to previous tab | | `[ t` | Go to previous tab |
| `<leader> m p` | Format with Prettier | | `<leader> m p` | Format with Prettier |
| `<leader> c a` | Execute code action | | `<leader> c a` | Execute code action |
| `<leader> r n` | Rename symbol | | `<leader> r n` | Rename symbol |
| `gI` | Find implementation | | `gI` | Find implementation |
| `<leader> l f` | Format buffer via LSP | | `<leader> l f` | Format buffer via LSP |
| `K` | Show hover documentation | | `K` | Show hover documentation |
| `gcc` | Comment/uncomment current line | | `gcc` | Comment/uncomment current line |
| `gc` | Comment/uncomment selected region | | `gc` | Comment/uncomment selected region |
| `gd` | Goto definitions | | `gd` | Goto definitions |
| `gr` | Goto references | | `gr` | Goto references |
...and a lot more, discoverable with which-key :) ...and a lot more, discoverable with which-key :)
## Contributing ## Contributing
This package is intentionally designed with a specific vision in mind, This package is intentionally designed with a specific vision in mind,
@@ -219,17 +214,14 @@ reflecting my own opinions and preferences. While contributions are
welcome, please understand that this configuration is quite welcome, please understand that this configuration is quite
opinionated. opinionated.
If you have suggestions or requests, they will be considered If you have suggestions or requests, they will be considered
carefully, but I cannot make any promises regarding implementation or carefully, but I cannot make any promises regarding implementation or
acceptance. Your input is valuable, and I appreciate any help or acceptance. Your input is valuable, and I appreciate any help or
feedback to improve the project. feedback to improve the project.
To contribute, feel free to open an issue or submit a pull To contribute, feel free to open an issue or submit a pull
request. Let's make this configuration even better together! request. Let's make this configuration even better together!
## About PRs ## About PRs
Always welcome, not a promise to accept though (see above). Please Always welcome, not a promise to accept though (see above). Please

View File

@@ -5,7 +5,7 @@ echo ">>> (re)Installing Emacs Kick ..."
sleep 2 sleep 2
echo ">>> Deleting packages, grammars and native compilation cache ..." echo ">>> Deleting packages, grammars and native compilation cache ..."
rm -rf eln-cache/ elpa/ tree-sitter/ rm -rf eln-cache/ elpa/ tree-sitter/ straight/
sleep 2 sleep 2
echo ">>> Starting Emacs and auto-package fetching/installing ..." echo ">>> Starting Emacs and auto-package fetching/installing ..."

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; -*- ;;; init.el --- Emacs-Kick --- A feature rich Emacs config for (neo)vi(m)mers -*- lexical-binding: t; -*-
;; Author: Rahul Martim Juliato ;; 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 ;; License: GPL-2.0-or-later
;;; Commentary: ;;; Commentary:
@@ -82,7 +83,7 @@
;; ;;
;; If you encounter any errors while installing Emacs-Kick, ;; If you encounter any errors while installing Emacs-Kick,
;; check the *Messages* buffer for more information. You can switch ;; 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`. ;; with `C-p` and `C-n`.
;; ;;
;; I hope you enjoy your Emacs journey, ;; 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?'. ;; 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. ;; 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. ;; 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
;; Requires the default Emacs package manager, similar to an 'import' in other languages. ;; 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, ;; 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) (require 'package)
;; Add MELPA (Milkypostman's Emacs Lisp Package Archive) to the list of package archives. ;; 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 ;; 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 ;; 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. ;; 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)
;; Define a global customizable variable `ek-use-nerd-fonts' to control the use of
;; Define a global customizable variable `ek-use-nerd-fonts' to control the use of ;; Nerd Fonts symbols throughout the configuration. This boolean variable allows
;; Nerd Fonts symbols throughout the configuration. This boolean variable allows ;; users to easily enable or disable the use of symbols from Nerd Fonts, providing
;; 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
;; flexibility in appearance settings. By setting it to `t', we enable Nerd Fonts
;; symbols; setting it to `nil' would disable them. ;; 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."
@@ -146,28 +171,30 @@
:group 'appearance) :group 'appearance)
;; From now on, you'll see configurations using the `use-package' macro, which ;; 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 ;; allows us to organize our Emacs setup in a modular way. These configurations
;; look like this: ;; look like this:
;; ;;
;; (use-package some-package ;; (use-package some-package
;; :ensure t ;; Ensure the package is installed. ;; :ensure t ;; Ensure the package is installed (used with package.el).
;; :config ;; Configuration settings for the package. ;; :straight t ;; Use straight.el to install and manage this package.
;; :config ;; Configuration settings for the package.
;; ;; Additional settings can go here. ;; ;; Additional settings can go here.
;; ) ;; )
;; ;;
;; This approach simplifies package management, enabling us to easily control ;; This approach simplifies package management, enabling us to easily control
;; both built-in (first-party) and external (third-party) packages. While Emacs ;; both built-in (first-party) and external (third-party) packages. While Emacs
;; is a vast and powerful editor, using `use-package' helps streamline our ;; is a vast and powerful editor, using `use-package`—especially in combination
;; configuration for better organization and customization. As we proceed, ;; with `straight.el`—helps streamline our configuration for better organization,
;; you'll see smaller `use-package' declarations for specific packages, which ;; reproducibility, and customization. As we proceed, you'll see smaller
;; will help us enable the desired features and improve our workflow. ;; `use-package` declarations for specific packages, which will help us enable
;; the desired features and improve our workflow.
;;; EMACS ;;; EMACS
;; This is biggest one. Keep going, plugins (oops, I mean packages) will be shorter :) ;; This is biggest one. Keep going, plugins (oops, I mean packages) will be shorter :)
(use-package emacs (use-package emacs
:ensure nil :ensure nil
:custom ;; Set custom variables to configure Emacs behavior. :custom ;; Set custom variables to configure Emacs behavior.
(column-number-mode t) ;; Display the column number in the mode line. (column-number-mode t) ;; Display the column number in the mode line.
(auto-save-default nil) ;; Disable automatic saving of buffers. (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 ;; 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. ;; 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) (defun skip-these-buffers (_window buffer _bury-or-kill)
"Function for `switch-to-prev-buffer-skip'." "Function for `switch-to-prev-buffer-skip'."
(string-match "\\*[^*]+\\*" (buffer-name buffer))) (string-match "\\*[^*]+\\*" (buffer-name buffer)))
(setq switch-to-prev-buffer-skip 'skip-these-buffers) (setq switch-to-prev-buffer-skip 'skip-these-buffers)
@@ -232,7 +259,7 @@
(when scroll-bar-mode (when scroll-bar-mode
(scroll-bar-mode -1)) ;; Disable the scroll bar if it is active. (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. (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). (indent-tabs-mode -1) ;; Disable the use of tabs for indentation (use spaces instead).
(recentf-mode 1) ;; Enable tracking of recently opened files. (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 a hook to run code after Emacs has fully initialized.
(add-hook 'after-init-hook (add-hook 'after-init-hook
(lambda () (lambda ()
(message "Emacs has fully loaded. This code runs after startup.") (message "Emacs has fully loaded. This code runs after startup.")
;; Insert a welcome message in the *scratch* buffer displaying loading time and activated packages. ;; Insert a welcome message in the *scratch* buffer displaying loading time and activated packages.
(with-current-buffer (get-buffer-create "*scratch*") (with-current-buffer (get-buffer-create "*scratch*")
(insert (format (insert (format
";; Welcome to Emacs! ";; Welcome to Emacs!
;; ;;
;; Loading time : %s ;; Loading time : %s
;; Packages : %s ;; Packages : %s
" "
(emacs-init-time) (emacs-init-time)
(number-to-string (length package-activated-list)))))))) (number-to-string (length package-activated-list))))))))
;;; WINDOW ;;; WINDOW
;; This section configures window management in Emacs, enhancing the way buffers ;; This section configures window management in Emacs, enhancing the way buffers
;; are displayed for a more efficient workflow. The `window' use-package helps ;; are displayed for a more efficient workflow. The `window' use-package helps
;; streamline how various buffers are shown, especially those related to help, ;; streamline how various buffers are shown, especially those related to help,
;; diagnostics, and completion. ;; diagnostics, and completion.
;; ;;
;; Note: I have left some commented-out code below that may facilitate your ;; Note: I have left some commented-out code below that may facilitate your
;; Emacs journey later on. These configurations can be useful for displaying ;; Emacs journey later on. These configurations can be useful for displaying
;; other types of buffers in side windows, allowing for a more organized workspace. ;; 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\\*" ;; ("\\*.*e?shell\\*"
;; (display-buffer-in-side-window) ;; (display-buffer-in-side-window)
;; (window-height . 0.25) ;; (window-height . 0.25)
;; (side . bottom) ;; (side . bottom)
;; (slot . -1)) ;; (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)
@@ -295,7 +322,7 @@
(window-height . 0.25) (window-height . 0.25)
(side . bottom) (side . bottom)
(slot . 0)) (slot . 0))
;; Configuration for displaying various diagnostic buffers on ;; Configuration for displaying various diagnostic buffers on
;; bottom 25%: ;; bottom 25%:
("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)" ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
@@ -303,20 +330,20 @@
(window-height . 0.25) (window-height . 0.25)
(side . bottom) (side . bottom)
(slot . 1)) (slot . 1))
))) )))
;;; DIRED ;;; DIRED
;; In Emacs, the `dired' package provides a powerful and built-in file manager ;; In Emacs, the `dired' package provides a powerful and built-in file manager
;; that allows you to navigate and manipulate files and directories directly ;; 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 ;; within the editor. If you're familiar with `oil.nvim', you'll find that
;; `dired' offers similar functionality natively in Emacs, making file ;; `dired' offers similar functionality natively in Emacs, making file
;; management seamless without needing external plugins. ;; management seamless without needing external plugins.
;; This configuration customizes `dired' to enhance its usability. The settings ;; This configuration customizes `dired' to enhance its usability. The settings
;; below specify how file listings are displayed, the target for file operations, ;; below specify how file listings are displayed, the target for file operations,
;; and associations for opening various file types with their respective applications. ;; and associations for opening various file types with their respective applications.
;; For example, image files will open with `feh', while audio and video files ;; For example, image files will open with `feh', while audio and video files
;; will utilize `mpv'. ;; 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.
@@ -336,16 +363,16 @@
;;; ERC ;;; ERC
;; In this section, we introduce ERC (Emacs Relay Chat), a built-in IRC client ;; 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 ;; 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 ;; 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 ;; 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 ;; 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 ;; videos and listening to music, to managing emails and even serving as a window
;; manager in Xorg, freeing themselves from traditional desktop environments. ;; manager in Xorg, freeing themselves from traditional desktop environments.
;; ;;
;; While this kickstarter focuses on essential configurations, I wanted to present ;; 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 ;; 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. ;; 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')
@@ -357,10 +384,10 @@
;;; ISEARCH ;;; ISEARCH
;; In this configuration, we're setting up isearch, Emacs's incremental search feature. ;; 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 ;; 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 ;; (like `/' and `?') are not bound in the same way. Instead, you'll need to use
;; the standard Emacs shortcuts: ;; the standard Emacs shortcuts:
;; - `C-s' to initiate a forward search ;; - `C-s' to initiate a forward search
;; - `C-r' to initiate a backward search ;; - `C-r' to initiate a backward search
;; The following settings enhance the isearch experience: ;; The following settings enhance the isearch experience:
@@ -377,10 +404,10 @@
;;; VC ;;; VC
;; The VC (Version Control) package is included here for awareness and completeness. ;; 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 ;; 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, ;; that it exists and can be used for other version control systems like Mercurial,
;; Subversion, and Bazaar. ;; 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. ;; for an enhanced Git experience.
;; The keybindings below serve as a reminder of some common VC commands. ;; The keybindings below serve as a reminder of some common VC commands.
;; But don't worry, you can always use `M-x command' :) ;; 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 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) ;; 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")
@@ -412,7 +439,7 @@
;;; SMERGE ;;; 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. ;; 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. ;; 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 ;; The keybindings below did not needed to be setted, are here just to show
@@ -428,21 +455,21 @@
;;; ELDOC ;;; ELDOC
;; Eldoc provides helpful inline documentation for functions and variables ;; Eldoc provides helpful inline documentation for functions and variables
;; in the minibuffer, enhancing the development experience. It can be particularly useful ;; 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. ;; 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. ;; This package is built-in, so there's no need to fetch it separately.
;; The following line enables Eldoc globally for all buffers. ;; 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
;; Flymake is an on-the-fly syntax checking extension that provides real-time feedback ;; 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 ;; 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 ;; coding experience by catching issues early. The configuration below activates
;; Flymake mode in programming buffers. ;; 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.
@@ -451,14 +478,14 @@
:custom :custom
(flymake-margin-indicators-string (flymake-margin-indicators-string
'((error "" compilation-error) (warning "»" compilation-warning) '((error "" compilation-error) (warning "»" compilation-warning)
(note "»" compilation-info)))) (note "»" compilation-info))))
;;; ORG-MODE ;;; ORG-MODE
;; Org-mode is a powerful system for organizing and managing your notes, ;; Org-mode is a powerful system for organizing and managing your notes,
;; tasks, and documents in plain text. It offers features like task management, ;; tasks, and documents in plain text. It offers features like task management,
;; outlining, scheduling, and much more, making it a versatile tool for ;; outlining, scheduling, and much more, making it a versatile tool for
;; productivity. The configuration below simply defers loading Org-mode until ;; productivity. The configuration below simply defers loading Org-mode until
;; it's explicitly needed, which can help speed up Emacs startup time. ;; it's explicitly needed, which can help speed up Emacs startup time.
(use-package org (use-package org
:ensure nil ;; This is built-in, no need to fetch it. :ensure nil ;; This is built-in, no need to fetch it.
@@ -466,10 +493,10 @@
;;; WHICH-KEY ;;; WHICH-KEY
;; `which-key' is an Emacs package that displays available keybindings in a ;; `which-key' is an Emacs package that displays available keybindings in a
;; popup window whenever you partially type a key sequence. This is particularly ;; popup window whenever you partially type a key sequence. This is particularly
;; useful for discovering commands and shortcuts, making it easier to learn ;; useful for discovering commands and shortcuts, making it easier to learn
;; Emacs and improve your workflow. It helps users remember key combinations ;; Emacs and improve your workflow. It helps users remember key combinations
;; and reduces the cognitive load of memorizing every command. ;; 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.
@@ -484,22 +511,23 @@
;; that enhance Emacs' functionality and extend its capabilities. ;; that enhance Emacs' functionality and extend its capabilities.
;;; VERTICO ;;; 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. ;; 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, ;; in a horizontal format, Vertico presents candidates in a vertical list,
;; making it easier to browse and select from multiple options. ;; making it easier to browse and select from multiple options.
;; ;;
;; In buffer completion, `switch-to-buffer' allows you to select from open buffers. ;; 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 ;; Vertico streamlines this process by displaying the buffer list in a way that
;; improves visibility and accessibility. This is particularly useful when you ;; improves visibility and accessibility. This is particularly useful when you
;; have many buffers open, allowing you to quickly find the one you need. ;; have many buffers open, allowing you to quickly find the one you need.
;; ;;
;; In minibuffer completion, such as when entering commands or file paths, ;; 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. ;; it easier to choose the correct one without typing out the entire string.
(use-package vertico (use-package vertico
:ensure t :ensure t
:straight t
:hook :hook
(after-init . vertico-mode) ;; Enable vertico after Emacs has initialized. (after-init . vertico-mode) ;; Enable vertico after Emacs has initialized.
:custom :custom
@@ -511,22 +539,23 @@
;; This will prefix the current candidate with “» ” to make it stand out. ;; This will prefix the current candidate with “» ” to make it stand out.
;; Reference: https://github.com/minad/vertico/wiki#prefix-current-candidate-with-arrow ;; 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))
(concat (concat
(if (= vertico--index index) (if (= vertico--index index)
(propertize "» " 'face '(:foreground "#80adf0" :weight bold)) (propertize "» " 'face '(:foreground "#80adf0" :weight bold))
" ") " ")
cand)))) cand))))
;;; ORDERLESS ;;; ORDERLESS
;; Orderless enhances completion in Emacs by allowing flexible pattern matching. ;; Orderless enhances completion in Emacs by allowing flexible pattern matching.
;; It works seamlessly with Vertico, enabling you to use partial strings and ;; It works seamlessly with Vertico, enabling you to use partial strings and
;; regular expressions to find files, buffers, and commands more efficiently. ;; regular expressions to find files, buffers, and commands more efficiently.
;; This combination provides a powerful and customizable completion experience. ;; This combination provides a powerful and customizable completion experience.
(use-package orderless (use-package orderless
:ensure t :ensure t
:straight t
:defer t ;; Load Orderless on demand. :defer t ;; Load Orderless on demand.
:after vertico ;; Ensure Vertico is loaded before Orderless. :after vertico ;; Ensure Vertico is loaded before Orderless.
:init :init
@@ -536,23 +565,25 @@
;;; MARGINALIA ;;; MARGINALIA
;; Marginalia enhances the completion experience in Emacs by adding ;; Marginalia enhances the completion experience in Emacs by adding
;; additional context to the completion candidates. This includes ;; additional context to the completion candidates. This includes
;; helpful annotations such as documentation and other relevant ;; helpful annotations such as documentation and other relevant
;; information, making it easier to choose the right option. ;; information, making it easier to choose the right option.
(use-package marginalia (use-package marginalia
:ensure t :ensure t
:straight t
:hook :hook
(after-init . marginalia-mode)) (after-init . marginalia-mode))
;;; CONSULT ;;; CONSULT
;; Consult provides powerful completion and narrowing commands for Emacs. ;; Consult provides powerful completion and narrowing commands for Emacs.
;; It integrates well with other completion frameworks like Vertico, enabling ;; It integrates well with other completion frameworks like Vertico, enabling
;; features like previews and enhanced register management. It's useful for ;; features like previews and enhanced register management. It's useful for
;; navigating buffers, files, and xrefs with ease. ;; navigating buffers, files, and xrefs with ease.
(use-package consult (use-package consult
:ensure t :ensure t
:straight t
:defer t :defer t
:init :init
;; Enhance register preview with thin lines and no mode line. ;; Enhance register preview with thin lines and no mode line.
@@ -564,33 +595,36 @@
;;; EMBARK ;;; EMBARK
;; Embark provides a powerful contextual action menu for Emacs, allowing ;; Embark provides a powerful contextual action menu for Emacs, allowing
;; you to perform various operations on completion candidates and other items. ;; you to perform various operations on completion candidates and other items.
;; It extends the capabilities of completion frameworks by offering direct ;; It extends the capabilities of completion frameworks by offering direct
;; actions on the candidates. ;; actions on the candidates.
;; Just `<leader> .' over any text, explore it :) ;; Just `<leader> .' over any text, explore it :)
(use-package embark (use-package embark
:ensure t :ensure t
:straight t
:defer t) :defer t)
;;; EMBARK-CONSULT ;;; 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. ;; that Consult commands, like previews, are available when using Embark.
(use-package embark-consult (use-package embark-consult
:ensure t :ensure t
:straight 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 ;;; TREESITTER-AUTO
;; Treesit-auto simplifies the use of Tree-sitter grammars in Emacs, ;; Treesit-auto simplifies the use of Tree-sitter grammars in Emacs,
;; providing automatic installation and mode association for various ;; providing automatic installation and mode association for various
;; programming languages. This enhances syntax highlighting and ;; programming languages. This enhances syntax highlighting and
;; code parsing capabilities, making it easier to work with modern ;; code parsing capabilities, making it easier to work with modern
;; programming languages. ;; programming languages.
(use-package treesit-auto (use-package treesit-auto
:ensure t :ensure t
:straight t
:after emacs :after emacs
:custom :custom
(treesit-auto-install 'prompt) (treesit-auto-install 'prompt)
@@ -600,39 +634,41 @@
;;; MARKDOWN-MODE ;;; MARKDOWN-MODE
;; Markdown Mode provides support for editing Markdown files in Emacs, ;; Markdown Mode provides support for editing Markdown files in Emacs,
;; enabling features like syntax highlighting, previews, and more. ;; enabling features like syntax highlighting, previews, and more.
;; Its particularly useful for README files, as it can be set ;; Its particularly useful for README files, as it can be set
;; to use GitHub Flavored Markdown for enhanced compatibility. ;; to use GitHub Flavored Markdown for enhanced compatibility.
(use-package markdown-mode (use-package markdown-mode
:defer t :defer t
:straight t
:ensure t :ensure t
:mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files. :mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files.
:init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command. :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
;;; COMPANY ;;; COMPANY
;; Company Mode provides a text completion framework for Emacs. ;; Company Mode provides a text completion framework for Emacs.
;; It enhances the editing experience by offering context-aware ;; It enhances the editing experience by offering context-aware
;; suggestions as you type. With support for multiple backends, ;; suggestions as you type. With support for multiple backends,
;; Company Mode is highly customizable and can be integrated with ;; Company Mode is highly customizable and can be integrated with
;; various modes and languages. ;; various modes and languages.
(use-package company (use-package company
:defer t :defer t
:straight t
:ensure t :ensure t
:custom :custom
(company-tooltip-align-annotations t) ;; Align annotations with completions. (company-tooltip-align-annotations t) ;; Align annotations with completions.
(company-minimum-prefix-length 1) ;; Trigger completion after typing 1 character (company-minimum-prefix-length 1) ;; Trigger completion after typing 1 character
(company-idle-delay 0.2) ;; Delay before showing completion (adjust as needed) (company-idle-delay 0.2) ;; Delay before showing completion (adjust as needed)
(company-tooltip-maximum-width 50) (company-tooltip-maximum-width 50)
:config :config
;; While using C-p C-n to select a completion candidate ;; While using C-p C-n to select a completion candidate
;; C-y quickly shows help docs for the current 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)
(company-show-doc-buffer))) (company-show-doc-buffer)))
(define-key company-active-map [tab] 'company-complete-selection) (define-key company-active-map [tab] 'company-complete-selection)
(define-key company-active-map (kbd "TAB") 'company-complete-selection) (define-key company-active-map (kbd "TAB") 'company-complete-selection)
(define-key company-active-map [ret] 'company-complete-selection) (define-key company-active-map [ret] 'company-complete-selection)
@@ -642,11 +678,11 @@
;;; LSP ;;; LSP
;; Emacs comes with an integrated LSP client called `eglot', which offers basic LSP functionality. ;; 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 ;; However, `eglot' has limitations, such as not supporting multiple language servers
;; simultaneously within the same buffer (e.g., handling both TypeScript, Tailwind and ESLint ;; 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 ;; 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 ;; `lsp-mode' is included as a third-party package, providing advanced IDE-like features
;; and better support for multiple language servers and configurations. ;; and better support for multiple language servers and configurations.
;; ;;
;; NOTE: To install or reinstall an LSP server, use `M-x install-server RET`. ;; 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/ ;; https://emacs-lsp.github.io/lsp-mode/
(use-package lsp-mode (use-package lsp-mode
:ensure t :ensure t
:straight t
:defer t :defer t
:hook (;; Replace XXX-mode with concrete major mode (e.g. python-mode) :hook (;; Replace XXX-mode with concrete major mode (e.g. python-mode)
(bash-ts-mode . lsp) ;; Enable LSP for Bash (bash-ts-mode . lsp) ;; Enable LSP for Bash
@@ -710,13 +747,14 @@
;;; LSP Additional Servers ;;; LSP Additional Servers
;; You can extend `lsp-mode' by integrating additional language servers for specific ;; You can extend `lsp-mode' by integrating additional language servers for specific
;; technologies. For example, `lsp-tailwindcss' provides support for Tailwind CSS ;; technologies. For example, `lsp-tailwindcss' provides support for Tailwind CSS
;; classes within your HTML files. By using various LSP packages, you can connect ;; classes within your HTML files. By using various LSP packages, you can connect
;; multiple LSP servers simultaneously, enhancing your coding experience across ;; multiple LSP servers simultaneously, enhancing your coding experience across
;; different languages and frameworks. ;; different languages and frameworks.
(use-package lsp-tailwindcss (use-package lsp-tailwindcss
:ensure t :ensure t
:straight t
:defer t :defer t
:config :config
(add-to-list 'lsp-language-id-configuration '(".*\\.erb$" . "html")) ;; Associate ERB files with HTML. (add-to-list 'lsp-language-id-configuration '(".*\\.erb$" . "html")) ;; Associate ERB files with HTML.
@@ -725,19 +763,20 @@
;;; Diff-HL ;;; Diff-HL
;; The `diff-hl' package provides visual indicators for version control changes ;; The `diff-hl' package provides visual indicators for version control changes
;; directly in the margin of the buffer, showing lines added, deleted, or changed. ;; 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, ;; This is useful for tracking modifications while you edit files. When enabled,
;; it automatically activates in every buffer that has a corresponding version ;; it automatically activates in every buffer that has a corresponding version
;; control backend, offering a seamless experience. ;; control backend, offering a seamless experience.
;; ;;
;; In comparison, Neovim users often rely on plugins like `gitsigns.nvim' or ;; In comparison, Neovim users often rely on plugins like `gitsigns.nvim' or
;; `vim-signify', which provide similar functionalities by displaying Git ;; `vim-signify', which provide similar functionalities by displaying Git
;; changes in the gutter and offer additional features like highlighting ;; changes in the gutter and offer additional features like highlighting
;; changed lines and displaying blame information. `diff-hl' aims to provide ;; changed lines and displaying blame information. `diff-hl' aims to provide
;; a comparable experience in Emacs with its own set of customizations. ;; a comparable experience in Emacs with its own set of customizations.
(use-package diff-hl (use-package diff-hl
:defer t :defer t
:straight t
:ensure t :ensure t
:hook :hook
(find-file . (lambda () (find-file . (lambda ()
@@ -747,53 +786,56 @@
:custom :custom
(diff-hl-side 'left) ;; Set the side for diff indicators. (diff-hl-side 'left) ;; Set the side for diff indicators.
(diff-hl-margin-symbols-alist '((insert . "") ;; Customize symbols for each change type. (diff-hl-margin-symbols-alist '((insert . "") ;; Customize symbols for each change type.
(delete . "-") (delete . "-")
(change . "") (change . "")
(unknown . "?") (unknown . "?")
(ignored . "i")))) (ignored . "i"))))
;;; Magit ;;; Magit
;; `magit' is a powerful Git interface for Emacs that provides a complete ;; `magit' is a powerful Git interface for Emacs that provides a complete
;; set of features to manage Git repositories. With its intuitive interface, ;; set of features to manage Git repositories. With its intuitive interface,
;; you can easily stage, commit, branch, merge, and perform other Git ;; you can easily stage, commit, branch, merge, and perform other Git
;; operations directly from Emacs. Magits powerful UI allows for a seamless ;; operations directly from Emacs. Magits powerful UI allows for a seamless
;; workflow, enabling you to visualize your repository's history and manage ;; workflow, enabling you to visualize your repository's history and manage
;; changes efficiently. ;; changes efficiently.
;; ;;
;; In the Neovim ecosystem, similar functionality is provided by plugins such as ;; In the Neovim ecosystem, similar functionality is provided by plugins such as
;; `fugitive.vim', which offers a robust Git integration with commands that ;; `fugitive.vim', which offers a robust Git integration with commands that
;; allow you to perform Git operations directly within Neovim. Another popular ;; allow you to perform Git operations directly within Neovim. Another popular
;; option is `neogit', which provides a more modern and user-friendly interface ;; option is `neogit', which provides a more modern and user-friendly interface
;; for Git commands in Neovim, leveraging features like diff views and staging ;; 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 ;; changes in a visual format. Both of these plugins aim to replicate and
;; extend the powerful capabilities that Magit offers in Emacs. ;; extend the powerful capabilities that Magit offers in Emacs.
(use-package magit (use-package magit
:ensure t :ensure t
:straight t
:defer t) :defer t)
;;; XCLIP ;;; XCLIP
;; `xclip' is an Emacs package that integrates the X Window System clipboard ;; `xclip' is an Emacs package that integrates the X Window System clipboard
;; with Emacs. It allows seamless copying and pasting between Emacs and other ;; with Emacs. It allows seamless copying and pasting between Emacs and other
;; applications using the clipboard. When `xclip' is enabled, any text copied ;; applications using the clipboard. When `xclip' is enabled, any text copied
;; in Emacs can be pasted in other applications, and vice versa, providing a ;; in Emacs can be pasted in other applications, and vice versa, providing a
;; smooth workflow when working across multiple environments. ;; smooth workflow when working across multiple environments.
(use-package xclip (use-package xclip
:ensure t :ensure t
:straight t
:defer t :defer t
:hook :hook
(after-init . xclip-mode)) ;; Enable xclip mode after initialization. (after-init . xclip-mode)) ;; Enable xclip mode after initialization.
;;; INDENT-GUIDE ;;; INDENT-GUIDE
;; The `indent-guide' package provides visual indicators for indentation levels ;; The `indent-guide' package provides visual indicators for indentation levels
;; in programming modes, making it easier to see code structure at a glance. ;; 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 ;; It draws vertical lines (by default, a character of your choice) at each
;; level of indentation, helping to improve readability and navigation within ;; level of indentation, helping to improve readability and navigation within
;; the code. ;; the code.
(use-package indent-guide (use-package indent-guide
:defer t :defer t
:straight t
:ensure t :ensure t
:hook :hook
(prog-mode . indent-guide-mode) ;; Activate indent-guide in programming modes. (prog-mode . indent-guide-mode) ;; Activate indent-guide in programming modes.
@@ -802,35 +844,36 @@
;;; ADD-NODE-MODULES-PATH ;;; ADD-NODE-MODULES-PATH
;; The `add-node-modules-path' package ensures that Emacs uses the local ;; The `add-node-modules-path' package ensures that Emacs uses the local
;; `node_modules/.bin' for a project rather than globally installed binaries. ;; `node_modules/.bin' for a project rather than globally installed binaries.
;; This is essential in JavaScript/TypeScript projects where different versions ;; This is essential in JavaScript/TypeScript projects where different versions
;; of tools like `eslint' and `typescript-language-server' might be needed ;; of tools like `eslint' and `typescript-language-server' might be needed
;; per project. ;; 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. ;; Node.js tools and ensures consistency across different environments.
;; ;;
;; Example in the wild: This is an example of a real-world issue often faced ;; 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 ;; by developers using modern tech stacks. When working on multiple projects
;; with different dependencies, Emacs must use the correct local versions ;; with different dependencies, Emacs must use the correct local versions
;; instead of relying on globally installed packages. This configuration ;; instead of relying on globally installed packages. This configuration
;; ensures that the environment is accurate and project-specific tools are ;; ensures that the environment is accurate and project-specific tools are
;; properly utilized. ;; properly utilized.
(use-package add-node-modules-path (use-package add-node-modules-path
:ensure t :ensure t
:straight t
:defer t :defer t
:custom :custom
;; Makes sure you are using the local bin for your ;; Makes sure you are using the local bin for your
;; node project. Local eslint, typescript server... ;; node project. Local eslint, typescript server...
(eval-after-load 'typescript-ts-mode (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 (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 (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 (eval-after-load 'js-mode
'(add-hook 'js-mode-hook #'add-node-modules-path))) '(add-hook 'js-mode-hook #'add-node-modules-path)))
;; EVIL ;; EVIL
@@ -840,6 +883,7 @@
;; experience. ;; experience.
(use-package evil (use-package evil
:ensure t :ensure t
:straight t
:defer t :defer t
:hook :hook
(after-init . evil-mode) (after-init . evil-mode)
@@ -856,8 +900,8 @@
(setq evil-want-fine-undo t) ;; Evil uses finer grain undoing steps (setq evil-want-fine-undo t) ;; Evil uses finer grain undoing steps
;; Define the leader key as Space ;; Define the leader key as Space
(evil-set-leader 'normal (kbd "SPC")) (evil-set-leader 'normal (kbd "SPC"))
(evil-set-leader 'visual (kbd "SPC")) (evil-set-leader 'visual (kbd "SPC"))
;; Keybindings for searching and finding files. ;; Keybindings for searching and finding files.
(evil-define-key 'normal 'global (kbd "<leader> s f") 'consult-find) (evil-define-key 'normal 'global (kbd "<leader> s f") 'consult-find)
@@ -933,29 +977,29 @@
;; Custom example. Formatting with prettier tool. ;; Custom example. Formatting with prettier tool.
(evil-define-key 'normal 'global (kbd "<leader> m p") (evil-define-key 'normal 'global (kbd "<leader> m p")
(lambda () (lambda ()
(interactive) (interactive)
(shell-command (concat "prettier --write " (shell-quote-argument (buffer-file-name)))) (shell-command (concat "prettier --write " (shell-quote-argument (buffer-file-name))))
(revert-buffer t t t))) (revert-buffer t t t)))
;; LSP commands keybindings ;; LSP commands keybindings
(evil-define-key 'normal lsp-mode-map (evil-define-key 'normal lsp-mode-map
;; (kbd "gd") 'lsp-find-definition ;; evil-collection already provides gd ;; (kbd "gd") 'lsp-find-definition ;; evil-collection already provides gd
(kbd "gr") 'lsp-find-references ;; Finds LSP references (kbd "gr") 'lsp-find-references ;; Finds LSP references
(kbd "<leader> c a") 'lsp-execute-code-action ;; Execute code actions (kbd "<leader> c a") 'lsp-execute-code-action ;; Execute code actions
(kbd "<leader> r n") 'lsp-rename ;; Rename symbol (kbd "<leader> r n") 'lsp-rename ;; Rename symbol
(kbd "gI") 'lsp-find-implementation ;; Find implementation (kbd "gI") 'lsp-find-implementation ;; Find implementation
(kbd "<leader> l f") 'lsp-format-buffer) ;; Format buffer via lsp (kbd "<leader> l f") 'lsp-format-buffer) ;; Format buffer via lsp
(defun ek/lsp-describe-and-jump () (defun ek/lsp-describe-and-jump ()
"Show hover documentation and jump to *lsp-help* buffer." "Show hover documentation and jump to *lsp-help* buffer."
(interactive) (interactive)
(lsp-describe-thing-at-point) (lsp-describe-thing-at-point)
(let ((help-buffer "*lsp-help*")) (let ((help-buffer "*lsp-help*"))
(when (get-buffer help-buffer) (when (get-buffer help-buffer)
(switch-to-buffer-other-window help-buffer)))) (switch-to-buffer-other-window help-buffer))))
;; Open hover documentation ;; Open hover documentation
(evil-define-key 'normal 'global (kbd "K") 'ek/lsp-describe-and-jump) (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, ;; Yeah, on terminals, Emacs doesn't support (YET), the use of floating windows,
@@ -966,16 +1010,16 @@
;; Commenting functionality for single and multiple lines ;; Commenting functionality for single and multiple lines
(evil-define-key 'normal 'global (kbd "gcc") (evil-define-key 'normal 'global (kbd "gcc")
(lambda () (lambda ()
(interactive) (interactive)
(if (not (use-region-p)) (if (not (use-region-p))
(comment-or-uncomment-region (line-beginning-position) (line-end-position))))) (comment-or-uncomment-region (line-beginning-position) (line-end-position)))))
(evil-define-key 'visual 'global (kbd "gc") (evil-define-key 'visual 'global (kbd "gc")
(lambda () (lambda ()
(interactive) (interactive)
(if (use-region-p) (if (use-region-p)
(comment-or-uncomment-region (region-beginning) (region-end))))) (comment-or-uncomment-region (region-beginning) (region-end)))))
;; Enable evil mode ;; Enable evil mode
(evil-mode 1)) (evil-mode 1))
@@ -988,6 +1032,7 @@
;; commands to fit the `evil' style. ;; commands to fit the `evil' style.
(use-package evil-collection (use-package evil-collection
:defer t :defer t
:straight t
:ensure t :ensure t
:custom :custom
(evil-collection-want-find-usages-bindings t) (evil-collection-want-find-usages-bindings t)
@@ -1008,6 +1053,7 @@
;; - https://github.com/emacs-evil/evil-surround?tab=readme-ov-file#examples ;; - https://github.com/emacs-evil/evil-surround?tab=readme-ov-file#examples
(use-package evil-surround (use-package evil-surround
:ensure t :ensure t
:straight t
:after evil-collection :after evil-collection
:config :config
(global-evil-surround-mode 1)) (global-evil-surround-mode 1))
@@ -1021,6 +1067,7 @@
;; Just use % for jumping between matching structures to check it out. ;; Just use % for jumping between matching structures to check it out.
(use-package evil-matchit (use-package evil-matchit
:ensure t :ensure t
:straight t
:after evil-collection :after evil-collection
:config :config
(global-evil-matchit-mode 1)) (global-evil-matchit-mode 1))
@@ -1034,6 +1081,7 @@
(use-package undo-tree (use-package undo-tree
:defer t :defer t
:ensure t :ensure t
:straight t
:hook :hook
(after-init . global-undo-tree-mode) (after-init . global-undo-tree-mode)
:init :init
@@ -1058,6 +1106,7 @@
;; a different color, making it easier to match pairs visually. ;; a different color, making it easier to match pairs visually.
(use-package rainbow-delimiters (use-package rainbow-delimiters
:defer t :defer t
:straight t
:ensure t :ensure t
:hook :hook
(prog-mode . rainbow-delimiters-mode)) (prog-mode . rainbow-delimiters-mode))
@@ -1067,18 +1116,20 @@
;; A simple major mode to provide .env files with color highlighting ;; A simple major mode to provide .env files with color highlighting
(use-package dotenv-mode (use-package dotenv-mode
:defer t :defer t
:straight t
:ensure t :ensure t
:config) :config)
;;; PULSAR ;;; PULSAR
;; The `pulsar' package enhances the user experience in Emacs by providing ;; The `pulsar' package enhances the user experience in Emacs by providing
;; visual feedback through pulsating highlights. This feature is especially ;; visual feedback through pulsating highlights. This feature is especially
;; useful in programming modes, where it can help users easily track ;; useful in programming modes, where it can help users easily track
;; actions such as scrolling, error navigation, yanking, deleting, and ;; actions such as scrolling, error navigation, yanking, deleting, and
;; jumping to definitions. ;; jumping to definitions.
(use-package pulsar (use-package pulsar
:defer t :defer t
:straight t
:ensure t :ensure t
:hook :hook
(after-init . pulsar-global-mode) (after-init . pulsar-global-mode)
@@ -1106,6 +1157,7 @@
;; experience by displaying relevant information in a compact format. ;; experience by displaying relevant information in a compact format.
(use-package doom-modeline (use-package doom-modeline
:ensure t :ensure t
:straight t
:defer t :defer t
:custom :custom
(doom-modeline-buffer-file-name-style 'buffer-name) ;; Set the buffer file name style to just the buffer name (without path). (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. ;; and integrates with version control to show file states.
(use-package neotree (use-package neotree
:ensure t :ensure t
:straight t
:custom :custom
(neo-show-hidden-files t) ;; By default shows hidden files (toggle with H) (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. (neo-theme 'nerd) ;; Set the default theme for Neotree to 'nerd' for a visually appealing look.
@@ -1138,35 +1191,38 @@
;;; NERD ICONS ;;; NERD ICONS
;; The `nerd-icons' package provides a set of icons for use in Emacs. These icons can ;; 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 ;; enhance the visual appearance of various modes and packages, making it easier to
;; distinguish between different file types and functionalities. ;; 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.
:straight t
: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 ;;; NERD ICONS Dired
;; The `nerd-icons-dired' package integrates nerd icons into the Dired mode, ;; The `nerd-icons-dired' package integrates nerd icons into the Dired mode,
;; providing visual icons for files and directories. This enhances the Dired ;; providing visual icons for files and directories. This enhances the Dired
;; interface by making it easier to identify file types at a glance. ;; 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.
:straight t
:defer t ;; Load the package only when needed to improve startup time. :defer t ;; Load the package only when needed to improve startup time.
:hook :hook
(dired-mode . nerd-icons-dired-mode)) (dired-mode . nerd-icons-dired-mode))
;;; NERD ICONS COMPLETION ;;; NERD ICONS COMPLETION
;; The `nerd-icons-completion' package enhances the completion interfaces in ;; The `nerd-icons-completion' package enhances the completion interfaces in
;; Emacs by integrating nerd icons with completion frameworks such as ;; Emacs by integrating nerd icons with completion frameworks such as
;; `marginalia'. This provides visual cues for the completion candidates, ;; `marginalia'. This provides visual cues for the completion candidates,
;; making it easier to distinguish between different types of items. ;; 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.
:straight t
:after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration. :after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration.
:config :config
(nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces. (nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces.
@@ -1174,25 +1230,26 @@
;;; CATPPUCCIN THEME ;;; CATPPUCCIN THEME
;; The `catppuccin-theme' package provides a visually pleasing color theme ;; The `catppuccin-theme' package provides a visually pleasing color theme
;; for Emacs that is inspired by the popular Catppuccin color palette. ;; for Emacs that is inspired by the popular Catppuccin color palette.
;; This theme aims to create a comfortable and aesthetic coding environment ;; This theme aims to create a comfortable and aesthetic coding environment
;; with soft colors that are easy on the eyes. ;; with soft colors that are easy on the eyes.
(use-package catppuccin-theme (use-package catppuccin-theme
:ensure t :ensure t
:straight t
:config :config
(custom-set-faces (custom-set-faces
;; Set the color for changes in the diff highlighting to blue. ;; 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. ;; 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. ;; 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 the Catppuccin theme without prompting for confirmation.
(load-theme 'catppuccin :no-confirm)) (load-theme 'catppuccin :no-confirm))
@@ -1210,16 +1267,7 @@
(message ">>> Configuring Nerd Fonts...") (message ">>> Configuring Nerd Fonts...")
(require 'nerd-icons) (require 'nerd-icons)
(nerd-icons-install-fonts) ;; Install all available nerd-fonts (nerd-icons-install-fonts) ;; Install all available nerd-fonts
(message ">>> Native compile 3rd-party packages...\n") (message ">>> Emacs-Kick installed! Press any key to close the installer and open Emacs normally. First boot will compile some extra stuff :)")
(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.
(read-key) ;; Wait for the user to press any key. (read-key) ;; Wait for the user to press any key.
(kill-emacs)) ;; Close Emacs after installation is complete. (kill-emacs)) ;; Close Emacs after installation is complete.