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
|
local first_install = false
|
||||||
|
|
||||||
if not present then
|
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..')
|
print('Cloning packer..')
|
||||||
-- remove the dir before cloning
|
-- remove the dir before cloning
|
||||||
|
|
|
@ -234,7 +234,7 @@ return packer.startup(function()
|
||||||
'nvim-treesitter/nvim-treesitter-refactor',
|
'nvim-treesitter/nvim-treesitter-refactor',
|
||||||
},
|
},
|
||||||
run = ':TSUpdate',
|
run = ':TSUpdate',
|
||||||
event = 'BufEnter',
|
-- event = 'BufEnter',
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.core.treesitter')
|
require('cosmic.core.treesitter')
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -65,23 +65,33 @@ local function unload(module_pattern, reload)
|
||||||
end
|
end
|
||||||
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()
|
function M.post_reload()
|
||||||
unload('cosmic')
|
unload('cosmic.core.theme.colors', true)
|
||||||
require('cosmic')
|
unload('cosmic.core.theme.highlights', true)
|
||||||
vim.cmd(':silent e')
|
unload('cosmic.core.statusline', true)
|
||||||
vim.notify('CosmicNvim reloaded!', vim.log.levels.INFO, {
|
vim.notify('CosmicNvim reloaded!', vim.log.levels.INFO, {
|
||||||
title = 'CosmicNvim',
|
title = 'CosmicNvim',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.reload_cosmic(sync)
|
function M.reload_cosmic(sync)
|
||||||
unload('cosmic.config')
|
|
||||||
require('cosmic.config')
|
|
||||||
vim.cmd([[autocmd User PackerCompileDone ++once lua require('cosmic.utils').post_reload()]])
|
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
|
if sync then
|
||||||
require('cosmic.packer').packer.sync()
|
vim.cmd(':PackerSync')
|
||||||
else
|
else
|
||||||
require('cosmic.packer').packer.compile()
|
vim.cmd(':PackerCompile')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue