• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript neovim.Neovim类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中neovim.Neovim的典型用法代码示例。如果您正苦于以下问题:TypeScript Neovim类的具体用法?TypeScript Neovim怎么用?TypeScript Neovim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Neovim类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: printEllipsis

export async function printEllipsis(nvim: Neovim, message: string) {
  /**
   * Print as much of msg as possible without triggering "Press Enter"
   * Inspired by neomake, which is in turn inspired by syntastic.
   */
  const columns = (await nvim.getOption('columns')) as number;
  let msg = message.replace('\n', '. ');
  if (msg.length > columns - 15) {
    msg = msg.substring(0, columns - 20) + '...';
  }
  await nvim.outWrite(`nvim-ts: ${msg} \n`);
}
开发者ID:epeli,项目名称:vimconfig,代码行数:12,代码来源:utils.ts


示例2: syncVimToVs

  // Data flows from Vim to VS
  private async syncVimToVs(vimState: VimState) {
    const buf = await this.nvim.buffer;
    const lines = await buf.getLines({ start: 0, end: -1, strictIndexing: false });

    // one Windows, lines that went to nvim and back have a '\r' at the end,
    // which causes the issues exhibited in #1914
    const fixedLines =
      process.platform === 'win32' ? lines.map((line, index) => line.replace(/\r$/, '')) : lines;

    await TextEditor.replace(
      new vscode.Range(
        0,
        0,
        TextEditor.getLineCount() - 1,
        TextEditor.getLineMaxColumn(TextEditor.getLineCount() - 1)
      ),
      fixedLines.join('\n')
    );

    logger.debug(`Neovim: ${lines.length} lines in nvim. ${TextEditor.getLineCount()} in editor.`);

    let [row, character] = ((await this.nvim.callFunction('getpos', ['.'])) as Array<number>).slice(
      1,
      3
    );
    vimState.editor.selection = new vscode.Selection(
      new Position(row - 1, character),
      new Position(row - 1, character)
    );

    if (configuration.expandtab) {
      await vscode.commands.executeCommand('editor.action.indentationToSpaces');
    }
    // We're only syncing back the default register for now, due to the way we could
    // be storing macros in registers.
    const vimRegToVsReg = {
      v: RegisterMode.CharacterWise,
      V: RegisterMode.LineWise,
      '\x16': RegisterMode.BlockWise,
    };
    vimState.currentRegisterMode =
      vimRegToVsReg[(await this.nvim.callFunction('getregtype', ['"'])) as string];
    Register.put((await this.nvim.callFunction('getreg', ['"'])) as string, vimState);
  }
开发者ID:octref,项目名称:Vim,代码行数:45,代码来源:neovim.ts


示例3: run

  async run(vimState: VimState, command: string) {
    if (!this.nvim) {
      this.nvim = await this.startNeovim();

      await this.nvim.uiAttach(80, 20, {
        ext_cmdline: false,
        ext_popupmenu: false,
        ext_tabline: false,
        ext_wildmenu: false,
        rgb: false,
      });

      const apiInfo = await this.nvim.apiInfo;
      const version = apiInfo[1].version;
      logger.debug(`Neovim Version: ${version.major}.${version.minor}.${version.patch}`);
    }

    await this.syncVSToVim(vimState);
    command = (':' + command + '\n').replace('<', '<lt>');

    // Clear the previous error and status messages.
    // API does not allow setVvar so do it manually
    await this.nvim.command('let v:errmsg="" | let v:statusmsg=""');

    // Execute the command
    logger.debug(`Neovim: Running ${command}.`);
    await this.nvim.input(command);
    const mode = await this.nvim.mode;
    if (mode.blocking) {
      await this.nvim.input('<esc>');
    }

    // Check if an error occurred
    const errMsg = await this.nvim.getVvar('errmsg');
    let statusBarText = '';
    if (errMsg && errMsg.toString() !== '') {
      statusBarText = errMsg.toString();
    } else {
      // Check to see if a status message was updated
      const statusMsg = await this.nvim.getVvar('statusmsg');
      if (statusMsg && statusMsg.toString() !== '') {
        statusBarText = statusMsg.toString();
      }
    }

    // Sync buffer back to vscode
    await this.syncVimToVs(vimState);

    return statusBarText;
  }
开发者ID:octref,项目名称:Vim,代码行数:50,代码来源:neovim.ts


示例4: Promise

 return new Promise(async (resolve, reject) => {
   await nvim.call('setqflist', [list, 'r', title]);
   if (autoOpen) {
     await nvim.command('copen');
   }
   resolve();
 });
开发者ID:epeli,项目名称:vimconfig,代码行数:7,代码来源:utils.ts


示例5: Promise

 return new Promise(async (res, rej) => {
   const input = await nvim.call(
     'input',
     `nvim-ts: Please Select from the following options: \n${canidates} \nplease choose one: `
   );
   if (!input) return rej('Nothing selected');
   if (parseInt(input) > options.length - 1) return rej('Not a valid options');
   return res(options[parseInt(input)].changes);
 });
开发者ID:epeli,项目名称:vimconfig,代码行数:9,代码来源:codeActions.ts


示例6: dispose

  dispose() {
    if (this.nvim) {
      this.nvim.quit();
    }

    if (this.process) {
      this.process.kill();
    }
  }
开发者ID:octref,项目名称:Vim,代码行数:9,代码来源:neovim.ts


示例7: syncVSToVim

  // Data flows from VS to Vim
  private async syncVSToVim(vimState: VimState) {
    const buf = await this.nvim.buffer;
    if (configuration.expandtab) {
      await vscode.commands.executeCommand('editor.action.indentationToTabs');
    }

    await this.nvim.setOption('gdefault', configuration.substituteGlobalFlag === true);
    await buf.setLines(TextEditor.getText().split('\n'), {
      start: 0,
      end: -1,
      strictIndexing: true,
    });

    const [rangeStart, rangeEnd] = [
      Position.EarlierOf(vimState.cursorPosition, vimState.cursorStartPosition),
      Position.LaterOf(vimState.cursorPosition, vimState.cursorStartPosition),
    ];
    await this.nvim.callFunction('setpos', [
      '.',
      [0, vimState.cursorPosition.line + 1, vimState.cursorPosition.character, false],
    ]);
    await this.nvim.callFunction('setpos', [
      "'<",
      [0, rangeStart.line + 1, rangeEnd.character, false],
    ]);
    await this.nvim.callFunction('setpos', [
      "'>",
      [0, rangeEnd.line + 1, rangeEnd.character, false],
    ]);
    for (const mark of vimState.historyTracker.getMarks()) {
      await this.nvim.callFunction('setpos', [
        `'${mark.name}`,
        [0, mark.position.line + 1, mark.position.character, false],
      ]);
    }

    // We only copy over " register for now, due to our weird handling of macros.
    let reg = await Register.get(vimState);
    let vsRegTovimReg = [undefined, 'c', 'l', 'b'];
    await this.nvim.callFunction('setreg', [
      '"',
      reg.text as string,
      vsRegTovimReg[vimState.effectiveRegisterMode] as string,
    ]);
  }
开发者ID:octref,项目名称:Vim,代码行数:46,代码来源:neovim.ts



注:本文中的neovim.Neovim类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript client.NeovimClient类代码示例发布时间:2022-05-25
下一篇:
TypeScript TransferTransaction.TransferTransaction类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap