stevearc / aerial.nvim

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

bug: golang missing variables, constants, fields if functions or structs are enabled #345

Open 0xmycf opened 4 months ago

0xmycf commented 4 months ago

Neovim version (nvim -v)

NVIM v0.9.1 Build type: Release LuaJIT 2.1.0-beta3

Operating system/version

MacOS 12.1

Output of :AerialInfo

Aerial Info


Filetype: go
Configured backends:
treesitter (supported)
lsp (supported)
markdown (not supported) [Filetype is not markdown]
man (not supported) [Filetype is not man]
Show symbols: Function, Method, Struct, Field, Variable, Constant

Describe the bug

This bug is related to this setting in the config:

  filter_kind = {
    "Function",
    "Method",
    "Struct",
    "Field",
    "Variable",
    "Constant",
  },

It displays this for those settings: screenshot

And if I disable method, function and struct: screenshot

I used this file to test it: https://gist.github.com/0xmycf/aa44b2f94db1bcf90d630666dea816ad

I would expect that it shows the fields, variables and constants also when method function and struct is enabled. I have no tested this for Enum or other kinds. This also happens for filter_kind = false

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. Get a go file like the one I used
  2. install and load aerial, configure it with
    filter_kind = {
    "Field",
    "Variable",
    "Constant",
    "Function",
    "Method",
    "Struct",
    },
  3. Open the go file and toggle aerial, see what things are listed
  4. Comment out Function, Method and Struct (or any combination)
  5. reload the vim config / exit re-enter vim with the go file
  6. Toggle aerial and see what things are listed

Expected Behavior

There is no difference between

 filter_kind = {
    "Field",
    "Variable",
    "Constant",
    "Function",
    "Method",
    "Struct",
  },

and

 filter_kind = {
    "Field",
    "Variable",
    "Constant",
  },

besides more or less fields.

Minimal example file

-- Call the setup function to change the default behavior
require("aerial").setup {
  backends = { "treesitter", "lsp", "markdown", "man" },
  layout = {
    max_width = { 120, 0.6 },
    default_direction = "prefer_right",
    placement = "edge",
  },
  filter_kind = {
    "Field",
    "Variable",
    "Constant",
    "Function",
    "Method",
    "Struct",
  },
}

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

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/aerial.nvim",
    config = function()
      require("aerial").setup({
        -- add your aerial config here
      })
    end,
  },
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require("nvim-treesitter.configs").setup({
        ensure_installed = { "c", "lua" },
        auto_install = true,
        highlight = { enable = true },
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

Edit: also type newtype strc is not recognized as a struct.