Browse Source

feat: add more Doom commands, e.g. `:DoomReport`

- Use Doom commands in keybindings instead of the Lua chunks

  - Create a separated function for Doom commands in `settings` module

  - Update internal documentation
my-config
NTBBloodbath 3 years ago
parent
commit
149130f5c7
No known key found for this signature in database GPG Key ID: 18D6730BC846AAC5
  1. 22
      doc/doom_nvim.norg
  2. 2
      lua/doom/core/init.lua
  3. 16
      lua/doom/core/settings/init.lua
  4. 8
      lua/doom/extras/keybindings/leader.lua

22
doc/doom_nvim.norg

@ -244,13 +244,21 @@
** Commands
Doom Nvim has its own commands, to make your life easier when developing on it.
┌─────────────┬──────────────────────────────────────────┐
│Command │ Description │
├─────────────┼──────────────────────────────────────────┤
│DoomUpdate │ Update Doom Nvim if there are updates │
├─────────────┼──────────────────────────────────────────┤
│DoomRollback │ Rollback Doom Nvim to a previous version │
└─────────────┴──────────────────────────────────────────┘
┌──────────────────┬────────────────────────────────────────────┐
│Command │ Description │
├──────────────────┼────────────────────────────────────────────┤
│DoomUpdate │ Update Doom Nvim if there are updates │
├──────────────────┼────────────────────────────────────────────┤
│DoomRollback │ Rollback Doom Nvim to a previous version │
├──────────────────┼────────────────────────────────────────────┤
│DoomManual │ Open Doom Nvim User Manual │
├──────────────────┼────────────────────────────────────────────┤
│DoomConfigs │ Open a selection menu to edit Doom configs │
├──────────────────┼────────────────────────────────────────────┤
│DoomConfigsReload │ Reload user-defined keybindings, etc │
├──────────────────┼────────────────────────────────────────────┤
│DoomReport │ Create a Doom Nvim markdown crash report │
└──────────────────┴────────────────────────────────────────────┘
Doom Nvim also uses [which-key.nvim](https://github.com/folke/which-key.nvim) as a commands manager, inspired by emacs' guide-key.
To open it, press `SPC` and wait for the popup to show, it should not take much time.

2
lua/doom/core/init.lua

@ -13,6 +13,8 @@ for i = 1, #core_modules, 1 do
require("doom.core.settings").load_default_options()
-- User-defined settings (global variables, mappings, ect)
require("doom.core.settings").custom_options()
-- Doom Nvim custom commands
require("doom.core.settings").doom_commands()
elseif core_modules[i] == "config" then
-- Automatically install language servers
require("doom.core.config").install_servers(require("doom.core.config.modules").modules.langs)

16
lua/doom/core/settings/init.lua

@ -140,8 +140,8 @@ M.load_default_options = function()
vim.opt.conceallevel = config.doom.conceallevel
end
-- Custom Doom Nvim commands
M.custom_options = function()
-- Doom Nvim commands
M.doom_commands = function()
-- Set a custom command to update Doom Nvim
-- can be called by using :DoomUpdate
vim.cmd('command! DoomUpdate lua require("doom.core.functions").update_doom()')
@ -151,7 +151,19 @@ M.custom_options = function()
-- Set a custom command to open Doom Nvim user manual
-- can be called by using :DoomManual
vim.cmd('command! DoomManual lua require("doom.core.functions").open_docs()')
-- Set a custom command to edit Doom Nvim private configurations
-- can be called by using :DoomConfigs
vim.cmd('command! DoomConfigs lua require("doom.core.functions").edit_config()')
-- Set a custom command to reload Doom Nvim custom mappings, autocommands, etc
-- can be called by using :DoomConfigsReload
vim.cmd('command! DoomConfigsReload lua require("doom.core.functions").reload_custom_settings()')
-- Set a custom command to create a crash report
-- can be called by using :DoomReport
vim.cmd('command! DoomReport lua require("doom.core.functions").create_report()')
end
-- Custom Doom Nvim options
M.custom_options = function()
-- Load user-defined settings from the Neovim field in the doom_config.lua file
functions.load_custom_settings(config.nvim.autocmds, "autocmds")
functions.load_custom_settings(config.nvim.commands, "commands")

8
lua/doom/extras/keybindings/leader.lua

@ -159,7 +159,7 @@ utils.map(
utils.map(
"n",
"<leader>dc",
'<cmd>lua require("doom.core.functions").edit_config()<CR>',
'<cmd>DoomConfigs<CR>',
opts,
"Doom",
"edit_doom_config",
@ -168,7 +168,7 @@ utils.map(
utils.map(
"n",
"<leader>dd",
"<cmd>lua require('doom.core.functions').open_docs()<CR>",
"<cmd>DoomManual<CR>",
opts,
"Doom",
"help_doom",
@ -187,7 +187,7 @@ utils.map(
utils.map(
"n",
"<leader>dR",
'<cmd>lua require("doom.core.functions").create_report()<CR>',
'<cmd>DoomReport<CR>',
opts,
"Doom",
"create_crash_report",
@ -214,7 +214,7 @@ utils.map(
utils.map(
"n",
"<leader>dl",
"<cmd>lua require('doom.core.functions').reload_custom_settings()<CR>",
"<cmd>DoomConfigsReload<CR>",
opts,
"Doom",
"reload_user_settings",

Loading…
Cancel
Save