fix(core): fix occasional treesitter issues
* fix(commands): better reloading
This commit is contained in:
parent
d8c561dbc1
commit
34da8714db
3 changed files with 19 additions and 9 deletions
|
@ -5,7 +5,7 @@ local present, packer = pcall(require, 'packer')
|
|||
local first_install = false
|
||||
|
||||
if not present then
|
||||
local packer_path = vim.fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
|
||||
local packer_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
|
||||
print('Cloning packer..')
|
||||
-- remove the dir before cloning
|
||||
|
|
|
@ -234,7 +234,7 @@ return packer.startup(function()
|
|||
'nvim-treesitter/nvim-treesitter-refactor',
|
||||
},
|
||||
run = ':TSUpdate',
|
||||
event = 'BufEnter',
|
||||
-- event = 'BufEnter',
|
||||
config = function()
|
||||
require('cosmic.core.treesitter')
|
||||
end,
|
||||
|
|
|
@ -65,23 +65,33 @@ local function unload(module_pattern, reload)
|
|||
end
|
||||
end
|
||||
|
||||
local function clear_cache()
|
||||
if 0 == vim.fn.delete(vim.fn.stdpath('config') .. '/lua/cosmic/compiled.lua') then
|
||||
vim.cmd(':LuaCacheClear')
|
||||
vim.notify('Cache cleared', vim.log.levels.INFO, {
|
||||
title = 'CosmicNvim',
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function M.post_reload()
|
||||
unload('cosmic')
|
||||
require('cosmic')
|
||||
vim.cmd(':silent e')
|
||||
unload('cosmic.core.theme.colors', true)
|
||||
unload('cosmic.core.theme.highlights', true)
|
||||
unload('cosmic.core.statusline', true)
|
||||
vim.notify('CosmicNvim reloaded!', vim.log.levels.INFO, {
|
||||
title = 'CosmicNvim',
|
||||
})
|
||||
end
|
||||
|
||||
function M.reload_cosmic(sync)
|
||||
unload('cosmic.config')
|
||||
require('cosmic.config')
|
||||
vim.cmd([[autocmd User PackerCompileDone ++once lua require('cosmic.utils').post_reload()]])
|
||||
clear_cache()
|
||||
unload('cosmic.pluginsInit', true)
|
||||
unload('cosmic.config', true)
|
||||
if sync then
|
||||
require('cosmic.packer').packer.sync()
|
||||
vim.cmd(':PackerSync')
|
||||
else
|
||||
require('cosmic.packer').packer.compile()
|
||||
vim.cmd(':PackerCompile')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue