feat: Update more autocmd calls to new api
This commit is contained in:
parent
5a8378a606
commit
a32b2d492e
4 changed files with 43 additions and 9 deletions
|
@ -5,9 +5,15 @@ local indent = 2
|
||||||
|
|
||||||
cmd([[
|
cmd([[
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
autocmd BufWritePre * :%s/\s\+$//e
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
local augroup_name = 'CosmicNvimEditor'
|
||||||
|
local group = vim.api.nvim_create_augroup(augroup_name, { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
command = [[%s/\s\+$//e]],
|
||||||
|
group = group,
|
||||||
|
})
|
||||||
|
|
||||||
g.mapleader = ' '
|
g.mapleader = ' '
|
||||||
|
|
||||||
-- misc
|
-- misc
|
||||||
|
|
|
@ -30,7 +30,9 @@ if not present then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- @TODO: check if snapshot exists, if not create it
|
||||||
packer.init({
|
packer.init({
|
||||||
|
-- snapshot = 'Cosmic',
|
||||||
display = {
|
display = {
|
||||||
open_fn = function()
|
open_fn = function()
|
||||||
return require('packer.util').float({ border = 'rounded' })
|
return require('packer.util').float({ border = 'rounded' })
|
||||||
|
|
|
@ -85,13 +85,16 @@ local default_cmp_opts = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.cmd([[
|
local augroup_name = 'CosmicNvimAutocomplete'
|
||||||
autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
|
local group = vim.api.nvim_create_augroup(augroup_name, { clear = true })
|
||||||
]])
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
callback = function()
|
||||||
|
require('cmp').setup.buffer({ enabled = false })
|
||||||
|
end,
|
||||||
|
group = group,
|
||||||
|
})
|
||||||
|
|
||||||
local opts = u.merge(default_cmp_opts, user_config.nvim_cmp or {})
|
cmp.setup(u.merge(default_cmp_opts, user_config.nvim_cmp or {}))
|
||||||
|
|
||||||
cmp.setup(opts)
|
|
||||||
|
|
||||||
cmp.setup.cmdline('/', {
|
cmp.setup.cmdline('/', {
|
||||||
sources = {
|
sources = {
|
||||||
|
@ -99,6 +102,15 @@ cmp.setup.cmdline('/', {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Set configuration for specific filetype.
|
||||||
|
cmp.setup.filetype('gitcommit', {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
-- cmp.setup.cmdline(':', {
|
-- cmp.setup.cmdline(':', {
|
||||||
-- sources = cmp.config.sources({
|
-- sources = cmp.config.sources({
|
||||||
-- { name = 'path' },
|
-- { name = 'path' },
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
local augroup_name = 'CosmicNvimUtils'
|
||||||
|
local group = vim.api.nvim_create_augroup(augroup_name, { clear = true })
|
||||||
|
|
||||||
function M.map(mode, lhs, rhs, opts)
|
function M.map(mode, lhs, rhs, opts)
|
||||||
local options = { noremap = true, silent = true }
|
local options = { noremap = true, silent = true }
|
||||||
|
@ -86,7 +88,13 @@ function M.reload_user_config_sync()
|
||||||
clear_cache()
|
clear_cache()
|
||||||
unload('cosmic.core.user', true)
|
unload('cosmic.core.user', true)
|
||||||
unload('cosmic.core.pluginsInit', true)
|
unload('cosmic.core.pluginsInit', true)
|
||||||
vim.cmd([[autocmd User PackerCompileDone ++once lua require('cosmic.utils').post_reload()]])
|
vim.api.nvim_create_autocmd('User PackerCompileDone', {
|
||||||
|
callback = function()
|
||||||
|
M.post_reload()
|
||||||
|
end,
|
||||||
|
group = group,
|
||||||
|
once = true,
|
||||||
|
})
|
||||||
vim.cmd(':PackerSync')
|
vim.cmd(':PackerSync')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,7 +102,13 @@ function M.reload_user_config(compile)
|
||||||
compile = compile or false
|
compile = compile or false
|
||||||
unload('cosmic.core.user', true)
|
unload('cosmic.core.user', true)
|
||||||
if compile then
|
if compile then
|
||||||
vim.cmd([[autocmd User PackerCompileDone ++once lua require('cosmic.utils').post_reload()]])
|
vim.api.nvim_create_autocmd('User PackerCompileDone', {
|
||||||
|
callback = function()
|
||||||
|
M.post_reload()
|
||||||
|
end,
|
||||||
|
group = group,
|
||||||
|
once = true,
|
||||||
|
})
|
||||||
vim.cmd(':PackerCompile')
|
vim.cmd(':PackerCompile')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue