Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use languageId field provided by LSP clients. #662

Merged
merged 10 commits into from
Mar 28, 2024

Conversation

Moosieus
Copy link
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
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.

projects/lexical_shared/lib/lexical/document.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document/path.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document/path.ex Outdated Show resolved Hide resolved
apps/server/lib/lexical/server/state.ex Outdated Show resolved Hide resolved
* Improve `DidOpen` event destructuring.
* Move `language_id_from_uri/1` from `Document.Path` to `Document`.
projects/lexical_shared/lib/lexical/document/path.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document/store.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document.ex Outdated Show resolved Hide resolved
apps/server/lib/lexical/server/state.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document/store.ex Outdated Show resolved Hide resolved
projects/lexical_shared/lib/lexical/document/store.ex Outdated Show resolved Hide resolved
* 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`.
Copy link
Collaborator

@scohen scohen left a comment

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
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants