feat(commands): Cosmic reload now will properly update themes on the fly!!
This commit is contained in:
parent
bbdf42e745
commit
a14a4bb118
4 changed files with 33 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
command! CosmicUpdate lua require('cosmic.utils').update()
|
command! CosmicUpdate lua require('cosmic.utils').update()
|
||||||
command! CosmicReload lua require('cosmic.utils').reload_cosmic()
|
command! CosmicReload lua require('cosmic.utils').reload_user_config(true)
|
||||||
|
command! CosmicReloadSync lua require('cosmic.utils').reload_user_config_sync()
|
||||||
]])
|
]])
|
||||||
-- command! CosmicReloadSync lua require('cosmic.utils').reload_cosmic(true)
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ M.init = function()
|
||||||
map('n', '<leader>ggs', ':Telescope git_status<cr>')
|
map('n', '<leader>ggs', ':Telescope git_status<cr>')
|
||||||
|
|
||||||
-- quickfix navigation
|
-- quickfix navigation
|
||||||
map('n', '<leader>cp', ':cprev<cr>')
|
map('n', '<leader>cp', ':cprev<cr>zz')
|
||||||
map('n', '<leader>cn', ':cnext<cr>')
|
map('n', '<leader>cn', ':cnext<cr>zz')
|
||||||
|
|
||||||
-- buffer navigation
|
-- buffer navigation
|
||||||
map('n', '<leader>bp', ':bprev<cr>')
|
map('n', '<leader>bp', ':bprev<cr>')
|
||||||
|
|
|
@ -68,30 +68,39 @@ end
|
||||||
local function clear_cache()
|
local function clear_cache()
|
||||||
if 0 == vim.fn.delete(vim.fn.stdpath('config') .. '/lua/cosmic/compiled.lua') then
|
if 0 == vim.fn.delete(vim.fn.stdpath('config') .. '/lua/cosmic/compiled.lua') then
|
||||||
vim.cmd(':LuaCacheClear')
|
vim.cmd(':LuaCacheClear')
|
||||||
vim.notify('Cache cleared', vim.log.levels.INFO, {
|
vim.notify('Cache cleared!', vim.log.levels.INFO, {
|
||||||
title = 'CosmicNvim',
|
title = 'CosmicNvim',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.post_reload()
|
function M.post_reload(msg)
|
||||||
|
unload('cosmic.utils', true)
|
||||||
unload('cosmic.core.theme.colors', true)
|
unload('cosmic.core.theme.colors', true)
|
||||||
unload('cosmic.core.theme.highlights', true)
|
unload('cosmic.core.theme.highlights', true)
|
||||||
unload('cosmic.core.statusline', true)
|
unload('cosmic.core.statusline', true)
|
||||||
vim.notify('CosmicNvim reloaded!', vim.log.levels.INFO, {
|
msg = msg or 'User config reloaded!'
|
||||||
|
vim.notify(msg, vim.log.levels.INFO, {
|
||||||
title = 'CosmicNvim',
|
title = 'CosmicNvim',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.reload_cosmic(sync)
|
function M.reload_user_config_sync()
|
||||||
vim.cmd([[autocmd User PackerCompileDone ++once lua require('cosmic.utils').post_reload()]])
|
M.reload_user_config()
|
||||||
clear_cache()
|
clear_cache()
|
||||||
unload('cosmic.pluginsInit', true)
|
|
||||||
unload('cosmic.config', true)
|
unload('cosmic.config', true)
|
||||||
if sync then
|
unload('cosmic.pluginsInit', true)
|
||||||
|
vim.cmd(
|
||||||
|
[[autocmd User PackerCompileDone ++once lua require('cosmic.utils').post_reload('User config reloaded! \nPlease restart CosmicNvim!')]]
|
||||||
|
)
|
||||||
vim.cmd(':PackerSync')
|
vim.cmd(':PackerSync')
|
||||||
else
|
end
|
||||||
vim.cmd(':PackerCompile')
|
|
||||||
|
function M.reload_user_config(notify)
|
||||||
|
notify = notify or false
|
||||||
|
unload('cosmic.config', true)
|
||||||
|
if notify then
|
||||||
|
M.post_reload()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
10
readme.md
10
readme.md
|
@ -102,12 +102,22 @@ CosmicNvim comes with first-class support for the following themes:
|
||||||
|
|
||||||
By default, this will assume the Cosmic git directory is placed at `vim.fn.stdpath('config')`, i.e. `~/.config/nvim`. Otherwise, you may define the shell environment variable `COSMICNVIM_INSTALL_DIR`.
|
By default, this will assume the Cosmic git directory is placed at `vim.fn.stdpath('config')`, i.e. `~/.config/nvim`. Otherwise, you may define the shell environment variable `COSMICNVIM_INSTALL_DIR`.
|
||||||
|
|
||||||
|
#### Clear cache and sync plugins
|
||||||
|
|
||||||
|
```
|
||||||
|
:CosmicReloadSync
|
||||||
|
```
|
||||||
|
|
||||||
|
Useful for changing themes or updating plugins on the fly!
|
||||||
|
|
||||||
#### Reload user config
|
#### Reload user config
|
||||||
|
|
||||||
```
|
```
|
||||||
:CosmicReload
|
:CosmicReload
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Useful for non-plugin related changes such as editor settings or mappings.
|
||||||
|
|
||||||
## Treesitter Support
|
## Treesitter Support
|
||||||
|
|
||||||
Enter `:TSInstall` followed by <TAB> to see your options for additional language support.
|
Enter `:TSInstall` followed by <TAB> to see your options for additional language support.
|
||||||
|
|
Loading…
Add table
Reference in a new issue