Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 })
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);
import { Plugin, Function, Autocmd, Command } from 'neovim'
import pify from 'pify'
import fs from 'fs'
import path from 'path'
@Plugin({ dev: false })
export default class NpmPlugin {
async findDirectory() {
let p = await this.nvim.eval('getcwd()')
while(true) {
if (!p || p == '/') break
try {
let stat = await pify(fs.stat)(path.join(p, 'package.json'))
if (stat.isFile()) {
return p
}
} catch (e) {
}
p = path.dirname(p)
}
}