How Do You Split the Neovim Spell Suggestion Window Horizontally?

Viewed 280

In Neovim, with the spell checker enabled by set spell, if you hover over a word which is underlined to indicate improper spelling and type z= a window will open which obscures the entirety of your work to list all of the suggested words. I would like for this window to be split horizontally, above, or below the the current buffer so that I can select the properly spelled word while still being able to see my work.

I'm not sure if this is possible. I can't find a setting that would change this functionality.

2 Answers

While not an exact answer to your question, you can just make a remap to display a drop-down list of suggestions like so (see image below - just Tab to traverse the list and press <Esc> to choose and be returned to normal mode):

" move to insert mode with drop-down menu of spelling suggestions for word under the cursor
nnoremap <Leader>sp a<C-X>s

enter image description here

I found that 99% of the time I chose the first spelling suggestion, so I made the mapping to do that and return to normal mode - with no window/drop-down list appearing - hence all you see is the word instantly change.:

" instantly go with first spelling suggestion for word under the cursor
nnoremap <Leader>sp a<C-X>s<Esc>

N.B. The above remaps work better than:

nnoremap <Leader>sp z=1<cr><cr>

since with this one there's a brief flash as the suggestion window appears and is quickly closed again.

Yes, there is an options called spellsuggest. You can use the following setting:

" use only 9 suggestions
set spellsuggest=best,9

After that, the spell suggestion will take only a small portion of the window:

enter image description here

Related