Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Use languageId field provided by LSP clients.#662

Merged
scohen merged 10 commits into
lexical-lsp:mainfrom
Moosieus:language_id
Mar 28, 2024
Merged

Use languageId field provided by LSP clients.#662
scohen merged 10 commits into
lexical-lsp:mainfrom
Moosieus:language_id

Conversation

@Moosieus

Copy link
Copy Markdown
Collaborator

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.

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

Copy link
Copy Markdown
Collaborator Author

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

This PR disables document-level completions for heex files, meaning diagnostics won't show until the file's saved. This is a preferable stop-gap until full support can be implemented, as mentioned here.

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

Comment thread projects/lexical_shared/lib/lexical/document.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document/path.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document/path.ex Outdated
Comment thread apps/server/lib/lexical/server/state.ex Outdated
* Improve `DidOpen` event destructuring.
* Move `language_id_from_uri/1` from `Document.Path` to `Document`.
Comment thread projects/lexical_shared/lib/lexical/document/path.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document/store.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document.ex Outdated
Comment thread apps/server/lib/lexical/server/state.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document/store.ex Outdated
Comment thread projects/lexical_shared/lib/lexical/document/store.ex Outdated
* Make `language_id_from_path/1` private.
* Remove `language_id_from_uri/1` as it's unused and less reliable.
* Infer language_id exclusively within `Document.new`.
* Improve ergonomics of `Document.Store.open`.
Comment thread apps/server/lib/lexical/server/state.ex Outdated

@scohen scohen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address the one remaining issue, then we're good to go.

@scohen scohen merged commit 902b13d into lexical-lsp:main Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants