Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] discovery = false not respected when non-fs buffer is added #446

Open
angles-n-daemons opened this issue Aug 20, 2024 · 0 comments
Open
Assignees

Comments

@angles-n-daemons
Copy link

angles-n-daemons commented Aug 20, 2024

NeoVim Version

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Describe the bug
I'm working on a large codebase so I have discovery = { enabled = false } setup. When using dap/dapui to debug a test, a buffer open triggers the autocmd here in the client. This buffer's file property is always set to "", and therefore the file_path variable is set to "/path/to/my/project" (a directory, and not a file specifically). Because of this, at the end of the nio.run call _update_positions is called with the root of my project, causing a full walk of the repository.

To Reproduce

local lazypath = '/tmp/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)

require('lazy').setup {
  {
    'nvim-neotest/neotest',
    dependencies = {
      'nvim-lua/plenary.nvim',
      'nvim-treesitter/nvim-treesitter',
      'fredrikaverpil/neotest-golang',
      {
        'mfussenegger/nvim-dap',
        dependencies = {
          'rcarriga/nvim-dap-ui',
          'nvim-neotest/nvim-nio',
          'williamboman/mason.nvim',
          'folke/neoconf.nvim',
          {
            'leoluz/nvim-dap-go',
            config = true,
          },
          {
            'williamboman/mason.nvim',
            cmd = 'Mason',
            build = ':MasonUpdate',
            config = function(_, opts)
              require('mason').setup(opts)
              local mr = require 'mason-registry'
              if not mr.get_package('delve'):is_installed() then
                mr.get_package('delve'):install()
              end
            end,
          },
        },
        keys = {
          -- requires neotest to be installed
          {
            '<leader>td',
            function()
              require('neotest').run.run { strategy = 'dap' }
            end,
            desc = 'Debug Nearest',
          },
        },
        config = function()
          local dap, dapui = require 'dap', require 'dapui'
          print 'setting up dap go'
          require('dap-go').setup {}
          dapui.setup()
          dap.listeners.after.event_initialized['dapui_config'] = dapui.open
          dap.listeners.before.event_terminated['dapui_config'] = dapui.close
          dap.listeners.before.event_exited['dapui_config'] = dapui.close
        end,
      },
    },
    config = function()
      -- Install any required parsers
      require('nvim-treesitter.configs').setup {
        ensure_installed = { 'go' },
      }

      require('neotest').setup {
        adapters = { require 'neotest-golang' {} },
        discovery = {
          enabled = false,
        },
      }
    end,
  },
}

This reproduction may be tricky, for some reason the above file worked eventually but was tricky to wrestle with.

Steps to reproduce the behavior:

  1. Clone the cockroach database repo.
  2. Run the build setup.
  3. Open an iterator test file: nvim pkg/ts/iterator_test.go.
  4. *Debug the tests in that file.

Expected behavior
When discovery is explicitly disabled, neotest should not recursively update positions of all files in the working path.

More concretely, BufAdd autocmd events with no file name should not trigger an _update_positions call which walks the codebase.

I feel like there are a couple approaches to addressing this:

  1. Ignoring buffer events without file names.
  2. Only continuing in BufAdd or BufWritePost if the file_path is a file and not a directory.
  3. Skipping update_positions directory branch if discovery is disabled.

Logs
Cannot retrieve logs as walking causes vim to freeze.

@angles-n-daemons angles-n-daemons changed the title [BUG] discovery = false escaped on non-fs buffers addition [BUG] discovery = false not respected when non-fs buffer is added Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants