Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, 50)
}
})
}
}
try {
proc.once('exit', () => {
if (exited) return
logger.info('highlight nvim exited.')
resolve([])
})
timer = setTimeout(() => {
exit()
resolve([])
}, timeout)
nvim = attach({ proc }, null, false)
const callback = (method, args) => {
if (method == 'redraw') {
for (let arr of args) {
let [name, ...list] = arr
if (name == 'hl_attr_define') {
for (let item of list) {
let id = item[0]
let { hi_name } = item[item.length - 1][0]
hlMap.set(id, hi_name)
}
}
if (name == 'grid_line') {
// logger.debug('list:', JSON.stringify(list, null, 2))
for (let def of list) {
let [, line, col, cells] = def
if (line >= lines.length) continue
export default (opts: Attach, requestApi = true): Plugin => {
const nvim: NeovimClient = attach(opts, log4js.getLogger('node-client'), requestApi)
// Overwriding the URI.file function in case of cygwin.
nvim.eval('has("win32unix")?get(g:,"coc_cygqwin_path_prefixes", v:null):v:null').then(prefixes => {
if (!prefixes) return
const old_uri = URI.file
URI.file = (path): URI => {
path = path.replace(/\\/g, '/')
Object.keys(prefixes).forEach(k => path = path.replace(new RegExp('^' + k, 'gi'), prefixes[k]))
return old_uri(path)
}
}).logError()
const plugin = new Plugin(nvim)
let clientReady = false
let initialized = false
nvim.on('notification', async (method, args) => {
switch (method) {
case 'VimEnter': {
const attach = require('@chemzqm/neovim').attach
const logger = require('../lib/logger')('server')
let nvim
if (process.env.NVIM_LISTEN_ADDRESS) {
nvim = attach({
socket: process.env.NVIM_LISTEN_ADDRESS
})
} else {
nvim = attach({
socket: {
port: process.env.NVIM_LISTEN_PORT,
host: '127.0.0.1'
}
})
}
nvim.on('request', (_method, args, resp) => {
let buffer = Buffer.alloc(args[0], 'a')
resp.send({ r: buffer.toString('ascii') })
})