Giter Site home page Giter Site logo

iamcco / coc-spell-checker Goto Github PK

View Code? Open in Web Editor NEW
256.0 4.0 13.0 660 KB

A basic spell checker that works well with camelCase code for (Neo)vim

License: MIT License

TypeScript 95.97% JavaScript 4.03%
spell-checker camelcase neovim vim coc-nvim coc

coc-spell-checker's Introduction

Spelling Checker for (Neo)vim

fork from vscode-spell-checker v1.7.24 and commit

A basic spell checker that works well with camelCase code.

The goal of this spell checker is to help catch common spelling errors while keeping the number of false positives low.

Functionality

Load a TypeScript, JavaScript, Text, etc. file. Words not in the dictionary files will have a squiggly underline.

screenshot

To see the list of suggestions:

screenshot

Paste below configurations to your init.vim or .vimrc

  • Remap for do codeAction of selected region

    vmap <leader>a <Plug>(coc-codeaction-selected)
    nmap <leader>a <Plug>(coc-codeaction-selected)

Then positioning the cursor in the word, any of the following should display the list of suggestions:

  • <leader>aap for current paragraph
  • <leader>aw for current word

Or use the coc-actions

image

Install

:CocInstall coc-spell-checker

Commands and Configurations

Supported Languages

  • English (US)
  • English (GB) - turn on by changing "cSpell.language": "en" to "cSpell.language": "en-GB"

Add-On Dictionaries

Enabled File Types

  • vim
  • AsciiDoc
  • C, C++
  • C#
  • css, less, scss
  • Elixir
  • Go
  • Html
  • Java
  • JavaScript
  • JSON / JSONC
  • LaTex
  • Markdown
  • PHP
  • PowerShell
  • Pug / Jade
  • Python
  • reStructuredText
  • Rust
  • Scala
  • Text
  • TypeScript
  • YAML

How it works with camelCase

The concept is simple, split camelCase words before checking them against a list of known English words.

  • camelCase -> camel case
  • HTMLInput -> html input -- Notice that the I is associated with Input and not HTML
  • snake_case_words -> snake case words
  • camel2snake -> camel snake -- (the 2 is ignored)

Special case will ALL CAPS words

There are a few special cases to help will common spelling practices for ALL CAPS words.

Trailing s, ing, ies, es, ed are kept with the previous word.

  • CURLs -> curls -- trailing s
  • CURLedRequest -> curled request -- trailing ed

Things to note

  • This spellchecker is case insensitive. It will not catch errors like english which should be English.
  • The spellchecker uses a local word dictionary. It does not send anything outside your machine.
  • The words in the dictionary can and do contain errors.
  • There are missing words.
  • Only words longer than 3 characters are checked. "jsj" is ok, while "jsja" is not.
  • All symbols and punctuation are ignored.

In Document Settings

It is possible to add spell check settings into your source code. This is to help with file specific issues that may not be applicable to the entire project.

All settings are prefixed with cSpell: or spell-checker:.

  • disable -- turn off the spell checker for a section of code.
  • enable -- turn the spell checker back on after it has been turned off.
  • ignore -- specify a list of words to be ignored.
  • words -- specify a list of words to be considered correct and will appear in the suggestions list.
  • ignoreRegExp -- Any text matching the regular expression will NOT be checked for spelling.
  • includeRegExp -- Only text matching the collection of includeRegExp will be checked.
  • enableCompoundWords / disableCompoundWords -- Allow / disallow words like: "stringlength".

Enable / Disable checking sections of code

It is possible to disable / enable the spell checker by adding comments to your code.

Disable Checking

  • /* cSpell:disable */
  • /* spell-checker: disable */
  • /* spellchecker: disable */
  • /* cspell: disable-line */
  • /* cspell: disable-next-line */

Enable Checking

  • /* cSpell:enable */
  • /* spell-checker: enable */
  • /* spellchecker: enable */

Example

// cSpell:disable
const wackyWord = ['zaallano', 'wooorrdd', 'zzooommmmmmmm'];
/* cSpell:enable */

// Nest disable / enable is not Supported

// spell-checker:disable
// It is now disabled.

var liep = 1;

/* cspell:disable */
// It is still disabled

// cSpell:enable
// It is now enabled

const str = "goededag";  // <- will be flagged as an error.

// spell-checker:enable <- doesn't do anything

// cSPELL:DISABLE <-- also works.

// if there isn't an enable, spelling is disabled till the end of the file.
const str = "goedemorgen";  // <- will NOT be flagged as an error.

Ignore

Ignore allows you the specify a list of words you want to ignore within the document.

// cSpell:ignore zaallano, wooorrdd
// cSpell:ignore zzooommmmmmmm
const wackyWord = ['zaallano', 'wooorrdd', 'zzooommmmmmmm'];

Note: words defined with ignore will be ignored for the entire file.

Words

The words list allows you to add words that will be considered correct and will be used as suggestions.

// cSpell:words woorxs sweeetbeat
const companyName = 'woorxs sweeetbeat';

Note: words defined with words will be used for the entire file.

Enable / Disable compound words

In some programing language it is common to glue words together.

// cSpell:enableCompoundWords
char * errormessage;  // Is ok with cSpell:enableCompoundWords
int    errornumber;   // Is also ok.

Note: Compound word checking cannot be turned on / off in the same file. The last setting in the file determines the value for the entire file.

Excluding and Including Text to be checked.

By default, the entire document is checked for spelling. cSpell:disable/cSpell:enable above allows you to block off sections of the document. ignoreRegExp and includeRegExp give you the ability to ignore or include patterns of text. By default the flags gim are added if no flags are given.

The spell checker works in the following way:

  1. Find all text matching includeRegExp
  2. Remove any text matching excludeRegExp
  3. Check the remaining text.

Exclude Example

// cSpell:ignoreRegExp 0x[0-9a-f]+     -- will ignore c style hex numbers
// cSpell:ignoreRegExp /0x[0-9A-F]+/g  -- will ignore upper case c style hex numbers.
// cSpell:ignoreRegExp g{5} h{5}       -- will only match ggggg, but not hhhhh or 'ggggg hhhhh'
// cSpell:ignoreRegExp g{5}|h{5}       -- will match both ggggg and hhhhh
// cSpell:ignoreRegExp /g{5} h{5}/     -- will match 'ggggg hhhhh'
/* cSpell:ignoreRegExp /n{5}/          -- will NOT work as expected because of the ending comment -> */
/*
   cSpell:ignoreRegExp /q{5}/          -- will match qqqqq just fine but NOT QQQQQ
*/
// cSpell:ignoreRegExp /[^\s]{40,}/    -- will ignore long strings with no spaces.
// cSpell:ignoreRegExp Email           -- this will ignore email like patterns -- see Predefined RegExp expressions
var encodedImage = 'HR+cPzr7XGAOJNurPL0G8I2kU0UhKcqFssoKvFTR7z0T3VJfK37vS025uKroHfJ9nA6WWbHZ/ASn...';
var email1 = '[email protected]';
var email2 = '<[email protected]>';

Note: ignoreRegExp and includeRegExp are applied to the entire file. They do not start and stop.

Include Example

In general you should not need to use includeRegExp. But if you are mixing languages then it could come in helpful.

# cSpell:includeRegExp #.*
# cSpell:includeRegExp ("""|''')[^\1]*\1
# only comments and block strings will be checked for spelling.
def sum_it(self, seq):
    """This is checked for spelling"""
    variabele = 0
    alinea = 'this is not checked'
    for num in seq:
        # The local state of 'value' will be retained between iterations
        variabele += num
        yield variabele

Predefined RegExp expressions

Exclude patterns

  • Urls1 -- Matches urls
  • HexDigits -- Matches hex digits: /^x?[0-1a-f]+$/i
  • HexValues -- Matches common hex format like #aaa, 0xfeef, \u0134
  • EscapeCharacters1 -- matches special characters: '\n', '\t' etc.
  • Base641 -- matches base64 blocks of text longer than 40 characters.
  • Email -- matches most email addresses.

Include Patterns

  • Everything1 -- By default we match an entire document and remove the excludes.
  • string -- This matches common string formats like '...', "...", and `...`
  • CStyleComment -- These are C Style comments /* */ and //
  • PhpHereDoc -- This matches PHPHereDoc strings.

1. These patterns are part of the default include/exclude list for every file.

Customization

Adding words to the Workspace Dictionary

You have the option to add you own words to the workspace dictionary. The easiest, is to put your cursor on the word you wish to add, hit <leader>aw You will get a list of suggestions and the option to add the word.

You can also type in a word you want to add to the dictionary: :CocCommand cSpell.addWordToDictionary and type in the word you wish to add.

cSpell.json

Words added to the dictionary are placed in the cSpell.json file in the .vim folder found in the workspace. Note, the settings in cSpell.json will override the equivalent cSpell settings in settings.json.

Example cSpell.json file

// cSpell Settings
{
    // Version of the setting file.  Always 0.1
    "version": "0.1",
    // language - current active spelling language
    "language": "en",
    // words - list of words to be always considered correct
    "words": [
        "mkdirp",
        "tsmerge",
        "githubusercontent",
        "streetsidesoftware",
        "vsmarketplacebadge",
        "visualstudio"
    ],
    // flagWords - list of words to be always considered incorrect
    // This is useful for offensive words and common spelling errors.
    // For example "hte" should be "the"
    "flagWords": [
        "hte"
    ]
}

Configuration Settings

    //-------- Code Spell Checker Configuration --------
    // The Language local to use when spell checking. "en" and "en-GB" are currently supported.
    "cSpell.language": "en",

    // Controls the maximum number of spelling errors per document.
    "cSpell.maxNumberOfProblems": 100,

    // Controls the number of suggestions shown.
    "cSpell.numSuggestions": 8,

    // The minimum length of a word before checking it against a dictionary.
    "cSpell.minWordLength": 4,

    // Specify file types to spell check.
    "cSpell.enabledLanguageIds": [
        "csharp",
        "go",
        "javascript",
        "javascriptreact",
        "markdown",
        "php",
        "plaintext",
        "typescript",
        "typescriptreact",
        "yml"
    ],

    // Enable / Disable the spell checker.
    "cSpell.enabled": true,

    // Display the spell checker status on the status bar.
    "cSpell.showStatus": true,

    // Words to add to dictionary for a workspace.
    "cSpell.words": [],

    // Enable / Disable compound words like 'errormessage'
    "cSpell.allowCompoundWords": false,

    // Words to be ignored and not suggested.
    "cSpell.ignoreWords": ["behaviour"],

    // User words to add to dictionary.  Should only be in the user settings.
    "cSpell.userWords": [],

    // Specify paths/files to ignore.
    "cSpell.ignorePaths": [
        "node_modules",        // this will ignore anything the node_modules directory
        "**/node_modules",     // the same for this one
        "**/node_modules/**",  // the same for this one
        "node_modules/**",     // Doesn't currently work due to how the current working directory is determined.
        "vscode-extension",    //
        ".git",                // Ignore the .git directory
        "*.dll",               // Ignore all .dll files.
        "**/*.dll"             // Ignore all .dll files
    ],

    // flagWords - list of words to be always considered incorrect
    // This is useful for offensive words and common spelling errors.
    // For example "hte" should be "the"`
    "cSpell.flagWords": ["hte"],

    // Set the delay before spell checking the document. Default is 50.
    "cSpell.spellCheckDelayMs": 50,

Dictionaries

The spell checker includes a set of default dictionaries.

General Dictionaries

  • wordsEn - Derived from Hunspell US English words.
  • wordsEnGb - Derived from Hunspell GB English words.
  • companies - List of well known companies
  • softwareTerms - Software Terms and concepts like "coroutine", "debounce", "tree", etc.
  • misc - Terms that do not belong in the other dictionaries.

Programming Language Dictionaries

  • typescript - keywords for Typescript and Javascript
  • node - terms related to using nodejs.
  • php - php keywords and library methods
  • go - go keywords and library methods
  • python - python keywords
  • powershell - powershell keywords
  • html - html related keywords
  • css - css, less, and scss related keywords

Miscellaneous Dictionaries

  • fonts - long list of fonts - to assist with css

Based upon the programming language, different dictionaries will be loaded.

Here are the default rules: "*" matches any language. "local" is used to filter based upon the "cSpell.language" setting.

{
"cSpell.languageSettings": [
    { "languageId": '*',      "local": 'en',               "dictionaries": ['wordsEn'] },
    { "languageId": '*',      "local": 'en-US',            "dictionaries": ['wordsEn'] },
    { "languageId": '*',      "local": 'en-GB',            "dictionaries": ['wordsEnGb'] },
    { "languageId": '*',                                   "dictionaries": ['companies', 'softwareTerms', 'misc'] },
    { "languageId": "python", "allowCompoundWords": true,  "dictionaries": ["python"]},
    { "languageId": "go",     "allowCompoundWords": true,  "dictionaries": ["go"] },
    { "languageId": "javascript",                          "dictionaries": ["typescript", "node"] },
    { "languageId": "javascriptreact",                     "dictionaries": ["typescript", "node"] },
    { "languageId": "typescript",                          "dictionaries": ["typescript", "node"] },
    { "languageId": "typescriptreact",                     "dictionaries": ["typescript", "node"] },
    { "languageId": "html",                                "dictionaries": ["html", "fonts", "typescript", "css"] },
    { "languageId": "php",                                 "dictionaries": ["php", "html", "fonts", "css", "typescript"] },
    { "languageId": "css",                                 "dictionaries": ["fonts", "css"] },
    { "languageId": "less",                                "dictionaries": ["fonts", "css"] },
    { "languageId": "scss",                                "dictionaries": ["fonts", "css"] },
];
}

How to add your own Dictionaries

Global Dictionary

To add a global dictionary, you will need change your user settings.

Define the Dictionary

In your user settings, you will need to tell the spell checker where to find your word list.

Example adding medical terms, so words like acanthopterygious can be found.

// A List of Dictionary Definitions.
"cSpell.dictionaryDefinitions": [
    { "name": "medicalTerms", "path": "/Users/guest/projects/cSpell-WordLists/dictionaries/medicalterms-en.txt"}
],
// List of dictionaries to use when checking files.
"cSpell.dictionaries": [
    "medicalTerms"
]

Explained: In this example, we have told the spell checker where to find the word list file. Since it is in the user settings, we have to use absolute paths.

Once the dictionary is defined. We need to tell the spell checker when to use it. Adding it to cSpell.dictionaries advises the spell checker to always include the medical terms when spell checking.

Note: Adding large dictionary files to be always used will slow down the generation of suggestions.

Project / Workspace Dictionary

To add a dictionary at the project level, it needs to be in the cSpell.json file. This file can be either at the project root or in the .vim directory.

Example adding medical terms, where the terms are checked into the project and we only want to use it for .md files.

{
    "dictionaryDefinitions": [
        { "name": "medicalTerms", "path": "./dictionaries/medicalterms-en.txt"},
        { "name": "cities", "path": "./dictionaries/cities.txt"}
    ],
    "dictionaries": [
        "cities"
    ],
    "languageSettings": [
        { "languageId": "markdown", "dictionaries": ["medicalTerms"] },
        { "languageId": "plaintext", "dictionaries": ["medicalTerms"] }
    ]
}

Explained: In this example, two dictionaries were defined: cities and medicalTerms. The paths are relative to the location of the cSpell.json file. This allows for dictionaries to be checked into the project.

The cities dictionary is used for every file type, because it was added to the list to dictionaries. The medicalTerms dictionary is only used when editing markdown or plaintext files.

FAQ

See: FAQ

Buy Me A Coffee ☕️

btc

image

coc-spell-checker's People

Contributors

dependabot[bot] avatar dinalt avatar esetnik avatar h-sifat avatar iamcco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coc-spell-checker's Issues

cSpell.addWordToDictionary overrides existed workspace words (cSpell.words)

Describe the bug
Adding a word to the workspace config will remove all other words in cSpell.words.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a misspelled word (which we want to exclude)
  2. Use keybinding to invoke paragraph action
  3. Select "Add "XXX" to folder dictionary"
  4. Check "cSpell.words" field in ${workSpaceFolder}/.vim/coc-settings.json, there is only one word, and all previously defined ones are gone.

Expected behavior
The new work adding to the workspace dictionary will be inserted in the "cSpell.words" field.

Desktop (please complete the following information):

  • OS: Linux
  • coc: 0.0.82
  • neovim: 0.8.0
  • node: 18.10.0

How to install in Neovim

How can i install in nvim with lazy.nvim.
I set this config:

{
	"iamcco/coc-spell-checker",
	config = function()
		require("coc-spell-checker").setup({})
	end,
}

but doesn't work.

Change gutter sign

Is there a way to change the gutter sign or even disable all signs from popping up in the sign column while still active? I apologize I am a newbie here. Thank you.

How to find the part of cspell.json ?

I'm using neovim and when i add word to user dictionary the error disappears from diagnostic.
However I'm not able to find cspell.json file anywhere.

Is there a command like CocConfig or something to open cspell.json file ?

I've configured a path in coc-config.json ("cSpell.import": ["~/.config/nvim/general"]) as well, but when i add word in dictionary it doesn't appear there.
Is there a way to configure the default path for coc-add-word-to-user-dictionary ?

[request] dart support

Thanks for making this plugin (and so many others).
I'd love it if dart files were also supported (flutter projects).
Sorry if this is the wrong place to ask about it.

Common words reported as misspelled

Describe the bug
Common words(language, mouse, import, etc.) are reported as misspelled on Arch Linux. Works fine on my mac.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: Arch Linux

Log:

How to add a new file type?

There's a list of enabled file types in the readme and I'd like to add one.
Where are these file types enabled?
Is it enough to add to src/fileTypes/fileTypeMap.json or is there another step?
Forgive me if this is documented somewhere, I couldn't see it in the FAQ.

Where does the words through "cSpell.addWordToDictionary" goes?

Thanks for this plugin! While I'm enjoying this plugin, I got a question.

I'm aware of coc-setting.json or cSpell.json, and one can add words like "cSpell.words": ["wword"], or "words": [ "wword" ], respectively.

But when I did :CocCommand cSpell.addWordToDictionary for word prototxt for example, there was no update information in those files. (Yes, the word has no more warning so it works well). I'm just wondering: when I add words through :CocCommand cSpell.addWordToDictionary, where can I see those words?

FYI, I'm not having cSpell.json and just only having coc-setting.json in ~/.config/nvim.

Word selection is slow

I've just installed coc-spell-checker. It all looks promising. I live the pop that allows you to scroll through suggestions using vim keys and even lets you add to dictionaries.

I'm finding the popup of suggestions can take 5-10 seconds to appear, which makes it unusable. Can I do anything to speed this up?

Also can I change to British English dictionary?

I'm using gvim 8.x on Windows 10.

Thanks

Allow enable/disable through command line

Coc itself comes with the commands CocEnable and CocDisable to allow toggling it on and off.
I don't mind always having spell-checking enabled in e.g. markdown-files, but when enabling it in code files, it displays a lot of "spelling-errors" that aren't really errors.
To circumvent this, it would be really helpful if I could enable it by default in all supported files, but then be able to toggle it on and of with a simply command, rather than needing to contaminate my code base with comments for a text editor tool.
E.g. :SpellOn and :SpellOff.

Any chance we could get this? I'm sure a lot of people would like it!

French words not spell checked correctly despite correct cspell configuration

Describe the bug
French words are not spell checked correctly.

To Reproduce
Steps to reproduce the behavior:

frontend/public/locales/fr/trainingPlans.json

