summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwindwp <windwp@users.noreply.github.com>2020-11-28 13:16:17 +0700
committerGitHub <noreply@github.com>2020-11-28 09:16:17 +0300
commit16f11b6c27f0b14a5a99b3f4802c719c5e6bf2d2 (patch)
tree558067e5e0f89d1f99df3300b069a4d90ca33787
parent6edbd1db5f1195445b8f8fc24ff982f6d36efd11 (diff)
feat: add lsp range code actions (#297)
https://github.com/neovim/neovim/pull/12962 authored by: @windwp
-rw-r--r--README.md73
-rw-r--r--lua/telescope/builtin/init.lua1
-rw-r--r--lua/telescope/builtin/lsp.lua7
3 files changed, 44 insertions, 37 deletions
diff --git a/README.md b/README.md
index e804642..46079a3 100644
--- a/README.md
+++ b/README.md
@@ -346,43 +346,44 @@ require('telescope.builtin').fd({ -- or new custom picker's attach_mappings fiel
Built-in function ready to be bound to any key you like :smile:.
-| Functions | Description |
-|-------------------------------------|------------------------------------------------------------------|
-| `builtin.planets` | Demo showcasing how simple to create pickers with telescope. |
-| `builtin.builtin` | Lists Built-in pickers and run them on enter. |
-| `builtin.find_files` | Lists Files in current directory. |
-| `builtin.git_files` | Lists Git files in current directory. |
-| `builtin.buffers` | Lists Open buffers in the current vim instance. |
-| `builtin.oldfiles` | Lists Previously open files. |
-| `builtin.commands` | Lists Available plugin/user commands and run it. |
-| `builtin.tags` | Lists Tags in current directory with preview (ctags -R) |
-| `builtin.command_history` | Lists Commands previously ran and run it on enter. |
-| `builtin.help_tags` | Lists Available help tags and open help document. |
-| `builtin.man_pages` | Lists Man entries. |
-| `builtin.marks` | Lists Markers and their value. |
-| `builtin.colorscheme` | Lists Colorscheme and switch to it on enter. |
-| `builtin.treesitter` | Lists Function names, variables, from Treesitter! |
-| `builtin.live_grep` | Searches in current directory files. (respecting .gitignore) |
-| `builtin.current_buffer_fuzzy_find` | Searches in current buffer lines. |
-| `builtin.current_buffer_tags` | Lists Tags in current buffer. |
-| `builtin.grep_string` | Searches for a string under the cursor in current directory. |
-| `builtin.lsp_references` | Searches in LSP references. |
-| `builtin.lsp_document_symbols` | Searches in LSP Document Symbols in the current document. |
-| `builtin.lsp_workspace_symbols` | Searches in LSP all workspace symbols. |
-| `builtin.lsp_code_actions` | Lists LSP action to be trigged on enter. |
-| `builtin.quickfix` | Lists items from quickfix. |
-| `builtin.loclist` | Lists items from current window's location list. |
-| `builtin.reloader` | Lists lua modules and reload them on enter. |
-| `builtin.vim_options` | Lists vim options and on enter edit the options value. |
-| `builtin.registers` | Lists vim registers and edit or paste selection. |
-| `builtin.keymaps` | Lists normal-mode mappings. |
-| `builtin.filetypes` | Lists all filetypes. |
-| `builtin.highlights` | Lists all highlights. |
-| `builtin.git_commits` | Lists git commits with diff preview and on enter checkout the commit.|
-| `builtin.git_bcommits` | Lists buffer's git commits with diff preview and checkouts it out on enter.|
-| `builtin.git_branches` | Lists all branches with log preview and checkout action. |
+| Functions | Description |
+|-------------------------------------|---------------------------------------------------------------------------------------------|
+| `builtin.planets` | Demo showcasing how simple to create pickers with telescope. |
+| `builtin.builtin` | Lists Built-in pickers and run them on enter. |
+| `builtin.find_files` | Lists Files in current directory. |
+| `builtin.git_files` | Lists Git files in current directory. |
+| `builtin.buffers` | Lists Open buffers in the current vim instance. |
+| `builtin.oldfiles` | Lists Previously open files. |
+| `builtin.commands` | Lists Available plugin/user commands and run it. |
+| `builtin.tags` | Lists Tags in current directory with preview (ctags -R) |
+| `builtin.command_history` | Lists Commands previously ran and run it on enter. |
+| `builtin.help_tags` | Lists Available help tags and open help document. |
+| `builtin.man_pages` | Lists Man entries. |
+| `builtin.marks` | Lists Markers and their value. |
+| `builtin.colorscheme` | Lists Colorscheme and switch to it on enter. |
+| `builtin.treesitter` | Lists Function names, variables, from Treesitter! |
+| `builtin.live_grep` | Searches in current directory files. (respecting .gitignore) |
+| `builtin.current_buffer_fuzzy_find` | Searches in current buffer lines. |
+| `builtin.current_buffer_tags` | Lists Tags in current buffer. |
+| `builtin.grep_string` | Searches for a string under the cursor in current directory. |
+| `builtin.lsp_references` | Searches in LSP references. |
+| `builtin.lsp_document_symbols` | Searches in LSP Document Symbols in the current document. |
+| `builtin.lsp_workspace_symbols` | Searches in LSP all workspace symbols. |
+| `builtin.lsp_code_actions` | Lists LSP action to be trigged on enter. |
+| `builtin.lsp_range_code_actions` | Lists LSP range code action to be trigged on enter. |
+| `builtin.quickfix` | Lists items from quickfix. |
+| `builtin.loclist` | Lists items from current window's location list. |
+| `builtin.reloader` | Lists lua modules and reload them on enter. |
+| `builtin.vim_options` | Lists vim options and on enter edit the options value. |
+| `builtin.registers` | Lists vim registers and edit or paste selection. |
+| `builtin.keymaps` | Lists normal-mode mappings. |
+| `builtin.filetypes` | Lists all filetypes. |
+| `builtin.highlights` | Lists all highlights. |
+| `builtin.git_commits` | Lists git commits with diff preview and on enter checkout the commit. |
+| `builtin.git_bcommits` | Lists buffer's git commits with diff preview and checkouts it out on enter. |
+| `builtin.git_branches` | Lists all branches with log preview and checkout action. |
| `builtin.git_status` | Lists current changes per file with diff preview and add action. (Multiselection still WIP) |
-| .................................. | Your next awesome finder function here :D |
+| .................................. | Your next awesome finder function here :D |
#### Built-in Sorters
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index f180cbe..4ac3a8c 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -62,6 +62,7 @@ builtin.highlights = require('telescope.builtin.internal').highlights
builtin.lsp_references = require('telescope.builtin.lsp').references
builtin.lsp_document_symbols = require('telescope.builtin.lsp').document_symbols
builtin.lsp_code_actions = require('telescope.builtin.lsp').code_actions
+builtin.lsp_range_code_actions = require('telescope.builtin.lsp').range_code_actions
builtin.lsp_workspace_symbols = require('telescope.builtin.lsp').workspace_symbols
return builtin
diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua
index 50acdc9..5e04b33 100644
--- a/lua/telescope/builtin/lsp.lua
+++ b/lua/telescope/builtin/lsp.lua
@@ -68,7 +68,7 @@ lsp.document_symbols = function(opts)
end
lsp.code_actions = function(opts)
- local params = vim.lsp.util.make_range_params()
+ local params = opts.params or vim.lsp.util.make_range_params()
params.context = {
diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
@@ -134,6 +134,11 @@ lsp.code_actions = function(opts)
}):find()
end
+lsp.range_code_actions = function(opts)
+ opts.params = vim.lsp.util.make_given_range_params()
+ lsp.code_actions(opts)
+end
+
lsp.workspace_symbols = function(opts)
opts.shorten_path = utils.get_default(opts.shorten_path, true)