summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/_autocommands/init.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/_autocommands/init.lua')
-rw-r--r--.config/nvim/lua/_autocommands/init.lua54
1 files changed, 54 insertions, 0 deletions
diff --git a/.config/nvim/lua/_autocommands/init.lua b/.config/nvim/lua/_autocommands/init.lua
new file mode 100644
index 0000000..a94cb0f
--- /dev/null
+++ b/.config/nvim/lua/_autocommands/init.lua
@@ -0,0 +1,54 @@
+local utils = require('_utils')
+
+local auto_formatters = { }
+
+local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
+if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end
+
+local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
+local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
+if O.tsserver.autoformat then
+ table.insert(auto_formatters, javascript_autoformat)
+ table.insert(auto_formatters, javascriptreact_autoformat)
+end
+
+local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
+if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
+
+local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
+if O.json.autoformat then table.insert(auto_formatters, json_format) end
+
+utils.define_augroups({
+ _general_settings = {
+ {'TextYankPost','*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
+ {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
+ {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
+ {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
+ {'VimLeavePre', '*', 'set title set titleold='}
+
+ -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
+ -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
+ },
+ _dashboard = {
+ -- seems to be nobuflisted that makes my stuff disapear will do more testing
+ {
+ 'FileType', 'dashboard',
+ 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '
+ }, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2'}
+ },
+ _markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}},
+ _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'}
+ },
+ _buffer_bindings = {
+ {'FileType', 'dashboard', 'nnoremap <silent> <buffer> q :q<CR>'},
+ {'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'},
+ {'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'},
+ },
+ _auto_formatters = auto_formatters
+})