init.lua 4.1 KB

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