Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit d27a3b3

Browse files
authored
feat: Refactor config handling (#108)
- Rename `doomrc.lua` and `plugins.lua` to `doom_modules.lua` and `doom_userplugins.lua`, respectively. - Rename `doom.core.config.doomrc` to `doom.core.config.modules`. - Change config files to modules to utilize `requires` mechanism. Add property `M.source` to hold load path of file. - Alphabetize `doom_modules.lua` and sync defaults with `doom.core.config.modules`. - Update help file. - Add `doom.core.config.userplugins` to be consistent.
1 parent a43aa48 commit d27a3b3

32 files changed

+820
-831
lines changed

doc/doom_nvim.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ INTRODUCTION *doom_nvim_intro*
5656

5757
Doom Neovim is a Neovim port of the Doom Emacs configuration framework, adapted
5858
for the Neovim user that wants less framework in their framework and the performance
59-
of a hand-made configuration. You can use it as a base for your own setup or as
59+
of a hand-made configuration. You can use it as a base for your own setup or as
6060
a learning resource on how to achieve a great Neovim configuration.
6161

6262
Doom Neovim features an opinionated collection of reasonable and optional
63-
defaults, with a focus on runtime and startup performance, and a clean,
63+
defaults, with a focus on runtime and startup performance, and a clean,
6464
readable code base.
6565

6666

@@ -81,7 +81,7 @@ COLORSCHEME *doom_nvim_colorscheme*
8181

8282
The colorscheme of Doom Nvim. Default is `doom-one`. There are some additional
8383
doom emacs' colorschemes port for Neovim that can be enabled by uncommenting
84-
the `doom-themes` in your `doomrc.lua`.
84+
the `doom-themes` in your `doom_modules.lua`.
8585

8686
You can switch between colorschemes by doing <Space>ds and then type the name
8787
of the colorscheme you want to use. You can also edit the `doom_config.lua`
@@ -129,7 +129,7 @@ See |doom_nvim_commands| for more information.
129129
==============================================================================
130130
FILE EXPLORER *doom_nvim_configuration_layout_explorer*
131131

132-
Doom Neovim uses the `kyazdani42/nvim-tree.lua` plugin as a file explorer.
132+
Doom Neovim uses the `kyazdani42/nvim-tree.lua` plugin as a file explorer.
133133
It can be toggled by running the following commands:
134134
<Space>oe for `FileExplorer`
135135
<F3> for `FileExplorer`
@@ -222,11 +222,11 @@ and Doom Nvim will automatically handle your changes on here.
222222
==============================================================================
223223
CUSTOM PLUGINS *doom_nvim_configuration_custom_plugins*
224224

225-
To use your own plugins in Doom Nvim you can use the `plugins.lua` file
226-
located in the Doom Nvim root directory.
225+
To use your own plugins in Doom Nvim you can use the `doom_userplugins.lua`
226+
file located in the Doom Nvim root directory.
227227

228228
NOTE: if you are familiar with `packer.nvim` (the plugins manager used by Doom
229-
Nvim) then you can see the `plugins.lua` file as a wrapper for it.
229+
Nvim) then you can see the `doom_userplugins.lua` file as a wrapper for it.
230230

231231
To add plugins without extra configurations (e.g., if a plugin does not depend
232232
on other plugins), you can simply set it as follow:
@@ -259,8 +259,8 @@ having to manually configure servers, Doom Nvim makes use of
259259

260260
To enable the language server for a certain programming language and
261261
automatically install it, just append a `+lsp` flag at the end of the language
262-
field in your `doomrc.lua`, e.g. for enabling Rust support in Doom and install
263-
`rust-analyzer`:
262+
field in your `doom_modules.lua`, e.g. for enabling Rust support in Doom and
263+
install `rust-analyzer`:
264264

265265
` local doom = {`
266266
` langs = {`
@@ -495,9 +495,9 @@ development environment without spending a lot of time setting everything up.
495495

496496
- Why does Doom Nvim only support Neovim 0.5.0 (and beyond)?
497497

498-
Doom Nvim relies on lua for the configuration and use of many plugins. Since
498+
Doom Nvim relies on lua for the configuration and use of many plugins. Since
499499
lua is not available in neovim 0.4.4 and below, it is not possible to use Doom
500-
Nvim with a neovim version lower than 0.5.0. However, the Doom Nvim installer
500+
Nvim with a neovim version lower than 0.5.0. However, the Doom Nvim installer
501501
automatically installs Neovim 0.5.0 for you!
502502

