coc.nvim
coc.nvim copied to clipboard
Occures Error when save the golang file with watchman
Result from CocInfo
CocInfo:
## versions
vim version: NVIM v0.8.2
node version: v19.5.0
coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800
coc.nvim directory: /Users/zls/.vim/plugged/coc.nvim
term: tmux
platform: darwin
## Log of coc.nvim
2023-02-01T03:51:22.358 INFO (pid:75922) [extension:coc-git] - Looking for git in: git
2023-02-01T03:51:22.414 INFO (pid:75922) [plugin] - coc.nvim initialized with node: v19.5.0 after 518
2023-02-01T03:51:22.417 INFO (pid:75922) [services] - LanguageClient golang state change: stopped => starting
2023-02-01T03:51:22.426 INFO (pid:75922) [language-client-index] - Language server "languageserver.golang" started with 76120
2023-02-01T03:51:22.531 INFO (pid:75922) [services] - LanguageClient golang state change: starting => running
2023-02-01T03:51:22.566 INFO (pid:75922) [services] - service languageserver.golang started
2023-02-01T03:51:23.406 INFO (pid:75922) [core-watchman] - watchman watching project: /Users/zls/workspace/project/src/github.com/whalecold/pilot-finder
2023-02-01T03:51:27.275 ERROR (pid:75922) [server] - uncaughtException TypeError: pattern is too long
at Ob (/Users/zls/.vim/plugged/coc.nvim/build/index.js:9:15878)
at m0.exports (/Users/zls/.vim/plugged/coc.nvim/build/index.js:9:14579)
at /Users/zls/.vim/plugged/coc.nvim/build/index.js:192:19466
at Array.filter (<anonymous>)
at ys.<anonymous> (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:19443)
at ys.emit (node:events:524:35)
at On.<anonymous> (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:14824)
at On.emit (node:events:512:28)
at On.process (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:10201)
at /Users/zls/.vim/plugged/coc.nvim/build/index.js:192:9803
2023-02-01T03:51:27.379 ERROR (pid:75922) [server] - uncaughtException Error: invalid bser int encoding 1, in Buffer of length 8192 (931 readable) at offset 1102 buffer: {"type":"Buffer","data":[1,4,173,1,1,3,8,2,3,12,115,117,98,115,99,114,105,112,116,105,111,110,2,3,36,97,53,52,48,99,99,56]}
at On.raise (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:10317)
at On.decodeInt (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:12084)
at On.decodeArray (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:11243)
at On.decodeAny (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:11037)
at On.process (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:10170)
at /Users/zls/.vim/plugged/coc.nvim/build/index.js:192:9803
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
2023-02-01T03:51:27.380 ERROR (pid:75922) [server] - uncaughtException Error: expected bser opcode 2 but got 1, in Buffer of length 8192 (1424 readable) at offset 1107 buffer: {"type":"Buffer","data":[3,8,2,3,12,115,117,98,115,99,114,105,112,116,105,111,110,2,3,36,97,53,52,48,99,99,56,48,45,97,49,97]}
at On.raise (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:10317)
at On.expectCode (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:10619)
at On.decodeString (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:11786)
at On.decodeObject (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:11420)
at On.decodeAny (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:11071)
at On.process (/Users/zls/.vim/plugged/coc.nvim/build/index.js:192:10170)
at /Users/zls/.vim/plugged/coc.nvim/build/index.js:192:9803
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
2023-02-01T03:51:30.971 INFO (pid:75922) [attach] - receive notification: showInfo []
Describe the bug
After installing watchman and opening a golang project, an error occurs when I use :w command to save file. And then it does not happen after removing watchman.
watchman version:
> watchman --version
2023.01.30.00

Reproduce the bug
We will close your issue when you don't provide minimal vimrc and we can't reproduce it
- Create file
mini.vimwith:
set nocompatible
set runtimepath^=/path/to/coc.nvim
filetype plugin indent on
syntax on
set hidden
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'preservim/nerdtree'
" Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'scrooloose/nerdtree-project-plugin'
Plug 'jiangmiao/auto-pairs'
Plug 'vim-airline/vim-airline'
" colorscheme
Plug 'morhetz/gruvbox'
Plug 'iamcco/mathjax-support-for-mkdp'
Plug 'iamcco/markdown-preview.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
" file search
Plug 'ctrlpvim/ctrlp.vim'
" grep plugin
" grepper is an Subset of LeaderF, so remove it.
" Plug 'mhinz/vim-grepper'
" restore cursor to file position in previous editing session
Plug 'farmergreg/vim-lastplace'
" plugin for rust
Plug 'rust-lang/rust.vim'
" plugin for intensely nerdy commenting powers
Plug 'preservim/nerdcommenter'
Plug 'rhysd/git-messenger.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'mattn/webapi-vim'
Plug 'preservim/tagbar'
" an efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly.
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
Plug 'whalecold/ZoomWin'
Plug 'APZelos/blamer.nvim'
"Plug 'dkprice/vim-easygrep'
"Plug 'othree/eregex.vim'
call plug#end()
-
Start (neo)vim with command:
vim -u mini.vimand open an golang project -
Operate vim with command
:w
Screenshots (optional)
If applicable, add screenshots to help explain your problem.
Can't reproduce, do you have any autocmd for saving? I don't find in your vimrc.
Can't reproduce, do you have any autocmd for saving? I don't find in your vimrc.
There is no error info when I try to open a small project, it is may be affected by the size of project ~
pattern is too long
Looks like this error came from glob, properly watchman checks long pattern in big project.
TypeError: pattern is too long
- language server will register watcher with globPattern, you can get this from the trace logs, for gopls, it want to watch go/mod/work files changes:
"watchers": [
{
"globPattern": "**/*.{mod,work}",
"kind": 7
},
{
"globPattern": {
"baseUri": "file:///Users/fannheyward/src/test",
"pattern": "**/*.{go,mod,sum,work}"
},
"kind": 7
}
]
- coc.nvim create a fileWatcher with watchman to watch files in project changes
- watchman detected any file changes, coc.nvim uses
minimatchto filter them with the globPattern, then fire file deleteEvent/createEvent/renameEvent etc
The issue is came from the minimatch step: minimatch limited the MAX_PATTERN_LENGTH, we got the pattern is too long error in big project.
We don't have any way to prevent this in coc.nvim side for now, maybe it's better to disable watchman in big project. Close for now.