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. 36
      lua/doom/core/functions/init.lua
  3. 11
      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 on
filetype plugin indent on filetype plugin indent on
PackerLoad nvim-treesitter PackerLoad nvim-treesitter
PackerLoad which-key.nvim
silent! bufdo e silent! bufdo e
]]) ]])
end, 15) end, 10)
end, 0) end, 0)
async:close() async:close()

36
lua/doom/core/functions/init.lua

@ -1,7 +1,7 @@
---[[---------------------------------------]]--- ---[[---------------------------------------]]---
-- functions - Doom Nvim Functions -- -- functions - Doom Nvim Functions --
-- Author: NTBBloodbath -- -- Author: NTBBloodbath --
-- License: GPLv2 -- -- License: GPLv2 --
---[[---------------------------------------]]--- ---[[---------------------------------------]]---
local utils = require('doom.utils') local utils = require('doom.utils')
@ -451,4 +451,38 @@ M.rollback_doom = function()
end end
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 return M

11
lua/doom/core/keybindings/init.lua

@ -14,14 +14,11 @@ log.debug('Loading Doom keybindings module ...')
-- Additional options for mappings -- Additional options for mappings
local opts = { silent = true } local opts = { silent = true }
-- selene: allow(undefined_variable) utils.map('n', '<Space>', '<Nop>', opts)
if packer_plugins and not packer_plugins['which-key.nvim'] then vim.g.mapleader = ' '
utils.map('n', '<Space>', '<Nop>', opts)
vim.g.mapleader = ' '
end
-- Map WhichKey popup menu -- 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( utils.map(
'n', 'n',
'<leader>dc', '<leader>dc',
'<cmd>e ' .. utils.doom_root .. '/doom_config.lua<CR>', '<cmd>lua require("doom.core.functions").edit_config()<CR>',
opts opts
) )
utils.map('n', '<leader>dd', '<cmd>help doom_nvim<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 = { f = {
description = { ' Open Private Configuration SPC d c' }, description = { ' Open Private Configuration SPC d c' },
command = ':e ' .. doom_root .. '/doom_config.lua', command = ':lua require("doom.core.functions").edit_config()',
}, },
g = { g = {
description = { ' Open Documentation SPC d d' }, 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') local disabled_whichkey = functions.is_plugin_disabled('which-key')
use({ use({
'folke/which-key.nvim', 'folke/which-key.nvim',
opt = true,
config = require('doom.modules.config.doom-whichkey'), config = require('doom.modules.config.doom-whichkey'),
event = 'BufWinEnter',
disable = disabled_whichkey, disable = disabled_whichkey,
}) })
@ -250,7 +250,6 @@ packer.startup(function(use)
-- Built-in LSP Config -- Built-in LSP Config
use({ use({
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
opt = true,
config = require('doom.modules.config.doom-lspconfig'), config = require('doom.modules.config.doom-lspconfig'),
disable = disabled_lsp, disable = disabled_lsp,
event = 'ColorScheme', event = 'ColorScheme',
@ -353,7 +352,7 @@ packer.startup(function(use)
use({ use({
'b3nj5m1n/kommentary', 'b3nj5m1n/kommentary',
disable = disabled_kommentary, disable = disabled_kommentary,
event = 'BufEnter', event = 'BufWinEnter',
}) })
-----[[-------------]]----- -----[[-------------]]-----

Loading…
Cancel
Save