Module: Jade::LSP::Snippets

Defined in:
lib/jade/lsp/snippets.rb

Defined Under Namespace

Classes: Snippet

Constant Summary collapse

TAB_STOP =
/\$\{\d+:?([^}]*)\}/
ALL =
[
  Snippet.new(
    label: 'def',
    detail: 'function declaration',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'type',
    detail: 'union type',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'struct',
    detail: 'struct declaration',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'case',
    detail: 'case expression, one branch per variant',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'if',
    detail: 'if/then/else block',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'module',
    detail: 'module header',
    body: 'module ${1:Name} exposing (${0})',
  ),
  Snippet.new(
    label: 'import',
    detail: 'import declaration',
    body: 'import ${1:Module} exposing (${0:Name})',
  ),
  Snippet.new(
    label: 'interface',
    detail: 'interface declaration',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'implements',
    detail: 'interface implementation',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'uses',
    detail: 'interop import',
    body: <<~SNIP.chomp,
  ),
  Snippet.new(
    label: 'lambda',
    detail: 'anonymous function',
    body: '(${1:args}) -> { ${0:body} }',
  ),
].freeze

Class Method Summary collapse

Class Method Details

.catalogObject

Every form, as plain Jade — what jade q syntax serves.



109
110
111
# File 'lib/jade/lsp/snippets.rb', line 109

def catalog
  ALL.map { { form: it.label, detail: it.detail, source: it.source } }
end

.find(form) ⇒ Object



113
114
115
# File 'lib/jade/lsp/snippets.rb', line 113

def find(form)
  catalog.find { it[:form] == form }
end