Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Reporting an error I receive anytime I try to open the query viewer. #3

Open
MostHated opened this issue Apr 2, 2023 · 6 comments
Open

Comments

@MostHated
Copy link

Hey there, I installed this and went to give it a try (just opened it on the setup method of this plugin first) but I end up getting the error below whenever I try to open the query popup.

Error detected while processing CursorHold Autocommands for "<buffer=36>":
Error executing lua callback: vim/shared.lua:0: s: expected string, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'gsplit'
        vim/shared.lua: in function 'split'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/parsers.lua:1628: in function 'guess_query_lang'
        ...ayground/lua/nvim-treesitter-playground/query_linter.lua:77: in function 'lint'
        ...ayground/lua/nvim-treesitter-playground/query_linter.lua:158: in function <...ayground/lua/nvim-treesitter-playground/query_linter.lua:157>
Press ENTER or type command to continue

Just for reference, this is where my cursor was when I gave it a go.

@ziontee113
Copy link
Owner

Hi @MostHated, I can't seem to reproduce the issue. Also your screenshot / stack trace doesn't have any direct connection to query-secretary itself.
I haven't updated my plugins for a while but your stack trace indicate something to do with nvim-treesitter-playground. Sorry but I can't really don't know how to help you atm.

@MostHated
Copy link
Author

Oh, interesting. I even read that and didn't think much of it. I didn't have TSPG opened or anything. I will try and play around with some settings and see if I can narrow something down.

@MostHated
Copy link
Author

MostHated commented Apr 5, 2023

So, it looks like, in the tree-sitter settings, if I turn off the setting

require'nvim-treesitter.configs'.setup {
    ...
    query_linter = { enable = false, }
    ...
}

Doing this, the error goes away, though, it is not really practical, to try and go in and swap out settings and what not each time I want to use it (which is quite frequently, at the moment).
Is there any sort of event exposed that I could tie into upon opening the window, then upon closing it? I am wondering if perhaps I can simply set that setting to false before it opens up, the re-enable it after it closes, if that might be enough.

If it were just one message upon opening it, that would not be a huge issue, but unfortunately, the error pops up for ever single cursor move you try to do while the query-secretary window is opened as seen below:

Once I turn it off, everything works as expected. It seems like whatever changes that are happening are making the CursorHold of the tree-sitters linter bug out.

If you have any recommendations, I would greatly appreciate it.

issue

@ziontee113
Copy link
Owner

ziontee113 commented Apr 5, 2023

The query_linter option is quite foreign to me. This is my entire nvim-treesitter config. I don't know if it's gonna help.

return {
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        dependencies = {
            "nvim-treesitter/playground",
            "windwp/nvim-ts-autotag",
            "p00f/nvim-ts-rainbow",
            "nvim-treesitter/nvim-treesitter-textobjects",
        },
        event = "BufReadPost",
        -- event = { "VeryLazy" },
        config = function()
            require("nvim-treesitter.configs").setup({
                ensure_installed = "all",
                sync_install = false,
                auto_install = true,

                highlight = {
                    enable = true,
                    additional_vim_regex_highlighting = false,
                },

                rainbow = {
                    enable = true,
                    extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
                    max_file_lines = nil, -- Do not enable for files with more than n lines, int
                },

                autotag = {
                    enable = true,
                },

                textobjects = {
                    select = {
                        enable = true,
                        keymaps = {
                            ["af"] = "@function.outer",
                            ["if"] = "@function.inner",
                            ["am"] = "@call.outer",
                            ["im"] = "@call.inner",
                            ["ab"] = "@block.outer",
                            ["ib"] = "@block.inner",
                            ["aa"] = "@parameter.outer",
                            ["ia"] = "@parameter.inner",
                            ["as"] = "@statement.outer",
                        },
                    },
                },

                playground = {
                    enable = true,
                    disable = {},
                    updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
                    persist_queries = true, -- Whether the query persists across vim sessions
                    keybindings = {
                        toggle_query_editor = "o",
                        toggle_hl_groups = "i",
                        toggle_injected_languages = "t",
                        toggle_anonymous_nodes = "a",
                        toggle_language_display = "I",
                        focus_language = "f",
                        unfocus_language = "F",
                        update = "R",
                        goto_node = "<cr>",
                        show_help = "?",
                    },
                },
            })
        end,
    },
}

@MostHated
Copy link
Author

MostHated commented Apr 5, 2023

I understand. It looks like info on the query linter is on the actual playground page, not the tree-sitter page: https://github.com/nvim-treesitter/playground#query-linter

I have the actual tree-sitter 'query language' language installed, as I am writing a tree-sitter grammar and parser for a language. My setup is probably a bit less common than other folks because of this, so not a lot of people may run into this issue. So not sure if it is worth your time to look into, which I can understand. I can just deal with the issue, and enable/disable the linter as needed.

@ziontee113
Copy link
Owner

Since I don't have adequate knowledge to diagnose and resolve the issue, I'll keep it open for now. Thank you for understanding.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants