mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
fix(lsp): use buffer scheme for files not stored on disk (#22407)
Sending `didOpen` with a `file` scheme causes problems with some language servers because they expect the file to exist on disk. See https://github.com/microsoft/language-server-protocol/pull/1679
This commit is contained in:

committed by
GitHub

parent
d66832c76d
commit
896d672736
@@ -2032,7 +2032,12 @@ end
|
||||
---@returns `TextDocumentIdentifier`
|
||||
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier
|
||||
function M.make_text_document_params(bufnr)
|
||||
return { uri = vim.uri_from_bufnr(bufnr or 0) }
|
||||
bufnr = bufnr or 0
|
||||
local uri = vim.uri_from_bufnr(bufnr)
|
||||
if not uv.fs_stat(api.nvim_buf_get_name(bufnr)) then
|
||||
uri = uri:gsub('^file://', 'buffer://')
|
||||
end
|
||||
return { uri = uri }
|
||||
end
|
||||
|
||||
--- Create the workspace params
|
||||
@@ -2065,7 +2070,7 @@ function M.make_formatting_params(options)
|
||||
insertSpaces = vim.bo.expandtab,
|
||||
})
|
||||
return {
|
||||
textDocument = { uri = vim.uri_from_bufnr(0) },
|
||||
textDocument = M.make_text_document_params(0),
|
||||
options = options,
|
||||
}
|
||||
end
|
||||
|
Reference in New Issue
Block a user