query.lua 1013 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- Neovim filetype plugin file
  2. -- Language: Treesitter query
  3. if vim.b.did_ftplugin == 1 then
  4. return
  5. end
  6. -- Do not set vim.b.did_ftplugin = 1 to allow loading of ftplugin/lisp.vim
  7. -- use treesitter over syntax
  8. vim.treesitter.start()
  9. -- set omnifunc
  10. vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'
  11. vim.opt_local.iskeyword:append('.')
  12. -- query linter
  13. local buf = vim.api.nvim_get_current_buf()
  14. local query_lint_on = vim.g.query_lint_on or { 'BufEnter', 'BufWrite' }
  15. if not vim.b.disable_query_linter and #query_lint_on > 0 then
  16. vim.api.nvim_create_autocmd(query_lint_on, {
  17. group = vim.api.nvim_create_augroup('querylint', { clear = false }),
  18. buffer = buf,
  19. callback = function()
  20. vim.treesitter.query.lint(buf)
  21. end,
  22. desc = 'Query linter',
  23. })
  24. end
  25. -- it's a lisp!
  26. vim.cmd([[runtime! ftplugin/lisp.vim]])
  27. vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl omnifunc< iskeyword<'
  28. vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'