Sha256: a8a2f4a7703a2756b88182d4c084a42c8a8629caa1af4d1551f78b767b4a1802
Contents?: true
Size: 1.07 KB
Versions: 36
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module ThemeCheck module LanguageServer class RenderSnippetCompletionProvider < CompletionProvider def completions(content, cursor) 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
36 entries across 36 versions & 1 rubygems