davidmh / cspell.nvim

A companion plugin for null-ls/none-ls, adding support for CSpell diagnostics and code actions.
82 stars 13 forks source link

Add all words in current buffer to dictionary #56

Closed sajadspeed closed 4 months ago

sajadspeed commented 4 months ago

Can I do this?

davidmh commented 4 months ago

Not with this plugin, but sounds like an achievable task using the CSpell cli, something like:

Screenshot 2024-05-05 at 13 40 11

You could wrap everything in a user command or a custom mapping:

vim.api.nvim_create_user_command("AddAllWordsToDictionary", function()
  local cmd = "node_modules/.bin/cspell --words-only --no-summary --no-color --no-progress "
    .. vim.fn.expand("%")
    .. " | sort -u > /tmp/words.txt"
  vim.fn.system(cmd)
  vim.cmd("edit") -- trigger a refresh in the current buffer so none-ls can reanalyze the contents
end, { nargs = 0 })

You would have to customize the path to the CSpell cli and the target directory

sajadspeed commented 4 months ago

OK I got it... Thank you very much.