From 0ad60e90a9b0dd557df10f73bec344e88549a9d7 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 6 Oct 2021 02:07:23 +0330 Subject: [Feature] better code action prompt and auto show codelens actions (#1698) --- lua/core/telescope.lua | 20 ++++++++++++++++++++ lua/core/which-key.lua | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'lua/core') diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index eba27eec..0fb735fa 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -159,6 +159,26 @@ function M.view_lunarvim_changelog() }):find() end +function M.code_actions() + local opts = { + winblend = 15, + layout_config = { + prompt_position = "top", + width = 80, + height = 12, + }, + borderchars = { + prompt = { "─", "│", " ", "│", "╭", "╮", "│", "│" }, + results = { "─", "│", "─", "│", "├", "┤", "╯", "╰" }, + preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + }, + border = {}, + previewer = false, + shorten_path = false, + } + require("telescope.builtin").lsp_code_actions(require("telescope.themes").get_dropdown(opts)) +end + function M.setup() local telescope = require "telescope" diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index a115bcc5..c9e9b2f4 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -139,7 +139,7 @@ M.config = function() l = { name = "LSP", - a = { "lua vim.lsp.buf.code_action()", "Code Action" }, + a = { "lua require('core.telescope').code_actions()", "Code Action" }, d = { "Telescope lsp_document_diagnostics", "Document Diagnostics", @@ -159,6 +159,7 @@ M.config = function() "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})", "Prev Diagnostic", }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, p = { name = "Peek", d = { "lua require('lsp.peek').Peek('definition')", "Definition" }, -- cgit v1.2.3