{
  "buttons": {
    "addOutsideCompletion": "Ajouter un achèvement extérieur"
  },
  "contentForEmpty": {
    "button": "Ajouter une certification",
    "description": "Les plans de formation sont générés en fonction des certifications que vous avez répertoriées\ndans le système ou par affectation de service. Télécharger une certification sur\ncommencez à démarrer ou contactez votre responsable de la formation pour obtenir de l'aide.",
    "title": "Aucun plan de formation trouvé"
  },
  "imagesAlts": {
    "headerImage": "plan d'entraînement {{name}}"
  },
  "labels": {
    "complete": "Compléter",
    "distributiveLimit": "Limite distributive",
    "headerProgress": "Progression du plan de formation",
    "overallProgress": "Les progrès d'ensemble",
    "requirements": "Conditions:",
    "used": "Utilisé"
  },
  "messages": {
    "noDescription": "Ce plan de formation n'a pas de description"
  },
  "placeholders": {
    "selectTrainingPlan": "Sélectionnez un plan de formation"
  },
  "title": "Plans de formation"
}

.cspell.json

{
  "version": "0.2",
  "ignorePaths": [
    ".vscode/settings.json",
    ".vim/coc-settings.json",
    "frontend/node_modules/**",
    "frontend/coverage/**",
    "frontend/build/**",
    "frontend/db/dist/**",
    "frontend/package.json",
    "docker-compose*.yml",
    "cloudformation.yml",
    "web/src/composer.json",
    "web/src/vendor",
    "web/src/shared/scripts",
    "web/src/css"
  ],
  "allowCompoundWords": true,
  "ignoreWords": ["culturehq"],
  "words": [
    "AMZN",
    "capce",
    "crunz",
    "cronitor",
    "entityid",
    "esetnik",
    "esnext",
    "falsey",
    "Gravatar",
    "hacky",
    "Handtevy",
    "hocs",
    "iframe",
    "imgix",
    "immer",
    "junit",
    "jwplayer",
    "luxon",
    "Maknz",
    "newid",
    "noopener",
    "NREMT",
    "nuka",
    "onstatechange",
    "onupdatefound",
    "phpcs",
    "phuocng",
    "recertification",
    "reduxjs",
    "signup",
    "testid",
    "tsql",
    "Tuupola",
    "unmount",
    "unregister",
    "UPDLOCK",
    "wdyr"
  ],
  "import": ["./frontend/node_modules/@cspell/dict-fr-fr/cspell-ext.json"],
  "overrides": [
    {
      "filename": "**/locales/fr/**/{*.json,*.yml}",
      "language": "en,fr"
    },
    {
      "filename": "**/__test__/**",
      "language": "en,fr"
    },
    {
      "filename": "**/{*.test.ts,*.test.tsx}",
      "language": "en,fr"
    }
  ]
}

.vim/coc-settings.json

{
  "cSpell.import": ["../.cspell.json"],
  "cSpell.spellCheckDelayMs": 500,
  "cSpell.enabledLanguageIds": [
    "vim",
    "asciidoc",
    "yaml.docker-compose",
    "c",
    "cpp",
    "csharp",
    "css",
    "git-commit",
    "go",
    "handlebars",
    "haskell",
    "html",
    "jade",
    "java",
    "javascript",
    "javascriptreact",
    "json",
    "jsonc",
    "latex",
    "less",
    "markdown",
    "php",
    "plaintext",
    "python",
    "pug",
    "restructuredtext",
    "rust",
    "scala",
    "scss",
    "text",
    "typescript",
    "typescriptreact",
    "yaml",
    "yml"
  ]
}

Expected behavior
Behavior between command line execution of cspell and coc-spell-checker should match

Screenshots

Screen Shot 2021-12-17 at 3 59 35 PM

Desktop (please complete the following information):

  • OS:
    macOS 12.1

Log:

not sure where to get log output

Feature: Exclude import statements

I think it would be a logical default to exclude import statements. Many packages are not real words. Is there an easy way to achieve this? Happy to submit a PR too.

Example:

image

Omit spell checker actions from coc-codeaction list

Using this extension with coc-actions. It's really nice having the spell checking actions displayed in a floating window near the selection to maximise efficiency, thank you.

