feat: Add highlight to builtin.git_status (#388)
This commit is contained in:
@@ -117,16 +117,7 @@ git.status = function(opts)
|
|||||||
prompt_title = 'Git Status',
|
prompt_title = 'Git Status',
|
||||||
finder = finders.new_table {
|
finder = finders.new_table {
|
||||||
results = vim.split(output, '\n'),
|
results = vim.split(output, '\n'),
|
||||||
entry_maker = function(entry)
|
entry_maker = make_entry.gen_from_git_status(opts)
|
||||||
if entry == '' then return nil end
|
|
||||||
local mod, file = string.match(entry, '(..).*%s[->%s]?(.+)')
|
|
||||||
return {
|
|
||||||
value = file,
|
|
||||||
status = mod,
|
|
||||||
ordinal = entry,
|
|
||||||
display = entry,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
previewer = previewers.git_file_diff.new(opts),
|
previewer = previewers.git_file_diff.new(opts),
|
||||||
sorter = conf.file_sorter(opts),
|
sorter = conf.file_sorter(opts),
|
||||||
|
|||||||
@@ -899,4 +899,43 @@ function make_entry.gen_from_autocommands(_)
|
|||||||
end
|
end
|
||||||
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
|
return make_entry
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ highlight default link TelescopeResultsNumber Number
|
|||||||
highlight default link TelescopeResultsComment Comment
|
highlight default link TelescopeResultsComment Comment
|
||||||
highlight default link TelescopeResultsSpecialComment SpecialComment
|
highlight default link TelescopeResultsSpecialComment SpecialComment
|
||||||
|
|
||||||
|
" Used for git status Results highlighting
|
||||||
|
highlight default link TelescopeResultsDiffChange DiffChange
|
||||||
|
highlight default link TelescopeResultsDiffAdd DiffAdd
|
||||||
|
highlight default link TelescopeResultsDiffDelete DiffDelete
|
||||||
|
|
||||||
" This is like "<C-R>" in your terminal.
|
" This is like "<C-R>" in your terminal.
|
||||||
" To use it, do `cmap <C-R> <Plug>(TelescopeFuzzyCommandSearch)
|
" To use it, do `cmap <C-R> <Plug>(TelescopeFuzzyCommandSearch)
|
||||||
cnoremap <silent> <Plug>(TelescopeFuzzyCommandSearch) <C-\>e
|
cnoremap <silent> <Plug>(TelescopeFuzzyCommandSearch) <C-\>e
|
||||||
|
|||||||
Reference in New Issue
Block a user