nerdtree icon indicating copy to clipboard operation
nerdtree copied to clipboard

Error while using nvim's vim.lsp.buf.references()

Open mrded opened this issue 2 years ago • 0 comments

Environment

  • Operating System: macOS 12.1 (21C52)
  • Vim/Neovim version :version: nvim v0.6.0
  • NERDTree version, found on first line of quickhelp ?: 6.10.16
  • Are you using any of these NERDTree-dependent plugins?: None
  • Provide a minimal .vimrc file that will reproduce the issue.
Plug 'scrooloose/nerdtree', { 'tag': '6.10.16' }
Plug 'neovim/nvim-lspconfig', { 'tag': 'v0.1.1'}

nnoremap <C-m> :NERDTreeFind<CR>

lua << EOF
local nvim_lsp = require('lspconfig')

local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  local opts = { noremap=true, silent=true }

  buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
end

local servers = { 'tsserver', 'gopls' }
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    flags = {
      debounce_text_changes = 150,
      }
    }
end
EOF

Steps to Reproduce the Issue

  1. Install scrooloose/nerdtree and neovim/nvim-lspconfig
  2. Select a function which is used elsewhere
  3. Call <cmd>lua vim.lsp.buf.references()<CR> (based on my setup, press gr) more info
  4. Select a references

Current Behavior (Include screenshots where appropriate.)

The error is shown:

NERDTree: no file for the current buffer

image

Expected Result

Open up the reference in the current buffer. (and it does open, if I remove nerdtree)

Notes:

I found that nnoremap <C-m> :NERDTreeFind<CR> is breaking it. If I remove that - everything works just fine.

mrded avatar Jan 17 '22 16:01 mrded