init.lua 3.4 KB

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