summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorCedric M'Passi <cempassi@student.42.fr>2021-01-04 23:04:58 +0100
committerGitHub <noreply@github.com>2021-01-04 23:04:58 +0100
commit9503603f888305ec799c9346f51a6e3da7f5b89b (patch)
tree2831b855a769249c0befcb390d49b243f87e5fc3 /lua/telescope/make_entry.lua
parent313ce9d0b6fb3bdb5ee07af60ee8840bdd4fbf73 (diff)
feat: Add highlight to builtin.git_status (#388)
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 7456e2b..17a5e4c 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -899,4 +899,43 @@ function make_entry.gen_from_autocommands(_)
end
end
+function make_entry.gen_from_git_status(_)
+ local displayer = entry_display.create {
+ separator = " ",
+ items = {
+ { width = 1},
+ { width = 1},
+ { remaining = true },
+ }
+ }
+
+ local make_display = function(entry)
+ local modified = "TelescopeResultsDiffChange"
+ local staged = "TelescopeResultsDiffAdd"
+
+ if entry.status == "??" then
+ modified = "TelescopeResultsDiffDelete"
+ staged = "TelescopeResultsDiffDelete"
+ end
+
+ return displayer {
+ { string.sub(entry.status, 1, 1), staged},
+ { string.sub(entry.status, -1), modified},
+ entry.value,
+ }
+ end
+
+ return function (entry)
+ if entry == '' then return nil end
+ local mod, file = string.match(entry, '(..).*%s[->%s]?(.+)')
+ return {
+ value = file,
+ status = mod,
+ ordinal = entry,
+ display = make_display,
+ }
+ end
+end
+
+
return make_entry