Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Add Snippet Completion + Document Links #223

Merged
merged 1 commit into from
Mar 23, 2021

Conversation

charlespwd
Copy link
Contributor

@charlespwd charlespwd commented Mar 23, 2021

Fixes #180

In this PR:

  • Add {% render '..' %} completions
  • Make snippets in {% render '..' %} clickable links

Demo: https://screenshot.click/23-09-71h84-pp23z.mp4
Also: https://screenshot.click/23-22-5tyee-kv5vl.mp4

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"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe should singularize this.

@charlespwd charlespwd force-pushed the feature/snippet-completion branch 2 times, most recently from 2aaba38 to cb62058 Compare March 23, 2021 16:59

def document_links(uri)
buffer = @storage.read(uri)
matches(buffer, PARTIAL_RENDER).map do |match|
Copy link
Contributor

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?

Copy link
Contributor Author

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, ""] }
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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! 👍

Copy link
Contributor

@jplhomer jplhomer left a 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)]
Copy link
Contributor Author

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.

@charlespwd charlespwd force-pushed the feature/snippet-completion branch from cb62058 to 0819717 Compare March 23, 2021 17:42
Copy link
Contributor

@macournoyer macournoyer left a 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, ""] }
Copy link
Contributor

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! 👍

@charlespwd charlespwd merged commit 8615142 into master Mar 23, 2021
@charlespwd charlespwd temporarily deployed to rubygems March 23, 2021 20:33 Inactive
@charlespwd charlespwd deleted the feature/snippet-completion branch April 12, 2021 18:02
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.

Complete render strings
3 participants