Skip to content

Working tree buffer is a 'real' buffer with LSP server(s) attached #293

Description

@gegoune

Hi there,
this is more of a request for assistance than a bug report but discussions are disabled here, hope you don't mind.

I have long struggled with various issues related to LSP functionality and Diffview, which I believe all come from the fact that working tree diff buffer (right hand side one) is a real, live, buffer rather than URI scheme prefixed with diffview://.

Please note that all LSP features are enabled through callback function of LspAttach autocommand.

  1. Opening Diffview on newly started Neovim (without any buffer loaded yet) will cause topmost file on the file panel to be loaded. If LSP folding feature is enabled with:
vim.wo[win][0].foldmethod = 'expr'
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'

this will cause right hand buffer to fold quite aggressively when LSP server attaches (with foldlevel=0 as opposed to my default foldlevel=99). It is the case for yaml-language-server at least (but likely all servers supporting FoldingRange will behave like this). Important distinction is that if I open the same buffer prior to opening Diffview, no such folding takes place. It's only an issue when Diffview opens the buffer.

  1. With the nature of representation of code lenses (at least on nightly) being on separate line above targetted definition the result is misaligned buffers due to virtual lines.

I tried various autocommands, Diffview hooks, to enable and disable LSP features but didn't manage to get it to work satisfactorily.

Do you think, perhaps being quite a fundamental change, Diffview could also treat right hand side buffer (working tree) as a special buffer for which all LSP functionalities are disabled the same way left hand side buffer is?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions