summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/internal.lua18
-rw-r--r--lua/telescope/make_entry.lua38
-rw-r--r--lua/telescope/pickers/entry_display.lua12
3 files changed, 39 insertions, 29 deletions
diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua
index 4557bd2..12c158e 100644
--- a/lua/telescope/builtin/internal.lua
+++ b/lua/telescope/builtin/internal.lua
@@ -34,14 +34,16 @@ internal.builtin = function(opts)
prompt_title = 'Telescope Builtin',
finder = finders.new_table {
results = objs,
- entry_maker = function(entry)return {
- value = entry,
- text = entry.text,
- display = entry.text,
- ordinal = entry.text,
- filename = entry.filename
- }end
- },
+ entry_maker = function(entry)
+ return {
+ value = entry,
+ text = entry.text,
+ display = entry.text,
+ ordinal = entry.text,
+ filename = entry.filename
+ }
+ end
+ },
previewer = previewers.builtin.new(opts),
sorter = conf.generic_sorter(opts),
attach_mappings = function(_)
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 945e841..118c321 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -20,13 +20,14 @@ local treesitter_type_highlight = {
}
local lsp_type_highlight = {
- ["Class"] = "Function",
- ["Constant"] = "Constant",
- ["Field"] = "Function",
- ["Function"] = "Function",
- ["Property"] = "Operator",
- ["Struct"] = "Struct",
- ["Variable"] = "SpecialChar",
+ ["Class"] = "TelescopeResultsClass",
+ ["Constant"] = "TelescopeResultsConstant",
+ ["Field"] = "TelescopeResultsField",
+ ["Function"] = "TelescopeResultsFunction",
+ ["Method"] = "TelescopeResultsMethod",
+ ["Property"] = "TelescopeResultsOperator",
+ ["Struct"] = "TelescopeResultsStruct",
+ ["Variable"] = "TelescopeResultsVariable",
}
local make_entry = {}
@@ -251,7 +252,7 @@ function make_entry.gen_from_git_commits()
local make_display = function(entry)
return displayer {
- {entry.value, "Number"},
+ {entry.value, "TelescopeResultsNumber"},
entry.msg
}
end
@@ -296,7 +297,7 @@ function make_entry.gen_from_quickfix(opts)
end
end
- local line_info = {table.concat({entry.lnum, entry.col}, ":"), "LineNr"}
+ local line_info = {table.concat({entry.lnum, entry.col}, ":"), "TelescopeResultsLineNr"}
return displayer {
line_info,
@@ -388,7 +389,7 @@ function make_entry.gen_from_lsp_symbols(opts)
}
if opts.ignore_filename and opts.show_line then
- table.insert(display_columns, 2, {entry.lnum .. ":" .. entry.col, "LineNr"})
+ table.insert(display_columns, 2, {entry.lnum .. ":" .. entry.col, "TelescopeResultsLineNr"})
end
return displayer(display_columns)
@@ -445,8 +446,8 @@ function make_entry.gen_from_buffer(opts)
end
return displayer {
- {entry.bufnr, "Number"},
- {entry.indicator, "Comment"},
+ {entry.bufnr, "TelescopeResultsNumber"},
+ {entry.indicator, "TelescopeResultsComment"},
display_bufname .. ":" .. entry.lnum
}
end
@@ -514,7 +515,7 @@ function make_entry.gen_from_treesitter(opts)
msg
}
if opts.show_line then
- table.insert(display_columns, 2, {entry.lnum .. ":" .. entry.col, "LineNr"})
+ table.insert(display_columns, 2, {entry.lnum .. ":" .. entry.col, "TelescopeResultsLineNr"})
end
return displayer(display_columns)
@@ -616,20 +617,17 @@ end
function make_entry.gen_from_registers(_)
local displayer = entry_display.create {
- separator = "",
+ separator = " ",
+ hl_chars = { ['['] = 'TelescopeBorder', [']'] = 'TelescopeBorder' },
items = {
- { width = 1 },
- { width = 1 },
- { width = 2 },
+ { width = 3 },
{ remaining = true },
},
}
local make_display = function(entry)
return displayer {
- {"[", "TelescopeBorder"},
- {entry.value, "Number"},
- {"]", "TelescopeBorder"},
+ {'[' .. entry.value .. ']', "TelescopeResultsNumber"},
entry.content,
}
end
diff --git a/lua/telescope/pickers/entry_display.lua b/lua/telescope/pickers/entry_display.lua
index 4edd0ae..c7a51ac 100644
--- a/lua/telescope/pickers/entry_display.lua
+++ b/lua/telescope/pickers/entry_display.lua
@@ -62,8 +62,18 @@ entry_display.create = function(configuration)
table.insert(highlights, { { hl_start, hl_end }, configuration.separator_hl })
end
end
+ local final_str = table.concat(results, configuration.separator or "│")
+ if configuration.hl_chars then
+ for i = 1, #final_str do
+ local c = final_str:sub(i,i)
+ local hl = configuration.hl_chars[c]
+ if hl then
+ table.insert(highlights, { { i - 1, i }, hl })
+ end
+ end
+ end
- return table.concat(results, configuration.separator or "│"), highlights
+ return final_str, highlights
end
end