diff options
| author | Senghan Bright <senghan.bright@deltaprojects.com> | 2021-01-06 14:57:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-06 14:57:14 +0100 |
| commit | dda5b44b94f715395798f92f9e17e84bd0666f4a (patch) | |
| tree | 729dad541085096bac68edd9a6cf97e3d2c49451 /lua | |
| parent | 402c2ea5fa68fe9c153d4dc98e416e2d1afe3fa0 (diff) | |
Spell suggestions (#399)
* feat: spell suggest picker
* set correct window title
* add entry to readme
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/builtin/init.lua | 1 | ||||
| -rw-r--r-- | lua/telescope/builtin/internal.lua | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 14e99a6..85739e9 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -54,6 +54,7 @@ builtin.keymaps = require('telescope.builtin.internal').keymaps builtin.filetypes = require('telescope.builtin.internal').filetypes builtin.highlights = require('telescope.builtin.internal').highlights builtin.autocommands = require('telescope.builtin.internal').autocommands +builtin.spell_suggest = require('telescope.builtin.internal').spell_suggest builtin.lsp_references = require('telescope.builtin.lsp').references builtin.lsp_document_symbols = require('telescope.builtin.lsp').document_symbols diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index 48165f9..4a3ed18 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -771,6 +771,29 @@ internal.autocommands = function(opts) }):find() end +internal.spell_suggest = function(opts) + if not vim.wo.spell then return false end + + local cursor_word = vim.fn.expand("<cword>") + local suggestions = vim.fn.spellsuggest(cursor_word) + + pickers.new(opts, { + prompt_title = 'Spelling Suggestions', + finder = finders.new_table { + results = suggestions, + }, + sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr) + actions.goto_file_selection_edit:replace(function() + local selection = actions.get_selected_entry() + actions.close(prompt_bufnr) + vim.cmd('normal! "_ciw"' .. selection[1]) + end) + return true + end + }):find() +end + local function apply_checks(mod) for k, v in pairs(mod) do mod[k] = function(opts) |
