Browse Source

big changes:

- Re-ordered init structure, now just load a file to rule them all
  - Removed some junk from autocommands
  - Improved lazy-loading (~20ms now)
  - Some configuration tweaks
  - Ditch `dot-http` in favour of `rest.nvim`
  - Fixed a which-key bug, was not common to get it but let's get rid of it ASAP
my-config
NTBBloodbath 3 years ago
parent
commit
d486efc879
No known key found for this signature in database GPG Key ID: 18D6730BC846AAC5
  1. 51
      init.lua
  2. 15
      lua/doom/core/autocmds/init.lua
  3. 16
      lua/doom/core/config/init.lua
  4. 6
      lua/doom/core/default/init.lua
  5. 8
      lua/doom/core/init.lua
  6. 21
      lua/doom/modules/config/doom-whichkey.lua
  7. 33
      lua/doom/modules/init.lua

51
init.lua

@ -12,47 +12,48 @@ vim.g.start_time = vim.fn.reltime()
-- Disable these for very fast startup time -- Disable these for very fast startup time
vim.cmd([[ vim.cmd([[
syntax off syntax off
filetype off
filetype plugin indent off filetype plugin indent off
]]) ]])
-- Temporarily disable shada file to improve performance -- Temporarily disable shada file to improve performance
vim.opt.shadafile = 'NONE' vim.opt.shadafile = 'NONE'
-- Disable some unused built-in Neovim plugins -- Disable some unused built-in Neovim plugins
vim.g.loaded_man = false
vim.g.loaded_gzip = false vim.g.loaded_gzip = false
vim.g.loaded_zipPlugin = false
vim.g.loaded_tarPlugin = false
vim.g.loaded_netrwPlugin = false vim.g.loaded_netrwPlugin = false
vim.g.loaded_tarPlugin = false
vim.g.loaded_zipPlugin = false
vim.g.loaded_2html_plugin = false vim.g.loaded_2html_plugin = false
vim.g.loaded_remote_plugins = false
local async local async
async = vim.loop.new_async(vim.schedule_wrap(function() async = vim.loop.new_async(vim.schedule_wrap(function()
---- Doom Configurations ------------------------ ---- Doom Configurations ------------------------
------------------------------------------------- -------------------------------------------------
-- Load configurations and plugins
require('doom.core.config')
-- UI settings
require('doom.core.config.ui')
-- Doom keybindings
require('doom.core.keybindings')
-- Doom autocommands
require('doom.core.autocmds')
-- If the current buffer name is empty then trigger Dashboard
if vim.api.nvim_buf_get_name(0):len() == 0 then
vim.cmd('Dashboard')
end
vim.opt.shadafile = ''
vim.defer_fn(function() vim.defer_fn(function()
vim.cmd([[ -- Load Doom core
rshada! require('doom.core')
doautocmd BufRead
syntax on -- If the current buffer name is empty then trigger Dashboard
filetype plugin indent on if vim.api.nvim_buf_get_name(0):len() == 0 then
silent! bufdo e vim.cmd('Dashboard')
]]) end
end, 15)
vim.opt.shadafile = ''
vim.defer_fn(function()
vim.cmd([[
rshada!
doautocmd BufRead
syntax on
filetype on
filetype plugin indent on
PackerLoad nvim-treesitter
silent! bufdo e
]])
end, 15)
end, 0)
async:close() async:close()
end)) end))

15
lua/doom/core/autocmds/init.lua

@ -36,6 +36,7 @@ if Doom.relative_num then
'*', '*',
'if &nu | set rnu | endif', 'if &nu | set rnu | endif',
}) })
else
table.insert(autocmds['doom_core'], { table.insert(autocmds['doom_core'], {
'BufLeave,WinEnter', 'BufLeave,WinEnter',
'*', '*',
@ -61,13 +62,7 @@ end
-- Enable auto comment -- Enable auto comment
if not Doom.auto_comment then if not Doom.auto_comment then
table.insert(autocmds['doom_core'], { vim.opt.formatoptions:remove({ 'c', 'r', 'o' })
{
'BufEnter',
'*',
'setlocal formatoptions-=c formatoptions-=r formatoptions-=o',
},
})
end end
-- Enable highlight on yank -- Enable highlight on yank
@ -102,12 +97,6 @@ if Doom.preserve_edit_pos then
endif endif
]], ]],
}) })
vim.cmd([[
if line("'\"") > 1 && line("'\"") <= line("$") |
exe "normal! g'\"" |
endif
]])
end end
-- Create augroups -- Create augroups

