├── doc
├── demo01.png
└── emacs-kick-logo.png
├── ek-reinstall.sh
├── .gitignore
├── README.md
├── LICENSE
└── init.el
/doc/demo01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LionyxML/emacs-kick/HEAD/doc/demo01.png
--------------------------------------------------------------------------------
/doc/emacs-kick-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LionyxML/emacs-kick/HEAD/doc/emacs-kick-logo.png
--------------------------------------------------------------------------------
/ek-reinstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | clear
4 | echo ">>> (re)Installing Emacs Kick ..."
5 | sleep 2
6 |
7 | echo ">>> Deleting packages, grammars and native compilation cache ..."
8 | rm -rf eln-cache/ elpa/ tree-sitter/ straight/
9 | sleep 2
10 |
11 | echo ">>> Starting Emacs and auto-package fetching/installing ..."
12 | sleep 2
13 | emacs --init-dir="./" -nw --eval="(ek/first-install)"
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gitignore file
2 | # Remove backup files
3 |
4 | !/tree-sitter/bin/
5 | # Emacs tmp files & Misc
6 | # Emacs packages
7 | *#
8 | *.
9 | *.elc
10 | *.eln
11 | *~
12 | .
13 | .#*
14 | .dap-breakpoints
15 | .lsp-session*
16 | .org-id-locations
17 | /.DS_Store
18 | /.cache/
19 | /.emacs.desktop
20 | /.emacs.desktop.lock
21 | /.mc-lists.el
22 | /.python-environments/
23 | /.watsonresults
24 | /ac-comphist.dat
25 | /auto-save-list
26 | /bbdb
27 | /bookmarks
28 | /eln-cache
29 | /elpa
30 | /emms
31 | /eshell
32 | /eshell/history
33 | /eshell/lastdir
34 | /games/
35 | /ido.last
36 | /image-dired
37 | /network-security.data
38 | /newsticker/feeds/
39 | /places
40 | /projectile-bookmarks.eld
41 | /projectile.cache
42 | /projects
43 | /recentf
44 | /secrets.el
45 | /snippets/
46 | /tramp
47 | /transient
48 | /transient/
49 | /tree-sitter/
50 | /tree-sitter/bin/*
51 | /url/
52 | custom-vars.el
53 | gnus.el
54 | history
55 | ielm-history.eld
56 | p/.extension/
57 | savehist
58 | straight/
59 | var/
60 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | A feature rich Emacs (kickstarter) config for (neo)vi(m)mers
10 |
11 |
12 |
18 |
19 | ---
20 |
21 | # Emacs-Kick(starter) for Vim/Neovim Users
22 |
23 | Welcome to `Emacs-Kick`, a feature-rich Emacs configuration designed
24 | for users familiar with `Vim`, `Neovim`, and `Vi`. With this
25 | setup, you don't need to leave behind your favorite terminal or tools
26 | like `yazi`, `starship`, `lazygit`, and `lazydocker` just to
27 | give Emacs a try.
28 |
29 | Use Emacs the same way you'd use `Neovim`, seamlessly integrating it
30 | into your workflow inside terminal multiplexers like `tmux` or
31 | `Zellij`, while also enjoying modern features such as `treesitter`
32 | and `LSP`, no hassle.
33 |
34 | 
35 |
36 | **Emacs-Kick** isn’t a full-fledged distribution but rather a
37 | **starting point** for building your own Emacs configuration. It’s
38 | designed to be especially accessible for Vim/Neovim users, letting you
39 | explore the power of Emacs without committing to its entire ecosystem.
40 |
41 | You can take advantage of Emacs’ features without needing to master
42 | every Emacs-specific workflow right away. And if you find yourself
43 | enjoying it, you can:
44 |
45 | - Run it in a GUI for a richer experience
46 | - Customize and expand your configuration as much as you want
47 | - Experiment with frameworks like Doom Emacs or Spacemacs
48 | - Tinker with vanilla Emacs to build a setup entirely your own
49 | OR...
50 | - Just keep using it on TUI, it is all up to you!
51 |
52 | With `Emacs-Kick`, the goal is to empower you to explore Emacs at your
53 | own pace. The sky's the limit! 🌟
54 |
55 | ## Minimum Requirements
56 |
57 | - Emacs version **>=30.1**
58 | - You can verify your installed Emacs version by running:
59 |
60 | ```bash
61 | emacs --version
62 | ```
63 |
64 | **Note**: floating windows on TUI are only supported from Emacs >=31 (current
65 | development version on Emacs master branch).
66 |
67 |
68 | ### macOS Warning
69 |
70 | On macOS, `Emacs-Kick` may fail to function correctly due to missing or
71 | incompatible system utilities. To avoid common issues, make sure the
72 | following tools are installed via Homebrew:
73 |
74 | ```bash
75 | brew install coreutils git
76 | ```
77 |
78 | This provides:
79 |
80 | - `gls`: The GNU version of `ls`, required by Dired to avoid errors
81 | like:
82 |
83 | ```
84 | Listing directory failed but 'access-file' worked.
85 | ```
86 |
87 | - `git`: macOS system usually has an older version of Git, this
88 | typically refers to the version installed through Apple's Command
89 | Line Tools (part of Xcode). Installing from Homebrew ensures a
90 | modern version of git is installed and will avoid problems with
91 | `magit`.
92 |
93 |
94 | ## Installation Instructions
95 |
96 | 1. **Clone the repository**:
97 |
98 | **Note**: If you already have an existing Emacs configuration in
99 | `~/.emacs.d`, please back it up before proceeding. You can do this
100 | by renaming the directory:
101 |
102 | ```bash
103 | mv ~/.emacs.d ~/.emacs.d.backup
104 | ```
105 |
106 | If you have any additional configurations from other Emacs
107 | installations, please clean them up. This includes directories and
108 | files such as `~/.emacs.d`, `~/.emacs`, `~/.emacs~`,
109 | `~/.config/emacs`, `~/.config/doom`, `~/.config/cache/emacs` and
110 | any other related files.
111 |
112 | After deleting/backing up, clone the repository:
113 |
114 | ```bash
115 | git clone https://github.com/LionyxML/emacs-kick.git ~/.emacs.d
116 | ```
117 |
118 | 2. **Run the setup**:
119 |
120 | After cloning, install the configuration by running:
121 |
122 | ```bash
123 | emacs -nw --eval="(ek/first-install)"
124 | ```
125 |
126 | Alternatively, you can run the provided script `ek-reinstall.sh`
127 | from inside `~/.emacs.d/`, which will achieve the same result:
128 |
129 | ```bash
130 | cd ~/.emacs.d/ && ./ek-reinstall.sh
131 | ```
132 |
133 | Both methods will install all necessary packages and apply the
134 | configuration.
135 |
136 | **NOTE**: During the initial setup, you'll be prompted to install Tree-sitter
137 | grammars and download some fonts. This configuration uses **Nerd Fonts** by
138 | default, so installing them now is highly recommended for the best experience.
139 |
140 | **VERY IMPORTANT**: On first launch, Emacs will also **native compile some
141 | external packages**, which may take a little time. Additionally, the first time
142 | you perform certain actions, like opening the tree explorer, Emacs may compile
143 | related components in the background. This is completely normal and only
144 | happens once per feature. You might notice a brief moment of sluggish
145 | performance during this initial compilation.
146 |
147 | 3. **Set terminal mode by default**:
148 |
149 | **Note on Emacs TUI/GUI**: Emacs automatically adapts to either
150 | graphical or terminal mode depending on the environment. But if
151 | you're in a graphical session and prefer terminal mode, just use:
152 |
153 | ```bash
154 | emacs -nw
155 | ```
156 |
157 | To ensure Emacs always opens in terminal mode, add the following to
158 | your `.bashrc` or `.zshrc`:
159 |
160 | ```bash
161 | alias emacs='emacs -nw'
162 | ```
163 |
164 | Then, reload your shell configuration with:
165 |
166 | ```bash
167 | source ~/.bashrc # for bash
168 | source ~/.zshrc # for zsh
169 | ```
170 |
171 | 4. **Start Emacs**:
172 |
173 | Once set up, start Emacs with:
174 |
175 | ```bash
176 | emacs
177 | ```
178 |
179 | **Usage Tips**:
180 |
181 | - **Leader Key**: The leader key is set to `SPC` (spacebar),
182 | `which-key` is there to help you discover keybindings.
183 | - **Help Commands**:
184 | - `SPC h i` opens the Emacs info documentation (`M-x info`).
185 | - `SPC h v` allows you to explore available variables.
186 | - `SPC h f` lets you explore functions.
187 | - `SPC h k` displays keybindings.
188 |
189 | **Troubleshooting**:
190 |
191 | - If you encounter any issues during installation, check the
192 | `*Messages*` buffer for more information. You can switch between
193 | buffers with `SPC SPC`, and navigate options using `C-p` and `C-n`.
194 |
195 | ## Available Commands
196 |
197 | | Keybinding | Action |
198 | | -------------- | ----------------------------------------- |
199 | | `SPC` | Leader key |
200 | | `TAB` | Call completion |
201 | | `C-d` | Scroll down |
202 | | `C-u` | Scroll up |
203 | | ` s f` | Find file |
204 | | ` s g` | Grep |
205 | | ` s G` | Git grep |
206 | | ` s r` | Ripgrep |
207 | | ` s h` | Consult info |
208 | | ` /` | Consult line |
209 | | ` x x` | Consult Flymake |
210 | | `] d` | Next Flymake error |
211 | | `[ d` | Previous Flymake error |
212 | | ` x d` | Dired |
213 | | ` x j` | Dired jump |
214 | | ` x f` | Find file |
215 | | `] c` | Next diff hunk |
216 | | `[ c` | Previous diff hunk |
217 | | ` e e` | Toggle NeoTree |
218 | | ` g g` | Open Magit status |
219 | | ` g l` | Show current log |
220 | | ` g d` | Show diff for current file |
221 | | ` g D` | Show diff for hunk |
222 | | ` g b` | Annotate buffer with version control info |
223 | | `] b` | Switch to next buffer |
224 | | `[ b` | Switch to previous buffer |
225 | | ` b i` | Consult buffer list |
226 | | ` b b` | Open Ibuffer |
227 | | ` b d` | Kill current buffer |
228 | | ` b k` | Kill current buffer |
229 | | ` b x` | Kill current buffer |
230 | | ` b s` | Save buffer |
231 | | ` b l` | Consult buffer |
232 | | `SPC` | Consult buffer |
233 | | ` p b` | Consult project buffer |
234 | | ` p p` | Switch project |
235 | | ` p f` | Find file in project |
236 | | ` p g` | Find regexp in project |
237 | | ` p k` | Kill project buffers |
238 | | ` p D` | Dired for project |
239 | | `P` | Yank from kill ring |
240 | | ` P` | Yank from kill ring |
241 | | ` .` | Embark act |
242 | | ` u` | Undo tree visualize |
243 | | ` h m` | Describe current mode |
244 | | ` h f` | Describe function |
245 | | ` h v` | Describe variable |
246 | | ` h k` | Describe key |
247 | | `] t` | Go to next tab |
248 | | `[ t` | Go to previous tab |
249 | | ` m p` | Format with Prettier |
250 | | ` c a` | Execute code action |
251 | | ` r n` | Rename symbol |
252 | | `gI` | Find implementation |
253 | | ` l f` | Format buffer via LSP |
254 | | `K` | Show hover documentation |
255 | | `gcc` | Comment/uncomment current line |
256 | | `gc` | Comment/uncomment selected region |
257 | | `gd` | Goto definitions |
258 | | `gr` | Goto references |
259 |
260 | ...and a lot more, discoverable with which-key :)
261 |
262 | ## Contributing
263 |
264 | This package is intentionally designed with a specific vision in mind,
265 | reflecting my own opinions and preferences. While contributions are
266 | welcome, please understand that this configuration is quite
267 | opinionated.
268 |
269 | If you have suggestions or requests, they will be considered
270 | carefully, but I cannot make any promises regarding implementation or
271 | acceptance. Your input is valuable, and I appreciate any help or
272 | feedback to improve the project.
273 |
274 | To contribute, feel free to open an issue or submit a pull
275 | request. Let's make this configuration even better together!
276 |
277 | ## About PRs
278 |
279 | Always welcome, not a promise to accept though (see above). Please
280 | direct your PRs to the `development` branch of this repository.
281 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/init.el:
--------------------------------------------------------------------------------
1 | ;;; init.el --- Emacs-Kick --- A feature rich Emacs config for (neo)vi(m)mers -*- lexical-binding: t; -*-
2 | ;; Author: Rahul Martim Juliato
3 |
4 | ;; Version: 0.3.3
5 | ;; Package-Requires: ((emacs "30.1"))
6 | ;; License: GPL-2.0-or-later
7 |
8 | ;;; Commentary:
9 | ;; =====================================================================
10 | ;; ==================== READ THIS BEFORE CONTINUING ====================
11 | ;; =====================================================================
12 | ;;
13 | ;; ⣠⣶⣿⣿⣶⡄ ⠀⣀⣤⣄⡀
14 | ;; ⣿⣿⣿⣿λ⣿ ⣾)⣿⣿⣿⡆
15 | ;; ⠹⢿⣿⣿⡿⠃ ⠀⣿⣿⣿⣿⣿⡏⢀⣀⡀
16 | ;; ⣠⣤⣦⡄ ⠈⠛⠿⣟⣋⣼⣽⣾⣽⣦⡀⠀
17 | ;; ⣼⣿⣷⣾⡽⡄ ⣴⣶⣶⣿⣿⣿⡿⢿⣟⣽⣾⣿⣿⣦
18 | ;; ⣸⣿⣿⣾⣿⣿⣮⣤⣤⣤⣤⡀ ⠻⣿⡯⠽⠿⠛⠛⠉⠉⢿⣿⣿⣿⣿⣷
19 | ;; ⣿⣿⢻⣿⣿⣿⣛⡿⠿⠟⠛⠁⣀⣠⣤⣤⣶⣶⣶⣶⣷⣶ ⠀⠻⣿⣿⣿⣿⣇
20 | ;; ⢻⣿⡆⢿⣿⣿⣿⣿⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟ ⣠⣶⣿⣿⣿⣿
21 | ;; ⠈⠛⠃⠈⢿⣿⣿⣿⣿⣿⣿⠿⠟⠛⠋⠉ ⣠⣾⣿⣿⣿⠟⠋
22 | ;; ⠙⢿⣿⣿⡏ ⠀⣴⣿⣿⣿⠟
23 | ;; ⢸E⣿⡇ ⣼⣿⣿⣿
24 | ;; ⢸M⣿⣿ ⢸⣿⣿⣿
25 | ;; ⢸A⣿⣿ ⠸⣿⣿
26 | ;; ⢸C⣿⣿
27 | ;; ⣼S⣿⡇
28 | ;; ⠀⠻⣿⡿
29 | ;; =====================================================================
30 | ;; =====================================================================
31 |
32 | ;; What is Emacs-Kick?
33 | ;;
34 | ;; Emacs-Kick is `not' a distribution.
35 | ;;
36 | ;; Emacs-Kick is a starting point for your own configuration. The goal
37 | ;; is that you can read every line of code, top-to-bottom, understand
38 | ;; what your configuration is doing, and modify it to suit your needs.
39 | ;;
40 | ;; Once you've done that, you can start exploring, configuring, and
41 | ;; tinkering to make Emacs your own! That might mean leaving Emacs
42 | ;; Kick just the way it is for a while or immediately breaking it into
43 | ;; modular pieces. It's up to you!
44 | ;;
45 | ;; If you don't know anything about Emacs Lisp, I recommend taking
46 | ;; some time to read through a guide.
47 | ;; One possible example which will only take 10-15 minutes:
48 | ;; - https://learnxinyminutes.com/docs/elisp/
49 | ;;
50 | ;; After understanding a bit more about Emacs Lisp, you can use `M-x
51 | ;; info RET` (info) for a reference on how Emacs integrates it.
52 | ;;
53 | ;;
54 | ;; Emacs-Kick Guide:
55 | ;;
56 | ;; Well, this config ASSUMES you already knows (neo)vi(m) bindings,
57 | ;; and the bases of how it works. This is the `Emacs config for
58 | ;; vimmers'. So, if you're not familiar with it, go for
59 | ;; `kickstart.nvim', get used to it, and than come back.
60 | ;;
61 | ;; On Emacs, help can be found multiple ways.
62 | ;; With this config, the leader key is SPC.
63 | ;; - h i opens the info (Also `M-x info RET')
64 | ;; - h v explores available variables
65 | ;; - h f explores avaliable functions
66 | ;; - h k explores avaliable keybindings
67 | ;;
68 | ;; If, at any time you need to find some functionality, Emacs `M-x'
69 | ;; (Meta is alt on most cases, option or command), works like a
70 | ;; command pallete, you can for example type `M-x quit' and be
71 | ;; presented with various options to quit Emacs.
72 | ;;
73 | ;; Once you've completed that, you can continue working through
74 | ;; `AND READING' the rest of the kickstart configuration.
75 | ;;
76 | ;; I have left several comments throughout the configuration. These
77 | ;; are hints about where to find more information about the relevant
78 | ;; settings, packages, or Emacs features used in Emacs-Kick.
79 | ;;
80 | ;; Feel free to delete them once you know what you're doing, but they
81 | ;; should serve as a guide for when you are first encountering a few
82 | ;; different constructs in your Emacs config.
83 | ;;
84 | ;; If you encounter any errors while installing Emacs-Kick,
85 | ;; check the *Messages* buffer for more information. You can switch
86 | ;; buffers using ` SPC`, and all option menus can be navigated
87 | ;; with `C-p` and `C-n`.
88 | ;;
89 | ;; I hope you enjoy your Emacs journey,
90 | ;; - Rahul
91 | ;;
92 | ;; P.S. You can delete this when you're done too. It's your config
93 | ;; now! :)
94 |
95 |
96 | ;;; Code:
97 |
98 | ;; Performance Hacks
99 | ;; Emacs is an Elisp interpreter, and when running programs or packages,
100 | ;; it can occasionally experience pauses due to garbage collection.
101 | ;; By increasing the garbage collection threshold, we reduce these pauses
102 | ;; during heavy operations, leading to smoother performance.
103 | (setq gc-cons-threshold #x40000000)
104 |
105 | ;; Set the maximum output size for reading process output, allowing for larger data transfers.
106 | (setq read-process-output-max (* 1024 1024 4))
107 |
108 | ;; Do I really need a speedy startup?
109 | ;; Well, this config launches Emacs in about ~0.3 seconds,
110 | ;; which, in modern terms, is a miracle considering how fast it starts
111 | ;; with external packages.
112 | ;; It wasn’t until the recent introduction of tools for lazy loading
113 | ;; that a startup time of less than 20 seconds was even possible.
114 | ;; Other fast startup methods were introduced over time.
115 | ;; You may have heard of people running Emacs as a server,
116 | ;; where you start it once and open multiple clients instantly connected to that server.
117 | ;; Some even run Emacs as a systemd or sysV service, starting when the machine boots.
118 | ;; While this is a great way of using Emacs, we WON’T be doing that here.
119 | ;; I think 0.3 seconds is fast enough to avoid issues that could arise from
120 | ;; running Emacs as a server, such as 'What version of Node is my LSP using?'.
121 | ;; Again, this setup configures Emacs much like how a Vimmer would configure Neovim.
122 |
123 |
124 | ;; Emacs comes with a built-in package manager (`package.el'), and we'll use it
125 | ;; when it makes sense. However, `straight.el' is a bit more user-friendly and
126 | ;; reproducible, especially for newcomers and shareable configs like emacs-kick.
127 | ;; So we bootstrap it here.
128 | (setq package-enable-at-startup nil) ;; Disables the default package manager.
129 |
130 | ;; Bootstraps `straight.el'
131 | (setq straight-check-for-modifications nil)
132 | (defvar bootstrap-version)
133 | (let ((bootstrap-file
134 | (expand-file-name
135 | "straight/repos/straight.el/bootstrap.el"
136 | (or (bound-and-true-p straight-base-dir)
137 | user-emacs-directory)))
138 | (bootstrap-version 7))
139 | (unless (file-exists-p bootstrap-file)
140 | (with-current-buffer
141 | (url-retrieve-synchronously
142 | "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
143 | 'silent 'inhibit-cookies)
144 | (goto-char (point-max))
145 | (eval-print-last-sexp)))
146 | (load bootstrap-file nil 'nomessage))
147 | (straight-use-package '(project :type built-in))
148 | (straight-use-package 'use-package)
149 |
150 |
151 | ;; In Emacs, a package is a collection of Elisp code that extends the editor's functionality,
152 | ;; much like plugins do in Neovim. We need to import this package to add package archives.
153 | (require 'package)
154 |
155 | ;; Add MELPA (Milkypostman's Emacs Lisp Package Archive) to the list of package archives.
156 | ;; This allows you to install packages from this widely-used repository, similar to how
157 | ;; pip works for Python or npm for Node.js. While Emacs comes with ELPA (Emacs Lisp
158 | ;; Package Archive) configured by default, which contains packages that meet specific
159 | ;; licensing criteria, MELPA offers a broader range of packages and is considered the
160 | ;; standard for Emacs users. You can also add more package archives later as needed.
161 | (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
162 |
163 | ;; Define a global customizable variable `ek-use-nerd-fonts' to control the use of
164 | ;; Nerd Fonts symbols throughout the configuration. This boolean variable allows
165 | ;; users to easily enable or disable the use of symbols from Nerd Fonts, providing
166 | ;; flexibility in appearance settings. By setting it to `t', we enable Nerd Fonts
167 | ;; symbols; setting it to `nil' would disable them.
168 | (defcustom ek-use-nerd-fonts t
169 | "Configuration for using Nerd Fonts Symbols."
170 | :type 'boolean
171 | :group 'appearance)
172 |
173 |
174 | ;; From now on, you'll see configurations using the `use-package` macro, which
175 | ;; allows us to organize our Emacs setup in a modular way. These configurations
176 | ;; look like this:
177 | ;;
178 | ;; (use-package some-package
179 | ;; :ensure t ;; Ensure the package is installed (used with package.el).
180 | ;; :straight t ;; Use straight.el to install and manage this package.
181 | ;; :config ;; Configuration settings for the package.
182 | ;; ;; Additional settings can go here.
183 | ;; )
184 | ;;
185 | ;; This approach simplifies package management, enabling us to easily control
186 | ;; both built-in (first-party) and external (third-party) packages. While Emacs
187 | ;; is a vast and powerful editor, using `use-package`—especially in combination
188 | ;; with `straight.el`—helps streamline our configuration for better organization,
189 | ;; reproducibility, and customization. As we proceed, you'll see smaller
190 | ;; `use-package` declarations for specific packages, which will help us enable
191 | ;; the desired features and improve our workflow.
192 |
193 |
194 | ;;; EMACS
195 | ;; This is biggest one. Keep going, plugins (oops, I mean packages) will be shorter :)
196 | (use-package emacs
197 | :ensure nil
198 | :custom ;; Set custom variables to configure Emacs behavior.
199 | (auto-save-default nil) ;; Disable automatic saving of buffers.
200 | (column-number-mode t) ;; Display the column number in the mode line.
201 | (create-lockfiles nil) ;; Prevent the creation of lock files when editing.
202 | (delete-by-moving-to-trash t) ;; Move deleted files to the trash instead of permanently deleting them.
203 | (delete-selection-mode 1) ;; Enable replacing selected text with typed text.
204 | (display-line-numbers-type 'relative) ;; Use relative line numbering in programming modes.
205 | (global-auto-revert-non-file-buffers t) ;; Automatically refresh non-file buffers.
206 | (history-length 25) ;; Set the length of the command history.
207 | (indent-tabs-mode nil) ;; Disable the use of tabs for indentation (use spaces instead).
208 | (inhibit-startup-message t) ;; Disable the startup message when Emacs launches.
209 | (initial-scratch-message "") ;; Clear the initial message in the *scratch* buffer.
210 | (ispell-dictionary "en_US") ;; Set the default dictionary for spell checking.
211 | (make-backup-files nil) ;; Disable creation of backup files.
212 | (pixel-scroll-precision-mode t) ;; Enable precise pixel scrolling.
213 | (pixel-scroll-precision-use-momentum nil) ;; Disable momentum scrolling for pixel precision.
214 | (ring-bell-function 'ignore) ;; Disable the audible bell.
215 | (split-width-threshold 300) ;; Prevent automatic window splitting if the window width exceeds 300 pixels.
216 | (switch-to-buffer-obey-display-actions t) ;; Make buffer switching respect display actions.
217 | (tab-always-indent 'complete) ;; Make the TAB key complete text instead of just indenting.
218 | (tab-width 4) ;; Set the tab width to 4 spaces.
219 | (treesit-font-lock-level 4) ;; Use advanced font locking for Treesit mode.
220 | (truncate-lines t) ;; Enable line truncation to avoid wrapping long lines.
221 | (use-dialog-box nil) ;; Disable dialog boxes in favor of minibuffer prompts.
222 | (use-short-answers t) ;; Use short answers in prompts for quicker responses (y instead of yes)
223 | (warning-minimum-level :emergency) ;; Set the minimum level of warnings to display.
224 |
225 | :hook ;; Add hooks to enable specific features in certain modes.
226 | (prog-mode . display-line-numbers-mode) ;; Enable line numbers in programming modes.
227 |
228 | :config
229 | ;; By default emacs gives you access to a lot of *special* buffers, while navigating with [b and ]b,
230 | ;; this might be confusing for newcomers. This settings make sure ]b and [b will always load a
231 | ;; file buffer. To see all buffers use SPC, b l, or b i.
232 | (defun skip-these-buffers (_window buffer _bury-or-kill)
233 | "Function for `switch-to-prev-buffer-skip'."
234 | (string-match "\\*[^*]+\\*" (buffer-name buffer)))
235 | (setq switch-to-prev-buffer-skip 'skip-these-buffers)
236 |
237 |
238 | ;; Configure font settings based on the operating system.
239 | ;; Ok, this kickstart is meant to be used on the terminal, not on GUI.
240 | ;; But without this, I fear you could start Graphical Emacs and be sad :(
241 | (set-face-attribute 'default nil :family "JetBrainsMono Nerd Font" :height 100)
242 | (when (eq system-type 'darwin) ;; Check if the system is macOS.
243 | (setq mac-command-modifier 'meta) ;; Set the Command key to act as the Meta key.
244 | (set-face-attribute 'default nil :family "JetBrainsMono Nerd Font" :height 130))
245 |
246 | ;; Save manual customizations to a separate file instead of cluttering `init.el'.
247 | ;; You can M-x customize, M-x customize-group, or M-x customize-themes, etc.
248 | ;; The saves you do manually using the Emacs interface would overwrite this file.
249 | ;; The following makes sure those customizations are in a separate file.
250 | (setq custom-file (locate-user-emacs-file "custom-vars.el")) ;; Specify the custom file path.
251 | (load custom-file 'noerror 'nomessage) ;; Load the custom file quietly, ignoring errors.
252 |
253 | ;; Makes Emacs vertical divisor the symbol │ instead of |.
254 | (set-display-table-slot standard-display-table 'vertical-border (make-glyph-code ?│))
255 |
256 | :init ;; Initialization settings that apply before the package is loaded.
257 | (tool-bar-mode -1) ;; Disable the tool bar for a cleaner interface.
258 | (menu-bar-mode -1) ;; Disable the menu bar for a more streamlined look.
259 |
260 | (when scroll-bar-mode
261 | (scroll-bar-mode -1)) ;; Disable the scroll bar if it is active.
262 |
263 | (global-hl-line-mode -1) ;; Disable highlight of the current line
264 | (global-auto-revert-mode 1) ;; Enable global auto-revert mode to keep buffers up to date with their corresponding files.
265 | (recentf-mode 1) ;; Enable tracking of recently opened files.
266 | (savehist-mode 1) ;; Enable saving of command history.
267 | (save-place-mode 1) ;; Enable saving the place in files for easier return.
268 | (winner-mode 1) ;; Enable winner mode to easily undo window configuration changes.
269 | (xterm-mouse-mode 1) ;; Enable mouse support in terminal mode.
270 | (file-name-shadow-mode 1) ;; Enable shadowing of filenames for clarity.
271 |
272 | ;; Set the default coding system for files to UTF-8.
273 | (modify-coding-system-alist 'file "" 'utf-8)
274 |
275 | ;; Add a hook to run code after Emacs has fully initialized.
276 | (add-hook 'after-init-hook
277 | (lambda ()
278 | (message "Emacs has fully loaded. This code runs after startup.")
279 |
280 | ;; Insert a welcome message in the *scratch* buffer displaying loading time and activated packages.
281 | (with-current-buffer (get-buffer-create "*scratch*")
282 | (insert (format
283 | ";; Welcome to Emacs!
284 | ;;
285 | ;; Loading time : %s
286 | ;; Packages : %s
287 | "
288 | (emacs-init-time)
289 | (length (hash-table-keys straight--recipe-cache))))))))
290 |
291 |
292 | ;;; WINDOW
293 | ;; This section configures window management in Emacs, enhancing the way buffers
294 | ;; are displayed for a more efficient workflow. The `window' use-package helps
295 | ;; streamline how various buffers are shown, especially those related to help,
296 | ;; diagnostics, and completion.
297 | ;;
298 | ;; Note: I have left some commented-out code below that may facilitate your
299 | ;; Emacs journey later on. These configurations can be useful for displaying
300 | ;; other types of buffers in side windows, allowing for a more organized workspace.
301 | (use-package window
302 | :ensure nil ;; This is built-in, no need to fetch it.
303 | :custom
304 | (display-buffer-alist
305 | '(
306 | ;; ("\\*.*e?shell\\*"
307 | ;; (display-buffer-in-side-window)
308 | ;; (window-height . 0.25)
309 | ;; (side . bottom)
310 | ;; (slot . -1))
311 |
312 | ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*"
313 | (display-buffer-in-side-window)
314 | (window-height . 0.25)
315 | (side . bottom)
316 | (slot . 0))
317 |
318 | ;; Example configuration for the LSP help buffer,
319 | ;; keeps it always on bottom using 25% of the available space:
320 | ("\\*\\(lsp-help\\)\\*"
321 | (display-buffer-in-side-window)
322 | (window-height . 0.25)
323 | (side . bottom)
324 | (slot . 0))
325 |
326 | ;; Configuration for displaying various diagnostic buffers on
327 | ;; bottom 25%:
328 | ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
329 | (display-buffer-in-side-window)
330 | (window-height . 0.25)
331 | (side . bottom)
332 | (slot . 1))
333 | )))
334 |
335 |
336 | ;;; DIRED
337 | ;; In Emacs, the `dired' package provides a powerful and built-in file manager
338 | ;; that allows you to navigate and manipulate files and directories directly
339 | ;; within the editor. If you're familiar with `oil.nvim', you'll find that
340 | ;; `dired' offers similar functionality natively in Emacs, making file
341 | ;; management seamless without needing external plugins.
342 |
343 | ;; This configuration customizes `dired' to enhance its usability. The settings
344 | ;; below specify how file listings are displayed, the target for file operations,
345 | ;; and associations for opening various file types with their respective applications.
346 | ;; For example, image files will open with `feh', while audio and video files
347 | ;; will utilize `mpv'.
348 | (use-package dired
349 | :ensure nil ;; This is built-in, no need to fetch it.
350 | :custom
351 | (dired-listing-switches "-lah --group-directories-first") ;; Display files in a human-readable format and group directories first.
352 | (dired-dwim-target t) ;; Enable "do what I mean" for target directories.
353 | (dired-guess-shell-alist-user
354 | '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open" "open") ;; Open image files with `feh' or the default viewer.
355 | ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open" "open") ;; Open audio and video files with `mpv'.
356 | (".*" "open" "xdg-open"))) ;; Default opening command for other files.
357 | (dired-kill-when-opening-new-dired-buffer t) ;; Close the previous buffer when opening a new `dired' instance.
358 | :config
359 | (when (eq system-type 'darwin)
360 | (let ((gls (executable-find "gls"))) ;; Use GNU ls on macOS if available.
361 | (when gls
362 | (setq insert-directory-program gls)))))
363 |
364 |
365 | ;;; ERC
366 | ;; In this section, we introduce ERC (Emacs Relay Chat), a built-in IRC client
367 | ;; that allows you to engage in real-time chat directly within Emacs. While
368 | ;; we're aiming to maintain functionality similar to Neovim, it's important to
369 | ;; recognize that Emacs is often viewed as more than just a text editor. Many
370 | ;; users leverage Emacs for a variety of tasks beyond editing text: from watching
371 | ;; videos and listening to music, to managing emails and even serving as a window
372 | ;; manager in Xorg, freeing themselves from traditional desktop environments.
373 | ;;
374 | ;; While this kickstarter focuses on essential configurations, I wanted to present
375 | ;; ERC as a glimpse into Emacs's versatility. With ERC, you can seamlessly connect
376 | ;; to IRC channels and interact with communities without leaving your editor.
377 | (use-package erc
378 | :defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET')
379 | :custom
380 | (erc-join-buffer 'window) ;; Open a new window for joining channels.
381 | (erc-hide-list '("JOIN" "PART" "QUIT")) ;; Hide messages for joins, parts, and quits to reduce clutter.
382 | (erc-timestamp-format "[%H:%M]") ;; Format for timestamps in messages.
383 | (erc-autojoin-channels-alist '((".*\\.libera\\.chat" "#emacs"))));; Automatically join the #emacs channel on Libera.Chat.
384 |
385 |
386 | ;;; ISEARCH
387 | ;; In this configuration, we're setting up isearch, Emacs's incremental search feature.
388 | ;; Since we're utilizing Vim bindings, keep in mind that classic Vim search commands
389 | ;; (like `/' and `?') are not bound in the same way. Instead, you'll need to use
390 | ;; the standard Emacs shortcuts:
391 | ;; - `C-s' to initiate a forward search
392 | ;; - `C-r' to initiate a backward search
393 | ;; The following settings enhance the isearch experience:
394 | (use-package isearch
395 | :ensure nil ;; This is built-in, no need to fetch it.
396 | :config
397 | (setq isearch-lazy-count t) ;; Enable lazy counting to show current match information.
398 | (setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count.
399 | (setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count.
400 | (setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace.
401 | :bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch.
402 | ("C-r" . isearch-backward))) ;; Bind C-r to backward isearch.
403 |
404 |
405 | ;;; VC
406 | ;; The VC (Version Control) package is included here for awareness and completeness.
407 | ;; While its support for Git is limited and generally considered subpar, it is good to know
408 | ;; that it exists and can be used for other version control systems like Mercurial,
409 | ;; Subversion, and Bazaar.
410 | ;; Magit, which is often regarded as the "father" of Neogit, will be configured later
411 | ;; for an enhanced Git experience.
412 | ;; The keybindings below serve as a reminder of some common VC commands.
413 | ;; But don't worry, you can always use `M-x command' :)
414 | (use-package vc
415 | :ensure nil ;; This is built-in, no need to fetch it.
416 | :defer t
417 | :bind
418 | (("C-x v d" . vc-dir) ;; Open VC directory for version control status.
419 | ("C-x v =" . vc-diff) ;; Show differences for the current file.
420 | ("C-x v D" . vc-root-diff) ;; Show differences for the entire repository.
421 | ("C-x v v" . vc-next-action)) ;; Perform the next version control action.
422 | :config
423 | ;; Better colors for g b (blame file)
424 | (setq vc-annotate-color-map
425 | '((20 . "#f5e0dc")
426 | (40 . "#f2cdcd")
427 | (60 . "#f5c2e7")
428 | (80 . "#cba6f7")
429 | (100 . "#f38ba8")
430 | (120 . "#eba0ac")
431 | (140 . "#fab387")
432 | (160 . "#f9e2af")
433 | (180 . "#a6e3a1")
434 | (200 . "#94e2d5")
435 | (220 . "#89dceb")
436 | (240 . "#74c7ec")
437 | (260 . "#89b4fa")
438 | (280 . "#b4befe"))))
439 |
440 |
441 | ;;; SMERGE
442 | ;; Smerge is included for resolving merge conflicts in files. It provides a simple interface
443 | ;; to help you keep changes from either the upper or lower version during a merge.
444 | ;; This package is built-in, so there's no need to fetch it separately.
445 | ;; The keybindings below did not needed to be setted, are here just to show
446 | ;; you how to work with it in case you are curious about it.
447 | (use-package smerge-mode
448 | :ensure nil ;; This is built-in, no need to fetch it.
449 | :defer t
450 | :bind (:map smerge-mode-map
451 | ("C-c ^ u" . smerge-keep-upper) ;; Keep the changes from the upper version.
452 | ("C-c ^ l" . smerge-keep-lower) ;; Keep the changes from the lower version.
453 | ("C-c ^ n" . smerge-next) ;; Move to the next conflict.
454 | ("C-c ^ p" . smerge-previous))) ;; Move to the previous conflict.
455 |
456 |
457 | ;;; ELDOC
458 | ;; Eldoc provides helpful inline documentation for functions and variables
459 | ;; in the minibuffer, enhancing the development experience. It can be particularly useful
460 | ;; in programming modes, as it helps you understand the context of functions as you type.
461 | ;; This package is built-in, so there's no need to fetch it separately.
462 | ;; The following line enables Eldoc globally for all buffers.
463 | (use-package eldoc
464 | :ensure nil ;; This is built-in, no need to fetch it.
465 | :config
466 | (setq eldoc-idle-delay 0) ;; Automatically fetch doc help
467 | (setq eldoc-echo-area-use-multiline-p nil) ;; We use the "K" floating help instead
468 | ;; set to t if you want docs on the echo area
469 | (setq eldoc-echo-area-display-truncation-message nil)
470 | :init
471 | (global-eldoc-mode))
472 |
473 |
474 | ;;; FLYMAKE
475 | ;; Flymake is an on-the-fly syntax checking extension that provides real-time feedback
476 | ;; about errors and warnings in your code as you write. This can greatly enhance your
477 | ;; coding experience by catching issues early. The configuration below activates
478 | ;; Flymake mode in programming buffers.
479 | (use-package flymake
480 | :ensure nil ;; This is built-in, no need to fetch it.
481 | :defer t
482 | :hook (prog-mode . flymake-mode)
483 | :custom
484 | (flymake-margin-indicators-string
485 | '((error "!»" compilation-error) (warning "»" compilation-warning)
486 | (note "»" compilation-info))))
487 |
488 |
489 | ;;; ORG-MODE
490 | ;; Org-mode is a powerful system for organizing and managing your notes,
491 | ;; tasks, and documents in plain text. It offers features like task management,
492 | ;; outlining, scheduling, and much more, making it a versatile tool for
493 | ;; productivity. The configuration below simply defers loading Org-mode until
494 | ;; it's explicitly needed, which can help speed up Emacs startup time.
495 | (use-package org
496 | :ensure nil ;; This is built-in, no need to fetch it.
497 | :defer t) ;; Defer loading Org-mode until it's needed.
498 |
499 |
500 | ;;; WHICH-KEY
501 | ;; `which-key' is an Emacs package that displays available keybindings in a
502 | ;; popup window whenever you partially type a key sequence. This is particularly
503 | ;; useful for discovering commands and shortcuts, making it easier to learn
504 | ;; Emacs and improve your workflow. It helps users remember key combinations
505 | ;; and reduces the cognitive load of memorizing every command.
506 | (use-package which-key
507 | :ensure nil ;; This is built-in, no need to fetch it.
508 | :defer t ;; Defer loading Which-Key until after init.
509 | :hook
510 | (after-init . which-key-mode)) ;; Enable which-key mode after initialization.
511 |
512 |
513 | ;;; ==================== EXTERNAL PACKAGES ====================
514 | ;;
515 | ;; From this point onward, all configurations will be for third-party packages
516 | ;; that enhance Emacs' functionality and extend its capabilities.
517 |
518 | ;;; VERTICO
519 | ;; Vertico enhances the completion experience in Emacs by providing a
520 | ;; vertical selection interface for both buffer and minibuffer completions.
521 | ;; Unlike traditional minibuffer completion, which displays candidates
522 | ;; in a horizontal format, Vertico presents candidates in a vertical list,
523 | ;; making it easier to browse and select from multiple options.
524 | ;;
525 | ;; In buffer completion, `switch-to-buffer' allows you to select from open buffers.
526 | ;; Vertico streamlines this process by displaying the buffer list in a way that
527 | ;; improves visibility and accessibility. This is particularly useful when you
528 | ;; have many buffers open, allowing you to quickly find the one you need.
529 | ;;
530 | ;; In minibuffer completion, such as when entering commands or file paths,
531 | ;; Vertico helps by showing a dynamic list of potential completions, making
532 | ;; it easier to choose the correct one without typing out the entire string.
533 | (use-package vertico
534 | :ensure t
535 | :straight t
536 | :hook
537 | (after-init . vertico-mode) ;; Enable vertico after Emacs has initialized.
538 | :custom
539 | (vertico-count 10) ;; Number of candidates to display in the completion list.
540 | (vertico-resize nil) ;; Disable resizing of the vertico minibuffer.
541 | (vertico-cycle nil) ;; Do not cycle through candidates when reaching the end of the list.
542 | :config
543 | ;; Customize the display of the current candidate in the completion list.
544 | ;; This will prefix the current candidate with “» ” to make it stand out.
545 | ;; Reference: https://github.com/minad/vertico/wiki#prefix-current-candidate-with-arrow
546 | (advice-add #'vertico--format-candidate :around
547 | (lambda (orig cand prefix suffix index _start)
548 | (setq cand (funcall orig cand prefix suffix index _start))
549 | (concat
550 | (if (= vertico--index index)
551 | (propertize "» " 'face '(:foreground "#80adf0" :weight bold))
552 | " ")
553 | cand))))
554 |
555 |
556 | ;;; ORDERLESS
557 | ;; Orderless enhances completion in Emacs by allowing flexible pattern matching.
558 | ;; It works seamlessly with Vertico, enabling you to use partial strings and
559 | ;; regular expressions to find files, buffers, and commands more efficiently.
560 | ;; This combination provides a powerful and customizable completion experience.
561 | (use-package orderless
562 | :ensure t
563 | :straight t
564 | :defer t ;; Load Orderless on demand.
565 | :after vertico ;; Ensure Vertico is loaded before Orderless.
566 | :init
567 | (setq completion-styles '(orderless basic) ;; Set the completion styles.
568 | completion-category-defaults nil ;; Clear default category settings.
569 | completion-category-overrides '((file (styles partial-completion))))) ;; Customize file completion styles.
570 |
571 |
572 | ;;; MARGINALIA
573 | ;; Marginalia enhances the completion experience in Emacs by adding
574 | ;; additional context to the completion candidates. This includes
575 | ;; helpful annotations such as documentation and other relevant
576 | ;; information, making it easier to choose the right option.
577 | (use-package marginalia
578 | :ensure t
579 | :straight t
580 | :hook
581 | (after-init . marginalia-mode))
582 |
583 |
584 | ;;; CONSULT
585 | ;; Consult provides powerful completion and narrowing commands for Emacs.
586 | ;; It integrates well with other completion frameworks like Vertico, enabling
587 | ;; features like previews and enhanced register management. It's useful for
588 | ;; navigating buffers, files, and xrefs with ease.
589 | (use-package consult
590 | :ensure t
591 | :straight t
592 | :defer t
593 | :init
594 | ;; Enhance register preview with thin lines and no mode line.
595 | (advice-add #'register-preview :override #'consult-register-window)
596 |
597 | ;; Use Consult for xref locations with a preview feature.
598 | (setq xref-show-xrefs-function #'consult-xref
599 | xref-show-definitions-function #'consult-xref))
600 |
601 |
602 | ;;; EMBARK
603 | ;; Embark provides a powerful contextual action menu for Emacs, allowing
604 | ;; you to perform various operations on completion candidates and other items.
605 | ;; It extends the capabilities of completion frameworks by offering direct
606 | ;; actions on the candidates.
607 | ;; Just ` .' over any text, explore it :)
608 | (use-package embark
609 | :ensure t
610 | :straight t
611 | :defer t)
612 |
613 |
614 | ;;; EMBARK-CONSULT
615 | ;; Embark-Consult provides a bridge between Embark and Consult, ensuring
616 | ;; that Consult commands, like previews, are available when using Embark.
617 | (use-package embark-consult
618 | :ensure t
619 | :straight t
620 | :hook
621 | (embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode.
622 |
623 |
624 | ;;; TREESITTER-AUTO
625 | ;; Treesit-auto simplifies the use of Tree-sitter grammars in Emacs,
626 | ;; providing automatic installation and mode association for various
627 | ;; programming languages. This enhances syntax highlighting and
628 | ;; code parsing capabilities, making it easier to work with modern
629 | ;; programming languages.
630 | (use-package treesit-auto
631 | :ensure t
632 | :straight t
633 | :after emacs
634 | :custom
635 | (treesit-auto-install 'prompt)
636 | :config
637 | (treesit-auto-add-to-auto-mode-alist 'all)
638 | (global-treesit-auto-mode t))
639 |
640 |
641 | ;;; MARKDOWN-MODE
642 | ;; Markdown Mode provides support for editing Markdown files in Emacs,
643 | ;; enabling features like syntax highlighting, previews, and more.
644 | ;; It’s particularly useful for README files, as it can be set
645 | ;; to use GitHub Flavored Markdown for enhanced compatibility.
646 | (use-package markdown-mode
647 | :defer t
648 | :straight t
649 | :ensure t
650 | :mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files.
651 | :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
652 |
653 |
654 | ;;; CORFU
655 | ;; Corfu Mode provides a text completion framework for Emacs.
656 | ;; It enhances the editing experience by offering context-aware
657 | ;; suggestions as you type.
658 | ;; Corfu Mode is highly customizable and can be integrated with
659 | ;; various modes and languages.
660 | (use-package corfu
661 | :ensure t
662 | :straight t
663 | :defer t
664 | :custom
665 | (corfu-auto nil) ;; Only completes when hitting TAB
666 | ;; (corfu-auto-delay 0) ;; Delay before popup (enable if corfu-auto is t)
667 | (corfu-auto-prefix 1) ;; Trigger completion after typing 1 character
668 | (corfu-quit-no-match t) ;; Quit popup if no match
669 | (corfu-scroll-margin 5) ;; Margin when scrolling completions
670 | (corfu-max-width 50) ;; Maximum width of completion popup
671 | (corfu-min-width 50) ;; Minimum width of completion popup
672 | (corfu-popupinfo-delay 0.5) ;; Delay before showing documentation popup
673 | :config
674 | (if ek-use-nerd-fonts
675 | (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
676 | :init
677 | (global-corfu-mode)
678 | (corfu-popupinfo-mode t))
679 |
680 |
681 | ;;; NERD-ICONS-CORFU
682 | ;; Provides Nerd Icons to be used with CORFU.
683 | (use-package nerd-icons-corfu
684 | :if ek-use-nerd-fonts
685 | :ensure t
686 | :straight t
687 | :defer t
688 | :after (:all corfu))
689 |
690 |
691 | ;;; LSP
692 | ;; Emacs comes with an integrated LSP client called `eglot', which offers basic LSP functionality.
693 | ;; However, `eglot' has limitations, such as not supporting multiple language servers
694 | ;; simultaneously within the same buffer (e.g., handling both TypeScript, Tailwind and ESLint
695 | ;; LSPs together in a React project). For this reason, the more mature and capable
696 | ;; `lsp-mode' is included as a third-party package, providing advanced IDE-like features
697 | ;; and better support for multiple language servers and configurations.
698 | ;;
699 | ;; NOTE: To install or reinstall an LSP server, use `M-x install-server RET`.
700 | ;; As with other editors, LSP configurations can become complex. You may need to
701 | ;; install or reinstall the server for your project due to version management quirks
702 | ;; (e.g., asdf or nvm) or other issues.
703 | ;; Fortunately, `lsp-mode` has a great resource site:
704 | ;; https://emacs-lsp.github.io/lsp-mode/
705 | (use-package lsp-mode
706 | :ensure t
707 | :straight t
708 | :defer t
709 | :hook (;; Replace XXX-mode with concrete major mode (e.g. python-mode)
710 | (lsp-mode . lsp-enable-which-key-integration) ;; Integrate with Which Key
711 | ((js-mode ;; Enable LSP for JavaScript
712 | tsx-ts-mode ;; Enable LSP for TSX
713 | typescript-ts-base-mode ;; Enable LSP for TypeScript
714 | css-mode ;; Enable LSP for CSS
715 | go-ts-mode ;; Enable LSP for Go
716 | js-ts-mode ;; Enable LSP for JavaScript (TS mode)
717 | prisma-mode ;; Enable LSP for Prisma
718 | python-base-mode ;; Enable LSP for Python
719 | ruby-base-mode ;; Enable LSP for Ruby
720 | rust-ts-mode ;; Enable LSP for Rust
721 | web-mode) . lsp-deferred)) ;; Enable LSP for Web (HTML)
722 | :commands lsp
723 | :custom
724 | (lsp-keymap-prefix "C-c l") ;; Set the prefix for LSP commands.
725 | (lsp-inlay-hint-enable nil) ;; Usage of inlay hints.
726 | (lsp-completion-provider :none) ;; Disable the default completion provider.
727 | (lsp-session-file (locate-user-emacs-file ".lsp-session")) ;; Specify session file location.
728 | (lsp-log-io nil) ;; Disable IO logging for speed.
729 | (lsp-idle-delay 0.5) ;; Set the delay for LSP to 0 (debouncing).
730 | (lsp-keep-workspace-alive nil) ;; Disable keeping the workspace alive.
731 | ;; Core settings
732 | (lsp-enable-xref t) ;; Enable cross-references.
733 | (lsp-auto-configure t) ;; Automatically configure LSP.
734 | (lsp-enable-links nil) ;; Disable links.
735 | (lsp-eldoc-enable-hover t) ;; Enable ElDoc hover.
736 | (lsp-enable-file-watchers nil) ;; Disable file watchers.
737 | (lsp-enable-folding nil) ;; Disable folding.
738 | (lsp-enable-imenu t) ;; Enable Imenu support.
739 | (lsp-enable-indentation nil) ;; Disable indentation.
740 | (lsp-enable-on-type-formatting nil) ;; Disable on-type formatting.
741 | (lsp-enable-suggest-server-download t) ;; Enable server download suggestion.
742 | (lsp-enable-symbol-highlighting t) ;; Enable symbol highlighting.
743 | (lsp-enable-text-document-color t) ;; Enable text document color.
744 | ;; Modeline settings
745 | (lsp-modeline-code-actions-enable nil) ;; Keep modeline clean.
746 | (lsp-modeline-diagnostics-enable nil) ;; Use `flymake' instead.
747 | (lsp-modeline-workspace-status-enable t) ;; Display "LSP" in the modeline when enabled.
748 | (lsp-signature-doc-lines 1) ;; Limit echo area to one line.
749 | (lsp-eldoc-render-all t) ;; Render all ElDoc messages.
750 | ;; Completion settings
751 | (lsp-completion-enable t) ;; Enable completion.
752 | (lsp-completion-enable-additional-text-edit t) ;; Enable additional text edits for completions.
753 | (lsp-enable-snippet nil) ;; Disable snippets
754 | (lsp-completion-show-kind t) ;; Show kind in completions.
755 | ;; Lens settings
756 | (lsp-lens-enable t) ;; Enable lens support.
757 | ;; Headerline settings
758 | (lsp-headerline-breadcrumb-enable-symbol-numbers t) ;; Enable symbol numbers in the headerline.
759 | (lsp-headerline-arrow "▶") ;; Set arrow for headerline.
760 | (lsp-headerline-breadcrumb-enable-diagnostics nil) ;; Disable diagnostics in headerline.
761 | (lsp-headerline-breadcrumb-icons-enable nil) ;; Disable icons in breadcrumb.
762 | ;; Semantic settings
763 | (lsp-semantic-tokens-enable nil)) ;; Disable semantic tokens.
764 |
765 |
766 | ;;; LSP Additional Servers
767 | ;; You can extend `lsp-mode' by integrating additional language servers for specific
768 | ;; technologies. For example, `lsp-tailwindcss' provides support for Tailwind CSS
769 | ;; classes within your HTML files. By using various LSP packages, you can connect
770 | ;; multiple LSP servers simultaneously, enhancing your coding experience across
771 | ;; different languages and frameworks.
772 | (use-package lsp-tailwindcss
773 | :ensure t
774 | :straight t
775 | :defer t
776 | :config
777 | (add-to-list 'lsp-language-id-configuration '(".*\\.erb$" . "html")) ;; Associate ERB files with HTML.
778 | :init
779 | (setq lsp-tailwindcss-add-on-mode t))
780 |
781 |
782 | ;;; ELDOC-BOX
783 | ;; eldoc-box enhances the default Eldoc experience by displaying documentation in a popup box,
784 | ;; usually in a child frame. This makes it easier to read longer docstrings without relying on
785 | ;; the minibuffer. It integrates seamlessly with Eldoc and activates when Eldoc is active.
786 | ;; Useful for graphical Emacs; terminal users may want to fall back to `eldoc-box-display-at-point-mode'.
787 | (use-package eldoc-box
788 | :ensure t
789 | :straight t
790 | :defer t)
791 |
792 |
793 | ;;; DIFF-HL
794 | ;; The `diff-hl' package provides visual indicators for version control changes
795 | ;; directly in the margin of the buffer, showing lines added, deleted, or changed.
796 | ;; This is useful for tracking modifications while you edit files. When enabled,
797 | ;; it automatically activates in every buffer that has a corresponding version
798 | ;; control backend, offering a seamless experience.
799 | ;;
800 | ;; In comparison, Neovim users often rely on plugins like `gitsigns.nvim' or
801 | ;; `vim-signify', which provide similar functionalities by displaying Git
802 | ;; changes in the gutter and offer additional features like highlighting
803 | ;; changed lines and displaying blame information. `diff-hl' aims to provide
804 | ;; a comparable experience in Emacs with its own set of customizations.
805 | (use-package diff-hl
806 | :defer t
807 | :straight t
808 | :ensure t
809 | :hook
810 | (find-file . (lambda ()
811 | (global-diff-hl-mode) ;; Enable Diff-HL mode for all files.
812 | (diff-hl-flydiff-mode) ;; Automatically refresh diffs.
813 | (diff-hl-margin-mode))) ;; Show diff indicators in the margin.
814 | :custom
815 | (diff-hl-side 'left) ;; Set the side for diff indicators.
816 | (diff-hl-margin-symbols-alist '((insert . "┃") ;; Customize symbols for each change type.
817 | (delete . "-")
818 | (change . "┃")
819 | (unknown . "┆")
820 | (ignored . "i"))))
821 |
822 |
823 | ;;; MAGIT
824 | ;; `magit' is a powerful Git interface for Emacs that provides a complete
825 | ;; set of features to manage Git repositories. With its intuitive interface,
826 | ;; you can easily stage, commit, branch, merge, and perform other Git
827 | ;; operations directly from Emacs. Magit’s powerful UI allows for a seamless
828 | ;; workflow, enabling you to visualize your repository's history and manage
829 | ;; changes efficiently.
830 | ;;
831 | ;; In the Neovim ecosystem, similar functionality is provided by plugins such as
832 | ;; `fugitive.vim', which offers a robust Git integration with commands that
833 | ;; allow you to perform Git operations directly within Neovim. Another popular
834 | ;; option is `neogit', which provides a more modern and user-friendly interface
835 | ;; for Git commands in Neovim, leveraging features like diff views and staging
836 | ;; changes in a visual format. Both of these plugins aim to replicate and
837 | ;; extend the powerful capabilities that Magit offers in Emacs.
838 | (use-package magit
839 | :ensure t
840 | :straight t
841 | :config
842 | (if ek-use-nerd-fonts ;; Check if nerd fonts are being used
843 | (setopt magit-format-file-function #'magit-format-file-nerd-icons)) ;; Turns on magit nerd-icons
844 | :defer t)
845 |
846 |
847 | ;;; XCLIP
848 | ;; `xclip' is an Emacs package that integrates the X Window System clipboard
849 | ;; with Emacs. It allows seamless copying and pasting between Emacs and other
850 | ;; applications using the clipboard. When `xclip' is enabled, any text copied
851 | ;; in Emacs can be pasted in other applications, and vice versa, providing a
852 | ;; smooth workflow when working across multiple environments.
853 | (use-package xclip
854 | :ensure t
855 | :straight t
856 | :defer t
857 | :hook
858 | (after-init . xclip-mode)) ;; Enable xclip mode after initialization.
859 |
860 |
861 | ;;; INDENT-GUIDE
862 | ;; The `indent-guide' package provides visual indicators for indentation levels
863 | ;; in programming modes, making it easier to see code structure at a glance.
864 | ;; It draws vertical lines (by default, a character of your choice) at each
865 | ;; level of indentation, helping to improve readability and navigation within
866 | ;; the code.
867 | (use-package indent-guide
868 | :defer t
869 | :straight t
870 | :ensure t
871 | :hook
872 | (prog-mode . indent-guide-mode) ;; Activate indent-guide in programming modes.
873 | :config
874 | (setq indent-guide-char "│")) ;; Set the character used for the indent guide.
875 |
876 |
877 | ;;; ADD-NODE-MODULES-PATH
878 | ;; The `add-node-modules-path' package ensures that Emacs uses the local
879 | ;; `node_modules/.bin' for a project rather than globally installed binaries.
880 | ;; This is essential in JavaScript/TypeScript projects where different versions
881 | ;; of tools like `eslint' and `typescript-language-server' might be needed
882 | ;; per project.
883 | ;;
884 | ;; This setup helps prevent conflicts between global and local versions of
885 | ;; Node.js tools and ensures consistency across different environments.
886 | ;;
887 | ;; Example in the wild: This is an example of a real-world issue often faced
888 | ;; by developers using modern tech stacks. When working on multiple projects
889 | ;; with different dependencies, Emacs must use the correct local versions
890 | ;; instead of relying on globally installed packages. This configuration
891 | ;; ensures that the environment is accurate and project-specific tools are
892 | ;; properly utilized.
893 | (use-package add-node-modules-path
894 | :ensure t
895 | :straight t
896 | :defer t
897 | :custom
898 | ;; Makes sure you are using the local bin for your
899 | ;; node project. Local eslint, typescript server...
900 | (eval-after-load 'typescript-ts-mode
901 | '(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
902 | (eval-after-load 'tsx-ts-mode
903 | '(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
904 | (eval-after-load 'typescriptreact-mode
905 | '(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
906 | (eval-after-load 'js-mode
907 | '(add-hook 'js-mode-hook #'add-node-modules-path)))
908 |
909 |
910 | ;; EVIL
911 | ;; The `evil' package provides Vim emulation within Emacs, allowing
912 | ;; users to edit text in a modal way, similar to how Vim
913 | ;; operates. This setup configures `evil-mode' to enhance the editing
914 | ;; experience.
915 | (use-package evil
916 | :ensure t
917 | :straight t
918 | :defer t
919 | :hook
920 | (after-init . evil-mode)
921 | :init
922 | (setq evil-want-integration t) ;; Integrate `evil' with other Emacs features (optional as it's true by default).
923 | (setq evil-want-keybinding nil) ;; Disable default keybinding to set custom ones.
924 | (setq evil-want-C-u-scroll t) ;; Makes C-u scroll
925 | (setq evil-want-C-u-delete t) ;; Makes C-u delete on insert mode
926 | :config
927 | (evil-set-undo-system 'undo-tree) ;; Uses the undo-tree package as the default undo system
928 |
929 | ;; Set the leader key to space for easier access to custom commands. (setq evil-want-leader t)
930 | (setq evil-leader/in-all-states t) ;; Make the leader key available in all states.
931 | (setq evil-want-fine-undo t) ;; Evil uses finer grain undoing steps
932 |
933 | ;; Define the leader key as Space
934 | (evil-set-leader 'normal (kbd "SPC"))
935 | (evil-set-leader 'visual (kbd "SPC"))
936 |
937 | ;; Keybindings for searching and finding files.
938 | (evil-define-key 'normal 'global (kbd " s f") 'consult-find)
939 | (evil-define-key 'normal 'global (kbd " s g") 'consult-grep)
940 | (evil-define-key 'normal 'global (kbd " s G") 'consult-git-grep)
941 | (evil-define-key 'normal 'global (kbd " s r") 'consult-ripgrep)
942 | (evil-define-key 'normal 'global (kbd " s h") 'consult-info)
943 | (evil-define-key 'normal 'global (kbd " /") 'consult-line)
944 |
945 | ;; Flymake navigation
946 | (evil-define-key 'normal 'global (kbd " x x") 'consult-flymake);; Gives you something like `trouble.nvim'
947 | (evil-define-key 'normal 'global (kbd "] d") 'flymake-goto-next-error) ;; Go to next Flymake error
948 | (evil-define-key 'normal 'global (kbd "[ d") 'flymake-goto-prev-error) ;; Go to previous Flymake error
949 |
950 | ;; Dired commands for file management
951 | (evil-define-key 'normal 'global (kbd " x d") 'dired)
952 | (evil-define-key 'normal 'global (kbd " x j") 'dired-jump)
953 | (evil-define-key 'normal 'global (kbd " x f") 'find-file)
954 |
955 | ;; Diff-HL navigation for version control
956 | (evil-define-key 'normal 'global (kbd "] c") 'diff-hl-next-hunk) ;; Next diff hunk
957 | (evil-define-key 'normal 'global (kbd "[ c") 'diff-hl-previous-hunk) ;; Previous diff hunk
958 |
959 | ;; NeoTree command for file exploration
960 | (evil-define-key 'normal 'global (kbd " e e") 'neotree-toggle)
961 | (evil-define-key 'normal 'global (kbd " e d") 'dired-jump)
962 |
963 | ;; Magit keybindings for Git integration
964 | (evil-define-key 'normal 'global (kbd " g g") 'magit-status) ;; Open Magit status
965 | (evil-define-key 'normal 'global (kbd " g l") 'magit-log-current) ;; Show current log
966 | (evil-define-key 'normal 'global (kbd " g d") 'magit-diff-buffer-file) ;; Show diff for the current file
967 | (evil-define-key 'normal 'global (kbd " g D") 'diff-hl-show-hunk) ;; Show diff for a hunk
968 | (evil-define-key 'normal 'global (kbd " g b") 'vc-annotate) ;; Annotate buffer with version control info
969 |
970 | ;; Buffer management keybindings
971 | (evil-define-key 'normal 'global (kbd "] b") 'switch-to-next-buffer) ;; Switch to next buffer
972 | (evil-define-key 'normal 'global (kbd "[ b") 'switch-to-prev-buffer) ;; Switch to previous buffer
973 | (evil-define-key 'normal 'global (kbd " b i") 'consult-buffer) ;; Open consult buffer list
974 | (evil-define-key 'normal 'global (kbd " b b") 'ibuffer) ;; Open Ibuffer
975 | (evil-define-key 'normal 'global (kbd " b d") 'kill-current-buffer) ;; Kill current buffer
976 | (evil-define-key 'normal 'global (kbd " b k") 'kill-current-buffer) ;; Kill current buffer
977 | (evil-define-key 'normal 'global (kbd " b x") 'kill-current-buffer) ;; Kill current buffer
978 | (evil-define-key 'normal 'global (kbd " b s") 'save-buffer) ;; Save buffer
979 | (evil-define-key 'normal 'global (kbd " b l") 'consult-buffer) ;; Consult buffer
980 | (evil-define-key 'normal 'global (kbd "SPC") 'consult-buffer) ;; Consult buffer
981 |
982 | ;; Project management keybindings
983 | (evil-define-key 'normal 'global (kbd " p b") 'consult-project-buffer) ;; Consult project buffer
984 | (evil-define-key 'normal 'global (kbd " p p") 'project-switch-project) ;; Switch project
985 | (evil-define-key 'normal 'global (kbd " p f") 'project-find-file) ;; Find file in project
986 | (evil-define-key 'normal 'global (kbd " p g") 'project-find-regexp) ;; Find regexp in project
987 | (evil-define-key 'normal 'global (kbd " p k") 'project-kill-buffers) ;; Kill project buffers
988 | (evil-define-key 'normal 'global (kbd " p D") 'project-dired) ;; Dired for project
989 |
990 | ;; Yank from kill ring
991 | (evil-define-key 'normal 'global (kbd "P") 'consult-yank-from-kill-ring)
992 | (evil-define-key 'normal 'global (kbd " P") 'consult-yank-from-kill-ring)
993 |
994 | ;; Embark actions for contextual commands
995 | (evil-define-key 'normal 'global (kbd " .") 'embark-act)
996 |
997 | ;; Undo tree visualization
998 | (evil-define-key 'normal 'global (kbd " u") 'undo-tree-visualize)
999 |
1000 | ;; Help keybindings
1001 | (evil-define-key 'normal 'global (kbd " h m") 'describe-mode) ;; Describe current mode
1002 | (evil-define-key 'normal 'global (kbd " h f") 'describe-function) ;; Describe function
1003 | (evil-define-key 'normal 'global (kbd " h v") 'describe-variable) ;; Describe variable
1004 | (evil-define-key 'normal 'global (kbd " h k") 'describe-key) ;; Describe key
1005 |
1006 | ;; Tab navigation
1007 | (evil-define-key 'normal 'global (kbd "] t") 'tab-next) ;; Go to next tab
1008 | (evil-define-key 'normal 'global (kbd "[ t") 'tab-previous) ;; Go to previous tab
1009 |
1010 |
1011 | ;; Custom example. Formatting with prettier tool.
1012 | (evil-define-key 'normal 'global (kbd " m p")
1013 | (lambda ()
1014 | (interactive)
1015 | (shell-command (concat "prettier --write " (shell-quote-argument (buffer-file-name))))
1016 | (revert-buffer t t t)))
1017 |
1018 | ;; LSP commands keybindings
1019 | (evil-define-key 'normal lsp-mode-map
1020 | ;; (kbd "gd") 'lsp-find-definition ;; evil-collection already provides gd
1021 | (kbd "gr") 'lsp-find-references ;; Finds LSP references
1022 | (kbd " c a") 'lsp-execute-code-action ;; Execute code actions
1023 | (kbd " r n") 'lsp-rename ;; Rename symbol
1024 | (kbd "gI") 'lsp-find-implementation ;; Find implementation
1025 | (kbd " l f") 'lsp-format-buffer) ;; Format buffer via lsp
1026 |
1027 |
1028 | (defun ek/lsp-describe-and-jump ()
1029 | "Show hover documentation and jump to *lsp-help* buffer."
1030 | (interactive)
1031 | (lsp-describe-thing-at-point)
1032 | (let ((help-buffer "*lsp-help*"))
1033 | (when (get-buffer help-buffer)
1034 | (switch-to-buffer-other-window help-buffer))))
1035 |
1036 | ;; Emacs 31 finaly brings us support for 'floating windows' (a.k.a. "child frames")
1037 | ;; to terminal Emacs. If you're still using 30, docs will be shown in a buffer at the
1038 | ;; inferior part of your frame.
1039 | (evil-define-key 'normal 'global (kbd "K")
1040 | (if (>= emacs-major-version 31)
1041 | #'eldoc-box-help-at-point
1042 | #'ek/lsp-describe-and-jump))
1043 |
1044 | ;; Commenting functionality for single and multiple lines
1045 | (evil-define-key 'normal 'global (kbd "gcc")
1046 | (lambda ()
1047 | (interactive)
1048 | (if (not (use-region-p))
1049 | (comment-or-uncomment-region (line-beginning-position) (line-end-position)))))
1050 |
1051 | (evil-define-key 'visual 'global (kbd "gc")
1052 | (lambda ()
1053 | (interactive)
1054 | (if (use-region-p)
1055 | (comment-or-uncomment-region (region-beginning) (region-end)))))
1056 |
1057 | ;; Enable evil mode
1058 | (evil-mode 1))
1059 |
1060 |
1061 | ;; EVIL COLLECTION
1062 | ;; The `evil-collection' package enhances the integration of
1063 | ;; `evil-mode' with various built-in and third-party packages. It
1064 | ;; provides a better modal experience by remapping keybindings and
1065 | ;; commands to fit the `evil' style.
1066 | (use-package evil-collection
1067 | :defer t
1068 | :straight t
1069 | :ensure t
1070 | :custom
1071 | (evil-collection-want-find-usages-bindings t)
1072 | ;; Hook to initialize `evil-collection' when `evil-mode' is activated.
1073 | :hook
1074 | (evil-mode . evil-collection-init))
1075 |
1076 |
1077 | ;; EVIL SURROUND
1078 | ;; The `evil-surround' package provides text object surround
1079 | ;; functionality for `evil-mode'. This allows for easily adding,
1080 | ;; changing, or deleting surrounding characters such as parentheses,
1081 | ;; quotes, and more.
1082 | ;;
1083 | ;; With this you can change 'hello there' with ci'" to have
1084 | ;; "hello there" and cs" to get
hello there
.
1085 | ;; More examples here:
1086 | ;; - https://github.com/emacs-evil/evil-surround?tab=readme-ov-file#examples
1087 | (use-package evil-surround
1088 | :ensure t
1089 | :straight t
1090 | :after evil-collection
1091 | :config
1092 | (global-evil-surround-mode 1))
1093 |
1094 |
1095 | ;; EVIL MATCHIT
1096 | ;; The `evil-matchit' package extends `evil-mode' by enabling
1097 | ;; text object matching for structures such as parentheses, HTML
1098 | ;; tags, and other paired delimiters. This makes it easier to
1099 | ;; navigate and manipulate code blocks.
1100 | ;; Just use % for jumping between matching structures to check it out.
1101 | (use-package evil-matchit
1102 | :ensure t
1103 | :straight t
1104 | :after evil-collection
1105 | :config
1106 | (global-evil-matchit-mode 1))
1107 |
1108 |
1109 | ;; UNDO TREE
1110 | ;; The `undo-tree' package provides an advanced and visual way to
1111 | ;; manage undo history. It allows you to navigate and visualize your
1112 | ;; undo history as a tree structure, making it easier to manage
1113 | ;; changes in your buffers.
1114 | (use-package undo-tree
1115 | :defer t
1116 | :ensure t
1117 | :straight t
1118 | :hook
1119 | (after-init . global-undo-tree-mode)
1120 | :init
1121 | (setq undo-tree-visualizer-timestamps t
1122 | undo-tree-visualizer-diff t
1123 | ;; Increase undo limits to avoid losing history due to Emacs' garbage collection.
1124 | ;; These values can be adjusted based on your needs.
1125 | ;; 10X bump of the undo limits to avoid issues with premature
1126 | ;; Emacs GC which truncates the undo history very aggressively.
1127 | undo-limit 800000 ;; Limit for undo entries.
1128 | undo-strong-limit 12000000 ;; Strong limit for undo entries.
1129 | undo-outer-limit 120000000) ;; Outer limit for undo entries.
1130 | :config
1131 | ;; Set the directory where `undo-tree' will save its history files.
1132 | ;; This keeps undo history across sessions, stored in a cache directory.
1133 | (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/.cache/undo"))))
1134 |
1135 |
1136 | ;;; RAINBOW DELIMITERS
1137 | ;; The `rainbow-delimiters' package provides colorful parentheses, brackets, and braces
1138 | ;; to enhance readability in programming modes. Each level of nested delimiter is assigned
1139 | ;; a different color, making it easier to match pairs visually.
1140 | (use-package rainbow-delimiters
1141 | :defer t
1142 | :straight t
1143 | :ensure t
1144 | :hook
1145 | (prog-mode . rainbow-delimiters-mode))
1146 |
1147 |
1148 | ;;; DOTENV
1149 | ;; A simple major mode to provide .env files with color highlighting
1150 | (use-package dotenv-mode
1151 | :defer t
1152 | :straight t
1153 | :ensure t
1154 | :config)
1155 |
1156 |
1157 | ;;; PULSAR
1158 | ;; The `pulsar' package enhances the user experience in Emacs by providing
1159 | ;; visual feedback through pulsating highlights. This feature is especially
1160 | ;; useful in programming modes, where it can help users easily track
1161 | ;; actions such as scrolling, error navigation, yanking, deleting, and
1162 | ;; jumping to definitions.
1163 | (use-package pulsar
1164 | :defer t
1165 | :straight t
1166 | :ensure t
1167 | :hook
1168 | (after-init . pulsar-global-mode)
1169 | :config
1170 | (setq pulsar-pulse t)
1171 | (setq pulsar-delay 0.025)
1172 | (setq pulsar-iterations 10)
1173 | (setq pulsar-face 'evil-ex-lazy-highlight)
1174 |
1175 | (add-to-list 'pulsar-pulse-functions 'evil-scroll-down)
1176 | (add-to-list 'pulsar-pulse-functions 'flymake-goto-next-error)
1177 | (add-to-list 'pulsar-pulse-functions 'flymake-goto-prev-error)
1178 | (add-to-list 'pulsar-pulse-functions 'evil-yank)
1179 | (add-to-list 'pulsar-pulse-functions 'evil-yank-line)
1180 | (add-to-list 'pulsar-pulse-functions 'evil-delete)
1181 | (add-to-list 'pulsar-pulse-functions 'evil-delete-line)
1182 | (add-to-list 'pulsar-pulse-functions 'evil-jump-item)
1183 | (add-to-list 'pulsar-pulse-functions 'diff-hl-next-hunk)
1184 | (add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk))
1185 |
1186 |
1187 | ;;; DOOM MODELINE
1188 | ;; The `doom-modeline' package provides a sleek, modern mode-line that is visually appealing
1189 | ;; and functional. It integrates well with various Emacs features, enhancing the overall user
1190 | ;; experience by displaying relevant information in a compact format.
1191 | (use-package doom-modeline
1192 | :ensure t
1193 | :straight t
1194 | :defer t
1195 | :custom
1196 | (doom-modeline-buffer-file-name-style 'buffer-name) ;; Set the buffer file name style to just the buffer name (without path).
1197 | (doom-modeline-project-detection 'project) ;; Enable project detection for displaying the project name.
1198 | (doom-modeline-buffer-name t) ;; Show the buffer name in the mode line.
1199 | (doom-modeline-vcs-max-length 25) ;; Limit the version control system (VCS) branch name length to 25 characters.
1200 | :config
1201 | (if ek-use-nerd-fonts ;; Check if nerd fonts are being used.
1202 | (setq doom-modeline-icon t) ;; Enable icons in the mode line if nerd fonts are used.
1203 | (setq doom-modeline-icon nil)) ;; Disable icons if nerd fonts are not being used.
1204 | :hook
1205 | (after-init . doom-modeline-mode))
1206 |
1207 |
1208 | ;;; NEOTREE
1209 | ;; The `neotree' package provides a file tree explorer for Emacs, allowing easy navigation
1210 | ;; through directories and files. It presents a visual representation of the file system
1211 | ;; and integrates with version control to show file states.
1212 | (use-package neotree
1213 | :ensure t
1214 | :straight t
1215 | :custom
1216 | (neo-show-hidden-files t) ;; By default shows hidden files (toggle with H)
1217 | (neo-theme 'nerd) ;; Set the default theme for Neotree to 'nerd' for a visually appealing look.
1218 | (neo-vc-integration '(face char)) ;; Enable VC integration to display file states with faces (color coding) and characters (icons).
1219 | :defer t ;; Load the package only when needed to improve startup time.
1220 | :config
1221 | (if ek-use-nerd-fonts ;; Check if nerd fonts are being used.
1222 | (setq neo-theme 'nerd-icons) ;; Set the theme to 'nerd-icons' if nerd fonts are available.
1223 | (setq neo-theme 'nerd))) ;; Otherwise, fall back to the 'nerd' theme.
1224 |
1225 |
1226 | ;;; NERD ICONS
1227 | ;; The `nerd-icons' package provides a set of icons for use in Emacs. These icons can
1228 | ;; enhance the visual appearance of various modes and packages, making it easier to
1229 | ;; distinguish between different file types and functionalities.
1230 | (use-package nerd-icons
1231 | :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
1232 | :ensure t ;; Ensure the package is installed.
1233 | :straight t
1234 | :defer t) ;; Load the package only when needed to improve startup time.
1235 |
1236 |
1237 | ;;; NERD ICONS Dired
1238 | ;; The `nerd-icons-dired' package integrates nerd icons into the Dired mode,
1239 | ;; providing visual icons for files and directories. This enhances the Dired
1240 | ;; interface by making it easier to identify file types at a glance.
1241 | (use-package nerd-icons-dired
1242 | :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
1243 | :ensure t ;; Ensure the package is installed.
1244 | :straight t
1245 | :defer t ;; Load the package only when needed to improve startup time.
1246 | :hook
1247 | (dired-mode . nerd-icons-dired-mode))
1248 |
1249 |
1250 | ;;; NERD ICONS COMPLETION
1251 | ;; The `nerd-icons-completion' package enhances the completion interfaces in
1252 | ;; Emacs by integrating nerd icons with completion frameworks such as
1253 | ;; `marginalia'. This provides visual cues for the completion candidates,
1254 | ;; making it easier to distinguish between different types of items.
1255 | (use-package nerd-icons-completion
1256 | :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
1257 | :ensure t ;; Ensure the package is installed.
1258 | :straight t
1259 | :after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration.
1260 | :config
1261 | (nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces.
1262 | (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display.
1263 |
1264 |
1265 | ;;; CATPPUCCIN THEME
1266 | ;; The `catppuccin-theme' package provides a visually pleasing color theme
1267 | ;; for Emacs that is inspired by the popular Catppuccin color palette.
1268 | ;; This theme aims to create a comfortable and aesthetic coding environment
1269 | ;; with soft colors that are easy on the eyes.
1270 | (use-package catppuccin-theme
1271 | :ensure t
1272 | :straight t
1273 | :config
1274 | (custom-set-faces
1275 | ;; Set the color for changes in the diff highlighting to blue.
1276 | `(diff-hl-change ((t (:background unspecified :foreground ,(catppuccin-get-color 'blue))))))
1277 |
1278 | (custom-set-faces
1279 | ;; Set the color for deletions in the diff highlighting to red.
1280 | `(diff-hl-delete ((t (:background unspecified :foreground ,(catppuccin-get-color 'red))))))
1281 |
1282 | (custom-set-faces
1283 | ;; Set the color for insertions in the diff highlighting to green.
1284 | `(diff-hl-insert ((t (:background unspecified :foreground ,(catppuccin-get-color 'green))))))
1285 |
1286 | ;; Load the Catppuccin theme without prompting for confirmation.
1287 | (load-theme 'catppuccin :no-confirm))
1288 |
1289 |
1290 | ;;; UTILITARY FUNCTION TO INSTALL EMACS-KICK
1291 | (defun ek/first-install ()
1292 | "Install tree-sitter grammars and compile packages on first run..."
1293 | (interactive) ;; Allow this function to be called interactively.
1294 | (switch-to-buffer "*Messages*") ;; Switch to the *Messages* buffer to display installation messages.
1295 | (message ">>> All required packages installed.")
1296 | (message ">>> Configuring Emacs-Kick...")
1297 | (message ">>> Configuring Tree Sitter parsers...")
1298 | (require 'treesit-auto)
1299 | (treesit-auto-install-all) ;; Install all available Tree Sitter grammars.
1300 | (message ">>> Configuring Nerd Fonts...")
1301 | (require 'nerd-icons)
1302 | (nerd-icons-install-fonts) ;; Install all available nerd-fonts
1303 | (message ">>> Emacs-Kick installed! Press any key to close the installer and open Emacs normally. First boot will compile some extra stuff :)")
1304 | (read-key) ;; Wait for the user to press any key.
1305 | (kill-emacs)) ;; Close Emacs after installation is complete.
1306 |
1307 | (provide 'init)
1308 | ;;; init.el ends here
1309 |
--------------------------------------------------------------------------------