port autocommands to lua

pull/197/head
REmerald 2 years ago committed by GitHub
parent 9a928f56a1
commit c3d653c2c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,37 +1,65 @@
vim.cmd [[ -- Autocommand that sources autocommands.lua whenever you save it
augroup _general_settings local au_src = vim.api.nvim_create_augroup("autocommands_source", {clear = true})
autocmd! vim.api.nvim_create_autocmd(
autocmd FileType qf,help,man,lspinfo nnoremap <silent> <buffer> q :close<CR> "BufWritePost",
autocmd TextYankPost * silent!lua require('vim.highlight').on_yank({higroup = 'Visual', timeout = 200}) {group = au_src, pattern = "autocommands.lua", command = "luafile <afile>"}
autocmd BufWinEnter * :set formatoptions-=cro )
autocmd FileType qf set nobuflisted
augroup end
augroup _git
autocmd!
autocmd FileType gitcommit setlocal wrap
autocmd FileType gitcommit setlocal spell
augroup end
augroup _markdown local gen_opts = vim.api.nvim_create_augroup("_general_settings", {clear = true})
autocmd! vim.api.nvim_create_autocmd(
autocmd FileType markdown setlocal wrap "FileType", {group = gen_opts,
autocmd FileType markdown setlocal spell pattern = {"qf","help","man","lspinfo"},
augroup end command = "nnoremap <silent> <buffer> q <Cmd>close<CR>"}
)
vim.api.nvim_create_autocmd(
"TextYankPost", {group = gen_opts,
command = "silent!lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})"}
)
vim.api.nvim_create_autocmd(
"FileType", {group = gen_opts,
pattern = "qf",
command = "set nobuflisted"}
)
augroup _auto_resize local au_git = vim.api.nvim_create_augroup("_git", {clear = true})
autocmd! vim.api.nvim_create_autocmd(
autocmd VimResized * tabdo wincmd = "FileType", {group = au_git,
augroup end pattern = "gitcommit",
command = "setlocal wrap spell"}
)
augroup _alpha local au_mark = vim.api.nvim_create_augroup("_markdown", {clear = true})
autocmd! vim.api.nvim_create_autocmd(
autocmd User AlphaReady set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2 "FileType", {group = au_mark,
augroup end pattern = "markdown",
]] command = "setlocal wrap spell"}
)
local au_res = vim.api.nvim_create_augroup("_auto_resize", {clear = true})
vim.api.nvim_create_autocmd(
"VimResized", {group = au_res, command = "tabdo wincmd ="}
)
-- Autoformat -- Autoformat
-- augroup _lsp -- local au_lsp = vim.api.nvim_create_augroup("_lsp", {clear = true})
-- autocmd! -- vim.api.nvim_create_autocmd(
-- autocmd BufWritePre * lua vim.lsp.buf.formatting() -- "BufWritePre", {group = au_lsp, command = "lua vim.lsp.buf.formatting()"}
-- augroup end -- )
-- Using <Bar> instead of | caused my neovim to either error out or remove tabline completely
-- Which is really weird and must be a bug
-- If it still happens to you anyways, use vim.cmd as a fallback
local aulpha = vim.api.nvim_create_augroup("_alpha", {clear = true})
vim.api.nvim_create_autocmd(
"User", {group = aulpha, pattern = "AlphaReady",
command = "set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2"
}
)
-- autocmd! remove all autocommands, if entered under a group it will clear that group
-- vim.cmd [[
-- augroup _alpha
-- autocmd!
-- autocmd User AlphaReady set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2
-- augroup end
-- ]]

Loading…
Cancel
Save