Skip to content

Commit

Permalink
Merge main into sweep/support-file-types
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Oct 17, 2023
2 parents 5c4fdfd + 17d166c commit 560821b
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Usage](#usage)
- [Installation](#installation)
- [Features](#features)
- [Usage with Neovim and null-ls](#usage-with-neovim-and-null-ls)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)
Expand Down Expand Up @@ -40,10 +41,61 @@ npm install -g cspell-tool

## Features

- Supports multiple file formats like `.md`, `.ts`, and `.json`.
- Supports multiple file formats like `.md`, `.ts`, `.lua` and `.json`.
- Easily customizable via `cspell.json`.
- Extends your project-specific dictionary.

### Usage with Neovim and null-ls

This assumes you have [`mason.nvim`](https://github.com/williamboman/mason.nvim) and [`null-ls.nvim`](https://github.com/nvimtools/none-ls.nvim) installed.

1. **Installing cSpell with Mason**

Make sure your `mason.nvim` configuration in your `init.lua` includes `cspell` under `ensure_installed`:

```lua
ensure_installed = {
-- code spell
"codespell",
"misspell",
"cspell",
},
```

2. **Setting Up null-ls**

Add the following code to your `init.lua` to set up `null-ls` for spell checking:

```lua
local cspell = require("cspell")
local ok, none_ls = pcall(require, "null-ls")
if not ok then
return
end

local b = none_ls.builtins
local sources = {
-- spell check
b.diagnostics.codespell,
b.diagnostics.misspell,
-- cspell
cspell.diagnostics.with({
diagnostics_postprocess = function(diagnostic)
diagnostic.severity = vim.diagnostic.severity["HINT"]
end,
}),
cspell.code_actions,
}

return {
sources = sources,
debounce = 200,
debug = true,
}
```

More details can be found in [`cspell example config with lazyvim`](./cspell.lua).

## Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Expand Down
53 changes: 53 additions & 0 deletions cspell.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-- Example config with lazyvim
return {
-- Auto install those tools with mason
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
-- code spell
"codespell",
"misspell",
"cspell",
},
},
},
-- Set up null-ls to check spelling
{
"nvimtools/none-ls.nvim",
keys = {
{ "<leader>cn", "<cmd>NullLsInfo<cr>", desc = "NullLs Info" },
},
dependencies = { "mason.nvim", "davidmh/cspell.nvim" },
event = { "BufReadPre", "BufNewFile" },
opts = function()
local cspell = require("cspell")
local ok, none_ls = pcall(require, "null-ls")
if not ok then
return
end

local b = none_ls.builtins

local sources = {

-- spell check
b.diagnostics.codespell,
b.diagnostics.misspell,
-- cspell
cspell.diagnostics.with({
-- Set the severity to HINT for unknown words
diagnostics_postprocess = function(diagnostic)
diagnostic.severity = vim.diagnostic.severity["HINT"]
end,
}),
cspell.code_actions,
}
return {
sources = sources,
debounce = 200,
debug = true,
}
end,
},
}

0 comments on commit 560821b

Please sign in to comment.