diff options
Diffstat (limited to '.config/coc/extensions/node_modules/coc-go/lib/utils')
15 files changed, 0 insertions, 708 deletions
diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/checktag.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/checktag.js deleted file mode 100644 index 053604a..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/checktag.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const request_1 = require("./request"); -const releaseFilter = /^v\d+\.\d+\.\d+$/; -async function checkLatestTag(repo, prefixFilter) { - const data = await (0, request_1.getJSON)(`https://api.github.com/repos/${repo}/tags`); - if (!Array.isArray(data)) { - return ''; - } - let tags = data.map(t => t.name); - if (prefixFilter) { - tags = tags - .filter(t => t.match(prefixFilter)) - .map(t => t.replace(prefixFilter, '')); - } - tags = tags - .filter(t => t.match(releaseFilter)); - return tags.length > 0 - ? tags[0].replace(/^v/, '') - : ''; -} -exports.default = checkLatestTag; -//# sourceMappingURL=checktag.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/config.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/config.js deleted file mode 100644 index d60955c..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/config.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setState = exports.getState = exports.configDir = exports.setStoragePath = exports.getConfig = void 0; -const tslib_1 = require("tslib"); -const path_1 = tslib_1.__importDefault(require("path")); -const os_1 = tslib_1.__importDefault(require("os")); -const fs_1 = tslib_1.__importDefault(require("fs")); -const coc_nvim_1 = require("coc.nvim"); -const fs_2 = require("./fs"); -const state = {}; -function getConfig() { - return coc_nvim_1.workspace.getConfiguration().get("go"); -} -exports.getConfig = getConfig; -function setStoragePath(dir) { - state.storagePath = dir; -} -exports.setStoragePath = setStoragePath; -async function configDir(...names) { - const storage = state.storagePath || path_1.default.join(os_1.default.homedir(), ".config", "coc", "go"); - const dir = path_1.default.join(storage, ...names); - return new Promise((resolve) => { - (0, fs_2.createDir)(dir); - resolve(dir); - }); -} -exports.configDir = configDir; -async function stateFile() { - return path_1.default.join(await configDir(), 'state.json'); -} -async function getStateData() { - try { - const f = await stateFile(); - const d = JSON.parse(await fs_1.default.promises.readFile(f, 'utf-8')); - return d || {}; - } - catch (err) { /* mute */ } - return {}; -} -async function setStateData(data) { - try { - await fs_1.default.promises.writeFile(await stateFile(), JSON.stringify(data, null, ' ')); - } - catch (err) { /* mute */ } -} -async function getState(key) { - const d = await getStateData(); - return d[key] || ''; -} -exports.getState = getState; -async function setState(key, value) { - const d = await getStateData(); - d[key] = value; - await setStateData(d); -} -exports.setState = setState; -//# sourceMappingURL=config.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/fs.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/fs.js deleted file mode 100644 index 899b1fd..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/fs.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createDir = void 0; -const tslib_1 = require("tslib"); -const fs_1 = tslib_1.__importDefault(require("fs")); -const path_1 = tslib_1.__importDefault(require("path")); -function createDir(dirPath) { - if (fs_1.default.existsSync(dirPath)) { - return; - } - createDir(path_1.default.dirname(dirPath)); - fs_1.default.mkdirSync(dirPath); -} -exports.createDir = createDir; -//# sourceMappingURL=fs.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/fs.test.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/fs.test.js deleted file mode 100644 index 28c3ec9..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/fs.test.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -const tmp_1 = tslib_1.__importDefault(require("tmp")); -const assert_1 = tslib_1.__importDefault(require("assert")); -const path_1 = tslib_1.__importDefault(require("path")); -const fs_1 = tslib_1.__importDefault(require("fs")); -const fs_2 = require("./fs"); -describe('createDir()', () => { - let tmpDir; - const joinPath = (...parts) => path_1.default.join(tmpDir.name, ...parts); - beforeEach(() => tmpDir = tmp_1.default.dirSync({ unsafeCleanup: true })); - afterEach(() => tmpDir.removeCallback()); - it('should create a directory', () => { - const dirPath = joinPath('test'); - (0, fs_2.createDir)(dirPath); - assert_1.default.ok(fs_1.default.existsSync(dirPath)); - }); - it('should create nested directories', () => { - const dirPath = joinPath('test', 'foo', 'bar'); - (0, fs_2.createDir)(dirPath); - assert_1.default.ok(fs_1.default.existsSync(dirPath)); - }); - it('should not fail if directory exists', () => { - (0, fs_2.createDir)(tmpDir.name); - assert_1.default.ok(fs_1.default.existsSync(tmpDir.name)); - }); -}); -//# sourceMappingURL=fs.test.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/impl.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/impl.js deleted file mode 100644 index f616827..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/impl.js +++ /dev/null @@ -1,43 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.generateImplStubs = void 0; -const coc_nvim_1 = require("coc.nvim"); -const binaries_1 = require("../binaries"); -const tools_1 = require("./tools"); -const interfaceRegex = /^(\w+ \*?\w+ )?([\w./-]+)$/; -async function generateImplStubs(document) { - try { - const implInput = await coc_nvim_1.window.requestInput("Enter receiver and interface [f *File io.Closer]"); - if (implInput == null) { - coc_nvim_1.window.showMessage("No input detected! Aborting.", "warning"); - return; - } - const matches = implInput.match(interfaceRegex); - if (!matches) { - throw Error(`Cannot parse input: ${implInput}`); - } - const edit = await runGoImpl(document, [matches[1], matches[2]]); - await coc_nvim_1.workspace.applyEdit({ changes: { [document.uri]: [edit] } }); - } - catch (error) { - coc_nvim_1.window.showMessage(error, "error"); - } -} -exports.generateImplStubs = generateImplStubs; -async function runGoImpl(document, args) { - const stdout = await (0, tools_1.execTool)(binaries_1.IMPL, args); - const { line } = await coc_nvim_1.window.getCursorPosition(); - const insertPos = { line: line + 1, character: 0 }; - const lineText = await coc_nvim_1.workspace.getLine(document.uri, line); - const newText = lineText.trim() === '' - ? stdout - : `\n${stdout}`; - return { - range: { - start: insertPos, - end: insertPos - }, - newText - }; -} -//# sourceMappingURL=impl.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/lspcommands.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/lspcommands.js deleted file mode 100644 index 8e5b4c6..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/lspcommands.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.goplsTidy = void 0; -const coc_nvim_1 = require("coc.nvim"); -async function goplsTidy() { - const doc = await coc_nvim_1.workspace.document; - await coc_nvim_1.commands.executeCommand('gopls.tidy', { URIs: [doc.uri] }); -} -exports.goplsTidy = goplsTidy; -//# sourceMappingURL=lspcommands.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/modify-tags.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/modify-tags.js deleted file mode 100644 index ca80186..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/modify-tags.js +++ /dev/null @@ -1,113 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.clearTags = exports.removeTags = exports.addTags = void 0; -const coc_nvim_1 = require("coc.nvim"); -const vscode_uri_1 = require("vscode-uri"); -const tools_1 = require("./tools"); -const binaries_1 = require("../binaries"); -//////////////////////////////////////////////////////////////////////////////// -async function addTags(document, params = {}) { - const config = coc_nvim_1.workspace.getConfiguration().get('go.tags', {}); - let tags = (params.tags && params.tags.length > 0) - ? params.tags.join(',') - : (config.tags || 'json'); - let options = (config.options || config.options === "") - ? config.options - : 'json=omitempty'; - const transform = (config.transform || "snakecase"); - const skipUnexported = config.skipUnexported; - let cursor; - if (params.prompt) { - cursor = await coc_nvim_1.window.getCursorPosition(); - tags = await coc_nvim_1.window.requestInput('Enter comma separated tag names', tags); - if (!tags) { - return; - } - options = await coc_nvim_1.window.requestInput('Enter comma separated options', options); - } - const args = [ - '-add-tags', tags.replace(/ +/g, ''), - '-override', - '-add-options', (options || ""), - '-transform', transform, - ...(await offsetArgs(document, (params.selection || "struct"), cursor)) - ]; - if (skipUnexported) { - args.push('--skip-unexported'); - } - await runGomodifytags(document, args); -} -exports.addTags = addTags; -async function removeTags(document, params = {}) { - const config = coc_nvim_1.workspace.getConfiguration().get('go.tags', {}); - let tags = (params.tags && params.tags.length > 0) - ? params.tags.join(',') - : (config.tags || 'json'); - let cursor; - if (params.prompt) { - cursor = await coc_nvim_1.window.getCursorPosition(); - tags = await coc_nvim_1.window.requestInput('Enter comma separated tag names', tags); - if (!tags) { - return; - } - } - await runGomodifytags(document, [ - '-remove-tags', (tags || "json"), - '-clear-options', - ...(await offsetArgs(document, (params.selection || "struct"), cursor)) - ]); -} -exports.removeTags = removeTags; -async function clearTags(document, params = {}) { - await runGomodifytags(document, [ - '-clear-tags', - '-clear-options', - ...(await offsetArgs(document, (params.selection || "struct"))) - ]); -} -exports.clearTags = clearTags; -//////////////////////////////////////////////////////////////////////////////// -async function runGomodifytags(document, args) { - const fileName = vscode_uri_1.URI.parse(document.uri).fsPath; - args.push('-modified', '-file', fileName, '-format', 'json'); - const input = fileArchive(fileName, document.getText()); - const edit = await execGomodifytags(args, input); - await coc_nvim_1.workspace.applyEdit({ changes: { [document.uri]: [edit] } }); -} -async function execGomodifytags(args, input) { - try { - const stdout = await (0, tools_1.execTool)(binaries_1.GOMODIFYTAGS, args, input); - const mods = JSON.parse(stdout); - return { - range: { - start: { line: mods.start - 1, character: 0 }, - end: { line: mods.end, character: 0 } - }, - newText: mods.lines.join("\n") + "\n" - }; - } - catch (err) { - coc_nvim_1.window.showMessage(`Cannot modify tags: ${err}`, 'error'); - throw err; - } -} -function fileArchive(fileName, fileContents) { - return fileName + '\n' + Buffer.byteLength(fileContents, 'utf8') + '\n' + fileContents; -} -// https://github.com/golang/vscode-go/blob/master/src/util.ts#L84 -function byteOffsetAt(document, position) { - const offset = document.offsetAt(position); - const text = document.getText(); - return Buffer.byteLength(text.substr(0, offset)).toString(); -} -async function offsetArgs(document, selection, cursor = null) { - cursor = cursor || await coc_nvim_1.window.getCursorPosition(); - coc_nvim_1.window.showMessage(`selection = ${selection}`); - switch (selection) { - case "struct": - return ['-offset', byteOffsetAt(document, cursor)]; - case "line": - return ['-line', String(cursor.line + 1)]; - } -} -//# sourceMappingURL=modify-tags.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/playground.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/playground.js deleted file mode 100644 index 9fef796..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/playground.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.openPlayground = void 0; -const coc_nvim_1 = require("coc.nvim"); -const tools_1 = require("./tools"); -const binaries_1 = require("../binaries"); -async function openPlayground(document) { - return runGoplay(document.getText()); -} -exports.openPlayground = openPlayground; -async function runGoplay(code) { - try { - const stdout = await (0, tools_1.execTool)(binaries_1.GOPLAY, ['-'], code); - coc_nvim_1.window.showMessage(stdout); - return true; - } - catch (err) { - coc_nvim_1.window.showMessage(`${err}`, "error"); - return false; - } -} -//# sourceMappingURL=playground.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/request.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/request.js deleted file mode 100644 index ad7c968..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/request.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getJSON = void 0; -const tslib_1 = require("tslib"); -const https_1 = tslib_1.__importDefault(require("https")); -const options = { - headers: { - 'User-Agent': `coc-go`, - } -}; -function getJSON(url) { - return new Promise((resolve, reject) => { - https_1.default.get(url, options, (res) => { - let body = ''; - res.on('data', (chunk) => (body += chunk)); - res.on('end', () => { - try { - resolve(JSON.parse(body)); - } - catch (err) { - reject(err); - } - }); - }).on('error', reject); - }); -} -exports.getJSON = getJSON; -//# sourceMappingURL=request.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/tests.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/tests.js deleted file mode 100644 index 4aa14b2..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/tests.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.extractFunctionName = exports.toogleTests = exports.generateTestsFunction = exports.generateTestsExported = exports.generateTestsAll = void 0; -const coc_nvim_1 = require("coc.nvim"); -const vscode_uri_1 = require("vscode-uri"); -const tools_1 = require("./tools"); -const binaries_1 = require("../binaries"); -//////////////////////////////////////////////////////////////////////////////// -async function generateTestsAll(document) { - if (isTest(document)) { - coc_nvim_1.window.showMessage("Document is a test file", "error"); - return; - } - await runGotests(document, ["-all"]) && await openTests(document); -} -exports.generateTestsAll = generateTestsAll; -async function generateTestsExported(document) { - if (isTest(document)) { - coc_nvim_1.window.showMessage("Document is a test file", "error"); - return; - } - await runGotests(document, ["-exported"]) && await openTests(document); -} -exports.generateTestsExported = generateTestsExported; -async function generateTestsFunction(document) { - if (isTest(document)) { - coc_nvim_1.window.showMessage("Document is a test file", "error"); - return; - } - const { line } = await coc_nvim_1.window.getCursorPosition(); - const text = await document.getText({ - start: { line, character: 0 }, - end: { line, character: Infinity }, - }); - coc_nvim_1.window.showMessage(text); - const funcName = extractFunctionName(text); - if (!funcName) { - coc_nvim_1.window.showMessage("No function found", "error"); - return; - } - await runGotests(document, ["-only", `^${funcName}$`]) && await openTests(document); -} -exports.generateTestsFunction = generateTestsFunction; -async function toogleTests(document) { - const targetURI = isTest(document) - ? sourceURI(document) - : testURI(document); - return coc_nvim_1.workspace.openResource(targetURI); -} -exports.toogleTests = toogleTests; -//////////////////////////////////////////////////////////////////////////////// -async function openTests(document) { - return coc_nvim_1.workspace.openResource(testURI(document)); -} -function isTest(document) { - return document.uri.endsWith('_test.go'); -} -function testURI(document) { - return document.uri.replace(/(_test)?\.go$/, '_test.go'); -} -function sourceURI(document) { - return document.uri.replace(/(_test)?\.go$/, '.go'); -} -async function runGotests(document, args) { - const config = coc_nvim_1.workspace.getConfiguration().get('go.tests', {}); - args.push(...(config.generateFlags || []), '-w', vscode_uri_1.URI.parse(document.uri).fsPath); - try { - const stdout = await (0, tools_1.execTool)(binaries_1.GOTESTS, args); - coc_nvim_1.window.showMessage(stdout || ""); - return true; - } - catch (err) { - coc_nvim_1.window.showMessage(`Error: ${err}`, "error"); - return false; - } -} -//////////////////////////////////////////////////////////////////////////////// -function extractFunctionName(line) { - const m = /^func +(\([^)]+\) +)?([^\s(]+)/.exec(line); - if (m) { - return m[2]; - } -} -exports.extractFunctionName = extractFunctionName; -//# sourceMappingURL=tests.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/tests.test.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/tests.test.js deleted file mode 100644 index 70d0801..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/tests.test.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -const assert_1 = tslib_1.__importDefault(require("assert")); -const tests_1 = require("./tests"); -describe('extractFunctionName()', () => { - const cases = [ - ['', null], - ['\tfuncFoo()', null], - ['func Foo() {', 'Foo'], - ['func Foo() string {', 'Foo'], - ['func Foo(str string) string {', 'Foo'], - ['func (b *Bar) Foo(str string) string {', 'Foo'], - ]; - cases.forEach(([line, name]) => { - it(`should extract ${JSON.stringify(name)} from "${line}"`, () => { - assert_1.default.equal(name, (0, tests_1.extractFunctionName)(line)); - }); - }); -}); -//# sourceMappingURL=tests.test.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/tools.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/tools.js deleted file mode 100644 index 375db4a..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/tools.js +++ /dev/null @@ -1,149 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.execTool = exports.commandExists = exports.runBin = exports.runGoTool = exports.goBinPath = exports.installGoBin = void 0; -const tslib_1 = require("tslib"); -const path_1 = tslib_1.__importDefault(require("path")); -const fs_1 = tslib_1.__importDefault(require("fs")); -const util_1 = tslib_1.__importDefault(require("util")); -const child_process_1 = require("child_process"); -const coc_nvim_1 = require("coc.nvim"); -const which_1 = tslib_1.__importDefault(require("which")); -const config_1 = require("./config"); -const versions_1 = require("./versions"); -const runExec = util_1.default.promisify(child_process_1.exec); -const isWin = process.platform === 'win32'; -async function installGoBin(source, force = false, getVersion) { - const name = goBinName(source); - if (!force && await goBinExists(name)) { - return true; - } - const statusItem = coc_nvim_1.window.createStatusBarItem(90, { progress: true }); - statusItem.text = `Installing '${name}'`; - statusItem.show(); - const success = await goInstall(source) && await goBinExists(name); - if (success) { - const vname = getVersion ? `${name}@${await getVersion()}` : name; - coc_nvim_1.window.showMessage(`Installed '${vname}'`); - } - else { - coc_nvim_1.window.showMessage(`Failed to install '${name}'`, 'error'); - } - statusItem.hide(); - return success; -} -exports.installGoBin = installGoBin; -async function goInstall(source) { - return await goVersionOrLater('1.17.0') - ? goRun(`install ${source}@latest`) - : goRun(`get ${source}@latest`); -} -async function goVersionOrLater(version) { - try { - return (0, versions_1.compareVersions)(version, await getGoVersion()) < 0; - } - catch (err) { - // mute - } - return false; -} -async function getGoVersion() { - try { - const [, out] = await runBin('go', ['version']); - return out.trim().match(/^go version go(\S+) .*$/)[1]; - } - catch (err) { - // mute - } - return ''; -} -async function goBinPath(source) { - const name = goBinName(source); - return path_1.default.join(await (0, config_1.configDir)('bin'), name + (isWin ? ".exe" : "")); -} -exports.goBinPath = goBinPath; -async function runGoTool(name, args = []) { - return runBin(await goBinPath(name), args); -} -exports.runGoTool = runGoTool; -async function runBin(bin, args = []) { - return new Promise((resolve) => { - const p = (0, child_process_1.spawn)(bin, args); - let out = ""; - p.stdout.on('data', (data) => out += data); - p.on("close", code => resolve([code, out])); - }); -} -exports.runBin = runBin; -async function commandExists(command) { - if (path_1.default.isAbsolute(command)) { - return fileExists(command); - } - return new Promise((resolve) => { (0, which_1.default)(command, (err) => resolve(err == null)); }); -} -exports.commandExists = commandExists; -//////////////////////////////////////////////////////////////////////////////// -async function goBinExists(source) { - const name = goBinName(source); - const bin = await goBinPath(name); - return fileExists(bin); -} -async function fileExists(path) { - return new Promise((resolve) => fs_1.default.open(path, 'r', (err) => resolve(err === null))); -} -async function goRun(args) { - const gopath = await (0, config_1.configDir)('tools'); - const gobin = await (0, config_1.configDir)('bin'); - const env = { - GO111MODULE: 'on', - GOBIN: gobin, - GOPATH: gopath, - GOROOT: '', - GOTOOLDIR: '', - }; - const cmd = isWin - ? `go ${args}` - : `env GOBIN="${gobin}" go ${args}`; - const opts = { - env: Object.assign({}, process.env, env), - cwd: gopath, - shell: isWin ? undefined : process.env.SHELL, - windowsHide: true, - }; - try { - await runExec(cmd, opts); - } - catch (ex) { - coc_nvim_1.window.showMessage(ex, 'error'); - return false; - } - return true; -} -async function execTool(source, args, input) { - const [bin, name] = await Promise.all([ - goBinPath(source), - goBinName(source), - ]); - if (!await commandExists(bin)) { - await installGoBin(source); - } - return new Promise((resolve, reject) => { - const p = (0, child_process_1.execFile)(bin, args, { cwd: coc_nvim_1.workspace.cwd }, async (err, stdout, stderr) => { - if (err && err.code === "ENOENT") { - return reject(`Error: Command ${name} not found! Run "CocCommand go.install.${name}" to install it and try again.`); - } - if (err) { - return reject(stderr.toString()); - } - return resolve(stdout.toString()); - }); - if (p.pid) { - p.stdin.end(input); - } - }); -} -exports.execTool = execTool; -//////////////////////////////////////////////////////////////////////////////// -function goBinName(source) { - return source.replace(/\/\.\.\.$/, '').split('/').pop(); -} -//# sourceMappingURL=tools.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/ui.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/ui.js deleted file mode 100644 index 772354e..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/ui.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.withProgress = void 0; -const coc_nvim_1 = require("coc.nvim"); -// eslint-disable-next-line no-unused-vars -async function withProgress(text, fn) { - const status = coc_nvim_1.window.createStatusBarItem(90, { progress: true }); - // Show status item at leaste one second - let offset = 1000; - const t = setTimeout(() => (offset = 0), offset); - const dispose = () => { - clearTimeout(t); - setTimeout(() => status.dispose(), offset); - }; - status.text = text; - status.show(); - await fn(status); - dispose(); -} -exports.withProgress = withProgress; -//# sourceMappingURL=ui.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/versions.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/versions.js deleted file mode 100644 index 1bcd82a..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/versions.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.parseVersion = exports.compareVersions = exports.isValidVersion = void 0; -const versionExp = /^v?(\d+)\.(\d+)(\.(\d+))?$/; -function isValidVersion(version) { - return Boolean(version.trim().match(versionExp)); -} -exports.isValidVersion = isValidVersion; -function compareVersions(version1, version2) { - const v1 = parseVersion(version1); - const v2 = parseVersion(version2); - for (let i = 0; i < 3; i++) { - if (v1[i] !== v2[i]) { - return Math.max(-1, Math.min(1, v1[i] - v2[i])); - } - } - return 0; -} -exports.compareVersions = compareVersions; -function parseVersion(v) { - let ver = [0, 0, 0]; - const match = v.trim().match(versionExp); - if (match) { - const [, major, minor, , patch = '0'] = match; - ver = [parseInt(major), parseInt(minor), parseInt(patch)]; - } - if (!isValidVersion(v)) { - throw new Error(`'${v}' is not a valid version`); - } - return ver; -} -exports.parseVersion = parseVersion; -//# sourceMappingURL=versions.js.map
\ No newline at end of file diff --git a/.config/coc/extensions/node_modules/coc-go/lib/utils/versions.test.js b/.config/coc/extensions/node_modules/coc-go/lib/utils/versions.test.js deleted file mode 100644 index 640786f..0000000 --- a/.config/coc/extensions/node_modules/coc-go/lib/utils/versions.test.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -const assert_1 = tslib_1.__importDefault(require("assert")); -const versions_1 = require("./versions"); -const v0_0_0 = [0, 0, 0]; -const v1_0_0 = [1, 0, 0]; -const v1_2_0 = [1, 2, 0]; -const v1_2_3 = [1, 2, 3]; -describe('isValidVersion()', () => { - it('should recognise valid versions', () => { - assert_1.default.ok((0, versions_1.isValidVersion)('v1.0.0')); - assert_1.default.ok((0, versions_1.isValidVersion)('1.0.0')); - assert_1.default.ok((0, versions_1.isValidVersion)('0.1.0')); - assert_1.default.ok((0, versions_1.isValidVersion)('0.0.1')); - assert_1.default.ok((0, versions_1.isValidVersion)('0.0.0')); - assert_1.default.ok((0, versions_1.isValidVersion)('v0.0.0')); - }); - it('should recognise invalid versions', () => { - assert_1.default.ok(!(0, versions_1.isValidVersion)('v 1.0.0')); - assert_1.default.ok(!(0, versions_1.isValidVersion)('1')); - assert_1.default.ok((0, versions_1.isValidVersion)('1.1')); - }); -}); -describe("parseVersion()", () => { - it("should parse simple versions", () => { - assert_1.default.deepStrictEqual((0, versions_1.parseVersion)('v0.0.0'), v0_0_0); - assert_1.default.deepStrictEqual((0, versions_1.parseVersion)('v1.0.0'), v1_0_0); - assert_1.default.deepStrictEqual((0, versions_1.parseVersion)('v1.2.0'), v1_2_0); - assert_1.default.deepStrictEqual((0, versions_1.parseVersion)('v1.2'), v1_2_0); - assert_1.default.deepStrictEqual((0, versions_1.parseVersion)('v1.2.3'), v1_2_3); - }); -}); -describe('compareVersions()', () => { - it('should compare equal version', () => { - assert_1.default.throws(() => (0, versions_1.compareVersions)('', '')); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.0.0', '1.0.0'), 0); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.2.0', '1.2.0'), 0); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.2.3', '1.2.3'), 0); - assert_1.default.strictEqual((0, versions_1.compareVersions)('v1.0.0', '1.0.0'), 0); - }); - it('should compare greater version', () => { - assert_1.default.throws(() => (0, versions_1.compareVersions)('', '')); - assert_1.default.strictEqual((0, versions_1.compareVersions)('2.0.0', '1.0.0'), 1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.1.0', '1.0.0'), 1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.0.4', '1.0.0'), 1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('v1.1.0', '1.0.0'), 1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.1.0', 'v1.0.0'), 1); - }); - it('should compare smaller version', () => { - assert_1.default.throws(() => (0, versions_1.compareVersions)('', '')); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.0.0', '2.0.0'), -1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.0.0', '1.1.0'), -1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.0.0', '1.0.4'), -1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('1.0.0', 'v1.1.0'), -1); - assert_1.default.strictEqual((0, versions_1.compareVersions)('v1.0.0', '1.1.0'), -1); - }); -}); -//# sourceMappingURL=versions.test.js.map
\ No newline at end of file |
