diff --git a/init.lua b/init.lua index ee565a2..afd698b 100644 --- a/init.lua +++ b/init.lua @@ -12,47 +12,48 @@ vim.g.start_time = vim.fn.reltime() -- Disable these for very fast startup time vim.cmd([[ syntax off + filetype off filetype plugin indent off ]]) -- Temporarily disable shada file to improve performance vim.opt.shadafile = 'NONE' -- Disable some unused built-in Neovim plugins +vim.g.loaded_man = false vim.g.loaded_gzip = false -vim.g.loaded_zipPlugin = false -vim.g.loaded_tarPlugin = 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_remote_plugins = false local async async = vim.loop.new_async(vim.schedule_wrap(function() ---- 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.cmd([[ - rshada! - doautocmd BufRead - syntax on - filetype plugin indent on - silent! bufdo e - ]]) - end, 15) + -- Load Doom core + require('doom.core') + + -- 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.cmd([[ + rshada! + doautocmd BufRead + syntax on + filetype on + filetype plugin indent on + PackerLoad nvim-treesitter + silent! bufdo e + ]]) + end, 15) + end, 0) async:close() end)) diff --git a/lua/doom/core/autocmds/init.lua b/lua/doom/core/autocmds/init.lua index 619591d..19e7fba 100644 --- a/lua/doom/core/autocmds/init.lua +++ b/lua/doom/core/autocmds/init.lua @@ -36,6 +36,7 @@ if Doom.relative_num then '*', 'if &nu | set rnu | endif', }) +else table.insert(autocmds['doom_core'], { 'BufLeave,WinEnter', '*', @@ -61,13 +62,7 @@ end -- Enable auto comment if not Doom.auto_comment then - table.insert(autocmds['doom_core'], { - { - 'BufEnter', - '*', - 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o', - }, - }) + vim.opt.formatoptions:remove({ 'c', 'r', 'o' }) end -- Enable highlight on yank @@ -102,12 +97,6 @@ if Doom.preserve_edit_pos then endif ]], }) - - vim.cmd([[ - if line("'\"") > 1 && line("'\"") <= line("$") | - exe "normal! g'\"" | - endif - ]]) end -- Create augroups diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index ab8f19e..763ca1e 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -34,22 +34,18 @@ end ----- Start Doom and run packer.nvim -- Search for a configuration file (doomrc) -local doomrc_exists = rc.check_doomrc() -if doomrc_exists then - rc.load_doomrc() +if rc.check_doomrc() then + rc.load_doomrc() end --- Set which separator should be used for paths, unused at the moment --- Which_os() - -- Load the default Neovim settings, e.g. tabs width default.load_default_options() - --- Load packer.nvim and load plugins settings -require('doom.modules') - -- Load the user-defined settings (global variables, autocmds, mappings) 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 functions.check_updates() diff --git a/lua/doom/core/default/init.lua b/lua/doom/core/default/init.lua index 1ebfdfe..7e5e178 100644 --- a/lua/doom/core/default/init.lua +++ b/lua/doom/core/default/init.lua @@ -30,8 +30,8 @@ M.load_default_options = function() vim.opt.hlsearch = true vim.opt.laststatus = 2 vim.opt.backspace = { 'indent', 'eol', 'start' } - vim.opt.updatetime = 100 - vim.opt.timeoutlen = 200 + vim.opt.updatetime = 200 + vim.opt.timeoutlen = 500 vim.opt.completeopt = { 'menu', 'menuone', @@ -47,6 +47,8 @@ M.load_default_options = function() -- Buffer options vim.opt.autoindent = true vim.opt.smartindent = true + vim.opt.copyindent = true + vim.opt.preserveindent = true -- set Gui Fonts vim.opt.guifont = Doom.guifont .. ':h' .. Doom.guifont_size diff --git a/lua/doom/core/init.lua b/lua/doom/core/init.lua new file mode 100644 index 0000000..b587fab --- /dev/null +++ b/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') diff --git a/lua/doom/modules/config/doom-whichkey.lua b/lua/doom/modules/config/doom-whichkey.lua index 3d3165b..6b79641 100644 --- a/lua/doom/modules/config/doom-whichkey.lua +++ b/lua/doom/modules/config/doom-whichkey.lua @@ -1,6 +1,18 @@ return function() - local wk = require('which-key') 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 ------------------------ --------------------------------------------- @@ -30,7 +42,7 @@ return function() ['zf'] = 'Create fold', ['!'] = 'Filter though external program', -- ['v'] = 'Visual Character Mode', - gc = 'Comments', + -- gc = 'Comments', }, icons = { breadcrumb = 'ยป', -- symbol used in the command line area that shows your active key combo @@ -43,10 +55,9 @@ return function() layout = { height = { min = 1, max = 10 }, -- min and max height of the columns }, - hidden = { '', '^:', '^ ' }, -- hide mapping boilerplate + hidden = { '', '', '', 'call', 'lua', '^:', '^ ' }, -- hide mapping boilerplate show_help = true, -- show help message on the command line when the popup is visible - triggers = { '' }, -- automatically setup triggers - -- triggers = {""} -- or specifiy a list manually + triggers = 'auto', -- automatically setup triggers }) ----- WhichKey binds ------------------------ diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index ef34402..fb6086c 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -58,10 +58,10 @@ packer.startup(function(use) ) use({ 'nvim-treesitter/nvim-treesitter', + opt = true, run = ':TSUpdate', config = require('doom.modules.config.doom-treesitter'), disable = (disabled_files and true or disabled_treesitter), - event = 'BufEnter', }) -- Sessions @@ -95,11 +95,17 @@ packer.startup(function(use) event = 'TabNewEntered', }) + -- Development icons + use({ + 'kyazdani42/nvim-web-devicons', + module = 'nvim-web-devicons', + }) + -- File tree local disabled_tree = utils.has_value(Doom.disabled_plugins, 'tree') use({ 'kyazdani42/nvim-tree.lua', - requires = { 'kyazdani42/nvim-web-devicons' }, + requires = 'nvim-web-devicons', config = require('doom.modules.config.doom-tree'), disable = disabled_tree, cmd = { @@ -199,7 +205,11 @@ packer.startup(function(use) use({ 'nvim-telescope/telescope.nvim', 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'), }) @@ -213,7 +223,8 @@ packer.startup(function(use) 'lewis6991/gitsigns.nvim', config = require('doom.modules.config.doom-gitsigns'), disable = (disabled_git and true or disabled_gitsigns), - event = 'ColorScheme', + requires = { 'nvim-lua/plenary.nvim' }, + event = 'BufRead', }) -- LazyGit integration @@ -245,7 +256,6 @@ packer.startup(function(use) 'ray-x/lsp_signature.nvim', config = require('doom.modules.config.doom-lsp-signature'), }, - { 'norcalli/snippets.nvim' }, }, config = require('doom.modules.config.doom-compe'), @@ -254,6 +264,10 @@ packer.startup(function(use) after = 'nvim-lspconfig', }) + -- Snippets + local disabled_snippets = utils.has_value(Doom.disabled_plugins, 'snippets') + use({ 'norcalli/snippets.nvim', after = 'nvim-compe' }) + -- install lsp saga local disabled_lspsaga = utils.has_value(Doom.disabled_plugins, 'lspsaga') use({ @@ -297,7 +311,7 @@ packer.startup(function(use) 'lukas-reineke/format.nvim', config = require('doom.modules.config.doom-format'), disable = (disabled_files and true or disabled_formatter), - event = 'BufEnter', + cmd = { 'Format', 'FormatWrite' }, }) -- Autopairs @@ -371,9 +385,12 @@ packer.startup(function(use) 'restclient' ) use({ - 'bayne/vim-dot-http', + 'NTBBloodbath/rest.nvim', + config = function() + require('rest-nvim').setup() + end, disable = (disabled_web and true or disabled_restclient), - cmd = 'DotHttp', + event = 'BufEnter', }) -- Emmet plugin