-
Notifications
You must be signed in to change notification settings - Fork 95
Add Snippet Completion + Document Links #223
Conversation
lib/theme_check/language_server.rb
Outdated
require_relative "language_server/handler" | ||
require_relative "language_server/server" | ||
require_relative "language_server/tokens" | ||
require_relative "language_server/position_helper" | ||
require_relative "language_server/completion_helper" | ||
require_relative "language_server/completion_provider" | ||
require_relative "language_server/completion_engine" | ||
require_relative "language_server/document_links_engine" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe should singularize this.
2aaba38
to
cb62058
Compare
|
||
def document_links(uri) | ||
buffer = @storage.read(uri) | ||
matches(buffer, PARTIAL_RENDER).map do |match| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file specific to render
support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, yes. But we might want to add support for things that get piped to asset_url in the future.
|
||
# Turn that into a hash of empty buffers | ||
files = fs.files | ||
.map { |fn| [fn, ""] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why you need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I need a list of snippets from the RenderSnippetCompletionProvider. The InMemoryStorage doesn't have anything in it and I didn't want to have both an InMemoryStorage instance for buffers and a FSStorage for files just so that the render snippet completion provider was able to list those files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see! Because that's what InMemoryStorage.new
expects! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
name | ||
end | ||
|
||
def read(name) | ||
@files[name] | ||
@files[relative_path(name)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I'm doing this is because I would otherwise have absolute paths in the InMemoryStorage. So we'd have duplicate entries for absolute paths and relative paths. I could also revert this and only have absolute paths.
cb62058
to
0819717
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧨
|
||
# Turn that into a hash of empty buffers | ||
files = fs.files | ||
.map { |fn| [fn, ""] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see! Because that's what InMemoryStorage.new
expects! 👍
Fixes #180
In this PR:
{% render '..' %}
completions{% render '..' %}
clickable linksDemo: https://screenshot.click/23-09-71h84-pp23z.mp4
Also: https://screenshot.click/23-22-5tyee-kv5vl.mp4