valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
764 stars 33 forks source link

Can not add words to dictionary #286

Open FalcoGer opened 10 months ago

FalcoGer commented 10 months ago

Describe the bug When using coc.nvim with the coc-ltex module, I can not add words to the user's dictionary.

I usually run vim from whatever path I'm currently in, and I don't want random .vscode directories pop up all over my filesystem, so I have set the configuration targets to be user.

    "ltex.configurationTarget": {
        "dictionary": "user",
        "disabledRules": "user",
        "hiddenFalsePositives": "user"
    },

But then when I try to add a word to the dictionary, I get this exception:

2023-11-16T22:53:44.833 ERROR (pid:1287619) [server] - unhandledRejection  Promise {
  <rejected> TypeError: Cannot add property en-US, object is not extensible
      at CommandHandler.<anonymous> (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17685:40)
      at Generator.next (<anonymous>)
      at /home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17111:71
      at new Promise (<anonymous>)
      at __webpack_modules__.1216.__awaiter (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17107:12)
      at CommandHandler.addToLanguageSpecificSettingInternalSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17671:16)
      at CommandHandler.addToLanguageSpecificSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17647:18)
      at CommandHandler.addToDictionary (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17609:14)
      at HR.execute (/home/user/.vim/plugged/coc.nvim/build/index.js:66:3095)
      at BR.executeCommand (/home/user/.vim/plugged/coc.nvim/build/index.js:66:4200)
} TypeError: Cannot add property en-US, object is not extensible
    at CommandHandler.<anonymous> (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17685:40)
    at Generator.next (<anonymous>)
    at /home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17111:71
    at new Promise (<anonymous>)
    at __webpack_modules__.1216.__awaiter (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17107:12)
    at CommandHandler.addToLanguageSpecificSettingInternalSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17671:16)
    at CommandHandler.addToLanguageSpecificSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17647:18)
    at CommandHandler.addToDictionary (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17609:14)
    at HR.execute (/home/user/.vim/plugged/coc.nvim/build/index.js:66:3095)
    at BR.executeCommand (/home/user/.vim/plugged/coc.nvim/build/index.js:66:4200)

I have tried setting an external file to be used with

    "ltex.dictionary": {
        "en-US": [
            ":~/.vim/ltex/dict/en_US.txt"
        ],
        "de-DE": [
            ":~/.vim/ltex/dict/de_DE.txt"
        ],
        "en-GB": [
            ":~/.vim/ltex/dict/en_GB.txt"
        ]
    },
    "ltex.enabledRules": {
        "en-US": [
            ":~/.vim/ltex/enabled/en_US.txt"
        ],
        "de-DE": [
            ":~/.vim/ltex/enabled/de_DE.txt"
        ],
        "en-GB": [
            ":~/.vim/ltex/enabled/en_GB.txt"
        ]
    },
    "ltex.disabledRules": {
        "en-US": [
            ":~/.vim/ltex/disabled/en_US.txt"
        ],
        "de-DE": [
            ":~/.vim/ltex/disabled/de_DE.txt"
        ],
        "en-GB": [
            ":~/.vim/ltex/disabled/en_GB.txt"
        ]
    },
    "ltex.hiddenFalsePositives": {
        "en-US": [
            ":~/.vim/ltex/hidden/en_US.txt"
        ],
        "de-DE": [
            ":~/.vim/ltex/hidden/de_DE.txt"
        ],
        "en-GB": [
            ":~/.vim/ltex/hidden/en_GB.txt"
        ]
    },

but then I get a different exception

