dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.57k stars 1.44k forks source link

Add language id option of CSpell #4700

Closed ohakutsu closed 10 months ago

ohakutsu commented 10 months ago

What

Fixed issue where adjustments to language-specific settings in cspell.json weren't being applied.

How

When using stdin, it appears that cspell is unable to detect the file type correctly. Therefore, I have modified it to explicitly specify the file type.

$ cat main.rb
1.upto(10) do |i|
  puts i
end

$ cat cspell.json
{
  "languageSettings": [
    {
      "languageId": "ruby",
      "dictionaries": ["ruby"]
    }
  ]
}
$ cspell lint --verbose main.rb
cspell;
Date: Thu, 28 Dec 2023 15:19:36 GMT
Options:
    verbose:   Yes
    config:    default
    exclude:   node_modules/**
    files:     main.rb
    wordsOnly: No
    unique:    No

Config Files Found:
    /path/to/cspell.json

Exclusion Globs:
    Glob: node_modules/** from command line

1/1 ./main.rbChecking: /path/to/main.rb, File type: auto, Language: default
Checked: /path/to/main.rb, File type: ruby, Language: en ... Issues: 0 209.35ms
Config file Used: /path/to/cspell.json
Dictionaries Used: companies, filetypes, public-licenses, softwareTerms, computing-acronyms, web-services, aws, cryptocurrencies, en_us, en-common-misspellings, fullstack, ruby
 209.35ms
CSpell: Files checked: 1, Issues found: 0 in 0 files

$ cat main.rb | cspell lint --verbose -- stdin
cspell;
Date: Thu, 28 Dec 2023 15:19:41 GMT
Options:
    verbose:   Yes
    config:    default
    exclude:   node_modules/**
    files:     stdin
    wordsOnly: No
    unique:    No

Config Files Found:
    /path/to/cspell.json

Exclusion Globs:
    Glob: node_modules/** from command line

1/1 ./stdin:Checking: stdin://, File type: auto, Language: default
Checked: stdin://, File type: text, Language: en ... Issues: 1 216.86ms
Config file Used: /path/to/cspell.json
Dictionaries Used: companies, filetypes, public-licenses, softwareTerms, computing-acronyms, web-services, aws, cryptocurrencies, en_us, en-common-misspellings
 216.86ms X
./:1:3 - Unknown word (upto) fix: (up to)
CSpell: Files checked: 1, Issues found: 1 in 1 files
ohakutsu commented 10 months ago

Cheers! :beers: