fix(builtin.tags): custom filename width (#1842)

This commit is contained in:
Michael Maves
2022-05-04 16:13:40 -04:00
committed by GitHub
parent 3f3cba430e
commit 85d95dfddd
3 changed files with 11 additions and 2 deletions

View File

@@ -880,6 +880,8 @@ builtin.tags({opts}) *telescope.builtin.tags()*
true) true)
{only_sort_tags} (boolean) if true we will only sort tags (default: {only_sort_tags} (boolean) if true we will only sort tags (default:
false) false)
{fname_width} (number) defines the width of the filename section
(default: 30)
builtin.current_buffer_tags({opts}) *telescope.builtin.current_buffer_tags()* builtin.current_buffer_tags({opts}) *telescope.builtin.current_buffer_tags()*
@@ -899,6 +901,8 @@ builtin.current_buffer_tags({opts}) *telescope.builtin.current_buffer_tags()*
true) true)
{only_sort_tags} (boolean) if true we will only sort tags (default: {only_sort_tags} (boolean) if true we will only sort tags (default:
false) false)
{fname_width} (number) defines the width of the filename section
(default: 30)
builtin.git_files({opts}) *telescope.builtin.git_files()* builtin.git_files({opts}) *telescope.builtin.git_files()*

View File

@@ -107,6 +107,7 @@ builtin.current_buffer_fuzzy_find = require_on_exported_call("telescope.builtin.
---@field ctags_file string: specify a particular ctags file to use ---@field ctags_file string: specify a particular ctags file to use
---@field show_line boolean: if true, shows the content of the line the tag is found on in the picker (default: true) ---@field show_line boolean: if true, shows the content of the line the tag is found on in the picker (default: true)
---@field only_sort_tags boolean: if true we will only sort tags (default: false) ---@field only_sort_tags boolean: if true we will only sort tags (default: false)
---@field fname_width number: defines the width of the filename section (default: 30)
builtin.tags = require_on_exported_call("telescope.builtin.files").tags builtin.tags = require_on_exported_call("telescope.builtin.files").tags
--- Lists all of the tags for the currently open buffer, with a preview --- Lists all of the tags for the currently open buffer, with a preview
@@ -115,6 +116,7 @@ builtin.tags = require_on_exported_call("telescope.builtin.files").tags
---@field ctags_file string: specify a particular ctags file to use ---@field ctags_file string: specify a particular ctags file to use
---@field show_line boolean: if true, shows the content of the line the tag is found on in the picker (default: true) ---@field show_line boolean: if true, shows the content of the line the tag is found on in the picker (default: true)
---@field only_sort_tags boolean: if true we will only sort tags (default: false) ---@field only_sort_tags boolean: if true we will only sort tags (default: false)
---@field fname_width number: defines the width of the filename section (default: 30)
builtin.current_buffer_tags = require_on_exported_call("telescope.builtin.files").current_buffer_tags builtin.current_buffer_tags = require_on_exported_call("telescope.builtin.files").current_buffer_tags
-- --

View File

@@ -920,13 +920,16 @@ function make_entry.gen_from_ctags(opts)
local display_items = { local display_items = {
{ remaining = true }, { remaining = true },
} }
local idx = 1
local hidden = utils.is_path_hidden(opts) local hidden = utils.is_path_hidden(opts)
if not hidden then if not hidden then
table.insert(display_items, 1, { width = 30 }) table.insert(display_items, idx, { width = vim.F.if_nil(opts.fname_width, 30) })
idx = idx + 1
end end
if opts.show_line then if opts.show_line then
table.insert(display_items, 1, { width = 30 }) table.insert(display_items, idx, { width = 30 })
end end
local displayer = entry_display.create { local displayer = entry_display.create {