diff --git a/init.lua b/init.lua index 51214ce..c6d3fa9 100644 --- a/init.lua +++ b/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() diff --git a/lua/doom/core/functions/init.lua b/lua/doom/core/functions/init.lua index f49b9e6..682cceb 100644 --- a/lua/doom/core/functions/init.lua +++ b/lua/doom/core/functions/init.lua @@ -1,7 +1,7 @@ ---[[---------------------------------------]]--- -- functions - Doom Nvim Functions -- -- Author: NTBBloodbath -- --- License: GPLv2 -- +-- License: GPLv2 -- ---[[---------------------------------------]]--- local utils = require('doom.utils') @@ -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 diff --git a/lua/doom/core/keybindings/init.lua b/lua/doom/core/keybindings/init.lua index ea2f452..e2df2fc 100644 --- a/lua/doom/core/keybindings/init.lua +++ b/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', '', '', opts) - vim.g.mapleader = ' ' -end +utils.map('n', '', '', opts) +vim.g.mapleader = ' ' -- Map WhichKey popup menu -utils.map('n', '', ':WhichKey ', opts) +-- utils.map('n', '', ':WhichKey ', opts) ------------------------------------------------- @@ -257,7 +254,7 @@ utils.map('n', 'bf', 'FormatWrite', opts) utils.map( 'n', 'dc', - 'e ' .. utils.doom_root .. '/doom_config.lua', + 'lua require("doom.core.functions").edit_config()', opts ) utils.map('n', 'dd', 'help doom_nvim', opts) diff --git a/lua/doom/modules/config/doom-dashboard.lua b/lua/doom/modules/config/doom-dashboard.lua index 34c9dbf..32a6545 100644 --- a/lua/doom/modules/config/doom-dashboard.lua +++ b/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' }, diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index 63fcc39..dbccc58 100644 --- a/lua/doom/modules/init.lua +++ b/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', }) -----[[-------------]]-----