aboutsummaryrefslogtreecommitdiff
path: root/runtime/ftplugin/query.lua
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2023-04-29 18:22:26 +0200
committerGitHub <noreply@github.com>2023-04-29 18:22:26 +0200
commitc194acbfc479d8e5839fa629363f93f6550d035c (patch)
tree134a12e3a5b6ee970081bcfc83c3494201dfa00f /runtime/ftplugin/query.lua
parent933fdff4660a17b1df7809105c57825e0ece1fc6 (diff)
downloadrneovim-c194acbfc479d8e5839fa629363f93f6550d035c.tar.gz
rneovim-c194acbfc479d8e5839fa629363f93f6550d035c.tar.bz2
rneovim-c194acbfc479d8e5839fa629363f93f6550d035c.zip
feat(treesitter): add query_linter from nvim-treesitter/playground (#22784)
Co-authored-by: clason <clason@users.noreply.github.com> Co-authored-by: lewis6991 <lewis6991@users.noreply.github.com>
Diffstat (limited to 'runtime/ftplugin/query.lua')
-rw-r--r--runtime/ftplugin/query.lua26
1 files changed, 25 insertions, 1 deletions
diff --git a/runtime/ftplugin/query.lua b/runtime/ftplugin/query.lua
index 3b99d67247..842d338fd9 100644
--- a/runtime/ftplugin/query.lua
+++ b/runtime/ftplugin/query.lua
@@ -1,6 +1,30 @@
-- Neovim filetype plugin file
-- Language: Tree-sitter query
--- Last Change: 2022 Mar 29
+-- Last Change: 2022 Apr 25
+
+if vim.b.did_ftplugin == 1 then
+ return
+end
+
+-- Do not set vim.b.did_ftplugin = 1 to allow loading of ftplugin/lisp.vim
+
+-- use treesitter over syntax
+vim.treesitter.start()
+
+-- query linter
+local buf = vim.api.nvim_get_current_buf()
+local query_lint_on = vim.g.query_lint_on or { 'BufEnter', 'BufWrite' }
+
+if not vim.b.disable_query_linter and #query_lint_on > 0 then
+ vim.api.nvim_create_autocmd(query_lint_on, {
+ group = vim.api.nvim_create_augroup('querylint', { clear = false }),
+ buffer = buf,
+ callback = function()
+ vim.treesitter.query.lint(buf)
+ end,
+ desc = 'Query linter',
+ })
+end
-- it's a lisp!
vim.cmd([[ runtime! ftplugin/lisp.vim ]])