503503
==============================================================================
@@ -515,7 +515,9 @@ This is the structure of Doom Nvim:
515515
├── doc # Doom Nvim documentation to be used inside Nvim
516516
│ └── doom_nvim.txt # Doom Nvim help file
517517
├── docs # Doom Nvim docs meant to be readed on GitHub
518-
├── doomrc # Doom Nvim user configurations file
518+
├── doom_config.lua # Doom Nvim user configurations file
519+
├── doom_modules.lua # Doom Nvim user module selection
520+
├── doom_userplugins.lua # Doom Nvim user plugins
519521
├── init.lua # init.lua file
520522
├── install.sh # Doom Nvim installer
521523
├── LICENSE # Doom Nvim License
@@ -537,8 +539,8 @@ This is the structure of Doom Nvim:
537539
│ └── init.lua # packer.nvim setup
538540
└── sessions # Location of Neovim workspaces
539541

540-
Doom Nvim also sets default configurations for the `doomrc.lua` and the
541-
`doom_config.lua` files, which serves as the user configuration file
542+
Doom Nvim also sets default configurations for the `doom_config.lua` and the
543+
`doom_modules.lua` files, which serves as the user configuration file
542544
if it is not present on the system. It allows a fine control over the core
543545
functions of Doom Nvim.
544546

docs/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ thus reach a solution more quickly.
5050
Some important data would be:
5151

5252
- Your custom configuration if you have one
53-
(`doomrc.lua`, `doom_config.lua` and `plugins.lua`)
53+
(`doom_modules.lua`, `doom_config.lua` and `doom_userplugins.lua`)
5454
- Which branch of Doom Nvim are you using
5555
- Which plugins are you using
5656

docs/getting_started.md

