How to use the vscode-uri.URI.parse function in vscode-uri

To help you get started, we’ve selected a few vscode-uri 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 ocaml-lsp / ocaml-language-server / src / bin / server / processes / merlin.ts View on Github external
public sync({ sync: query }: merlin.Sync, id?: LSP.TextDocumentIdentifier): merlin.Response {
    // this.session.connection.console.log(
    //   JSON.stringify({ query, id, priority }),
    // );
    const context: ["auto", string] | undefined = id ? ["auto", URI.parse(id.uri).fsPath] : undefined;
    const request = context ? { context, query } : query;
    return new Promise(resolve => {
      const task = new merlin.Task(request);
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      const callback: async.AsyncResultArrayCallback<i> = (value: any) =&gt; {
        resolve(null == value ? undefined : value);
      };
      this.queue.push(task, 0, callback);
    });
  }
</i>
github ocaml-lsp / ocaml-language-server / src / bin / server / virtual / resource.ts View on Github external
if (null == localappdataFile) throw new Error("LOCALAPPDATA must be set in environment to interpret WSL /home");
      // FIXME: compute localappdata earlier and do it only once
      const localappdata = URI.file(localappdataFile).toString(skipEncoding);
      let match: RegExpMatchArray | null = null;
      // rewrite /mnt/…
      if (null != (match = uri.match(/^file:\/\/\/mnt\/([a-zA-Z])\/(.*)$/))) {
        match.shift();
        const drive = match.shift() as string;
        const rest = match.shift() as string;
        return URI.parse(`file:///${drive}:/${rest}`);
      }
      // rewrite /home/…
      if (null != (match = uri.match(/^file:\/\/\/home\/(.+)$/))) {
        match.shift();
        const rest = match.shift() as string;
        return URI.parse(`${localappdata}/lxss/home/${rest}`);
      }
      throw new Error("unreachable");
    };
    switch (this.source) {
github streetsidesoftware / cspell / packages / cspell-lib / src / exclusionHelper.ts View on Github external
function testUriPath(uriPath: string): boolean {
        const uri = Uri.parse(uriPath);
        return testUri(uri);
    }
    return testUriPath;
github streetsidesoftware / vscode-spell-checker / packages / _server / src / documentSettings.ts View on Github external
private resolveConfigImports(config: CSpellUserSettings, folderUri: string): CSpellUserSettings {
        const uriFsPath = Uri.parse(folderUri).fsPath;
        const imports = typeof config.import === 'string' ? [config.import] : config.import || [];
        if (!imports.length) {
            return config;
        }
        const importAbsPath = imports.map(file => path.resolve(file, uriFsPath));
        return CSpell.mergeSettings(CSpell.readSettingsFiles(importAbsPath), config);
    }
}
github streetsidesoftware / vscode-spell-checker / packages / _server / src / documentSettings.ts View on Github external
function configPathsForRoot(workspaceRootUri?: string) {
    const workspaceRoot = workspaceRootUri ? Uri.parse(workspaceRootUri).fsPath : '';
    const paths = workspaceRoot ? [
        path.join(workspaceRoot, '.vscode', CSpell.defaultSettingsFilename.toLowerCase()),
        path.join(workspaceRoot, '.vscode', CSpell.defaultSettingsFilename),
        path.join(workspaceRoot, '.' + CSpell.defaultSettingsFilename.toLowerCase()),
        path.join(workspaceRoot, CSpell.defaultSettingsFilename.toLowerCase()),
        path.join(workspaceRoot, CSpell.defaultSettingsFilename),
    ] : [];
    return paths;
}
github neoclide / coc.nvim / src / workspace.ts View on Github external
let { nvim } = this
    let doc = this.getDocument(uri)
    let bufnr = doc ? doc.bufnr : -1
    await nvim.command(`normal! m'`)
    if (bufnr == this.bufnr && jumpCommand == 'edit') {
      if (position) await this.moveTo(position)
    } else if (bufnr != -1 && jumpCommand == 'edit') {
      let moveCmd = ''
      if (position) {
        let line = doc.getline(position.line)
        let col = byteLength(line.slice(0, position.character)) + 1
        moveCmd = position ? `+call\\ cursor(${position.line + 1},${col})` : ''
      }
      await this.nvim.call('coc#util#execute', [`buffer ${moveCmd} ${bufnr}`])
    } else {
      let { fsPath, scheme } = URI.parse(uri)
      let pos = position == null ? null : [position.line + 1, position.character + 1]
      if (scheme == 'file') {
        let bufname = fixDriver(path.normalize(fsPath))
        await this.nvim.call('coc#util#jump', [jumpCommand, bufname, pos])
      } else {
        await this.nvim.call('coc#util#jump', [jumpCommand, uri, pos])
      }
    }
  }
github neoclide / coc.nvim / src / configuration / index.ts View on Github external
affectsConfiguration: (section, resource) => {
        if (!resource || target != ConfigurationTarget.Workspace) return changed.indexOf(section) !== -1
        let u = URI.parse(resource)
        if (u.scheme !== 'file') return changed.indexOf(section) !== -1
        let filepath = u.fsPath
        let preRoot = workspaceConfigFile ? path.resolve(workspaceConfigFile, '../..') : ''
        if (configFile && !isParentFolder(preRoot, filepath, true) && !isParentFolder(path.resolve(configFile, '../..'), filepath)) {
          return false
        }
        return changed.indexOf(section) !== -1
      }
    })
github neoclide / coc.nvim / src / workspace.ts View on Github external
public getDocument(uri: number | string): Document {
    if (typeof uri === 'number') {
      return this.buffers.get(uri)
    }
    uri = URI.parse(uri).toString()
    for (let doc of this.buffers.values()) {
      if (doc && doc.uri === uri) return doc
    }
    return null
  }
github crashco / ember-template-component-import / lib / langserver.js View on Github external
function uriToPath(stringUri) {
	const uri = URI.parse(stringUri);
	if (uri.scheme !== 'file') {
			return undefined;
	}
	return uri.fsPath;
}