summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorrowario <r0wario@ya.ru>2022-04-18 10:23:07 +0300
committerGitHub <noreply@github.com>2022-04-18 09:23:07 +0200
commit32505ece725755a564f3f4c7366929c630d75e24 (patch)
tree13a9eac47cfc33c34cc3378f57aadd675707b7ea /lua
parent831f76a809d9f09724d9f3825a3660ed714470d9 (diff)
feat: added trim option to make_entry.gen_from_quickfix (#1838)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/init.lua8
-rw-r--r--lua/telescope/make_entry.lua4
2 files changed, 12 insertions, 0 deletions
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index 6b20c5f..bd70a47 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -240,11 +240,13 @@ builtin.commands = require_on_exported_call("telescope.builtin.internal").comman
--- Lists items in the quickfix list, jumps to location on `<cr>`
---@param opts table: options to pass to the picker
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.quickfix = require_on_exported_call("telescope.builtin.internal").quickfix
--- Lists items from the current window's location list, jumps to location on `<cr>`
---@param opts table: options to pass to the picker
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.loclist = require_on_exported_call("telescope.builtin.internal").loclist
--- Lists previously open files, opens on `<cr>`
@@ -337,11 +339,13 @@ builtin.spell_suggest = require_on_exported_call("telescope.builtin.internal").s
--- Lists the tag stack for the current window, jumps to tag on `<cr>`
---@param opts table: options to pass to the picker
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.tagstack = require_on_exported_call("telescope.builtin.internal").tagstack
--- Lists items from Vim's jumplist, jumps to location on `<cr>`
---@param opts table: options to pass to the picker
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.jumplist = require_on_exported_call("telescope.builtin.internal").jumplist
--
@@ -354,12 +358,14 @@ builtin.jumplist = require_on_exported_call("telescope.builtin.internal").jumpli
---@param opts table: options to pass to the picker
---@field include_declaration boolean: include symbol declaration in the lsp references (default: true)
---@field include_current_line boolean: include current line (default: false)
+---@field trim_text boolean: trim results text (default: false)
builtin.lsp_references = require_on_exported_call("telescope.builtin.lsp").references
--- Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
---@field jump_type string: how to goto definition if there is only one, values: "tab", "split", "vsplit", "never"
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.lsp_definitions = require_on_exported_call("telescope.builtin.lsp").definitions
--- Goto the definition of the type of the word under the cursor, if there's only one,
@@ -367,12 +373,14 @@ builtin.lsp_definitions = require_on_exported_call("telescope.builtin.lsp").defi
---@param opts table: options to pass to the picker
---@field jump_type string: how to goto definition if there is only one, values: "tab", "split", "vsplit", "never"
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.lsp_type_definitions = require("telescope.builtin.lsp").type_definitions
--- Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
---@field jump_type string: how to goto implementation if there is only one, values: "tab", "split", "vsplit", "never"
---@field ignore_filename boolean: dont show filenames (default: true)
+---@field trim_text boolean: trim results text (default: false)
builtin.lsp_implementations = require_on_exported_call("telescope.builtin.lsp").implementations
--- Lists any LSP actions for the word under the cursor which can be triggered with `<cr>`
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index df2d608..e5a3dc3 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -324,6 +324,10 @@ function make_entry.gen_from_quickfix(opts)
local line_info = { table.concat({ entry.lnum, entry.col }, ":"), "TelescopeResultsLineNr" }
+ if opts.trim_text then
+ entry.text = entry.text:gsub("^%s*(.-)%s*$", "%1")
+ end
+
return displayer {
line_info,
entry.text:gsub(".* | ", ""),