utils.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. local function define_augroups(definitions) -- {{{1
  2. -- Create autocommand groups based on the passed definitions
  3. --
  4. -- The key will be the name of the group, and each definition
  5. -- within the group should have:
  6. -- 1. Trigger
  7. -- 2. Pattern
  8. -- 3. Text
  9. -- just like how they would normally be defined from Vim itself
  10. for group_name, definition in pairs(definitions) do
  11. vim.cmd('augroup ' .. group_name)
  12. vim.cmd('autocmd!')
  13. for _, def in pairs(definition) do
  14. local command = table.concat(vim.tbl_flatten {'autocmd', def}, ' ')
  15. vim.cmd(command)
  16. end
  17. vim.cmd('augroup END')
  18. end
  19. end
  20. define_augroups(
  21. {_general_settings = {
  22. {'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'IncSearch\', timeout = 200})'},
  23. {'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  24. {'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  25. {'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
  26. {'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'},
  27. },
  28. }
  29. )
  30. -- Add this to lightbulb, java makes this annoying tho
  31. -- autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()