Sha256: 3d7e5f3aa8bef21f22a55f5f15adac8fb6927eee5488ae960e503b7200abae33
Contents?: true
Size: 1.1 KB
Versions: 21
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module PlatformosCheck module LanguageServer class TagCompletionProvider < CompletionProvider def completions(context) content = context.content return [] if content.nil? return [] unless can_complete?(context) partial = first_word(context.buffer.lines[context.line]) || '' PlatformosLiquid::SourceIndex.tags.select { |tag| tag.name.start_with?(partial) } .map { |tag| tag_to_completion(tag) } end def can_complete?(context) context.content.start_with?(Liquid::TagStart) && (cursor_on_first_word?(context.buffer.lines[context.line], context.col) || cursor_on_start_content?(context.buffer.lines[context.line], context.col, Liquid::TagStart)) end private def tag_to_completion(tag) content = PlatformosLiquid::Documentation.tag_doc(tag.name) { contents: content, label: tag.name, kind: CompletionItemKinds::KEYWORD, **format_hash(tag), **doc_hash(content) } end end end end
Version data entries
21 entries across 21 versions & 1 rubygems