neoclide / coc.nvim

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

"Cannot assign to read only property" when loading a LSP with overidden settings #4887

Closed lf- closed 7 months ago

lf- commented 8 months ago

Result from CocInfo

CocInfo ``` ## versions vim version: NVIM v0.10.0-dev-1254+g386bc23e43 node version: v21.6.1 coc.nvim version: 0.0.82-master coc.nvim directory: /home/jade/dev/coc.nvim term: alacritty platform: linux ## Log of coc.nvim 2024-02-05T21:37:13.421 INFO (pid:2935688) [configurations] - Add folder configuration from cwd: /home/jade/.dotfiles/programs/hsutils/.vim/coc-settings.json 2024-02-05T21:37:13.591 INFO (pid:2935688) [plugin] - coc.nvim initialized with node: v21.6.1 after 215 2024-02-05T21:37:24.421 INFO (pid:2935688) [services] - LanguageClient haskell state change: stopped => starting 2024-02-05T21:37:24.437 INFO (pid:2935688) [language-client-index] - Language server "languageserver.haskell" started with 2935707 2024-02-05T21:37:24.487 INFO (pid:2935688) [core-watchman] - watchman watching project: /home/jade/.dotfiles/programs/hsutils 2024-02-05T21:37:27.684 INFO (pid:2935688) [services] - LanguageClient haskell state change: starting => running 2024-02-05T21:37:27.691 ERROR (pid:2935688) [language-client-client] - Server languageserver.haskell initialization failed. TypeError: Cannot assign to read only property 'formattingProvider' of object '#' at mergeConfigProperties (/home/jade/dev/coc.nvim/build/index.js:40351:18) at SyncConfigurationFeature.getConfiguredSettings (/home/jade/dev/coc.nvim/build/index.js:70980:16) at didChangeConfiguration (/home/jade/dev/coc.nvim/build/index.js:70968:71) at SyncConfigurationFeature.onDidChangeConfiguration (/home/jade/dev/coc.nvim/build/index.js:70972:100) at SyncConfigurationFeature.register (/home/jade/dev/coc.nvim/build/index.js:70933:16) at SyncConfigurationFeature.initialize (/home/jade/dev/coc.nvim/build/index.js:70916:16) at LanguageClient.initializeFeatures (/home/jade/dev/coc.nvim/build/index.js:75302:19) at LanguageClient.doInitialize (/home/jade/dev/coc.nvim/build/index.js:74940:16) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async LanguageClient._start (/home/jade/dev/coc.nvim/build/index.js:74716:11) 2024-02-05T21:37:27.692 INFO (pid:2935688) [services] - LanguageClient haskell state change: running => stopped 2024-02-05T21:37:27.693 ERROR (pid:2935688) [services] - Server languageserver.haskell failed to start: TypeError: Cannot assign to read only property 'formattingProvider' of object '#' at mergeConfigProperties (/home/jade/dev/coc.nvim/build/index.js:40351:18) at SyncConfigurationFeature.getConfiguredSettings (/home/jade/dev/coc.nvim/build/index.js:70980:16) at didChangeConfiguration (/home/jade/dev/coc.nvim/build/index.js:70968:71) at SyncConfigurationFeature.onDidChangeConfiguration (/home/jade/dev/coc.nvim/build/index.js:70972:100) at SyncConfigurationFeature.register (/home/jade/dev/coc.nvim/build/index.js:70933:16) at SyncConfigurationFeature.initialize (/home/jade/dev/coc.nvim/build/index.js:70916:16) at LanguageClient.initializeFeatures (/home/jade/dev/coc.nvim/build/index.js:75302:19) at LanguageClient.doInitialize (/home/jade/dev/coc.nvim/build/index.js:74940:16) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async LanguageClient._start (/home/jade/dev/coc.nvim/build/index.js:74716:11) ```

Describe the bug

When my language server is started, with the following configuration in ~/.config/nvim/coc-settings.json, and a conflicting workspace configuration, it fails to start due to Coc throwing an exception.

global config:

{
    "languageserver": {
        "haskell": {
            "command": "direnv-hls",
            "args": ["--lsp"],
            "rootPatterns": [
                "*.cabal",
                "stack.yaml",
                "cabal.project",
                "package.yaml",
                "hie.yaml"
            ],
            "filetypes": ["haskell", "lhaskell"],
            "settings": {
                "haskell": {
                    "formattingProvider": "fourmolu",
                },
            },
            // "trace.server": "verbose",
            // "trace.server.verbosity": "verbose",
        },
    }
}

workspace config (.vim/coc-settings.json):

{
    "languageserver": {
        "haskell": {
            "command": "direnv-hls",
            "settings": {
                "haskell.formattingProvider": "fourmolu"
            },
            "filetypes": ["haskell"]
        }
    }
}

Relative to commit: 9c079ad79d66d4ede7886cc4094a822352559502; Here is a resolved stacktrace using source maps.

Exception has occurred: TypeError: Cannot assign to read only property 'formattingProvider' of object '#<Object>'
  at mergeConfigProperties (/home/jade/dev/coc.nvim/src/configuration/util.ts:145:16)
    at Function.getConfiguredSettings (/home/jade/dev/coc.nvim/src/language-client/configuration.ts:212:12)
    at didChangeConfiguration (/home/jade/dev/coc.nvim/src/language-client/configuration.ts:199:67)
    at SyncConfigurationFeature.onDidChangeConfiguration (/home/jade/dev/coc.nvim/src/language-client/configuration.ts:203:96)
    at SyncConfigurationFeature.register (/home/jade/dev/coc.nvim/src/language-client/configuration.ts:162:12)
    at SyncConfigurationFeature.initialize (/home/jade/dev/coc.nvim/src/language-client/configuration.ts:143:12)
    at LanguageClient.initializeFeatures (/home/jade/dev/coc.nvim/src/language-client/client.ts:1531:15)
    at LanguageClient.doInitialize (/home/jade/dev/coc.nvim/src/language-client/client.ts:1075:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at LanguageClient._start (/home/jade/dev/coc.nvim/src/language-client/client.ts:835:7)

Reproduce the bug

vimrc:

set nocompatible
set runtimepath^=/home/jade/.local/share/nvim/site/pack/packer/start/coc.nvim
filetype plugin indent on
syntax on
set hidden

run with nvim --clean -u minimal.vim, then open a haskell file.

Screenshots (optional)

If applicable, add screenshots to help explain your problem.