From c9e2adbbc8fd7a5398c8c66d21f0e02dc7b60203 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 8 Nov 2021 23:13:05 +0100 Subject: Add new lunarvin updates --- .config/nvim/lua/core/autocmds.lua | 154 ++++++++++++++----------------------- 1 file changed, 56 insertions(+), 98 deletions(-) (limited to '.config/nvim/lua/core/autocmds.lua') 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(\"\"))", - }, - { - "FileType", - "qf", - "nnoremap q :q", +--- 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 q :close" }, + { + "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 q :q", + _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 q :q" }, }, - { - "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 q :close", + }, }, - -- { "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 q :q" }, - }, - _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 q :q" }, - }, - - -- _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 -- cgit v1.2.3-70-g09d2