Skip to content

Bug: lsp commands doesn't work on source generated files with Roslyn LSP #2218

@molostovvs

Description

@molostovvs

RTFM Checklist

  • I have searched exisiting issues / discussions
  • I have read the Wiki including the Advanced section
  • I have read man fzf / I am well versed in shell fzf

Operating system

Linux

Shell

fish, version 4.0.2

Neovim version (nvim --version)

NVIM v0.12.0-dev-916+g68eece8b84

Fzf version (fzf --version)

0.65.0 (04c4269d)

Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))

nil

Is the problem reproducible with mini.sh?

  • My issue is reproducible with mini.sh
  • My issue IS NOT reproducible with mini.sh
  • I have not tested with mini.sh (not relevant, requires LSP, Windows, etc)

Fzf-lua configuration

opts = {
      winopts = {
        width = 0.98,
        height = 0.98,
        backdrop = 85,
        preview = {
          layout = 'vertical',
          vertical = 'down:60%',
          delay = 30,
        },
      },
      files = {
        path_shorten = 10,
        git_icons = true,
      },
      previewers = {
        builtin = {
          title_fnamemodify = function(s)
            return s
          end,
        },
      },
    },
    config = function(_, opts)
      require('fzf-lua').setup(opts)
      require('fzf-lua').register_ui_select()
    end

Describe the bug / steps to reproduce

Hi!
Thanks for your awesome plugin! I use it daily and really enjoy it.

I'm encountering a bug when using :FzfLua lsp_definitions on a method whose body is source-generated with C# source generators. The call results in the following error:

Lua :command callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1024: Cursor position outside buffer
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1024: in function 'jump_to_location'
        .../fzf-lua/lua/fzf-lua/actions.lua:251: in function <.../fzf-lua/lua/fzf-lua/actions.lua:149>
        .../fzf-lua/lua/fzf-lua/actions.lua:268: in function 'vimcmd_entry'
        .../fzf-lua/lua/fzf-lua/actions.lua:275: in function 'jump_to_location'
        .../fzf-lua/lua/fzf-lua/providers/lsp.lua:433: in function 'fn_contents'
        .../fzf-lua/lua/fzf-lua/providers/lsp.lua:611: in function <.../fzf-lua/lua/fzf-lua/providers/lsp.lua:606>
        .../fzf-lua/lua/fzf-lua/cmd.lua:35: in function 'run_command'
        .../fzf-lua/plugin/fzf-lua.lua:10: in function <.../fzf-lua/plugin/fzf-lua.lua:9>

The buffer that gets opened has a path like this (notice the tilde prefix):

~/source/work/demo/Sourcegen/roslyn-source-generated://8050b016-c2f9-41b3-a089-5c75e8000202/Example.HelloWorld.g.cs?documentId=c08647b7-f2a8-79d3-3de3-f3ae9d6a489d&hintName=Example.HelloWorld.g.cs&assemblyName=Generators&assemblyVersion=1.0.0.0&typeName=Generators.HelloWorldGenerator&assemblyPath=/home/mvs/source/work/demo/Sourcegen/src/Generators/bin/Debug/netstandard2.0/Generators.dll

But the correct buffer path should be:

roslyn-source-generated://8050b016-c2f9-41b3-a089-5c75e8000202/Example.HelloWorld.g.cs?documentId=c08647b7-f2a8-79d3-3de3-f3ae9d6a489d&hintName=Example.HelloWorld.g.cs&assemblyName=Generators&assemblyVersion=1.0.0.0&typeName=Generators.HelloWorldGenerator&assemblyPath=%2Fhome%2Fmvs%2Fsource%2Fwork%2Fdemo%2FSourcegen%2Fsrc%2FGenerators%2Fbin%2FDebug%2Fnetstandard2.0%2FGenerators.dll

Interestingly, using :lua vim.lsp.buf.definition() or :lua vim.lsp.buf.references() works as expected and opens the buffer correctly.

You can reproduce the issue using this minimal repo

To reproduce:

  1. Run dotnet build (requires .NET 10 Preview).
  2. Open Program.cs.
  3. Use “Go to definition” (FzfLua lsp_definitions) on the HelloWorld() method.

You'll also need the roslyn.nvim plugin, and the Roslyn LSP server as described in its README (from a custom mason registry).

Let me know if you need any help reproducing

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions