Sha256: b4b2670c515876743681de34c367b2a98509d717fb571d95ce4022778ccf5f49
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true module PlatformosCheck module LanguageServer class RenderSnippetCompletionProvider < CompletionProvider def completions(context) content = context.content cursor = context.cursor return [] if content.nil? return [] unless cursor_on_quoted_argument?(content, cursor) partial = snippet(content) || '' snippets .select { |x| x.start_with?(partial) } .map { |x| snippet_to_completion(x) } end private def cursor_on_quoted_argument?(content, cursor) match = content.match(PARTIAL_RENDER) return false if match.nil? match.begin(:partial) <= cursor && cursor <= match.end(:partial) end def snippet(content) match = content.match(PARTIAL_RENDER) return if match.nil? match[:partial] end def snippets @storage .files .select { |x| x.include?('snippets/') } end def snippet_to_completion(file) { label: File.basename(file, '.liquid'), kind: CompletionItemKinds::SNIPPET, detail: file } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems