summaryrefslogtreecommitdiff
path: root/lua/lvim/core/autocmds.lua
diff options
context:
space:
mode:
authorSubho Banerjee <[email protected]>2021-10-16 05:03:17 -0500
committerGitHub <[email protected]>2021-10-16 12:03:17 +0200
commit281c54ba55651af0b33dadeb3419e19b10fbed45 (patch)
tree91ac4dc26af395ed40fd64c181b97f06394d9848 /lua/lvim/core/autocmds.lua
parentef41a3d24e753b7e82fe31ebe9e74048881c13e8 (diff)
[Bugfix]: Allow user autocmds (#1776)
Co-authored-by: kylo252 <[email protected]>
Diffstat (limited to 'lua/lvim/core/autocmds.lua')
-rw-r--r--lua/lvim/core/autocmds.lua155
1 files changed, 57 insertions, 98 deletions
diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua
index 4f29f0e1..5d1d365e 100644
--- a/lua/lvim/core/autocmds.lua
+++ b/lua/lvim/core/autocmds.lua
@@ -1,110 +1,69 @@
-local autocommands = {}
-local user_config_file = require("lvim.config"):get_user_config_path()
+local M = {}
-lvim.autocommands = {
- _general_settings = {
- {
- "Filetype",
- "*",
- "lua require('lvim.utils.ft').do_filetype(vim.fn.expand(\"<amatch>\"))",
- },
- {
- "FileType",
- "qf",
- "nnoremap <silent> <buffer> q :q<CR>",
+--- Load the default set of autogroups and autocommands.
+function M.load_augroups()
+ local user_config_file = vim.fn.resolve(require("lvim.config"):get_user_config_path())
+
+ return {
+ _general_settings = {
+ {
+ "Filetype",
+ "*",
+ "lua require('lvim.utils.ft').do_filetype(vim.fn.expand(\"<amatch>\"))",
+ },
+ { "FileType", "qf,help,man", "nnoremap <silent> <buffer> q :close<CR>" },
+ {
+ "TextYankPost",
+ "*",
+ "lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})",
+ },
+ {
+ "BufWinEnter",
+ "dashboard",
+ "setlocal cursorline signcolumn=yes cursorcolumn number",
+ },
+ { "BufWritePost", user_config_file, "lua require('lvim.config'):reload()" },
+ { "FileType", "qf", "set nobuflisted" },
+ -- { "VimLeavePre", "*", "set title set titleold=" },
},
- {
- "FileType",
- "lsp-installer",
- "nnoremap <silent> <buffer> q :q<CR>",
+ _formatoptions = {
+ {
+ "BufWinEnter,BufRead,BufNewFile",
+ "*",
+ "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
+ },
},
- {
- "TextYankPost",
- "*",
- "lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})",
+ _filetypechanges = {
+ { "BufWinEnter", ".tf", "setlocal filetype=terraform" },
+ { "BufRead", "*.tf", "setlocal filetype=terraform" },
+ { "BufNewFile", "*.tf", "setlocal filetype=terraform" },
+ { "BufWinEnter", ".zsh", "setlocal filetype=sh" },
+ { "BufRead", "*.zsh", "setlocal filetype=sh" },
+ { "BufNewFile", "*.zsh", "setlocal filetype=sh" },
},
- {
- "BufWinEnter",
- "*",
- "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
+ _git = {
+ { "FileType", "gitcommit", "setlocal wrap" },
+ { "FileType", "gitcommit", "setlocal spell" },
},
- {
- "BufWinEnter",
- "dashboard",
- "setlocal cursorline signcolumn=yes cursorcolumn number",
+ _markdown = {
+ { "FileType", "markdown", "setlocal wrap" },
+ { "FileType", "markdown", "setlocal spell" },
},
- {
- "BufRead",
- "*",
- "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
+ _buffer_bindings = {
+ { "FileType", "floaterm", "nnoremap <silent> <buffer> q :q<CR>" },
},
- {
- "BufNewFile",
- "*",
- "setlocal formatoptions-=c formatoptions-=r formatoptions-=o",
+ _auto_resize = {
+ -- will cause split windows to be resized evenly if main window is resized
+ { "VimResized", "*", "tabdo wincmd =" },
},
- { "BufWritePost", user_config_file, "lua require('lvim.config'):reload()" },
- {
- "FileType",
- "qf",
- "set nobuflisted",
+ _general_lsp = {
+ { "FileType", "lspinfo,lsp-installer,null-ls-info", "nnoremap <silent> <buffer> q :close<CR>" },
},
- -- { "VimLeavePre", "*", "set title set titleold=" },
- },
- _filetypechanges = {
- { "BufWinEnter", ".tf", "setlocal filetype=terraform" },
- { "BufRead", "*.tf", "setlocal filetype=terraform" },
- { "BufNewFile", "*.tf", "setlocal filetype=terraform" },
- { "BufWinEnter", ".zsh", "setlocal filetype=sh" },
- { "BufRead", "*.zsh", "setlocal filetype=sh" },
- { "BufNewFile", "*.zsh", "setlocal filetype=sh" },
- },
- -- _solidity = {
- -- {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'},
- -- {'BufNewFile', '*.sol', 'setlocal filetype=solidity'}
- -- },
- -- _gemini = {
- -- {'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'},
- -- {'BufNewFile', '*.gmi', 'setlocal filetype=markdown'}
- -- },
- _git = {
- { "FileType", "gitcommit", "setlocal wrap" },
- { "FileType", "gitcommit", "setlocal spell" },
- },
- _markdown = {
- { "FileType", "markdown", "setlocal wrap" },
- { "FileType", "markdown", "setlocal spell" },
- },
- _buffer_bindings = {
- { "FileType", "floaterm", "nnoremap <silent> <buffer> q :q<CR>" },
- },
- _auto_resize = {
- -- will cause split windows to be resized evenly if main window is resized
- { "VimResized", "*", "wincmd =" },
- },
- _packer_compile = {
- -- will run PackerCompile after writing plugins.lua
- { "BufWritePost", "plugins.lua", "PackerCompile" },
- },
- _general_lsp = {
- { "FileType", "lspinfo", "nnoremap <silent> <buffer> q :q<CR>" },
- },
-
- -- _fterm_lazygit = {
- -- -- will cause esc key to exit lazy git
- -- {"TermEnter", "*", "call LazyGitNativation()"}
- -- },
- -- _mode_switching = {
- -- -- will switch between absolute and relative line numbers depending on mode
- -- {'InsertEnter', '*', 'if &relativenumber | let g:ms_relativenumberoff = 1 | setlocal number norelativenumber | endif'},
- -- {'InsertLeave', '*', 'if exists("g:ms_relativenumberoff") | setlocal relativenumber | endif'},
- -- {'InsertEnter', '*', 'if &cursorline | let g:ms_cursorlineoff = 1 | setlocal nocursorline | endif'},
- -- {'InsertLeave', '*', 'if exists("g:ms_cursorlineoff") | setlocal cursorline | endif'},
- -- },
- custom_groups = {},
-}
+ custom_groups = {},
+ }
+end
-function autocommands.define_augroups(definitions) -- {{{1
+function M.define_augroups(definitions) -- {{{1
-- Create autocommand groups based on the passed definitions
--
-- The key will be the name of the group, and each definition
@@ -126,4 +85,4 @@ function autocommands.define_augroups(definitions) -- {{{1
end
end
-return autocommands
+return M