lexical-lsp / lexical

Lexical is a next-generation elixir language server
874 stars 80 forks source link

Use `languageId` field provided by LSP clients. #662

Closed Moosieus closed 6 months ago

Moosieus commented 6 months ago

Presently, Lexical reads file extensions to evaluate files as eex, heex, or elixir. This approach doesn't work for documents that haven't been saved to the file system. Consequently unsaved eex and heex files don't receive proper diagnostics.

This commit adds language_id to the Document struct and sets it when provided by LSP. If not available, the file extension will be used as a fallback.

Moosieus commented 6 months ago

This PR also fixes two issues. Presently, as-you-type completions don't work with heex files, see:

Diagnostics in eex were also resulting in LSP errors, fixed by a slight tweak to the error messaging regex.