16
lua/doom/core/config/init.lua

@ -34,22 +34,18 @@ end
----- Start Doom and run packer.nvim ----- Start Doom and run packer.nvim
-- Search for a configuration file (doomrc) -- Search for a configuration file (doomrc)
local doomrc_exists = rc.check_doomrc() if rc.check_doomrc() then
if doomrc_exists then rc.load_doomrc()
rc.load_doomrc()
end end
-- Set which separator should be used for paths, unused at the moment
-- Which_os()
-- Load the default Neovim settings, e.g. tabs width -- Load the default Neovim settings, e.g. tabs width
default.load_default_options() default.load_default_options()
-- Load packer.nvim and load plugins settings
require('doom.modules')
-- Load the user-defined settings (global variables, autocmds, mappings) -- Load the user-defined settings (global variables, autocmds, mappings)
default.custom_options() default.custom_options()
-- Load packer.nvim and load plugins settings
require('doom.modules')
-- Load UI settings
require('doom.core.config.ui')
if Doom.check_updates then if Doom.check_updates then
functions.check_updates() functions.check_updates()

6
lua/doom/core/default/init.lua

@ -30,8 +30,8 @@ M.load_default_options = function()
vim.opt.hlsearch = true vim.opt.hlsearch = true
vim.opt.laststatus = 2 vim.opt.laststatus = 2
vim.opt.backspace = { 'indent', 'eol', 'start' } vim.opt.backspace = { 'indent', 'eol', 'start' }
vim.opt.updatetime = 100 vim.opt.updatetime = 200
vim.opt.timeoutlen = 200 vim.opt.timeoutlen = 500
vim.opt.completeopt = { vim.opt.completeopt = {
'menu', 'menu',
'menuone', 'menuone',
@ -47,6 +47,8 @@ M.load_default_options = function()
-- Buffer options -- Buffer options
vim.opt.autoindent = true vim.opt.autoindent = true
vim.opt.smartindent = true vim.opt.smartindent = true
vim.opt.copyindent = true
vim.opt.preserveindent = true
-- set Gui Fonts -- set Gui Fonts
vim.opt.guifont = Doom.guifont .. ':h' .. Doom.guifont_size vim.opt.guifont = Doom.guifont .. ':h' .. Doom.guifont_size

8
lua/doom/core/init.lua

@ -0,0 +1,8 @@
--- Main Doom configuration file
--- also loads ui, doomrc modules
--- and the packer setup internally
require('doom.core.config')
-- Doom aeybindings
require('doom.core.keybindings')
-- Doom autocommands
require('doom.core.autocmds')

21
lua/doom/modules/config/doom-whichkey.lua

@ -1,6 +1,18 @@
return function() return function()
local wk = require('which-key')
local utils = require('doom.utils') local utils = require('doom.utils')
-- Load Doomrc if it is not loaded yet to avoid errors at startup
-- with lazy-loading.
--
-- TODO: change this behavior, we should ditch the doomrc to a fragmented
-- and better solution for putting user configurations.
if not Doom then
-- Do the same as `doom.core.config.doomrc` so we can use
-- all the debugging levels when sourcing that module
if vim.fn.filereadable(utils.doom_root .. '/doomrc') then
vim.cmd('silent! luafile ' .. utils.doom_root .. '/doomrc')
end
end
local wk = require('which-key')
----- WhichKey setup ------------------------ ----- WhichKey setup ------------------------
--------------------------------------------- ---------------------------------------------
@ -30,7 +42,7 @@ return function()
['zf'] = 'Create fold', ['zf'] = 'Create fold',
['!'] = 'Filter though external program', ['!'] = 'Filter though external program',
-- ['v'] = 'Visual Character Mode', -- ['v'] = 'Visual Character Mode',
gc = 'Comments', -- gc = 'Comments',
}, },
icons = { icons = {
breadcrumb = '»', -- symbol used in the command line area that shows your active key combo breadcrumb = '»', -- symbol used in the command line area that shows your active key combo
@ -43,10 +55,9 @@ return function()
layout = { layout = {
height = { min = 1, max = 10 }, -- min and max height of the columns height = { min = 1, max = 10 }, -- min and max height of the columns
}, },
hidden = { '<silent>', '^:', '^ ' }, -- hide mapping boilerplate hidden = { '<silent>', '<cmd>', '<Plug>', 'call', 'lua', '^:', '^ ' }, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible show_help = true, -- show help message on the command line when the popup is visible
triggers = { '<leader>' }, -- automatically setup triggers triggers = 'auto', -- automatically setup triggers
-- triggers = {"<leader>"} -- or specifiy a list manually
}) })
----- WhichKey binds ------------------------ ----- WhichKey binds ------------------------

