From a3757e6210174b4ddf81eaf8e66fcab9d224aa73 Mon Sep 17 00:00:00 2001 From: Otto Modinos Date: Fri, 17 Feb 2023 14:25:50 +0200 Subject: [PATCH] feat(query_linter)!: remove use_virtual_text I believe `use_diagnostics` is superior in every way --- lua/nvim-treesitter-playground.lua | 1 - .../query_linter.lua | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/lua/nvim-treesitter-playground.lua b/lua/nvim-treesitter-playground.lua index 8b8b294..89eaaa0 100644 --- a/lua/nvim-treesitter-playground.lua +++ b/lua/nvim-treesitter-playground.lua @@ -23,7 +23,6 @@ function M.init() query_linter = { module_path = "nvim-treesitter-playground.query_linter", use_diagnostics = true, - use_virtual_text = false, lint_events = { "BufWrite", "CursorHold" }, is_supported = function(lang) return lang == "query" and parsers.has_parser "query" diff --git a/lua/nvim-treesitter-playground/query_linter.lua b/lua/nvim-treesitter-playground/query_linter.lua index 2600b14..2d78e6d 100644 --- a/lua/nvim-treesitter-playground/query_linter.lua +++ b/lua/nvim-treesitter-playground/query_linter.lua @@ -1,12 +1,10 @@ local api = vim.api local queries = require "nvim-treesitter.query" local parsers = require "nvim-treesitter.parsers" -local ts_utils = require "nvim-treesitter.ts_utils" local utils = require "nvim-treesitter.utils" local configs = require "nvim-treesitter.configs" local namespace = api.nvim_create_namespace "nvim-playground-lints" -local ERROR_HL = "TSQueryLinterError" local MAGIC_NODE_NAMES = { "_", "ERROR" } local playground_module = require "nvim-treesitter-playground.internal" @@ -14,7 +12,6 @@ local M = {} M.lints = {} M.use_diagnostics = true -M.use_virtual_text = false M.lint_events = { "BufWrite", "CursorHold" } local function show_lints(buf, lints) @@ -28,20 +25,6 @@ local function show_lints(buf, lints) } end, lints) vim.diagnostic.set(namespace, buf, diagnostics) - else - for _, lint in ipairs(lints) do - if lint.type ~= "Invalid Query" then - ts_utils.highlight_range(lint.range, buf, namespace, ERROR_HL) - end - - if M.use_virtual_text then - api.nvim_buf_set_extmark(buf, namespace, lint.range[1], lint.range[2], { - end_row = lint.range[3], - end_col = lint.range[4], - virt_text = { lint.message, ERROR_HL } - }) - end - end end end @@ -157,7 +140,6 @@ end function M.clear_virtual_text(buf) vim.diagnostic.reset(namespace, buf) - api.nvim_buf_clear_namespace(buf, namespace, 0, -1) end function M.attach(buf, _) @@ -165,7 +147,6 @@ function M.attach(buf, _) local config = configs.get_module "query_linter" M.use_diagnostics = config.use_diagnostics - M.use_virtual_text = config.use_virtual_text M.lint_events = config.lint_events vim.api.nvim_create_autocmd(M.lint_events, {