Browse Source

feat:

- Introduce a new prompt to edit doom configurations
  - Improve how which-key plugin is being lazy-loaded
  - Change kommentary plugin lazy-load event
  - Small improvements to startup (decreased by ~10ms)
my-config
NTBBloodbath 3 years ago
parent
commit
8a23f343ec
No known key found for this signature in database GPG Key ID: 18D6730BC846AAC5
  1. 3
      init.lua
  2. 34
      lua/doom/core/functions/init.lua
  3. 7
      lua/doom/core/keybindings/init.lua
  4. 2
      lua/doom/modules/config/doom-dashboard.lua
  5. 5
      lua/doom/modules/init.lua

3
init.lua

@ -57,9 +57,10 @@ async = vim.loop.new_async(vim.schedule_wrap(function()
filetype on
filetype plugin indent on
PackerLoad nvim-treesitter
PackerLoad which-key.nvim
silent! bufdo e
]])
end, 15)
end, 10)
end, 0)
async:close()

34
lua/doom/core/functions/init.lua

@ -451,4 +451,38 @@ M.rollback_doom = function()
end
end
-- edit_config creates a prompt to modify a doom configuration file
M.edit_config = function()
local selected_config = tonumber(
vim.fn.input(
'Select a configuration file to edit:'
.. '\n\t1. doom_config.lua'
.. '\n\t2. doomrc.lua'
.. '\n\t3. plugins.lua'
.. '\n\n>> '
)
)
local open_command = config.doom.new_file_split and 'split' or 'edit'
if selected_config == 1 then
vim.cmd(
string.format(
'%s %s/doom_config.lua',
open_command,
utils.doom_root
)
)
elseif selected_config == 2 then
vim.cmd(
string.format('%s %s/doomrc.lua', open_command, utils.doom_root)
)
elseif selected_config == 3 then
vim.cmd(
string.format('%s %s/plugins.lua', open_command, utils.doom_root)
)
else
log.error('Invalid option selected.')
end
end
return M

7
lua/doom/core/keybindings/init.lua

@ -14,14 +14,11 @@ log.debug('Loading Doom keybindings module ...')
-- Additional options for mappings
local opts = { silent = true }
-- selene: allow(undefined_variable)
if packer_plugins and not packer_plugins['which-key.nvim'] then
utils.map('n', '<Space>', '<Nop>', opts)
vim.g.mapleader = ' '
end
-- Map WhichKey popup menu
utils.map('n', '<Space>', ':WhichKey <leader><CR>', opts)
-- utils.map('n', '<Space>', ':WhichKey <leader><CR>', opts)
-------------------------------------------------
@ -257,7 +254,7 @@ utils.map('n', '<leader>bf', '<cmd>FormatWrite<CR>', opts)
utils.map(
'n',
'<leader>dc',
'<cmd>e ' .. utils.doom_root .. '/doom_config.lua<CR>',
'<cmd>lua require("doom.core.functions").edit_config()<CR>',
opts
)
utils.map('n', '<leader>dd', '<cmd>help doom_nvim<CR>', opts)

2
lua/doom/modules/config/doom-dashboard.lua

@ -29,7 +29,7 @@ return function()
},
f = {
description = { ' Open Private Configuration SPC d c' },
command = ':e ' .. doom_root .. '/doom_config.lua',
command = ':lua require("doom.core.functions").edit_config()',
},
g = {
description = { ' Open Documentation SPC d d' },

5
lua/doom/modules/init.lua

@ -180,8 +180,8 @@ packer.startup(function(use)
local disabled_whichkey = functions.is_plugin_disabled('which-key')
use({
'folke/which-key.nvim',
opt = true,
config = require('doom.modules.config.doom-whichkey'),
event = 'BufWinEnter',
disable = disabled_whichkey,
})
@ -250,7 +250,6 @@ packer.startup(function(use)
-- Built-in LSP Config
use({
'neovim/nvim-lspconfig',
opt = true,
config = require('doom.modules.config.doom-lspconfig'),
disable = disabled_lsp,
event = 'ColorScheme',
@ -353,7 +352,7 @@ packer.startup(function(use)
use({
'b3nj5m1n/kommentary',
disable = disabled_kommentary,
event = 'BufEnter',
event = 'BufWinEnter',
})
-----[[-------------]]-----

Loading…
Cancel
Save