33
lua/doom/modules/init.lua

@ -58,10 +58,10 @@ packer.startup(function(use)
) )
use({ use({
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
opt = true,
run = ':TSUpdate', run = ':TSUpdate',
config = require('doom.modules.config.doom-treesitter'), config = require('doom.modules.config.doom-treesitter'),
disable = (disabled_files and true or disabled_treesitter), disable = (disabled_files and true or disabled_treesitter),
event = 'BufEnter',
}) })
-- Sessions -- Sessions
@ -95,11 +95,17 @@ packer.startup(function(use)
event = 'TabNewEntered', event = 'TabNewEntered',
}) })
-- Development icons
use({
'kyazdani42/nvim-web-devicons',
module = 'nvim-web-devicons',
})
-- File tree -- File tree
local disabled_tree = utils.has_value(Doom.disabled_plugins, 'tree') local disabled_tree = utils.has_value(Doom.disabled_plugins, 'tree')
use({ use({
'kyazdani42/nvim-tree.lua', 'kyazdani42/nvim-tree.lua',
requires = { 'kyazdani42/nvim-web-devicons' }, requires = 'nvim-web-devicons',
config = require('doom.modules.config.doom-tree'), config = require('doom.modules.config.doom-tree'),
disable = disabled_tree, disable = disabled_tree,
cmd = { cmd = {
@ -199,7 +205,11 @@ packer.startup(function(use)
use({ use({
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
cmd = 'Telescope', cmd = 'Telescope',
requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } }, module = 'telescope',
requires = {
{ 'nvim-lua/popup.nvim' },
{ 'nvim-lua/plenary.nvim' },
},
config = require('doom.modules.config.doom-telescope'), config = require('doom.modules.config.doom-telescope'),
}) })
@ -213,7 +223,8 @@ packer.startup(function(use)
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
config = require('doom.modules.config.doom-gitsigns'), config = require('doom.modules.config.doom-gitsigns'),
disable = (disabled_git and true or disabled_gitsigns), disable = (disabled_git and true or disabled_gitsigns),
event = 'ColorScheme', requires = { 'nvim-lua/plenary.nvim' },
event = 'BufRead',
}) })
-- LazyGit integration -- LazyGit integration
@ -245,7 +256,6 @@ packer.startup(function(use)
'ray-x/lsp_signature.nvim', 'ray-x/lsp_signature.nvim',
config = require('doom.modules.config.doom-lsp-signature'), config = require('doom.modules.config.doom-lsp-signature'),
}, },
{ 'norcalli/snippets.nvim' },
}, },
config = require('doom.modules.config.doom-compe'), config = require('doom.modules.config.doom-compe'),
@ -254,6 +264,10 @@ packer.startup(function(use)
after = 'nvim-lspconfig', after = 'nvim-lspconfig',
}) })
-- Snippets
local disabled_snippets = utils.has_value(Doom.disabled_plugins, 'snippets')
use({ 'norcalli/snippets.nvim', after = 'nvim-compe' })
-- install lsp saga -- install lsp saga
local disabled_lspsaga = utils.has_value(Doom.disabled_plugins, 'lspsaga') local disabled_lspsaga = utils.has_value(Doom.disabled_plugins, 'lspsaga')
use({ use({
@ -297,7 +311,7 @@ packer.startup(function(use)
'lukas-reineke/format.nvim', 'lukas-reineke/format.nvim',
config = require('doom.modules.config.doom-format'), config = require('doom.modules.config.doom-format'),
disable = (disabled_files and true or disabled_formatter), disable = (disabled_files and true or disabled_formatter),
event = 'BufEnter', cmd = { 'Format', 'FormatWrite' },
}) })
-- Autopairs -- Autopairs
@ -371,9 +385,12 @@ packer.startup(function(use)
'restclient' 'restclient'
) )
use({ use({
'bayne/vim-dot-http', 'NTBBloodbath/rest.nvim',
config = function()
require('rest-nvim').setup()
end,
disable = (disabled_web and true or disabled_restclient), disable = (disabled_web and true or disabled_restclient),
cmd = 'DotHttp', event = 'BufEnter',
}) })
-- Emmet plugin -- Emmet plugin

Loading…
Cancel
Save