nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.41k stars 287 forks source link

Keymaps for command `Lspsage finder` not work when cross file #1379

Closed 0x00-ketsu closed 7 months ago

0x00-ketsu commented 7 months ago

Describe the bug

Declared a function in file utils.lua then reference it in file index.lua (only one buffer is file index.lua), press command Lspsage finder, references is rendered in finer window, but when press command s (vsplit) is not work.

If open file utils.lua add it to buffer list, then press command Lspsage finder, keymap s can work.

screen

Steps to reproduce

min.lua

local api = vim.api

api.nvim_command('set nu')
api.nvim_command('set relativenumber')

-- Plugins
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)

-- Example using a list of specs with the default options
vim.g.mapleader = ',' -- Make sure to set `mapleader` before lazy so your mappings are correct

require('lazy').setup({
  {
    'neovim/nvim-lspconfig',
    config = function()
      require('lspconfig').lua_ls.setup({})
      require('lspconfig').gopls.setup({})
      require('lspconfig').pyright.setup({})
    end,
  },
  {
    'williamboman/mason.nvim',
    config = function()
      require('mason').setup({})
    end,
  },
  { 'williamboman/mason-lspconfig.nvim' },
  {
    'glepnir/lspsaga.nvim',
    event = 'BufRead',
    config = function()
      require('lspsaga').setup({
        implement = { enable = true },
      })
    end,
    dependencies = { { 'nvim-tree/nvim-web-devicons' }, { 'nvim-treesitter/nvim-treesitter' } },
  },
})

exp/utils.lua

local M = {}

M.foo = function()
  print('foo')
end

return M

exp/index.lua

local utils = require('exp.utils')
utils.foo()

Press command Lspsaga finder at exp/index.lua foo()

Expected behavior

Keymaps in finder window works normal.

Neovim version (nvim -v)

v0.9.5

lspsaga commit

3112b7a

Terminal name/version

alacritty 0.14.0-dev (1b9131c7)

0x00-ketsu commented 7 months ago

Sorry, It's my mistake, close.