Coc.nvim: UnhandledRejection: TypeError: Cannot read property 'workspaceFolders' of undefined

Created on 10 Jul 2020  Â·  12Comments  Â·  Source: neoclide/coc.nvim

Result from CocInfo

## versions

vim version: NVIM v0.4.3
node version: v14.5.0
coc.nvim version: 0.0.78
coc.nvim directory: /home/kgn/src/private/dotfiles/.config/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux

## Output channel: snippets

[Info 09.40.42] Using ultisnips directories: UltiSnips /home/kgn/.config/nvim/snippets
[Info 09.40.42] Using ultisnips python command: pyx

## Output channel: highlight

[Info  - 09.40.42] Highlight server running in node v14.5.0

Describe the bug

After upgrading to latest version of coc and coc-go I get an error when opening .go files
"UnhandledRejection: TypeError: Cannot read property 'workspaceFolders' of undefined" and all LSP related not working. The error only happens if coc-go is installed

Reproduce the bug

Install coc and coc-go
We will close your issue when you don't provide minimal vimrc and we can't
reproduce it

  • Create file mini.vim with:
let g:plugin_path = '~/.config/nvim/plugged'

if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
    echo "Downloading junegunn/vim-plug to manage plugins..."
    silent !mkdir -p ~/.config/nvim/autoload/
    silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
    autocmd VimEnter * PlugInstall
endif

call plug#begin(g:plugin_path)
    " Autocompletion
    Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
    " after installation of coc.vim I did a :CocInstall coc-tsserver coc-go
call plug#end()
  • Start (neo)vim with command: vim -u mini.vim

nvim -u minimal.vim main.go

processes the error: [coc.nvim]: UnhandledRejection: TypeError: Cannot read property 'workspaceFolders' of undefined

coc-settings.json:

{
  "suggest.noselect": true,
  "snippets.userSnippetsDirectory": "~/.config/nvim/snippets",
  "solargraph.diagnostics": true,
  "solargraph.autoformat": true,
  "solargraph.completion": true,
  "solargraph.formatting": true,
  "solargraph.useBundler": false,
  "solargraph.hover": true,
  "python.linting.enabled": true,
  "python.linting.pylintArgs": [
    "--extension-pkg-whitelist=dlib,cv2"
  ],
  "python.linting.pylamaEnabled":true,
  "python.linting.pylamaArgs": [
    "-i E501"
  ],
  "coc.source.buffer.enable": false,
  "coc.preferences.formatOnType": false,
  "coc.preferences.useQuickfixForLocations": true,
  "coc.preferences.formatOnSaveFiletypes": [
    "go"
  ]
}

Most helpful comment

solved for me by adding this config

{
  "go.disable": {
    "workspaceFolders": false
  }
}

ref : https://github.com/josa42/coc-go/pull/89

All 12 comments

Having the same issue.

Result from CocInfo

vim version: NVIM v0.5.0-553-gd8c5d122f
node version: v14.4.0
coc.nvim version: 0.0.78-449dcad0b2
coc.nvim directory: /home/vim/.local/share/nvim/plugged/coc.nvim
term: xterm-256color
platform: linux

Output channel: snippets

[Info 5:28:51 PM] Using ultisnips directories: UltiSnips /home/vim/.config/coc/ultisnips
[Info 5:28:51 PM] Using ultisnips python command: pyx

Output channel: highlight

[Info - 5:28:51 PM] Highlight server running in node v14.4.0

Reproduce the bug

  • Create file mini.vim with:

    set runtimepath^=/path/to/coc.nvim
    filetype plugin indent on
    syntax on
    set hidden
    
  • Start neovim with command: nvim -u mini.vim main.go

[coc.nvim]: UnhandledRejection: TypeError: Cannot read property 'workspaceFolders' of undefined

Having the same issue.

Having the same issue.

coc-settings.json
"golang": {
"command": "go-langserver",
"filetypes": ["go"],
"initializationOptions": {
"gocodeCompletionEnabled": true,
"diagnosticsEnabled": true,
"lintTool": "golint"
}
},

Having the same issue with gopls:

  "languageserver": {
    "golang": {
      "command": "gopls",
      "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"],
      "filetypes": ["go"],
      "initializationOptions": { "usePlaceholders": true }
    }
  }

There's an ongoing fix there: https://github.com/josa42/coc-go/issues/90

solved for me by adding this config

{
  "go.disable": {
    "workspaceFolders": false
  }
}

ref : https://github.com/josa42/coc-go/pull/89

solved for me by adding this config

{
  "go.disable": {
    "workspaceFolders": false
  }
}

ref : josa42/coc-go#89

solved by same way

solved for me by adding this config

{
  "go.disable": {
    "workspaceFolders": false
  }
}

ref : josa42/coc-go#89

Solved by same way

This looks fixed upstream on coc-go. Not reproducing it anymore.

Was this page helpful?
0 / 5 - 0 ratings