Skip to content

Conversation

SandyJackson
Copy link

Description

The spelling module is great. I previously raised #954 because I wanted to use it more widely. (anyone coming from that issue see solution below). I now use it regularly in daily workflows.

However I find it is much quicker to use home-row and other alpha keys to make selections than numbers. Currently the keys are hard coded as a local string. I propose to make those user configurable.

Related Issue(s)

#954 is not really related but for anyone coming from there the solution I found was to call require('which-key').show('z='). See example config below:

Solution

Simple addition of a new variable within opts.plugins.spelling to allow user customisation of the keys used.
I have also added a simple validation to ensure the number of keys exceeds the number of suggestions. Docs updated to match new config.

Challenges/Questions

Currently that validation is within spelling.setup(). I call Util.warn() in the same way the config.validate() does. However, you may prefer this validation to sit within config.validate. I thought probably better to only call it when the spelling plug-in is enabled.

Summary

This is a fairly small PR and hopefully does not add complexity to the overall module. Happy for feedback and to make minor changes are required. Thanks for creating this (and other!) great tools.

Example config

{ 
  'SandyJackson/which-key.nvim', -- Change if PR merged
  branch = 'spelling_keys', -- Delete when back on Main
  event = 'VeryLazy',
  keys = {
    { -- Example Keybind to go to next misspelled word and open the which-key spelling module
      '<C-s>',
      mode = 'n',
      function()
        vim.cmd 'normal! ]s' -- Goto next misspelled word
        require('which-key').show 'z=' -- Open which-key spelling module
      end,
      desc = 'Fix Spelling',
    },
  },
  opts = {
    -- The rest of your configuration goes here
    -- Now setup the custom keys
    plugins = {
      spelling = {
        enabled = true,
        suggestions = 20,
        -- custom keys that suit my ergonomics
        keys = 'fjdkslaruvmeicghtybnwoxpqz', 
      },
    },
    -- Your configuration continues here
  },
}

Sandy Jackson added 2 commits July 30, 2025 11:58
Includes checking in spelling setup() for number of keys provided.
@SandyJackson SandyJackson changed the title Add custom keys to spelling module feat(config)Add custom keys to spelling module Jul 30, 2025
@SandyJackson SandyJackson changed the title feat(config)Add custom keys to spelling module feat(config) Add custom keys to spelling module Jul 30, 2025
@SandyJackson SandyJackson changed the title feat(config) Add custom keys to spelling module feat(config): Add custom keys to spelling module Jul 30, 2025
@SandyJackson SandyJackson changed the title feat(config): Add custom keys to spelling module feat(config): add custom keys to spelling module Jul 30, 2025
Copy link
Contributor

This PR is stale because it has been open 30 days with no activity.

@github-actions github-actions bot added the stale This issue or PR has been inactive for a while label Aug 30, 2025
@SandyJackson
Copy link
Author

Yes Bot, but the maintainer has been away so let's give him time to review. Feel free to close if not appropriate/out of scope.

@github-actions github-actions bot removed the stale This issue or PR has been inactive for a while label Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant