Merge pull request #346 from yilkalargaw/master

added a crystal (crystal-lang) snippets for crystal-mode
This commit is contained in:
Andrea Crotti 2019-10-09 07:25:52 +01:00 committed by GitHub
commit 2ec2ada21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 195 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: any? { |...| ... }
# key: any
# group : collections
# --
any? { |${e}| $0 }

View File

@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: case ... end
# key: case
# group : general
# --
case ${1:object}
when ${2:condition}
$0
end

12
snippets/crystal-mode/cls Normal file
View File

@ -0,0 +1,12 @@
# -*- mode: snippet -*-
# name: class ... end
# key: cls
# group : definitions
# --
class ${1:`(let ((fn (capitalize (file-name-nondirectory
(file-name-sans-extension
(or (buffer-file-name)
(buffer-name (current-buffer))))))))
(replace-regexp-in-string "_" "" fn t t))`}
$0
end

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: def ... end
# key: def
# key: def
# --
def ${1:method}${2:(${3:args})}
$0
end

6
snippets/crystal-mode/ea Normal file
View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: each { |...| ... }
# key: ea
# group : collections
# --
each { |${e}| $0 }

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: each_cons(...) { |...| ... }
# key: eac
# group : collections
# --
each_cons(${1:2}) { |${group}| $0 }

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: each_index { |i| ... }
# key: eai
# group : collections
# --
each_index { |${i}| $0 }

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: each_with_index { |e, i| ... }
# key: eawi
# group : collections
# --
each_with_index { |${e}, ${i}| $0 }

7
snippets/crystal-mode/el Normal file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: else ...
# key: el
# group : control structure
# --
else`(indent-for-tab-command)`
$1

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: elsif ...
# key: esi
# group : control structure
# --
elsif`(indent-for-tab-command)` ${1:condition}
$2

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: for
# key: for
# group : control structure
# --
for ${1:el} in ${2:collection}
$0
end

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: for ... in ...; ... end
# key: forin
# group : control structure
# --
for ${1:element} in ${2:collection}
$0
end

8
snippets/crystal-mode/if Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: if ... end
# key: if
# group : control structure
# --
if ${1:condition}
$0
end

10
snippets/crystal-mode/ife Normal file
View File

@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: if ... else ... end
# key: ife
# group : control structure
# --
if ${1:condition}
$2
else
$3
end

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: include Module
# key: inc
# group: general
# --
include ${1:Module}
$0

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: init
# key: init
# --
def initialize(${1:args})
$0
end

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: map { |...| ... }
# key: map
# group : collections
# --
map { |${e}| $0 }

14
snippets/crystal-mode/mod Normal file
View File

@ -0,0 +1,14 @@
# -*- mode: snippet -*-
# name: module ... end
# group : definitions
# key: mod
# --
module ${1:`(let ((fn (capitalize (file-name-nondirectory
(file-name-sans-extension
(or (buffer-file-name)
(buffer-name (current-buffer))))))))
(while (string-match "_" fn)
(setq fn (replace-match "" nil nil fn)))
fn)`}
$0
end

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: reduce(...) { |...| ... }
# key: red
# group : collections
# --
reduce(${1:0}) { |${2:accumulator}, ${3:element}| $0 }

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: reject { |...| ... }
# key: reject
# group : collections
# --
reject { |${1:element}| $0 }

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: require "..."
# key: require
# group : general
# --
require '$0'

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: select { |...| ... }
# key: select
# group : collections
# --
select { |${1:element}| $0 }

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: upto(...) { |n| ... }
# key: upt
# group : control structure
# --
upto(${n}) { |${i}|
$0
}

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: when ... end
# key: when
# group : control structure
# --
when ${condition}
$0
end

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: while ... end
# key: while
# group : control structure
# --
while ${condition}
$0
end

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: zip(...) { |...| ... }
# key: zip
# group : collections
# --
zip(${enums}) { |${row}| $0 }