Lines changed: 84 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -305,86 +305,93 @@ a previous release (for main branch) or a previous commit (for development branc
305305
306306
## Configuration
307307

308-
You can configure Doom Nvim by tweaking the `doomrc.lua`, `doom_config.lua` and
309-
the `plugins.lua` files located in your Doom Nvim root directory
310-
(`$HOME/.config/doom-nvim/` by default).
308+
You can configure Doom Nvim by tweaking the `doom_config.lua`,
309+
`doom_modules.lua` and the `doom_userplugins.lua` files located in your
310+
Doom Nvim root directory (`$HOME/.config/doom-nvim/` by default).
311311

312-
### doomrc.lua
312+
### doom_modules.lua
313313

314314
This file handles all the Doom Nvim modules, its structure is really simple and
315315
easy to understand.
316316

317317
This one will look like that:
318318

319319
```lua
320-
local doom = {
321-
ui = {
322-
'dashboard', -- Start screen
323-
-- 'doom-themes', -- Additional doom emacs' colorschemes
324-
'statusline', -- Statusline
325-
'tabline', -- Tabline, shows your buffers list at top
326-
-- 'zen', -- Distraction free environment
327-
'which-key', -- Keybindings popup menu like Emacs' guide-key
328-
-- 'indentlines', -- Show indent lines
329-
},
330-
doom = {
331-
-- 'neorg', -- Life Organization Tool
332-
-- 'runner', -- Open a REPL for the current language or run the current file
333-
-- 'compiler', -- Compile (and run) your code with just pressing three keys!
334-
},
335-
editor = {
336-
'auto-session', -- A small automated session manager for Neovim
337-
-- 'terminal', -- Terminal for Neovim (NOTE: needed for runner and compiler)
338-
'explorer', -- Tree explorer
339-
'symbols', -- LSP symbols and tags
340-
-- 'minimap', -- Code minimap, requires github.com/wfxr/code-minimap
341-
'gitsigns', -- Git signs
342-
'telescope', -- Highly extendable fuzzy finderover lists
343-
-- 'restclient', -- A fast Neovim http client
344-
'formatter', -- File formatting
345-
'autopairs', -- Autopairs
346-
-- 'editorconfig', -- EditorConfig support for Neovim
347-
'kommentary', -- Comments plugin
348-
'lsp', -- Language Server Protocols
349-
'snippets', -- LSP snippets
350-
},
351-
langs = {
352-
-- To enable the language server for a language justadd the +lsp flag
353-
-- at the end, e.g. 'rust +lsp'. This will install the rust TreeSitter
354-
-- parser and rust-analyzer
355-
--
356-
-- 'html', -- HTML support
357-
-- 'css', -- CSS support
358-
-- 'javascript', -- JavaScript support
359-
-- 'typescript', -- TypeScript support
360-
-- 'bash', -- The terminal gods language
361-
-- 'python +lsp', -- Python support + lsp
362-
-- 'ruby', -- Look ma, I love the gems!
363-
'lua', -- Support for our gods language
364-
-- 'elixir', -- Build scalable and maintainablesoftware
365-
-- 'haskell', -- Because Functional programming is fun, isn't it?
366-
367-
-- 'rust +lsp', -- Let's get rusty!
368-
-- 'go', -- Hello, gopher
369-
-- 'cpp', -- C++ support
370-
-- 'java', -- Java support
371-
372-
-- 'config', -- Configuration files (JSON, YAML, TOML)
373-
-- 'dockerfile', -- Do you like containers, right?
374-
},
375-
utilities = {
376-
-- 'suda', -- Write and read files without sudo permissions
377-
-- 'lazygit', -- LazyGit integration for Neovim, requires LazyGit
378-
-- 'neogit', -- Magit for Neovim
379-
-- 'colorizer', -- Fastets colorizer for Neovim
380-
'range-highlight', -- hightlights ranges you haveentered in commandline
381-
},
320+
local M = {}
321+
M.source = debug.getinfo(1, "S").source:sub(2)
322+
323+
M.modules = {
324+
ui = {
325+
"dashboard", -- Start screen
326+
-- "doom-themes", -- Additional doom emacs' colorschemes
327+
-- "indentlines", -- Show indent lines
328+
-- "show_registers", -- popup that shows register contents
329+
"statusline", -- Statusline
330+
"tabline", -- Tabline, shows your buffers list at top
331+
"which-key", -- Keybindings popup menu like Emacs' guide-key
332+
-- "zen", -- Distraction free environment
333+
},
334+
doom = {
335+
-- "compiler", -- Compile (and run) your code with just pressing three keys!
336+
-- "neorg", -- Life Organization Tool
337+
-- "runner", -- Open a REPL for the current language or run the current file
338+
},
339+
editor = {
340+
"autopairs", -- Autopairs
341+
"auto-session", -- A small automated session manager for Neovim
342+
"dap", -- Debug Adapter Protocol
343+
-- "editorconfig", -- EditorConfig support for Neovim
344+
"explorer", -- Tree explorer
345+
"formatter", -- File formatting
346+
"gitsigns", -- Git signs
347+
"kommentary", -- Comments plugin
348+
"lsp", -- Language Server Protocols
349+
-- "minimap", -- Code minimap, requires github.com/wfxr/code-minimap
350+
-- "ranger", -- Ranger File Browser, requires ranger file browser
351+
"snippets", -- LSP snippets
352+
"symbols", -- LSP symbols and tags
353+
"telescope", -- Highly extendable fuzzy finder over lists
354+
-- "terminal", -- Terminal for Neovim (NOTE: needed for runner and compiler)
355+
},
356+
langs = {
357+
-- To enable the language server for a language just add the +lsp flag
358+
-- at the end, e.g. 'rust +lsp'. This will install the rust TreeSitter
359+
-- parser and rust-analyzer
360+
--
361+
-- "bash", -- The terminal gods language
362+
-- "config", -- Configuration files (JSON, YAML, TOML)
363+
-- "cpp", -- C++ support
364+
-- "css", -- CSS support
365+
-- "dockerfile", -- Do you like containers, right?
366+
-- "elixir", -- Build scalable and maintainable software
367+
-- "go", -- Hello, gopher
368+
-- "haskell", -- Because Functional programming is fun, isn't it?
369+
-- "html", -- HTML support
370+
-- "java", -- Java support
371+
-- "javascript", -- JavaScript support
372+
"lua", -- Support for our gods language
373+
-- "python +lsp", -- Python support + lsp
374+
-- "ruby", -- Look ma, I love the gems!
375+
-- "rust +lsp", -- Let's get rusty!
376+
-- "typescript", -- TypeScript support
377+
},
378+
utilities = {
379+
-- "lazygit", -- LazyGit integration for Neovim, requires LazyGit
380+
-- "neogit", -- Magit for Neovim
381+
"range-highlight", -- hightlights ranges you have entered in commandline
382+
-- "suda", -- Write and read files without sudo permissions
383+
},
384+
web = {
385+
-- "colorizer", -- Fastest colorizer for Neovim
386+
-- "firenvim", -- requires firenvim browser extension; change fontsize by increasing guifontsize in doom_config
387+
-- "restclient", -- A fast Neovim http client
388+
}
382389
}
383390

384-
return doom
391+
return M
385392
```
386393

387-
And as the `doomrc.lua` file self-documentation says, you will only need to uncomment
394+
And as the `doom_modules.lua` file self-documentation says, you will only need to uncomment
388395
or comment the plugins names in order to enable or disable them. e.g. to enable the `terminal`
389396
plugin you will only need to uncomment the `-- 'terminal',` line and restart Neovim.
390397
Doom will automatically handle your changes and install the `terminal` plugin for you.
@@ -419,7 +426,7 @@ return {
419426
> **NOTE**: all your used-defined configurations here will be live-reloaded, e.g.
420427
> mappings, autocommands, etc.
421428
422-
### plugins.lua
429+
### doom_userplugins.lua
423430

424431
This file handles your custom plugins, in other words, it handles all the extra
425432
plugins you need that are not covered by Doom Nvim.
@@ -440,7 +447,7 @@ return {
440447
}
441448
```
442449

443-
And as with the `doomrc.lua` file, Doom Nvim will automatically handle your changes
450+
And as with the `doom_modules.lua` file, Doom Nvim will automatically handle your changes
444451
and install or uninstall the plugins declared on here.
445452

446453
> **NOTE**: all the valid options for declaring plugins can be found in
@@ -450,7 +457,7 @@ and install or uninstall the plugins declared on here.
450457

451458
Doom Nvim consists of around 5 modules. A Doom Nvim Module is a bundle of plugins,
452459
configuration and commands, organized into a unit that can be toggled easily by
453-
tweaking your `doomrc.lua` (found in `$HOME/.config/doom-nvim`).
460+
tweaking your `doom_modules.lua` (found in `$HOME/.config/doom-nvim`).
454461

455462
Please see [Plugin Management](#plugin-management) for more information.
456463

@@ -464,7 +471,7 @@ in your Doom Nvim root directory. Read on to learn how to use this system to ins
464471
your own plugins.
465472

466473
> **WARNING:** Do not install plugins directly in `lua/doom/modules/init.lua`. Instead,
467-
> use your `doomrc.lua` and `plugins.lua` files to modify them.
474+
> use your `doom_modules.lua` and `doom_userplugins.lua` files to modify them.
468475
469476
### Configuring Doom
470477

@@ -480,7 +487,7 @@ Do you want to change some configurations of some modules?
480487
Go to `lua/doom/modules/config` directory and you will find the configurations
481488
for the plugins.
482489

483-
Otherwise if you want to configure a plugin declared in your `plugins.lua` you
490+
Otherwise if you want to configure a plugin declared in your `doom_userplugins.lua` you
484491
can use the packer's `config` field, e.g.
485492

486493
```lua
@@ -500,7 +507,7 @@ To easily install language servers and without having to do it system-wide or ha
500507
manually configure servers, Doom Nvim makes use of [kabouzeid/nvim-lspinstall](https://github.com/kabouzeid/nvim-lspinstall).
501508

502509
To enable the language server for a certain programming language and automatically
503-
install it, just append a `+lsp` flag at the end of the language field in your `doomrc.lua`,
510+
install it, just append a `+lsp` flag at the end of the language field in your `doom_modules.lua`,
504511
e.g. for enabling Rust support in Doom and install `rust-analyzer`:
505512

506513
```lua
@@ -545,7 +552,7 @@ But first let's see what's new:
545552
- New logging system powered by [vlog]. A faster and smaller logging system
546553
because complexity is not always the best choice.
547554
- Easily enable and disable plugins. Now toggling the doom default plugins is easier
548-
than before, just comment or uncomment it in your `doomrc.lua`!
555+
than before, just comment or uncomment it in your `doom_modules.lua`!
549556
- Better custom plugins management. Now the custom plugins are being directly
550557
handled by packer as it should be, no more nonsense wrappers around it.
551558
- Better updating mechanism. Forget these annoying merging issues and save the
@@ -618,12 +625,12 @@ And now, how can I start using the new configuration files?
618625
I'm going to explain you in a short way because the new configuration files has
619626
a rich documentation inside them.
620627

621-
- `doomrc.lua`, this file handles the Doom Nvim modules, in other words, which
628+
- `doom_modules.lua`, this file handles the Doom Nvim modules, in other words, which
622629
plugins are being installed and loaded and which plugins are not.
623630
- `doom_config.lua`, this file handles the user configurations for doom nvim,
624631
e.g. if mouse is enabled or not. This one also handles user-defined Neovim
625632
configurations like global variables and mappings.
626-
- `plugins.lua`, this file handles the user-defined plugins, it is the
633+
- `doom_userplugins.lua`, this file handles the user-defined plugins, it is the
627634
replacement for the `custom_plugins` field in the old doomrc.
628635

629636
> Are you having issues with the 3.0.0 version? Don't hesitate to [report them]

0 commit comments

Comments
 (0)