stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.55k stars 76 forks source link

bug: Missing symbols when using treesitter as backend #337

Closed PedroG14 closed 6 months ago

PedroG14 commented 6 months ago

Neovim version (nvim -v)

NVIM v0.10.0-dev-1873+g8f08b1efb

Operating system/version

Arch Linux

Output of :AerialInfo

Aerial Info


Filetype: lua
Configured backends:
treesitter (supported) (attached)
lsp (not supported) [No LSP client found that supports symbols]
markdown (not supported) [Filetype is not markdown]
man (not supported) [Filetype is not man]
Show symbols: all symbols

Describe the bug

Every time i try to use aerial with treesitter as main backend it generally doesn't show any symbols, and when it shows it's only the functions present in the file, even if i set filter_kind to false.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. Execute nvim -u repro.lua
  2. Open any file which filetype is supported by treesitter (i suggest to test with the minimal config file used)
  3. Execute AerialToggle

Expected Behavior

In this scenario would be expected for aerial to show me all symbols existent in my file, not only the functions.

Minimal example file

The minimal config file below can be used to reproduce the issue.

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

local plugins = {
    {
        "nvim-treesitter/nvim-treesitter",
        build = ":TSUpdate",
        opts = {
            ensure_installed = { "c", "lua", "vim", "vimdoc", "query" },
            sync_install = false,
            auto_install = true,
            highlight = { enable = true },
            indent = { enable = true }
        },
        config = function(_, opts)
            require("nvim-treesitter.configs").setup(opts)
        end
    },
    {
        "stevearc/aerial.nvim",
        dependencies = {
            "nvim-treesitter/nvim-treesitter",
            "nvim-tree/nvim-web-devicons"
        },
        opts = {
            filter_kind = false
        }
    }
}

require("lazy").setup(plugins, {
    root = root .. "/plugins"
})

vim.cmd.colorscheme("retrobox")

Additional context

No response

stevearc commented 6 months ago

This is expected. The treesitter backend doesn't support as many symbols as LSP because for each one I have to write a query and a test. Multiply that across all the supported languages and it's just far too much work for me to do. So I added the most important symbols for all the languages and have been relying on PRs to add anything that's missing.

By all means, use the LSP backend if you like seeing more symbols. There's absolutely nothing wrong with it (it's just a bit slower and requires the LSP to be installed). If you have an interest, I'd also love to review PRs that add treesitter support for more symbols of any language.