How to use coc - 10 common examples

To help you get started, we’ve selected a few coc 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 neoclide / coc-sources / packages / omni / index.js View on Github external
doComplete: async function (opt) {
      let {nvim} = workspace
      let func = await nvim.eval('&omnifunc')
      if (!func) return null
      let {line, colnr, col} = opt
      let startcol = col
      try {
        startcol = await nvim.call(func, [1, ''])
        startcol = Number(startcol)
      } catch (e) {
        workspace.showMessage(`vim error from ${func} :${e.message}`, 'error')
        return null
      }
      // invalid startcol
      if (isNaN(startcol) || startcol < 0 || startcol > colnr) return null
      let text = byteSlice(line, startcol, colnr - 1)
      let [words] = await nvim.eval(`[${func}(0, '${text.replace(/'/g, "''")}'),cursor(${opt.linenr},${colnr})]`)
      if (!words || words.length == 0) return null
      if (words.hasOwnProperty('words')) {
        words = words.words
      }
      let res = {items: convertToItems(words, this.menu)}
      res.startcol = startcol
      return res
    }
  }))
github neoclide / coc-vetur / src / index.ts View on Github external
export async function activate(context: ExtensionContext): Promise {
  let { subscriptions } = context
  let c = workspace.getConfiguration()
  const config = c.get('vetur') as any
  const enable = config.enable
  if (enable === false) return
  let file: string
  let devPath = config.dev && config.dev.vlsPath // config.get('dev.vlsPath', null)
  if (devPath && fs.existsSync(devPath)) {
    file = path.join(devPath, 'dist/vueServerMain.js')
    if (!fs.existsSync(file)) {
      workspace.showMessage(`vetur server module "${file}" not found!`, 'error')
      return
    }
  } else {
    file = requireFunc.resolve('vue-language-server')
    if (!file) {
      workspace.showMessage('vue-language-server module not found!', 'error')
      return
    }
  }
  const selector: DocumentSelector = [{
    language: 'vue',
    scheme: 'file'
  }]

  let serverOptions: ServerOptions = {
    module: file,
github josa42 / coc-go / src / utils / tests.ts View on Github external
cp.execFile(gotests, args, {env: {}}, async (err, stdout, stderr) => {
      if (err) {
        workspace.showMessage(`Error: ${stderr}`, "error")
        return reject()
      }

      workspace.showMessage(stdout || "")

      resolve(true)
    })
  })
github NullVoxPopuli / coc-ember / src / index.ts View on Github external
function getConfig(): WorkspaceConfiguration {
  let config = workspace.getConfiguration('ember');

  return config;
}
github neoclide / coc-tsserver / src / server / index.ts View on Github external
constructor(private pluginManager: PluginManager) {
    const config = workspace.getConfiguration('tsserver')
    const enableJavascript = !!config.get('enableJavascript')
    this.enable = config.get('enable')
    this.descriptions = standardLanguageDescriptions.filter(o => {
      return enableJavascript ? true : o.id != 'javascript'
    })
    this.selector = this.descriptions.reduce((arr, c) => {
      return arr.concat(c.modeIds)
    }, [])
  }
github neoclide / coc-tsserver / src / server / typescriptServiceClientHost.ts View on Github external
private configurationChanged(): void {
    const config = workspace.getConfiguration('tsserver')
    this.reportStyleCheckAsWarnings = config.get('reportStyleChecksAsWarnings', true)
  }
github neoclide / coc-tsserver / src / server / features / fileConfigurationManager.ts View on Github external
public enableJavascript(): boolean {
    const config = workspace.getConfiguration('tsserver')
    return !!config.get('enableJavascript')
  }
github neoclide / coc-sources / packages / neosnippet / index.js View on Github external
doComplete: async function (opt) {
      let loaded = await nvim.getVar('loaded_neosnippet')
      if (!loaded) {
        if (!loadError) workspace.showMessage('Neosnippet not loaded', 'error')
        loadError = true
        return
      }
      let items = await getItems(opt.filetype, this.menu)
      return { items }
    },
    onCompleteDone: () => {
github neoclide / coc-tsserver / src / server / features / watchBuild.ts View on Github external
task.onStderr(lines => {
      workspace.showMessage(`TSC error: ` + lines.join('\n'), 'error')
    })
    this.disposables.push(Disposable.create(() => {
github neoclide / coc-vimtex / src / index.js View on Github external
exports.activate = async context => {
  let config = workspace.getConfiguration('coc.source.vimtex')
  let {nvim} = workspace

  let regex = await nvim.getVar('vimtex#re#deoplete')
  if (!regex) {
    workspace.showMessage('vimtex not loaded', 'error')
    return
  }
  regex = regex.slice(2, regex.length)
  let pattern = new RegExp(convertRegex(regex) + '$')

  function convertItems(list) {
    let res = []
    for (let item of list) {
      if (typeof item == 'string') {
        res.push(Object.assign({word: item}))
      }
      if (item.hasOwnProperty('word')) {
        res.push(item)
      }
    }
    return res

coc

ISC
Latest version published 9 years ago

Package Health Score

40 / 100
Full package analysis