2023-11-16T22:54:45.990 ERROR (pid:1287619) [server] - unhandledRejection  Promise {
  <rejected> TypeError: Cannot assign to read only property 'en-US' of object '[object Object]'
      at CommandHandler.<anonymous> (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17685:40)
      at Generator.next (<anonymous>)
      at /home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17111:71
      at new Promise (<anonymous>)
      at __webpack_modules__.1216.__awaiter (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17107:12)
      at CommandHandler.addToLanguageSpecificSettingInternalSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17671:16)
      at CommandHandler.addToLanguageSpecificSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17647:18)
      at CommandHandler.addToDictionary (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17609:14)
      at HR.execute (/home/user/.vim/plugged/coc.nvim/build/index.js:66:3095)
      at BR.executeCommand (/home/user/.vim/plugged/coc.nvim/build/index.js:66:4200)
} TypeError: Cannot assign to read only property 'en-US' of object '[object Object]'
    at CommandHandler.<anonymous> (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17685:40)
    at Generator.next (<anonymous>)
    at /home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17111:71
    at new Promise (<anonymous>)
    at __webpack_modules__.1216.__awaiter (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17107:12)
    at CommandHandler.addToLanguageSpecificSettingInternalSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17671:16)
    at CommandHandler.addToLanguageSpecificSetting (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17647:18)
    at CommandHandler.addToDictionary (/home/user/.config/coc/extensions/node_modules/coc-ltex/dist/extension.js:17609:14)
    at HR.execute (/home/user/.vim/plugged/coc.nvim/build/index.js:66:3095)
    at BR.executeCommand (/home/user/.vim/plugged/coc.nvim/build/index.js:66:4200)
2023-11-16T22:54:46.258 INFO (pid:1287619) [attach] - receive notification: highlight []

Stepse to reproduce Steps to reproduce the behavior:

  1. Open file with grammar mistake in nvim
  2. If required, enable coc-ltex with CocList extensions, select coc-ltex and enter
  3. Wait for the diagnostics to populate
  4. Do a coc-code action at cursor
  5. Select Add to dictionary

Expected behavior One of the following:

Sample document

```text This is a unknownword. ```

LTeX configuration

``` ```json "ltex.enabled": [ "bibtex", "context", "context.tex", "html", "latex", "markdown", "org", "restructuredtext", "rsweave", "text", "shellscript", "c", "csharp", "cpp", "javascript", "lua", "perl", "php", "powershell", "python", "ruby", "rust", "sql", "verilog", "vb" ], "ltex.language": "en-US", "ltex.sentenceCacheSize": 2000, "ltex.dictionary": { "en-US": [ ":~/.vim/ltex/dict/en_US.txt" ], "de-DE": [ ":~/.vim/ltex/dict/de_DE.txt" ], "en-GB": [ ":~/.vim/ltex/dict/en_GB.txt" ] }, "ltex.enabledRules": { "en-US": [ ":~/.vim/ltex/enabled/en_US.txt" ], "de-DE": [ ":~/.vim/ltex/enabled/de_DE.txt" ], "en-GB": [ ":~/.vim/ltex/enabled/en_GB.txt" ] }, "ltex.disabledRules": { "en-US": [ ":~/.vim/ltex/disabled/en_US.txt" ], "de-DE": [ ":~/.vim/ltex/disabled/de_DE.txt" ], "en-GB": [ ":~/.vim/ltex/disabled/en_GB.txt" ] }, "ltex.hiddenFalsePositives": { "en-US": [ ":~/.vim/ltex/hidden/en_US.txt" ], "de-DE": [ ":~/.vim/ltex/hidden/de_DE.txt" ], "en-GB": [ ":~/.vim/ltex/hidden/en_GB.txt" ] }, "ltex.configurationTarget": { "dictionary": "user", "disabledRules": "user", "hiddenFalsePositives": "user" }, "ltex.additionalRules.enablePickyRules": true, "ltex.additionalRules.motherTongue": "de-DE", "ltex.ltex-ls.logLevel": "warning", "ltex.completionEnabled": true, "ltex.diagnosticSeverity": {"PASSIVE_VOICE": "hint", "default": "information"}, "ltex.checkFrequency": "edit", "ltex.clearDiagnosticsWhenClosingFile": true, "ltex.statusBarItem": false, "ltex.trace.server": "off", ```

LTeX LS log Paste the log (output) of LTeX LS here:

``` See above ```

Version information List here the version information of the relevant software.

openjdk 18.0.2-ea 2022-07-19
OpenJDK Runtime Environment (build 18.0.2-ea+9-Ubuntu-222.04)
OpenJDK 64-Bit Server VM (build 18.0.2-ea+9-Ubuntu-222.04, mixed mode, sharing)

Additional context/information Would enjoy documentation on how to set the path for the settings file.