spell.lua 951 B

123456789101112131415161718192021222324252627282930313233
  1. --- @meta
  2. -- luacheck: no unused args
  3. --- Check {str} for spelling errors. Similar to the Vimscript function
  4. --- [spellbadword()].
  5. ---
  6. --- Note: The behaviour of this function is dependent on: 'spelllang',
  7. --- 'spellfile', 'spellcapcheck' and 'spelloptions' which can all be local to
  8. --- the buffer. Consider calling this with [nvim_buf_call()].
  9. ---
  10. --- Example:
  11. ---
  12. --- ```lua
  13. --- vim.spell.check("the quik brown fox")
  14. --- -- =>
  15. --- -- {
  16. --- -- {'quik', 'bad', 5}
  17. --- -- }
  18. --- ```
  19. ---
  20. --- @param str string
  21. --- @return [string, 'bad'|'rare'|'local'|'caps', integer][]
  22. --- List of tuples with three items:
  23. --- - The badly spelled word.
  24. --- - The type of the spelling error:
  25. --- "bad" spelling mistake
  26. --- "rare" rare word
  27. --- "local" word only valid in another region
  28. --- "caps" word should start with Capital
  29. --- - The position in {str} where the word begins.
  30. function vim.spell.check(str) end