本文整理汇总了TypeScript中promised-neovim-client.Nvim.input方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Nvim.input方法的具体用法?TypeScript Nvim.input怎么用?TypeScript Nvim.input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类promised-neovim-client.Nvim
的用法示例。
在下文中一共展示了Nvim.input方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
async run(vimState: VimState, command: string) {
await this.syncVSToVim(vimState);
command = ':' + command + '\n';
command = command.replace('<', '<lt>');
await this.nvim.input(command);
if ((await this.nvim.getMode()).blocking) {
await this.nvim.input('<esc>');
}
await this.syncVimToVs(vimState);
return;
}
示例2: input
async input(vimState: VimState, keys: string) {
await this.syncVSToVim(vimState);
await this.nvim.input(keys);
await this.syncVimToVs(vimState);
return;
}
示例3:
client.eval('mode()').then((value: string) => {
if (value.length === 0) {
return;
}
const command = value[0] === 'n' ? 'ggVG' : '<Esc>ggVG';
client.input(command);
});
示例4: char2nr
client.eval('mode()').then((value: string) => {
if (value.length === 0) {
return;
}
const ch = value[0];
const code = value.charCodeAt(0);
if (ch === 'v' // visual mode
|| ch === 'V' // visual line mode
|| code === 22 // visual block mode. 22 is returned by ':echo char2nr("\<C-v>")'
) {
client.input('"+y');
}
});
示例5: run
async run(vimState: VimState, command: string) {
if (!this.nvim) {
this.nvim = await this.startNeovim();
}
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
await this.nvim.input(command);
if ((await this.nvim.getMode()).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;
}
示例6: if
client.eval('mode()').then((value: string) => {
if (value.length === 0) {
return;
}
let command: string;
const ch = value[0];
const code = value.charCodeAt(0);
if (ch === 'v') {
// visual mode
// deleting the highlighted area
// to prevent vim from copying the area to the pasteboard
command = '"_d"+P';
} else if (ch === 'V') {
// visual line mode
command = '"_d"+p';
} else if (code === 22 || ch === 'n') {
// visual block mode
// the "_d trick doesn't work here
// because the visual selection will disappear after "_d command
// or normal mode
command = '"+p';
} else if (ch === 'i') {
// insert mode
// gp will move cursor to the last of pasted content
command = '<C-o>"+gp';
} else if (ch === 'c') {
// command line mode
command = '<C-r>+';
}
if (command) {
client.input(command);
}
});