本文整理汇总了TypeScript中@chemzqm/neovim.NeovimClient类的典型用法代码示例。如果您正苦于以下问题:TypeScript NeovimClient类的具体用法?TypeScript NeovimClient怎么用?TypeScript NeovimClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NeovimClient类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: default
export default (opts: Attach): Plugin => {
const nvim: NeovimClient = attach(opts)
const plugin = new Plugin(nvim)
let initialized = false
nvim.on('notification', async (method, args) => {
switch (method) {
case 'VimEnter': {
if (!initialized) {
initialized = true
await plugin.init()
}
break
}
case 'OptionSet':
await events.fire('OptionSet', args)
break
case 'InputChar':
await events.fire('InputChar', args)
break
case 'GlobalChange':
await events.fire('GlobalChange', args)
break
case 'CocAutocmd':
await events.fire(args[0], args.slice(1))
break
default:
const m = method[0].toLowerCase() + method.slice(1)
if (typeof plugin[m] == 'function') {
try {
await Promise.resolve(plugin[m].apply(plugin, args))
} catch (e) {
// tslint:disable-next-line:no-console
console.error(`error on notification '${method}': ${e}`)
}
}
}
})
nvim.on('request', async (method: string, args, resp) => {
try {
if (method == 'CocAutocmd') {
await events.fire(args[0], args.slice(1))
resp.send()
return
}
let m = method[0].toLowerCase() + method.slice(1)
if (typeof plugin[m] !== 'function') {
return resp.send(`Method ${m} not found`, true)
}
let res = await Promise.resolve(plugin[m].apply(plugin, args))
resp.send(res)
} catch (e) {
logger.error(`Error on "${method}": ` + e.stack)
resp.send(e.message, true)
}
})
nvim.channelId.then(async channelId => {
if (isTest) nvim.command(`let g:coc_node_channel_id = ${channelId}`, true)
let json = require('../package.json')
let { major, minor, patch } = semver.parse(json.version)
nvim.setClientInfo('coc', { major, minor, patch }, 'remote', {}, {})
let entered = await nvim.getVvar('vim_did_enter')
if (entered && !initialized) {
initialized = true
await plugin.init()
}
}).catch(e => {
console.error(`Channel create error: ${e.message}`) // tslint:disable-line
})
return plugin
}
开发者ID:demelev,项目名称:coc.nvim,代码行数:72,代码来源:attach.ts
示例2: require
nvim.channelId.then(async channelId => {
if (isTest) nvim.command(`let g:coc_node_channel_id = ${channelId}`, true)
let json = require('../package.json')
let { major, minor, patch } = semver.parse(json.version)
nvim.setClientInfo('coc', { major, minor, patch }, 'remote', {}, {})
let entered = await nvim.getVvar('vim_did_enter')
if (entered && !initialized) {
initialized = true
await plugin.init()
}
}).catch(e => {
开发者ID:demelev,项目名称:coc.nvim,代码行数:11,代码来源:attach.ts
注:本文中的@chemzqm/neovim.NeovimClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论