neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.47k stars 957 forks source link

Disable Chinese word-breaking #4828

Closed eight04 closed 8 months ago

eight04 commented 11 months ago

Result from CocInfo

``` ## versions vim version: VIM - Vi IMproved 9.0 9001046 node version: v20.5.1 coc.nvim version: 0.0.82-b7375d5f 2023-01-30 05:09:03 +0800 coc.nvim directory: C:\Users\eight04\vimfiles\pack\plugins\start\coc term: undefined platform: win32 ## Log of coc.nvim 2023-12-10T09:36:02.070 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:36:03.219 INFO (pid:11552) [plugin] - coc.nvim initialized with node: v20.5.1 after 6300 2023-12-10T09:36:03.222 INFO (pid:11552) [services] - LanguageClient ESLint state change: stopped => starting 2023-12-10T09:36:03.251 INFO (pid:11552) [language-client-index] - Language server "eslint" started with 11416 2023-12-10T09:36:03.832 INFO (pid:11552) [services] - service tsserver started 2023-12-10T09:36:03.844 INFO (pid:11552) [services] - LanguageClient ESLint state change: starting => running 2023-12-10T09:36:03.855 INFO (pid:11552) [services] - service eslint started 2023-12-10T09:36:18.045 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:36:24.608 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:36:26.124 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:36:26.576 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:36:28.217 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:37:08.139 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T09:37:08.607 INFO (pid:11552) [attach] - Request action: doAutocmd [ 1, 4 ] 2023-12-10T09:37:09.841 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T16:52:08.969 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:30:21.381 INFO (pid:11552) [services] - LanguageClient Pyright Server state change: stopped => starting 2023-12-10T17:30:21.411 INFO (pid:11552) [language-client-index] - Language server "pyright" started with 5224 2023-12-10T17:30:21.414 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:30:21.414 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:30:23.863 INFO (pid:11552) [services] - LanguageClient Pyright Server state change: starting => running 2023-12-10T17:30:23.870 INFO (pid:11552) [services] - service pyright started 2023-12-10T17:31:56.949 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:32:17.263 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:32:24.034 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:32:25.593 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:32:26.880 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:00.963 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:06.073 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:07.102 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:08.586 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:09.073 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:34.450 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:37.727 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:42.260 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:49.795 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:50.576 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:53.683 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:33:56.680 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:16.618 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:19.028 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:21.718 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:23.823 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:24.291 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:25.509 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:26.242 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:27.338 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:28.926 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:30.076 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:30.670 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:31.092 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:33.011 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:33.601 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:34.240 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:36.717 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:39.370 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:53.521 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:54.692 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:55.036 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:56.003 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:57.188 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:57.810 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:58.371 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:34:59.650 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:00.013 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:02.705 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:05.692 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:06.439 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:10.008 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:14.837 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T17:35:15.834 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:35.356 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:37.948 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:38.466 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:42.173 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:44.127 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:44.517 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:47.145 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:47.661 INFO (pid:11552) [attach] - Request action: doAutocmd [ 1, 158 ] 2023-12-10T19:28:48.054 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T19:28:55.872 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:28:00.811 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:28:03.429 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:28:03.942 INFO (pid:11552) [attach] - Request action: doAutocmd [ 1, 158 ] 2023-12-10T21:28:04.683 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:16.612 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:17.296 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:18.260 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:19.471 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:20.514 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:29.833 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:30.613 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:43.066 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:51.184 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:43:55.640 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:02.885 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:05.026 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:11.505 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:12.255 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:16.126 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:17.217 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:20.103 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:25.004 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:28.310 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:30.212 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:33.921 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:35.998 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:36.373 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:38.810 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:41.053 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:44.476 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:44.979 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T21:44:45.572 INFO (pid:11552) [attach] - Request action: doAutocmd [ 1, 160 ] 2023-12-10T21:44:45.931 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:18:40.262 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:21:43.289 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:21:44.442 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:21:45.530 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:21:46.419 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:21:50.707 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:21:52.110 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:24:21.632 INFO (pid:11552) [attach] - receive notification: highlight [] 2023-12-10T23:24:23.879 INFO (pid:11552) [attach] - receive notification: showInfo [] ```

Describe the bug

coc.nvim seems to breakup Chinese sentences into multiple words. However this is very inconvenient, we usually want to complete the entire string/item and completing a single Chinese character/word is pretty useless: image In the above image, 奶油泡芙 were broken into two words 奶油 and 泡芙; 冰牛奶 were broken into two words and 牛奶.

It would make more sense to break words by whitespaces and symbols.

Reproduce the bug

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

Screenshots (optional)

If applicable, add screenshots to help explain your problem.

fannheyward commented 11 months ago

You can disable this with suggest.asciiMatch.

eight04 commented 11 months ago

After changing suggestion.asciiMatch to false: image I can still reproduce the issue: image

eight04 commented 11 months ago

It seems that this issue was caused by this commit: https://github.com/neoclide/coc.nvim/commit/9181a83f14929e7cb62069d4c61c7515e78674e4

Can we have an option to configure granularity? I think sentence works better with daily coding.

fannheyward commented 11 months ago

Yes, suggestion.asciiMatch only control asscii input, not working on inputing Chinese character directly.

eight04 commented 11 months ago

I tried replacing granularity:"word" with granularity:"sentence" in coc/build/index.js but it didn't work.

eight04 commented 11 months ago

It seems we also need a isWordLike alternative. isWordLike doesn't work with sentences.

With the following change:

Intl.Segmenter("cn",{granularity:"sentence"}).segment(n);for(let i of t)1&&(yield i.segment)

image

fannheyward commented 11 months ago

I prefer a simple configuration to disable Chinese Segments in buffer/around sources.

eight04 commented 11 months ago

It seems we also need a isWordLike alternative. isWordLike doesn't work with sentences.

A simpler method is to stay with granularity:"word" but re-concat consecutive word-like segments into a single string. Then we will have the full sentence split by punctuation.

I prefer a simple configuration to disable Chinese Segments in buffer/around sources.

That should also work. It should be the old behavior before https://github.com/neoclide/coc.nvim/commit/9181a83f14929e7cb62069d4c61c7515e78674e4 right?

BTW I wonder why only Chinese got segmented. What about other languages?

fannheyward commented 11 months ago

why only Chinese got segmented

I remember someone mentioned this request in the Gitter chat, only Chinese sentence will be segmented to complete.