LunarVim/lua/lv-autocommands/init.lua

81 lines
4.1 KiB
Lua
Raw Normal View History

2021-04-15 06:17:48 +02:00
local utils = require('lv-utils')
2021-03-28 09:52:09 +02:00
local auto_formatters = { }
local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
2021-06-28 06:36:29 +02:00
if O.lang.python.autoformat then table.insert(auto_formatters, python_autoformat) end
2021-03-28 09:52:09 +02:00
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)'}
local typescript_autoformat = {'BufWritePre', '*.ts', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
local typescriptreact_autoformat = {'BufWritePre', '*.tsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
2021-06-28 06:36:29 +02:00
if O.lang.tsserver.autoformat then
2021-03-28 09:52:09 +02:00
table.insert(auto_formatters, javascript_autoformat)
table.insert(auto_formatters, javascriptreact_autoformat)
table.insert(auto_formatters, typescript_autoformat)
table.insert(auto_formatters, typescriptreact_autoformat)
2021-03-28 09:52:09 +02:00
end
local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
2021-06-28 06:36:29 +02:00
if O.lang.lua.autoformat then table.insert(auto_formatters, lua_format) end
2021-03-28 09:52:09 +02:00
local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
2021-06-28 06:36:29 +02:00
if O.lang.json.autoformat then table.insert(auto_formatters, json_format) end
2021-03-28 09:52:09 +02:00
2021-04-27 06:59:23 +02:00
local ruby_format = {'BufWritePre', '*.rb', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
2021-06-28 06:36:29 +02:00
if O.lang.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
2021-04-27 06:59:23 +02:00
2021-05-25 00:01:24 +02:00
local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
2021-06-28 06:36:29 +02:00
if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end
2021-05-25 00:01:24 +02:00
2021-03-28 09:52:09 +02:00
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'},
2021-04-13 01:50:04 +02:00
{'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
{'VimLeavePre', '*', 'set title set titleold='},
{'FileType', 'qf', 'set nobuflisted'},
2021-06-28 07:46:25 +02:00
{'BufWinEnter', 'lv-config.lua', 'PackerCompile'},
{'BufWinLeave', 'lv-config.lua', 'PackerCompile'},
{'BufWritePost', 'lv-config.lua', 'PackerCompile'}
2021-03-28 09:52:09 +02:00
-- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
-- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
},
_java = {
-- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
2021-03-28 09:52:09 +02:00
{'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'}
},
2021-06-28 07:46:25 +02:00
2021-05-25 00:01:24 +02:00
_go = {
-- Go generally requires Tabs instead of spaces.
{'FileType', 'go', 'setlocal tabstop=4'},
{'FileType', 'go', 'setlocal shiftwidth=4'},
{'FileType', 'go', 'setlocal softtabstop=4'},
{'FileType', 'go', 'setlocal noexpandtab'},
},
2021-03-28 09:52:09 +02:00
_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'}
2021-03-28 09:52:09 +02:00
},
_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'}
},
2021-04-08 17:55:44 +02:00
_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>'},
2021-04-07 06:29:10 +02:00
{'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'},
},
2021-03-28 09:52:09 +02:00
_auto_formatters = auto_formatters
})