[3/4] Refactor: init: Use async | Move theme stuff to theme.lua
third commit of refactor perf improvements due to async run packer sync if base16 not found this is not perfect error handling for initial run, but something handle require errors
This commit is contained in:
parent
3e83ec5314
commit
643d1bd7d8
4 changed files with 57 additions and 24 deletions
36
init.lua
36
init.lua
|
@ -1,14 +1,28 @@
|
||||||
-- load all plugins
|
-- load all options
|
||||||
require "pluginList"
|
|
||||||
require "options"
|
require "options"
|
||||||
|
|
||||||
-- colorscheme related stuff
|
-- only try to load stuff if atleast base16 is initialized
|
||||||
vim.g.nvchad_theme = "onedark"
|
-- TODO: Find a better way to trigger PackerSync
|
||||||
local base16 = require "base16"
|
if require "theme" then
|
||||||
base16(base16.themes["onedark"], true)
|
local async
|
||||||
|
async =
|
||||||
|
vim.loop.new_async(
|
||||||
|
vim.schedule_wrap(
|
||||||
|
function()
|
||||||
|
require "pluginList"
|
||||||
|
require "plugins.bufferline"
|
||||||
|
require "highlights"
|
||||||
|
require "mappings"
|
||||||
|
require("utils").hideStuff()
|
||||||
|
|
||||||
require "highlights"
|
async:close()
|
||||||
require "mappings"
|
end
|
||||||
require "plugins.bufferline"
|
)
|
||||||
|
)
|
||||||
require("utils").hideStuff()
|
async:send()
|
||||||
|
else
|
||||||
|
-- otherwise run packer sync
|
||||||
|
require "pluginList"
|
||||||
|
print("Now PackerSync will be executed, after completion, restart neovim.\n")
|
||||||
|
vim.cmd("PackerSync")
|
||||||
|
end
|
||||||
|
|
|
@ -76,7 +76,17 @@ _G.s_tab_complete = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _G.completions()
|
function _G.completions()
|
||||||
local npairs = require("nvim-autopairs")
|
local npairs
|
||||||
|
if
|
||||||
|
not pcall(
|
||||||
|
function()
|
||||||
|
npairs = require "nvim-autopairs"
|
||||||
|
end
|
||||||
|
)
|
||||||
|
then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if vim.fn.pumvisible() == 1 then
|
if vim.fn.pumvisible() == 1 then
|
||||||
if vim.fn.complete_info()["selected"] ~= -1 then
|
if vim.fn.complete_info()["selected"] ~= -1 then
|
||||||
return vim.fn["compe#confirm"]("<CR>")
|
return vim.fn["compe#confirm"]("<CR>")
|
||||||
|
|
21
lua/theme.lua
Normal file
21
lua/theme.lua
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
-- colorscheme related stuff
|
||||||
|
vim.g.nvchad_theme = "onedark"
|
||||||
|
|
||||||
|
local base16
|
||||||
|
if
|
||||||
|
not pcall(
|
||||||
|
function()
|
||||||
|
base16 = require "base16"
|
||||||
|
end
|
||||||
|
)
|
||||||
|
then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
base16(base16.themes["onedark"], true)
|
||||||
|
local cmd = vim.cmd
|
||||||
|
|
||||||
|
-- load bg color before async for smooth transition
|
||||||
|
local background = require("themes/" .. vim.g.nvchad_theme).black
|
||||||
|
vim.cmd("hi Normal guibg=" .. background)
|
||||||
|
return true
|
||||||
|
end
|
|
@ -1,17 +1,5 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- blankline config
|
|
||||||
M.blankline = function()
|
|
||||||
vim.g.indentLine_enabled = 1
|
|
||||||
vim.g.indent_blankline_char = "▏"
|
|
||||||
|
|
||||||
vim.g.indent_blankline_filetype_exclude = {"help", "terminal", "dashboard"}
|
|
||||||
vim.g.indent_blankline_buftype_exclude = {"terminal"}
|
|
||||||
|
|
||||||
vim.g.indent_blankline_show_trailing_blankline_indent = false
|
|
||||||
vim.g.indent_blankline_show_first_indent_level = false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- hide line numbers , statusline in specific buffers!
|
-- hide line numbers , statusline in specific buffers!
|
||||||
M.hideStuff = function()
|
M.hideStuff = function()
|
||||||
vim.api.nvim_exec(
|
vim.api.nvim_exec(
|
||||||
|
|
Loading…
Reference in a new issue