{"record":{"id":"1ab2173ffdcb54d2","repo":"neoclide/coc.nvim","slug":"function-coc-source-name-fn-not-found","errorCode":null,"errorMessage":"function \"coc#source#${name}#${fn}\" not found","messagePattern":"function \"coc#source#(.+?)#(.+?)\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/completion/sources.ts","lineNumber":127,"sourceCode":"      dispose: () => {\n        this.sourceMap.delete(name)\n      }\n    }\n  }\n  /**\n   * @internal\n   */\n\n  public async createVimSourceExtension(filepath: string): Promise<void> {\n    let { nvim } = this\n    try {\n      let name = path.basename(filepath, '.vim')\n      await nvim.command(`source ${filepath.split(path.sep).join(path.posix.sep)}`)\n      let fns = await nvim.call('coc#_remote_fns', name) as string[]\n      let lowercased = fns.map(fn => fn[0].toLowerCase() + fn.slice(1))\n      for (let fn of ['init', 'complete']) {\n        if (!lowercased.includes(fn)) {\n          throw new Error(`function \"coc#source#${name}#${fn}\" not found`)\n        }\n      }\n      let props = await nvim.call(`coc#source#${name}#${getMethodName('init', fns)}`, []) as VimSourceConfig\n      let packageJSON = {\n        name: `coc-vim-source-${name}`,\n        engines: {\n          coc: \">= 0.0.1\"\n        },\n        activationEvents: props.filetypes ? props.filetypes.map(f => `onLanguage:${f}`) : ['*'],\n        contributes: {\n          configuration: {\n            properties: {\n              [`coc.source.${name}.enable`]: {\n                type: 'boolean',\n                default: true\n              },\n              [`coc.source.${name}.firstMatch`]: {\n                type: 'boolean',","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/completion/sources.ts#L109-L145","documentation":"When coc loads a remote vim completion source, it asks the editor for the list of remote functions the source exports and requires that both 'init' and 'complete' (case-insensitively) exist. If either is missing, source loading aborts with this error, preventing a broken source from registering.","triggerScenarios":"Loading a .vim file as a completion source whose autoload functions do not include the required init/complete functions, e.g. the sourced file defines only 'on_enter' or the functions are not declared with coc#remote#init style registration.","commonSituations":"Installing a vim completion source plugin incompatible with current coc source API; function name typos; the remote-fns list not including expected names because the plugin was not properly sourced.","solutions":["Add the missing coc#source#<name>#init or #complete function to the .vim source","Verify the source with :echo coc#_remote_fns('<name>')","Update the source plugin to a coc-compatible version","Remove/disable the broken source plugin"],"exampleFix":"// before: source missing complete\nfunction! coc#source#demo#init() abort\n  return {...}\nendfunction\n// after\nfunction! coc#source#demo#complete(opt, cb) abort\n  call a:cb([], v:false)\nendfunction","handlingStrategy":"validation","validationCode":"const fns = await nvim.call('coc#_remote_fns', name)\nif (!['init','complete'].every(fn => fns.map(f=>f[0].toLowerCase()+f.slice(1)).includes(fn))) {\n  return logger.warn(`vim source ${name} missing required functions`)\n}","typeGuard":"const remoteSourceOk = (fns) => Array.isArray(fns) &&\n  fns.some(f => /^init$/i.test(f)) && fns.some(f => /^complete$/i.test(f))","tryCatchPattern":"try {\n  await createVimSources([filepath])\n} catch (e) {\n  if (String(e.message).includes('not found')) logger.warn(`skipping invalid vim source: ${e.message}`)\n  else throw e\n}","preventionTips":["Follow the documented coc remote source template exactly","Verify with :echo coc#_remote_fns('<name>') before relying on a source","Keep vim source plugins updated for coc API changes"],"tags":["completion","vim-source","loading"],"backgroundTag":"missing-function","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}