summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/autocmds.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-11-08 23:13:05 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-11-08 23:13:05 +0100
commitc9e2adbbc8fd7a5398c8c66d21f0e02dc7b60203 (patch)
tree274263ba15e0197180af8bb681e22c4780d5de05 /.config/nvim/lua/core/autocmds.lua
parente4ea22e223bbd6b4091610c6fa093862cbd32f75 (diff)
Add new lunarvin updates
Diffstat (limited to '.config/nvim/lua/core/autocmds.lua')
-rw-r--r--.config/nvim/lua/core/autocmds.lua154
1 files changed, 56 insertions, 98 deletions
diff --git a/.config/nvim/lua/core/autocmds.lua b/.config/nvim/lua/core/autocmds.lua
index 9ee9e90..1f50308 100644
--- a/.config/nvim/lua/core/autocmds.lua
+++ b/.config/nvim/lua/core/autocmds.lua
@@ -1,110 +1,68 @@
-local autocommands = {}
-local config = require "config"
+local M = {}
-options.autocommands = {
- _general_settings = {
- {
- "Filetype",
- "*",
- "lua require('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("config"):get_user_config_path())
+
+ return {
+ _general_settings = {
+ { "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('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", config.path, "lua require('utils').reload_config()" },
- {
- "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 +84,4 @@ function autocommands.define_augroups(definitions) -- {{{1
end
end
-return autocommands
+return M