WhoIsSethDaniel / goldsmith.nvim

Use Neovim features, such as built-in LSP and tree-sitter, and develop Go code.
MIT License
57 stars 3 forks source link

fix: Default to utf-16 to satisfy LSP spec #57

Closed antoineco closed 2 years ago

antoineco commented 2 years ago

In my previous PR (#56) I assumed utf-8 to be a safe default in case we fail to obtain the preferred offset encoding from the client. However, I missed the part of the spec that defines utf-16 as the only mandatory encoding for Text Documents:

To stay backwards compatible the only mandatory encoding is UTF-16 represented via the string utf-16. [...] If the string value utf-16 is missing from the client’s capability general.positionEncodings servers can safely assume that the client supports UTF-16. If the server omits the position encoding in its initialize result the encoding defaults to the string value utf-16.

-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocuments

This PR sets utf-16 as the fallback offset encoding instead of utf-8 to be better aligned with the LSP spec.

WhoIsSethDaniel commented 2 years ago

I need to remember this. I never use utf-16 except with LSP. Thanks.