How to use neovim - 10 common examples

To help you get started, we’ve selected a few neovim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github billyvg / tigris.nvim / rplugin / node / tigris.js / src / index.js View on Github external
eval: 'expand("")',
  })
  onTextChanged(args) {
    this.flyParse(args);
  }
  @Autocmd('BufEnter', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  async onBufEnter() {
    const filename = await this.nvim.buffer.name;
    console.log(`[${filename.split('/').pop()}] Handle buffer enter`);
    this.parse({ filename, clear: true });
  }

  @Autocmd('InsertLeave', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onInsertLeave(filename) {
    this.parse({ filename, clear: true });
  }

  highlight(buffer, id, name, lineStart, columnStart, columnEnd, isDebug) {
    // Save highlighting group for console.logging
    if (isDebug) {
      _.range(columnEnd - columnStart + 1).forEach((num) => {
        const key = `${lineStart + 1},${columnStart + num}`; // [lineStart, columnStart + num];
        if (!DEBUG_MAP.has(key)) {
          DEBUG_MAP.set(key, []);
        }
        const groups = DEBUG_MAP.get(key);
github mhartington / nvim-typescript / rplugin / node / nvim_typescript / src / index.ts View on Github external
// });
    // console.warn(JSON.stringify(watcher.getWatched()));


  }


  @Command('TSStop')
  async tsstop() {
    if (this.client.serverHandle != null) {
      this.client.stopServer();
      await printHighlight(this.nvim, `Server stopped`, 'ErrorMsg');
    }
  }

  @Command('TSReloadProject')
  async reloadProject() {
    await this.client.reloadProject();
    await this.getDiagnostics();
  }

  @Function('TSCmRefresh')
  async onCMRefresh(args: any[]) {
    const info = args[0];
    const ctx = args[1];

    const line = ctx['lnum'];
    const offset = ctx['col'];
    const prefix = ctx['base'];
    const startcol = ctx['startcol'];
    // recheck
    if (await this.nvim.call('cm#context_changed', ctx)) return;
github mhartington / nvim-typescript / rplugin / node / nvim_typescript / src / index.ts View on Github external
//   // console.warn(JSON.stringify(this.completionChangeEvent));
  //
  //   // console.warn('COMPLETION START')
  //   this.doingCompletion = true
  // }
  // @Autocmd('CompleteDone', { pattern: '*', sync: true})
  // async onCompleteDone() {
  //   this.completedItem  = await this.nvim.getVvar('completed_item') as CompletionItem;
  //   // console.warn(JSON.stringify(this.completedItem));
  //
  //   // console.warn("COMPLECTION DONE")
  //   this.doingCompletion = false
  //   this.getDiagnostics()
  // }

  @Command('TSType')
  async getType() {
    await this.reloadFile();
    const args = await this.getCommonData();
    try {
      const typeInfo = await this.client.quickInfo(args);
      if (Object.getOwnPropertyNames(typeInfo).length > 0) {
        try {
          const window = await createHoverWindow(this.nvim, typeInfo)
          this.floatingWindow.push(window);
        }
        catch (e) {
          await printHighlight(this.nvim, await truncateMsg(this.nvim, typeInfo.displayString), 'MoreMsg', 'Function');
        }
      }
    } catch (err) {
      // console.warn('in catch', JSON.stringify(err));
github mhartington / nvim-typescript / rplugin / node / nvim_typescript / src / index.ts View on Github external
import { Autocmd, Command, Function, Neovim, Plugin, Window } from 'neovim';
import { fileSync } from 'tmp';
import protocol from 'typescript/lib/protocol';
import { TSServer } from './client';
import { applyCodeFixes, promptForSelection } from './codeActions';
import { DiagnosticHost } from './diagnostic';
import { createFloatingWindow, createHoverWindow } from './floatingWindow';
import { CompletionChangeEvent, CompletionItem } from './types';
import { convertDetailEntry, convertEntry, createLocList, createQuickFixList, getKind, isRenameSuccess, printHighlight, reduceByPrefix, triggerChar, trim, truncateMsg, processErrors } from './utils';
// import { watch } from 'chokidar'
// import {createMonitor} from 'watch'

// var nsfw = require('nsfw');
// var watchr = require('watchr')

@Plugin({ dev: false })
export default class TSHost {
  private client = TSServer;
  private diagnosticHost = DiagnosticHost;
  private maxCompletion: number;
  private expandSnippet: boolean;
  enableDiagnostics: boolean;
  quietStartup: boolean;

  private completionChangeEvent: CompletionChangeEvent;
  private completedItem: CompletionItem;
  floatingWindow: Window[] = [];
  doingCompletion = false;
  suggestionsEnabled: any;
  constructor(public nvim: Neovim) { }

  // @Autocmd('TextChangedP', { pattern: '*', sync: true })
github billyvg / tigris.nvim / rplugin / node / tigris.js / src / index.js View on Github external
console.log('Error with highlight debug, position doesnt exist');
      }
    } else {
      this.nvim.command('echomsg "[tigris] console.log mode not enabled: `let g:tigris#console.log=1` to enable"');
    }
  }

  @Autocmd('TextChangedI', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onTextChangedI(args) {
    this.flyParse(args);
  }

  @Autocmd('TextChanged', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onTextChanged(args) {
    this.flyParse(args);
  }
  @Autocmd('BufEnter', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  async onBufEnter() {
    const filename = await this.nvim.buffer.name;
    console.log(`[${filename.split('/').pop()}] Handle buffer enter`);
    this.parse({ filename, clear: true });
  }
github billyvg / tigris.nvim / rplugin / node / tigris.js / src / index.js View on Github external
@Autocmd('TextChangedI', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onTextChangedI(args) {
    this.flyParse(args);
  }

  @Autocmd('TextChanged', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onTextChanged(args) {
    this.flyParse(args);
  }
  @Autocmd('BufEnter', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  async onBufEnter() {
    const filename = await this.nvim.buffer.name;
    console.log(`[${filename.split('/').pop()}] Handle buffer enter`);
    this.parse({ filename, clear: true });
  }

  @Autocmd('InsertLeave', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onInsertLeave(filename) {
    this.parse({ filename, clear: true });
  }
github billyvg / tigris.nvim / rplugin / node / tigris.js / src / index.js View on Github external
const DEBUG_MAP = new Map();
const HL_MAP = new Map();


const debouncedParser = _.debounce.call(_, async (nvim, filename, parseFunc) => {
  const enableFly = await nvim.getVar(FLY_VAR);

  console.log(`[${filename.split('/').pop()}] Fly parse enabled: ${enableFly}`);

  if (enableFly) {
    parseFunc({ filename, clear: true });

  }
}, DELAY_DEFAULT);

@Plugin({
  name: 'tigris',
})
class TigrisPlugin {
  flyParse(filename) {
    debouncedParser(this.nvim, filename, this.parse.bind(this));
  }

  @Function('tigris_enable')
  async enable() {
    await this.nvim.setVar(ENABLE_VAR, true);
    this.parse();
  }

  @Function('tigris_disable')
  disable() {
    this.nvim.setVar(ENABLE_VAR, false);
github billyvg / tigris.nvim / rplugin / node / tigris.js / src / index.js View on Github external
const group = DEBUG_MAP.get(key);
        this.nvim.command(
          `echomsg "[tigris] position: ${key} - Highlight groups: ${[group.join(', ')]}"`
        );
      } else {
        this.nvim.command(
          'echomsg "[tigris] Error, position doesn\'t exist"'
        );
        console.log('Error with highlight debug, position doesnt exist');
      }
    } else {
      this.nvim.command('echomsg "[tigris] console.log mode not enabled: `let g:tigris#console.log=1` to enable"');
    }
  }

  @Autocmd('TextChangedI', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onTextChangedI(args) {
    this.flyParse(args);
  }

  @Autocmd('TextChanged', {
    pattern: '*.js,*.jsx',
    eval: 'expand("")',
  })
  onTextChanged(args) {
    this.flyParse(args);
  }
  @Autocmd('BufEnter', {
    pattern: '*.js,*.jsx',
github neoclide / coc.nvim / lib / index.js View on Github external
neovim_1.Function('CocResult', { sync: false })
], CompletePlugin.prototype, "cocResult", null);
tslib_1.__decorate([
    neovim_1.Function('CocCheckHealth', { sync: true })
], CompletePlugin.prototype, "cocCheckHealth", null);
tslib_1.__decorate([
    neovim_1.Function('CocSourceStat', { sync: true })
], CompletePlugin.prototype, "cocSourceStat", null);
tslib_1.__decorate([
    neovim_1.Function('CocSourceToggle', { sync: true })
], CompletePlugin.prototype, "cocSourceToggle", null);
tslib_1.__decorate([
    neovim_1.Function('CocSourceRefresh', { sync: true })
], CompletePlugin.prototype, "cocSourceRefresh", null);
tslib_1.__decorate([
    neovim_1.Function('CocFileTypeChange', { sync: false })
], CompletePlugin.prototype, "cocFileTypeChange", null);
tslib_1.__decorate([
    neovim_1.Function('CocShowSignature', { sync: false })
], CompletePlugin.prototype, "cocShowSignature", null);
tslib_1.__decorate([
    neovim_1.Function('CocShowDefinition', { sync: false })
], CompletePlugin.prototype, "cocShowType", null);
tslib_1.__decorate([
    neovim_1.Command('CocShowDoc', { sync: false, nargs: '*' })
], CompletePlugin.prototype, "cocShowDoc", null);
tslib_1.__decorate([
    neovim_1.Function('CocJumpDefinition', { sync: true })
], CompletePlugin.prototype, "cocJumpDefninition", null);
CompletePlugin = tslib_1.__decorate([
    neovim_1.Plugin({ dev: false })
], CompletePlugin);
github neoclide / coc.nvim / lib / index.js View on Github external
neovim_1.Function('CocInitAsync', { sync: false })
], CompletePlugin.prototype, "cocInitAsync", null);
tslib_1.__decorate([
    neovim_1.Function('CocInitSync', { sync: true })
], CompletePlugin.prototype, "cocInitSync", null);
tslib_1.__decorate([
    neovim_1.Function('CocBufUnload', { sync: false })
], CompletePlugin.prototype, "cocBufUnload", null);
tslib_1.__decorate([
    neovim_1.Function('CocBufChange', { sync: false })
], CompletePlugin.prototype, "cocBufChange", null);
tslib_1.__decorate([
    neovim_1.Function('CocStart', { sync: false })
], CompletePlugin.prototype, "cocStart", null);
tslib_1.__decorate([
    neovim_1.Function('CocInsertCharPre', { sync: true })
], CompletePlugin.prototype, "cocInsertCharPre", null);
tslib_1.__decorate([
    neovim_1.Function('CocInsertLeave', { sync: false })
], CompletePlugin.prototype, "cocInsertLeave", null);
tslib_1.__decorate([
    neovim_1.Function('CocCompleteDone', { sync: true })
], CompletePlugin.prototype, "cocCompleteDone", null);
tslib_1.__decorate([
    neovim_1.Function('CocTextChangedP', { sync: true })
], CompletePlugin.prototype, "cocTextChangedP", null);
tslib_1.__decorate([
    neovim_1.Function('CocTextChangedI', { sync: true })
], CompletePlugin.prototype, "cocTextChangedI", null);
tslib_1.__decorate([
    neovim_1.Function('CocResult', { sync: false })
], CompletePlugin.prototype, "cocResult", null);

neovim

Nvim msgpack API client and remote plugin provider

MIT
Latest version published 2 months ago

Package Health Score

81 / 100
Full package analysis