-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.coffee
63 lines (56 loc) · 2.11 KB
/
index.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Simply add stars for newlines in KDoc comments
# Also provides autocomplete for tags in KDoc comments
module.exports =
activate: ->
@observe = atom.workspace.observeTextEditors (editor) =>
editor.onDidInsertText (event) =>
if (event.text is "\n") and (editor.getCursorScope().scopes.includes("comment.kdoc.kotlin"))
editor.insertText "* " # Insert a star in new lines of kdoc comments
deactivate: ->
@observe?.dispose()
provideKDocCompletion: -> {
selector: '.source.kotlin .comment.kdoc.kotlin'
getSuggestions: ({prefix, activatedManually}) ->
new Promise (resolve) ->
out = []
createNone = (text) ->
out.push {
displayText: "@#{text}"
snippet: "@#{text}"
type: 'tag'
replacementPrefix: "@#{prefix}"
}
createDoc = (text, extra = "Documentation") ->
out.push {
displayText: "@#{text}"
snippet: "@#{text} ${1:#{extra}}"
type: 'tag'
replacementPrefix: "@#{prefix}"
}
createSingleWithDescription = (text, type = "Type", extra = "Documentation") ->
out.push {
displayText: "@#{text}"
snippet: "@#{text} ${1:#{type}} ${2:#{extra}}"
type: 'tag'
replacementPrefix: "@#{prefix}"
}
# Create all of the types
createSingleWithDescription("param", "Parameter")
createDoc("return", "Type and documentation")
createDoc("constructor", "Document main constructor")
createDoc("receiver")
createSingleWithDescription("property", "Property")
createSingleWithDescription("throws")
createSingleWithDescription("exception")
createSingleWithDescription("sample", "Identifier")
createSingleWithDescription("see", "Identifier")
createDoc("author", "Name")
createDoc("since", "v1.2.3")
createNone("suppress")
if activatedManually
resolve(out)
else
resolve(out.filter((item) ->
item.displayText.startsWith("@#{prefix}")
))
}