feat(autocmds): Split config for autocmds

This commit is contained in:
Xavier Logerais 2023-11-02 18:29:29 +01:00
parent 0bde02eab6
commit 095d08c050
4 changed files with 47 additions and 7 deletions

View File

@ -0,0 +1,28 @@
vim.api.nvim_create_autocmd(
"FileType", {
desc = "Customizations for groovy files",
-- group = vim.api.nvim_create_augroup("groovy", { clear = true }),
pattern = { "groovy", "Jenkinsfile" },
callback = function()
local Terminal = require('toggleterm.terminal').Terminal
local groovysh = Terminal:new({
name = "groovysh",
cmd = "groovysh",
hidden = true,
close_on_exit = true,
})
function _groovysh_toggle()
groovysh:toggle()
end
vim.api.nvim_set_keymap("n", "<F5>", "<cmd>lua _groovysh_toggle()<CR>", { noremap = true, silent = true })
vim.api.nvim_set_keymap("i", "<F5>", "<cmd>lua _groovysh_toggle()<CR>", { noremap = true, silent = true })
-- vim.api.nvim_set_keymap('n', '<F5>', ':terminal groovysh<CR>', { noremap = true, silent = true })
-- vim.opt_local.wrap = true
-- vim.opt_local.spell = true
end,
-- command = "setlocal wrap spell",
}
)

View File

@ -0,0 +1,6 @@
vim.api.nvim_create_autocmd("TermOpen", {
desc = "Auto switch to insert mode for terminal",
group = vim.api.nvim_create_augroup("term_auto_insert", { clear = true }),
pattern = "term://*",
command = "startinsert",
})

View File

@ -0,0 +1,9 @@
vim.api.nvim_create_autocmd("FileType", {
desc = "Enable wrap and spell for text like documents",
group = vim.api.nvim_create_augroup("auto_spell", { clear = true }),
pattern = { "gitcommit", "markdown", "text", "plaintex" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})

View File

@ -14,13 +14,10 @@ return {
-- })
-- Set up custom autocmds
vim.api.nvim_create_augroup("myterm", { clear = true })
vim.api.nvim_create_autocmd("TermOpen", {
desc = "Auto switch to insert mode for terminal",
group = "myterm",
pattern = "term://*",
command = "startinsert",
})
require "user.autocmds.text"
require "user.autocmds.terminal"
require "user.autocmds.groovy"
-- Set up custom filetypes
-- vim.filetype.add {
-- extension = {