當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript neovim.Neovim類代碼示例

本文整理匯總了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;未經允許,請勿轉載。