Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function(options: Attach): IPlugin {
const nvim: NeovimClient = attach(options)
nvim.on('notification', async (method: string, args: any[]) => {
const opts = args[0] || args
const bufnr = opts.bufnr
const buffers = await nvim.buffers
const buffer = buffers.find(b => b.id === bufnr)
if (method === 'refresh_content') {
const winline = await nvim.call('winline')
const currentWindow = await nvim.window
const winheight = await nvim.call('winheight', currentWindow.id)
const cursor = await nvim.call('getpos', '.')
const renderOpts = await nvim.getVar('mkdp_preview_options')
const pageTitle = await nvim.getVar('mkdp_page_title')
const name = await buffer.name
const content = await buffer.getLines()
const currentBuffer = await nvim.buffer
function default_1(options) {
const nvim = neovim_1.attach(options);
nvim.on('notification', (method, args) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const opts = args[0];
const bufnr = opts.bufnr;
const buffers = yield nvim.buffers;
const buffer = buffers.find(b => b.id === bufnr);
if (method === 'refresh_content') {
const cursor = yield nvim.call('getpos', '.');
const content = yield buffer.getLines();
app.refreshPage({
bufnr,
data: {
cursor,
content
}
});
}
private async startNeovim() {
this.logger.debug('Spawning Neovim process...');
let dir = dirname(vscode.window.activeTextEditor!.document.uri.fsPath);
if (!(await util.promisify(exists)(dir))) {
dir = __dirname;
}
this.process = spawn(configuration.neovimPath, ['-u', 'NONE', '-i', 'NONE', '-n', '--embed'], {
cwd: dir,
});
this.process.on('error', err => {
this.logger.error(`Error spawning neovim. ${err.message}.`);
configuration.enableNeovim = false;
});
return attach({ proc: this.process });
}
function default_1(options) {
const nvim = neovim_1.attach(options);
nvim.on('notification', (method, args) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const opts = args[0] || args;
const bufnr = opts.bufnr;
const buffers = yield nvim.buffers;
const buffer = buffers.find(b => b.id === bufnr);
if (method === 'refresh_content') {
const winline = yield nvim.call('winline');
const currentWindow = yield nvim.window;
const winheight = yield nvim.call('winheight', currentWindow.id);
const cursor = yield nvim.call('getpos', '.');
const renderOpts = yield nvim.getVar('mkdp_preview_options');
const pageTitle = yield nvim.getVar('mkdp_page_title');
const name = yield buffer.name;
const content = yield buffer.getLines();
const currentBuffer = yield nvim.buffer;
app.refreshPage({
export default function(options: Attach): IPlugin {
const nvim: NeovimClient = attach(options)
nvim.on('notification', async (method: string, args: any[]) => {
const opts = args[0]
const bufnr = opts.bufnr
const buffers = await nvim.buffers
const buffer = buffers.find(b => b.id === bufnr)
if (method === 'refresh_content') {
const cursor = await nvim.call('getpos', '.')
const content = await buffer.getLines()
app.refreshPage({
bufnr,
data: {
cursor,
content
}
})