-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (33 loc) · 958 Bytes
/
index.js
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
const {sources} = require('coc.nvim')
const fs = require('fs')
const {promisify} = require('util')
let items
exports.activate = async context => {
const filpeath = context.asAbsolutePath('nerdfonts.txt')
let source = {
name: 'nerdfonts',
triggerOnly: true,
doComplete: async function (opt) {
if (!items) {
let content = await promisify(fs.readFile)(filpeath, 'utf8')
let lines = content.split(/\n/).slice(0, -1)
items = lines.map(str => {
let parts = str.split(':')
return {description: parts[0], character: parts[1]}
})
}
return {
startcol: opt.col - 3,
items: items.map(o => {
return {
word: o.character,
abbr: `${o.character} ${o.description}`,
menu: this.menu,
filterText: o.description,
}
})
}
}
}
context.subscriptions.push(sources.createSource(source))
}