The issue I'm experiencing is when coc-codeaction is run all the spelling suggestions for the entire file appear in the list. I can't see how this would be useful and it adds a lot of noise.

Is there anyway to exclude spell checker results from the coc-codeaction list?

cSpell.addWordToDictionary not works

Describe the bug
A clear and concise description of what the bug is.
nnoremap <Leader>ca :<C-U>CocCommand cSpell.addWordToDictionary<CR> not works since update coc to 79 version.

image

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS:

Log:

How to enable spell check in git COMMIT_EDITMSG file.

Sorry for bothering you guys.

For me, the spell checker works everywhere except the git COMMIT_EDITMSG file. In my init.vim
and coc-settings.json I don't have any configuration related to spell checker.
Though I tried setting the following "cSpell.enabledLanguageIds": ["*"], but it didn't work.

Could anyone kindly tell me, how can I get the spell checker to support the commit message file?
Thanks in advance 💝

Deprecation of workspace.createStatusBarItem

I noticed a deprecation warning in the logs. The message suggests to use window.createStatusBarItem.

const sbCheck = coc.workspace.createStatusBarItem(0, { progress: true });

Warning

WARN (pid:1874436) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. at Object.t.initStatusBar (/home/andreas/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:155873)

Words are not being added to user dictionary - Windows

Hello,

I am using Windows vim and for some reason all the words I add to the user dictionary are not being saved. The README.md states the the words get saved inside .vim folder within the project but this is not project related. Simply using it to write notes

Example:

# open vim buffer
vim someText.txt

# add incorrect words like
noob
newb

# hover over word and add to user dictionary
<leader>aw

# save and close buffer
ZZ

If I reopen the same text file, the word is still unrecognized. I do not see a .vim folder anywhere in my home directory. Not even cSpell.json or coc-settings.json that has the words.

Running :h vimrc in vim states that in Windows, vim configurations are in the vimfile folder instead of .vim folder. Not sure if that has anything to do with it but I ended up creating a .vim folder and putting json settings there but that didn't help either.

Maybe I am doing something wrong? Some guidance would be greatly appreciated.

CocCommand cSpell.toggleEnableSpellChecker does not work

Describe the bug
When calling CocCommand cSpell.toggleEnableSpellChecker, spell checking is
not toggled. Instead the following error message is shown:

[coc.nvim]: Unable to locate workspace folder configuration for undefined

To Reproduce
Steps to reproduce the behavior:

  1. Start neovim with coc.nvim and coc-spell-checker installed
  2. Run the command CocCommand cSpell.toggleEnableSpellChecker
  3. See the error message: [coc.nvim]: Unable to locate workspace folder configuration for undefined

Expected behavior
Spell checking is enabled/disabled.

Screenshots
This little gif shows what is happening:
cspell

minimal config
neovim was started like this

VIMRUNTIME=/usr/local/src/neovim/runtime /usr/local/src/neovim/build/bin/nvim
--clean -u /usr/local/src/neovim_minimal_stuff/minimal_init.vim
/usr/local/src/neovim_minimal_stuff/minimal.txt

with a minimal config containing

set nocompatible

let g:coc_config_home = '/usr/local/src/neovim_minimal_stuff/.config/nvim'
let g:coc_data_home = '/usr/local/src/neovim_minimal_stuff/.config/coc'

set runtimepath+=/usr/local/src/neovim_minimal_stuff/coc.nvim

filetype plugin indent on

nvim --version shows

NVIM v0.9.0-dev-588+g99cf11128
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by lorenz@chicken

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

coc.nvim is on the release branch, holding the commit

commit 95b43f67147391cf2c69e550bd001b742781d226

coc-spell-checker was just installed with CocInstall coc-spell-checker

My coc-settings.json contains the following entry

{
  "cSpell.enabled": true,
}

Desktop (please complete the following information):

  • OS: GNU/Linux

Log:
CocOpenLog opens the following log file after CocCommand cSpell.toggleEnableSpellChecker was invoked:

