fix(builtin)!: quickfix entry maker does not used fixed width for file (#2842)

This commit is contained in:
JD
2024-01-09 04:14:24 -05:00
committed by GitHub
parent 03681adde1
commit 4367e05c06
3 changed files with 16 additions and 59 deletions

View File

@@ -281,7 +281,6 @@ builtin.commands = require_on_exported_call("telescope.builtin.__internal").comm
---@param opts table: options to pass to the picker
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field fname_width number: defines the width of the filename section (default: 30)
---@field nr number: specify the quickfix list number
builtin.quickfix = require_on_exported_call("telescope.builtin.__internal").quickfix
@@ -294,7 +293,6 @@ builtin.quickfixhistory = require_on_exported_call("telescope.builtin.__internal
---@param opts table: options to pass to the picker
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field fname_width number: defines the width of the filename section (default: 30)
builtin.loclist = require_on_exported_call("telescope.builtin.__internal").loclist
--- Lists previously open files, opens on `<cr>`
@@ -399,14 +397,12 @@ builtin.spell_suggest = require_on_exported_call("telescope.builtin.__internal")
---@param opts table: options to pass to the picker
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field fname_width number: defines the width of the filename section (default: 30)
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 show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field fname_width number: defines the width of the filename section (default: 30)
builtin.jumplist = require_on_exported_call("telescope.builtin.__internal").jumplist
--
@@ -420,7 +416,6 @@ builtin.jumplist = require_on_exported_call("telescope.builtin.__internal").jump
---@field include_declaration boolean: include symbol declaration in the lsp references (default: true)
---@field include_current_line boolean: include current line (default: false)
---@field jump_type string: how to goto reference if there is only one and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field file_encoding string: file encoding for the previewer
@@ -428,7 +423,6 @@ builtin.lsp_references = require_on_exported_call("telescope.builtin.__lsp").ref
--- Lists LSP incoming calls for word under the cursor, jumps to reference on `<cr>`
---@param opts table: options to pass to the picker
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field file_encoding string: file encoding for the previewer
@@ -436,7 +430,6 @@ builtin.lsp_incoming_calls = require_on_exported_call("telescope.builtin.__lsp")
--- Lists LSP outgoing calls for word under the cursor, jumps to reference on `<cr>`
---@param opts table: options to pass to the picker
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field file_encoding string: file encoding for the previewer
@@ -445,7 +438,6 @@ builtin.lsp_outgoing_calls = require_on_exported_call("telescope.builtin.__lsp")
--- 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 and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false)
@@ -456,7 +448,6 @@ builtin.lsp_definitions = require_on_exported_call("telescope.builtin.__lsp").de
--- 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 and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false)
@@ -466,7 +457,6 @@ builtin.lsp_type_definitions = require_on_exported_call("telescope.builtin.__lsp
--- 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 and the definition file is different from the current file, values: "tab", "tab drop", "split", "vsplit", "never"
---@field fname_width number: defines the width of the filename section (default: 30)
---@field show_line boolean: show results text (default: true)
---@field trim_text boolean: trim results text (default: false)
---@field reuse_win boolean: jump to existing window if buffer is already opened (default: false)

View File

@@ -452,37 +452,24 @@ function make_entry.gen_from_quickfix(opts)
local show_line = vim.F.if_nil(opts.show_line, true)
local hidden = utils.is_path_hidden(opts)
local items = {
{ width = vim.F.if_nil(opts.fname_width, 30) },
{ remaining = true },
}
if hidden then
items[1] = { width = 8 }
end
if not show_line then
table.remove(items, 1)
end
local displayer = entry_display.create { separator = "", items = items }
local make_display = function(entry)
local input = {}
if not hidden then
table.insert(input, string.format("%s:%d:%d", utils.transform_path(opts, entry.filename), entry.lnum, entry.col))
else
table.insert(input, string.format("%4d:%2d", entry.lnum, entry.col))
local display_filename = utils.transform_path(opts, entry.filename)
local display_string = string.format("%s:%d:%d", display_filename, entry.lnum, entry.col)
if hidden then
display_string = string.format("%4d:%2d", entry.lnum, entry.col)
end
if show_line then
local text = entry.text
if opts.trim_text then
text = text:gsub("^%s*(.-)%s*$", "%1")
text = vim.trim(text)
end
text = text:gsub(".* | ", "")
table.insert(input, text)
display_string = display_string .. ":" .. text
end
return displayer(input)
return display_string
end
local get_filename = get_filename_fn()