init.lua 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. local utils = require('lv-utils')
  2. local auto_formatters = { }
  3. local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
  4. if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end
  5. local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
  6. local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
  7. if O.tsserver.autoformat then
  8. table.insert(auto_formatters, javascript_autoformat)
  9. table.insert(auto_formatters, javascriptreact_autoformat)
  10. end
  11. local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
  12. if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
  13. local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
  14. if O.json.autoformat then table.insert(auto_formatters, json_format) end
  15. utils.define_augroups({
  16. _general_settings = {
  17. {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
  18. {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  19. {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  20. {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  21. {'VimLeavePre', '*', 'set title set titleold='}
  22. -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
  23. -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
  24. },
  25. _java = {
  26. {'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'},
  27. {'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'}
  28. },
  29. _dashboard = {
  30. -- seems to be nobuflisted that makes my stuff disapear will do more testing
  31. {
  32. 'FileType', 'dashboard',
  33. 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '
  34. }, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2'}
  35. },
  36. _markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}},
  37. _solidity = {
  38. {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'},
  39. {'BufNewFile', '*.sol', 'setlocal filetype=solidity'}
  40. },
  41. _gemini = {
  42. {'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'},
  43. {'BufNewFile', '*.gmi', 'setlocal filetype=markdown'}
  44. },
  45. _buffer_bindings = {
  46. {'FileType', 'dashboard', 'nnoremap <silent> <buffer> q :q<CR>'},
  47. {'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'},
  48. {'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'},
  49. },
  50. _auto_formatters = auto_formatters
  51. })