2022-12-31T12:41:45.900 INFO (pid:95200) [plugin] - coc.nvim initialized with node: v18.12.1 after 130
2022-12-31T12:41:45.914 WARN (pid:95200) [workspace] - workspace.createStatusBarItem is deprecated, please use window.createStatusBarItem instead. 
    at t.initStatusBar (/usr/local/src/neovim_minimal_stuff/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:156009)
    at t.activate (/usr/local/src/neovim_minimal_stuff/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:23162)
2022-12-31T12:41:45.919 INFO (pid:95200) [language-client-index] - Language server "cSpell" started with 95212
2022-12-31T12:41:57.862 INFO (pid:95200) [attach] - receive notification: openLog []
2022-12-31T12:41:57.875 INFO (pid:95200) [attach] - receive notification: doAutocmd [ 1 ]
2022-12-31T12:42:00.471 INFO (pid:95200) [attach] - receive notification: doAutocmd [ 1 ]
2022-12-31T12:42:14.774 INFO (pid:95200) [attach] - Request action: commandList [ 'cSpe', 'CocCommand cSpe', 15 ]
2022-12-31T12:42:19.015 INFO (pid:95200) [attach] - receive notification: runCommand [ 'cSpell.toggleEnableSpellChecker' ]
2022-12-31T12:42:19.019 ERROR (pid:95200) [configurations] - Unable to locate workspace folder configuration undefined Error
    at Object.update (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:152:6903)
    at t.setSettingInVSConfig (/usr/local/src/neovim_minimal_stuff/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:16962)
    at t.toggleEnableSpellChecker (/usr/local/src/neovim_minimal_stuff/.config/coc/extensions/node_modules/coc-spell-checker/out/index.js:1:29162)
    at Kk.execute (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:69:2984)
    at Qk.executeCommand (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:69:4090)
    at Qk.fireCommand (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:69:4186)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Nm.runCommand (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:256:24046)
    at async cb.cocAction (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:276:46545)
    at async EventEmitter.<anonymous> (/usr/local/src/neovim_minimal_stuff/coc.nvim/build/index.js:276:48151)
2022-12-31T12:42:22.243 INFO (pid:95200) [attach] - receive notification: openLog []

Thank you very much for that plugin. If you need more input just ask. :)

[Question] How may I select which cSpell.<CocCommandName> get shown in the actions?

Hi @iamcco,
First of all, thank you for the plugin, really helps a lot!

My question is, say, I have a word "lolfoo" that is specific to my work, not
really a known word; I would like to consider some options, like add it to the
workspace dictionary or do smth else by way of invoking the actions menu.
Currently what I have is only an option to add to my user dictionary, which is
not always the case for what I would like to do. How can I add/remove selected
actions for cSpell in the config?

Thanks!

Not working in Git COMMIT_EDITMSG

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. In a git repository, run git commit --allow-empty
  2. Run :CocInstall coc-spell-checker
  3. Type errror (note the extra "r")
  4. Notice that the misspelled word is not called out

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

  • OS: macOS 11.2 beta

Log: Would appreciate instructions on getting the specific logs you need

Comments:

This is similar to streetsidesoftware/vscode-spell-checker#346 . However we don't ignore all of **.git/**, and have git-commit added as a default type in enableLanguageIDs.

Global dictionary relative to home directory

Is there any way to set dictionaryDefinitions paths relative to my home directory.

In my ~/.config/nvim/coc-settings.json I have

  "cSpell.dictionaryDefinitions": [
    { 
      "name": "dotfiles", 
      "path": "/Users/ian/.config/dictionaries/dotfiles.txt"
    }
  ],

which works fine, but I'd like to do this relative to my home directory so that this configuration works across different accounts, e.g.

  "cSpell.dictionaryDefinitions": [
    { 
      "name": "dotfiles", 
      "path": "~/.config/dictionaries/dotfiles.txt"
    }
  ],

However this doesn't work and the dictionary doesn't get loaded. I guess the the ~ symbol is not recognised. Is there anyway to achieve this?

Thx for the awesome coc extension :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.