init.lua 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.lang.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.lang.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.lang.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.lang.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.lang.ruby.autoformat then table.insert(auto_formatters, ruby_format) end
  21. local go_format = {'BufWritePre', '*.go', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
  22. if O.lang.go.autoformat then table.insert(auto_formatters, go_format) end
  23. local rust_format = {'BufWritePre', '*.rs', 'lua vim.lsp.buf.formatting_sync(nil,1000)'}
  24. if O.lang.rust.autoformat then table.insert(auto_formatters, rust_format) end
  25. utils.define_augroups({
  26. _general_settings = {
  27. {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
  28. {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  29. {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  30. {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  31. {'VimLeavePre', '*', 'set title set titleold='},
  32. {'FileType', 'qf', 'set nobuflisted'},
  33. {'BufWinEnter', 'lv-config.lua', 'PackerCompile'},
  34. {'BufWinLeave', 'lv-config.lua', 'PackerCompile'},
  35. {'BufWritePost', 'lv-config.lua', 'PackerCompile'}
  36. -- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
  37. -- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
  38. },
  39. _java = {
  40. -- {'FileType', 'java', 'luafile '..CONFIG_PATH..'/lua/lsp/java-ls.lua'},
  41. {'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'}
  42. },
  43. _go = {
  44. -- Go generally requires Tabs instead of spaces.
  45. {'FileType', 'go', 'setlocal tabstop=4'},
  46. {'FileType', 'go', 'setlocal shiftwidth=4'},
  47. {'FileType', 'go', 'setlocal softtabstop=4'},
  48. {'FileType', 'go', 'setlocal noexpandtab'},
  49. },
  50. _dashboard = {
  51. -- seems to be nobuflisted that makes my stuff disapear will do more testing
  52. {
  53. 'FileType', 'dashboard',
  54. 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '
  55. }, {'FileType', 'dashboard', 'set showtabline=0 | autocmd BufLeave <buffer> set showtabline=2'}
  56. },
  57. _markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}},
  58. -- _solidity = {
  59. -- {'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'},
  60. -- {'BufNewFile', '*.sol', 'setlocal filetype=solidity'}
  61. -- },
  62. -- _gemini = {
  63. -- {'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'},
  64. -- {'BufNewFile', '*.gmi', 'setlocal filetype=markdown'}
  65. -- },
  66. _buffer_bindings = {
  67. {'FileType', 'dashboard', 'nnoremap <silent> <buffer> q :q<CR>'},
  68. {'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'},
  69. {'FileType', 'floaterm', 'nnoremap <silent> <buffer> q :q<CR>'},
  70. },
  71. _auto_formatters = auto_formatters
  72. })