diff options
Diffstat (limited to 'lua/telescope/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 380 |
1 files changed, 195 insertions, 185 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 12da181..e2c6d45 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -1,28 +1,28 @@ -local entry_display = require('telescope.pickers.entry_display') -local utils = require('telescope.utils') -local strings = require('plenary.strings') -local Path = require('plenary.path') +local entry_display = require "telescope.pickers.entry_display" +local utils = require "telescope.utils" +local strings = require "plenary.strings" +local Path = require "plenary.path" local treesitter_type_highlight = { ["associated"] = "TSConstant", - ["constant"] = "TSConstant", - ["field"] = "TSField", - ["function"] = "TSFunction", - ["method"] = "TSMethod", - ["parameter"] = "TSParameter", - ["property"] = "TSProperty", - ["struct"] = "Struct", - ["var"] = "TSVariableBuiltin", + ["constant"] = "TSConstant", + ["field"] = "TSField", + ["function"] = "TSFunction", + ["method"] = "TSMethod", + ["parameter"] = "TSParameter", + ["property"] = "TSProperty", + ["struct"] = "Struct", + ["var"] = "TSVariableBuiltin", } local lsp_type_highlight = { - ["Class"] = "TelescopeResultsClass", + ["Class"] = "TelescopeResultsClass", ["Constant"] = "TelescopeResultsConstant", - ["Field"] = "TelescopeResultsField", + ["Field"] = "TelescopeResultsField", ["Function"] = "TelescopeResultsFunction", - ["Method"] = "TelescopeResultsMethod", + ["Method"] = "TelescopeResultsMethod", ["Property"] = "TelescopeResultsOperator", - ["Struct"] = "TelescopeResultsStruct", + ["Struct"] = "TelescopeResultsStruct", ["Variable"] = "TelescopeResultsVariable", } @@ -38,7 +38,7 @@ do local mt_string_entry = { __index = function(t, k) return rawget(t, rawget(lookup_keys, k)) - end + end, } function make_entry.gen_from_string() @@ -75,7 +75,7 @@ do display, hl_group = utils.transform_devicons(entry.value, display, disable_devicons) if hl_group then - return display, { { {1, 3}, hl_group } } + return display, { { { 1, 3 }, hl_group } } else return display end @@ -83,10 +83,12 @@ do mt_file_entry.__index = function(t, k) local raw = rawget(mt_file_entry, k) - if raw then return raw end + if raw then + return raw + end if k == "path" then - local retpath = Path:new({t.cwd, t.value}):absolute() + local retpath = Path:new({ t.cwd, t.value }):absolute() if not vim.loop.fs_access(retpath, "R", nil) then retpath = t.value end @@ -97,7 +99,7 @@ do end return function(line) - return setmetatable({line}, mt_file_entry) + return setmetatable({ line }, mt_file_entry) end end end @@ -114,17 +116,21 @@ do local ok ok, lnum = pcall(tonumber, lnum) - if not ok then lnum = nil end + if not ok then + lnum = nil + end ok, col = pcall(tonumber, col) - if not ok then col = nil end + if not ok then + col = nil + end t.filename = filename t.lnum = lnum t.col = col t.text = text - return {filename, lnum, col, text} + return { filename, lnum, col, text } end --- Special options: @@ -144,7 +150,7 @@ do if Path:new(t.filename):is_absolute() then return t.filename, false else - return Path:new({t.cwd, t.filename}):absolute(), false + return Path:new({ t.cwd, t.filename }):absolute(), false end end, @@ -187,12 +193,12 @@ do local display, hl_group = utils.transform_devicons( entry.filename, - string.format(display_string, display_filename, coordinates, entry.text), + string.format(display_string, display_filename, coordinates, entry.text), disable_devicons ) if hl_group then - return display, { { {1, 3}, hl_group } } + return display, { { { 1, 3 }, hl_group } } else return display end @@ -200,12 +206,16 @@ do __index = function(t, k) local raw = rawget(mt_vimgrep_entry, k) - if raw then return raw end + if raw then + return raw + end local executor = rawget(execute_keys, k) if executor then local val, save = executor(t) - if save then rawset(t, k, val) end + if save then + rawset(t, k, val) + end return val end @@ -214,7 +224,7 @@ do } return function(line) - return setmetatable({line}, mt_vimgrep_entry) + return setmetatable({ line }, mt_vimgrep_entry) end end end @@ -224,11 +234,11 @@ function make_entry.gen_from_git_stash() if entry == "" then return nil end - local splitted = vim.split(entry, ':') + local splitted = vim.split(entry, ":") return { value = splitted[1], ordinal = splitted[3], - display = splitted[3] + display = splitted[3], } end end @@ -240,14 +250,14 @@ function make_entry.gen_from_git_commits(opts) separator = " ", items = { { width = 8 }, - { remaining = true } - } - } + { remaining = true }, + }, + } local make_display = function(entry) return displayer { - {entry.value, "TelescopeResultsIdentifier"}, - entry.msg + { entry.value, "TelescopeResultsIdentifier" }, + entry.msg, } end @@ -256,7 +266,7 @@ function make_entry.gen_from_git_commits(opts) return nil end - local sha, msg = string.match(entry, '([^ ]+) (.+)') + local sha, msg = string.match(entry, "([^ ]+) (.+)") if not msg then sha = entry @@ -265,10 +275,10 @@ function make_entry.gen_from_git_commits(opts) return { value = sha, - ordinal = sha .. ' ' .. msg, + ordinal = sha .. " " .. msg, msg = msg, display = make_display, - current_file = opts.current_file + current_file = opts.current_file, } end end @@ -281,14 +291,14 @@ function make_entry.gen_from_quickfix(opts) items = { { width = 8 }, { width = 50 }, - { remaining = true } - } + { remaining = true }, + }, } local make_display = function(entry) local filename = utils.transform_path(opts, entry.filename) - local line_info = {table.concat({entry.lnum, entry.col}, ":"), "TelescopeResultsLineNr"} + local line_info = { table.concat({ entry.lnum, entry.col }, ":"), "TelescopeResultsLineNr" } return displayer { line_info, @@ -304,10 +314,7 @@ function make_entry.gen_from_quickfix(opts) valid = true, value = entry, - ordinal = ( - not opts.ignore_filename and filename - or '' - ) .. ' ' .. entry.text, + ordinal = (not opts.ignore_filename and filename or "") .. " " .. entry.text, display = make_display, bufnr = entry.bufnr, @@ -326,9 +333,9 @@ function make_entry.gen_from_lsp_symbols(opts) local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() local display_items = { - { width = opts.symbol_width or 25 }, -- symbol + { width = opts.symbol_width or 25 }, -- symbol { width = opts.symbol_type_width or 8 }, -- symbol type - { remaining = true }, -- filename{:optional_lnum+col} OR content preview + { remaining = true }, -- filename{:optional_lnum+col} OR content preview } if opts.ignore_filename and opts.show_line then @@ -337,8 +344,8 @@ function make_entry.gen_from_lsp_symbols(opts) local displayer = entry_display.create { separator = " ", - hl_chars = { ['['] = 'TelescopeBorder', [']'] = 'TelescopeBorder' }, - items = display_items + hl_chars = { ["["] = "TelescopeBorder", ["]"] = "TelescopeBorder" }, + items = display_items, } local make_display = function(entry) @@ -347,18 +354,13 @@ function make_entry.gen_from_lsp_symbols(opts) -- what to show in the last column: filename or symbol information if opts.ignore_filename then -- ignore the filename and show line preview instead -- TODO: fixme - if ignore_filename is set for workspace, bufnr will be incorrect - msg = vim.api.nvim_buf_get_lines( - bufnr, - entry.lnum - 1, - entry.lnum, - false - )[1] or '' + msg = vim.api.nvim_buf_get_lines(bufnr, entry.lnum - 1, entry.lnum, false)[1] or "" msg = vim.trim(msg) else local filename = utils.transform_path(opts, entry.filename) if opts.show_line then -- show inline line info - filename = filename .. " [" ..entry.lnum .. ":" .. entry.col .. "]" + filename = filename .. " [" .. entry.lnum .. ":" .. entry.col .. "]" end msg = filename end @@ -366,12 +368,12 @@ function make_entry.gen_from_lsp_symbols(opts) local type_highlight = opts.symbol_highlights or lsp_type_highlight local display_columns = { entry.symbol_name, - {entry.symbol_type:lower(), type_highlight[entry.symbol_type], type_highlight[entry.symbol_type]}, + { entry.symbol_type:lower(), type_highlight[entry.symbol_type], type_highlight[entry.symbol_type] }, msg, } if opts.ignore_filename and opts.show_line then - table.insert(display_columns, 2, {entry.lnum .. ":" .. entry.col, "TelescopeResultsLineNr"}) + table.insert(display_columns, 2, { entry.lnum .. ":" .. entry.col, "TelescopeResultsLineNr" }) end return displayer(display_columns) @@ -380,13 +382,13 @@ function make_entry.gen_from_lsp_symbols(opts) return function(entry) local filename = entry.filename or vim.api.nvim_buf_get_name(entry.bufnr) local symbol_msg = entry.text:gsub(".* | ", "") - local symbol_type, symbol_name = symbol_msg:match("%[(.+)%]%s+(.*)") + local symbol_type, symbol_name = symbol_msg:match "%[(.+)%]%s+(.*)" local ordinal = "" if not opts.ignore_filename and filename then ordinal = filename .. " " end - ordinal = ordinal .. symbol_name .. " " .. (symbol_type or "unknown") + ordinal = ordinal .. symbol_name .. " " .. (symbol_type or "unknown") return { valid = true, @@ -412,7 +414,7 @@ function make_entry.gen_from_buffer(opts) local icon_width = 0 if not disable_devicons then - local icon, _ = utils.get_devicons('fname', disable_devicons) + local icon, _ = utils.get_devicons("fname", disable_devicons) icon_width = strings.strdisplaywidth(icon) end @@ -434,21 +436,21 @@ function make_entry.gen_from_buffer(opts) local icon, hl_group = utils.get_devicons(entry.filename, disable_devicons) return displayer { - {entry.bufnr, "TelescopeResultsNumber"}, - {entry.indicator, "TelescopeResultsComment"}, + { entry.bufnr, "TelescopeResultsNumber" }, + { entry.indicator, "TelescopeResultsComment" }, { icon, hl_group }, - display_bufname .. ":" .. entry.lnum - } + display_bufname .. ":" .. entry.lnum, + } end return function(entry) - local bufname = entry.info.name ~= "" and entry.info.name or '[No Name]' + local bufname = entry.info.name ~= "" and entry.info.name or "[No Name]" -- if bufname is inside the cwd, trim that part of the string bufname = Path:new(bufname):normalize(cwd) - local hidden = entry.info.hidden == 1 and 'h' or 'a' - local readonly = vim.api.nvim_buf_get_option(entry.bufnr, 'readonly') and '=' or ' ' - local changed = entry.info.changed == 1 and '+' or ' ' + local hidden = entry.info.hidden == 1 and "h" or "a" + local readonly = vim.api.nvim_buf_get_option(entry.bufnr, "readonly") and "=" or " " + local changed = entry.info.changed == 1 and "+" or " " local indicator = entry.flag .. hidden .. readonly .. changed return { @@ -490,28 +492,23 @@ function make_entry.gen_from_treesitter(opts) local type_highlight = opts.symbol_highlights or treesitter_type_highlight local make_display = function(entry) - local msg = vim.api.nvim_buf_get_lines( - bufnr, - entry.lnum, - entry.lnum, - false - )[1] or '' + local msg = vim.api.nvim_buf_get_lines(bufnr, entry.lnum, entry.lnum, false)[1] or "" msg = vim.trim(msg) local display_columns = { entry.text, - {entry.kind, type_highlight[entry.kind], type_highlight[entry.kind]}, - msg + { entry.kind, type_highlight[entry.kind], type_highlight[entry.kind] }, + msg, } if opts.show_line then - table.insert(display_columns, 2, {entry.lnum .. ":" .. entry.col, "TelescopeResultsLineNr"}) + table.insert(display_columns, 2, { entry.lnum .. ":" .. entry.col, "TelescopeResultsLineNr" }) end return displayer(display_columns) end return function(entry) - local ts_utils = require('nvim-treesitter.ts_utils') + local ts_utils = require "nvim-treesitter.ts_utils" local start_row, start_col, end_row, _ = ts_utils.get_node_range(entry.node) local node_text = ts_utils.get_node_text(entry.node)[1] return { @@ -530,7 +527,7 @@ function make_entry.gen_from_treesitter(opts) col = start_col, text = node_text, start = start_row, - finish = end_row + finish = end_row, } end end @@ -559,9 +556,11 @@ end function make_entry.gen_from_apropos(opts) local sections = {} - if #opts.sections == 1 and opts.sections[1] == 'ALL' then + if #opts.sections == 1 and opts.sections[1] == "ALL" then setmetatable(sections, { - __index = function() return true end, + __index = function() + return true + end, }) else for _, section in ipairs(opts.sections) do @@ -570,7 +569,7 @@ function make_entry.gen_from_apropos(opts) end local displayer = entry_display.create { - separator = ' ', + separator = " ", items = { { width = 30 }, { remaining = true }, @@ -579,21 +578,24 @@ function make_entry.gen_from_apropos(opts) local make_display = function(entry) return displayer { - { entry.keyword, 'TelescopeResultsFunction' }, - entry.description + { entry.keyword, "TelescopeResultsFunction" }, + entry.description, } end return function(line) - local keyword, cmd, section, desc = line:match'^((.-)%s*%(([^)]+)%).-)%s+%-%s+(.*)$' - return keyword and sections[section] and { - value = cmd, - description = desc, - ordinal = cmd, - display = make_display, - section = section, - keyword = keyword, - } or nil + local keyword, cmd, section, desc = line:match "^((.-)%s*%(([^)]+)%).-)%s+%-%s+(.*)$" + return keyword + and sections[section] + and { + value = cmd, + description = desc, + ordinal = cmd, + display = make_display, + section = section, + keyword = keyword, + } + or nil end end @@ -611,7 +613,7 @@ function make_entry.gen_from_marks(_) lnum = cursor_position[2], col = cursor_position[3], start = cursor_position[2], - filename = vim.api.nvim_buf_get_name(cursor_position[1]) + filename = vim.api.nvim_buf_get_name(cursor_position[1]), } end end @@ -619,7 +621,7 @@ end function make_entry.gen_from_registers(_) local displayer = entry_display.create { separator = " ", - hl_chars = { ['['] = 'TelescopeBorder', [']'] = 'TelescopeBorder' }, + hl_chars = { ["["] = "TelescopeBorder", ["]"] = "TelescopeBorder" }, items = { { width = 3 }, { remaining = true }, @@ -629,8 +631,8 @@ function make_entry.gen_from_registers(_) local make_display = function(entry) local content = entry.content return displayer { - {'[' .. entry.value .. ']', "TelescopeResultsNumber"}, - type(content) == 'string' and content:gsub('\n','\\n') or content, + { "[" .. entry.value .. "]", "TelescopeResultsNumber" }, + type(content) == "string" and content:gsub("\n", "\\n") or content, } end @@ -640,7 +642,7 @@ function make_entry.gen_from_registers(_) value = entry, ordinal = entry, content = vim.fn.getreg(entry), - display = make_display + display = make_display, } end end @@ -662,20 +664,22 @@ end function make_entry.gen_from_buffer_lines(opts) local displayer = entry_display.create { - separator = ' │ ', + separator = " │ ", items = { { width = 5 }, - { remaining = true, }, + { remaining = true }, }, } local make_display = function(entry) - return displayer { - { entry.lnum, opts.lnum_highlight_group or 'TelescopeResultsSpecialComment' }, + { entry.lnum, opts.lnum_highlight_group or "TelescopeResultsSpecialComment" }, { - entry.text, function() - if not opts.line_highlights then return {} end + entry.text, + function() + if not opts.line_highlights then + return {} + end local line_hl = opts.line_highlights[entry.lnum] or {} -- TODO: We could probably squash these together if the are the same... @@ -683,17 +687,17 @@ function make_entry.gen_from_buffer_lines(opts) local result = {} for col, hl in pairs(line_hl) do - table.insert(result, { {col, col+1}, hl }) + table.insert(result, { { col, col + 1 }, hl }) end return result - end + end, }, } end return function(entry) - if opts.skip_empty_lines and string.match(entry.text, '^$') then + if opts.skip_empty_lines and string.match(entry.text, "^$") then return end @@ -713,12 +717,12 @@ function make_entry.gen_from_vimoptions() local ok, value_origin local option = { - name = "", - description = "", + name = "", + description = "", current_value = "", default_value = "", - value_type = "", - set_by_user = false, + value_type = "", + set_by_user = false, last_set_from = "", } @@ -772,7 +776,7 @@ function make_entry.gen_from_vimoptions() local displayer = entry_display.create { separator = "", - hl_chars = { ['['] = 'TelescopeBorder', [']'] = 'TelescopeBorder' }, + hl_chars = { ["["] = "TelescopeBorder", ["]"] = "TelescopeBorder" }, items = { { width = 25 }, { width = 12 }, @@ -781,10 +785,9 @@ function make_entry.gen_from_vimoptions() } local make_display = function(entry) - return displayer { - {entry.name, "Keyword"}, - {"["..entry.value_type.."]", "Type"}, + { entry.name, "Keyword" }, + { "[" .. entry.value_type .. "]", "Type" }, utils.display_termcodes(tostring(entry.current_value)), entry.description, } @@ -796,9 +799,9 @@ function make_entry.gen_from_vimoptions() return end - entry.valid = true + entry.valid = true entry.display = make_display - entry.value = line + entry.value = line entry.ordinal = line.full_name -- entry.raw_value = d.raw_value -- entry.last_set_from = d.last_set_from @@ -813,7 +816,7 @@ function make_entry.gen_from_ctags(opts) opts = opts or {} local cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd()) - local current_file = Path:new(vim.fn.expand('%')):normalize(cwd) + local current_file = Path:new(vim.fn.expand "%"):normalize(cwd) local display_items = { { remaining = true }, @@ -855,7 +858,7 @@ function make_entry.gen_from_ctags(opts) end return function(line) - if line == '' or line:sub(1, 1) == '!' then + if line == "" or line:sub(1, 1) == "!" then return nil end @@ -864,7 +867,7 @@ function make_entry.gen_from_ctags(opts) tag, file, scode = string.match(line, '([^\t]+)\t([^\t]+)\t/^\t?(.*)/;"\t+.*') if not tag then -- hasktags gives us: 'tags\tfile\tlnum' - tag, file, lnum = string.match(line, '([^\t]+)\t([^\t]+)\t(%d+).*') + tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*") end if opts.only_current_file and file ~= current_file then @@ -876,7 +879,7 @@ function make_entry.gen_from_ctags(opts) if opts.only_sort_tags then ordinal = tag else - ordinal = file .. ': ' .. tag + ordinal = file .. ": " .. tag end return { @@ -903,11 +906,12 @@ function make_entry.gen_from_lsp_diagnostics(opts) signs = {} for severity, _ in pairs(lsp_type_diagnostic) do -- pcall to catch entirely unbound or cleared out sign hl group - if type(severity) == 'string' then - local status, sign = pcall( - function() return vim.trim(vim.fn.sign_getdefined("LspDiagnosticsSign" .. severity)[1].text) end) + if type(severity) == "string" then + local status, sign = pcall(function() + return vim.trim(vim.fn.sign_getdefined("LspDiagnosticsSign" .. severity)[1].text) + end) if not status then - sign = severity:sub(1,1) + sign = severity:sub(1, 1) end signs[severity] = sign end @@ -916,13 +920,15 @@ function make_entry.gen_from_lsp_diagnostics(opts) local layout = { { width = utils.if_nil(signs, 8, 10) }, - { remaining = true } + { remaining = true }, } local line_width = utils.get_default(opts.line_width, 45) - if not utils.is_path_hidden(opts) then table.insert(layout, 2, {width = line_width}) end + if not utils.is_path_hidden(opts) then + table.insert(layout, 2, { width = line_width }) + end local displayer = entry_display.create { separator = "▏", - items = layout + items = layout, } local make_display = function(entry) @@ -932,7 +938,7 @@ function make_entry.gen_from_lsp_diagnostics(opts) local pos = string.format("%4d:%2d", entry.lnum, entry.col) local line_info = { (signs and signs[entry.type] .. " " or "") .. pos, - "LspDiagnosticsDefault" .. entry.type + "LspDiagnosticsDefault" .. entry.type, } return displayer { @@ -949,10 +955,7 @@ function make_entry.gen_from_lsp_diagnostics(opts) valid = true, value = entry, - ordinal = ( - not opts.ignore_filename and filename - or '' - ) .. ' ' .. entry.text, + ordinal = (not opts.ignore_filename and filename or "") .. " " .. entry.text, display = make_display, filename = filename, type = entry.type, @@ -965,7 +968,6 @@ function make_entry.gen_from_lsp_diagnostics(opts) end end - function make_entry.gen_from_autocommands(_) local displayer = entry_display.create { separator = "▏", @@ -979,26 +981,26 @@ function make_entry.gen_from_autocommands(_) local make_display = function(entry) return displayer { - {entry.event, "vimAutoEvent"}, - {entry.group , "vimAugroup"}, - {entry.ft_pattern, "vimAutoCmdSfxList"}, - entry.command + { entry.event, "vimAutoEvent" }, + { entry.group, "vimAugroup" }, + { entry.ft_pattern, "vimAutoCmdSfxList" }, + entry.command, } end -- TODO: <action> dump current filtered items to buffer return function(entry) return { - event = entry.event, - group = entry.group, + event = entry.event, + group = entry.group, ft_pattern = entry.ft_pattern, - command = entry.command, - value = string.format("+%d %s", entry.source_lnum, entry.source_file), + command = entry.command, + value = string.format("+%d %s", entry.source_lnum, entry.source_file), source_file = entry.source_file, source_lnum = entry.source_lnum, -- valid = true, - ordinal = entry.event .. " " .. entry.group .. " " .. entry.ft_pattern .. " " .. entry.command, + ordinal = entry.event .. " " .. entry.group .. " " .. entry.ft_pattern .. " " .. entry.command, display = make_display, } end @@ -1018,11 +1020,17 @@ function make_entry.gen_from_commands(_) local make_display = function(entry) local attrs = "" - if entry.bang then attrs = attrs .. "!" end - if entry.bar then attrs = attrs .. "|" end - if entry.register then attrs = attrs .. '"' end + if entry.bang then + attrs = attrs .. "!" + end + if entry.bar then + attrs = attrs .. "|" + end + if entry.register then + attrs = attrs .. '"' + end return displayer { - {entry.name, "TelescopeResultsIdentifier"}, + { entry.name, "TelescopeResultsIdentifier" }, attrs, entry.nargs, entry.complete or "", @@ -1032,28 +1040,28 @@ function make_entry.gen_from_commands(_) return function(entry) return { - name = entry.name, - bang = entry.bang, - nargs = entry.nargs, - complete = entry.complete, - definition = entry.definition, + name = entry.name, + bang = entry.bang, + nargs = entry.nargs, + complete = entry.complete, + definition = entry.definition, -- - value = entry, - valid = true, - ordinal = entry.name, - display = make_display, + value = entry, + valid = true, + ordinal = entry.name, + display = make_display, } end end local git_icon_defaults = { - added = "+", - changed = "~", - copied = ">", - deleted = "-", - renamed = "➡", - unmerged = "‡", - untracked = "?" + added = "+", + changed = "~", + copied = ">", + deleted = "-", + renamed = "➡", + unmerged = "‡", + untracked = "?", } function make_entry.gen_from_git_status(opts) @@ -1061,24 +1069,24 @@ function make_entry.gen_from_git_status(opts) local col_width = ((opts.git_icons and opts.git_icons.added) and opts.git_icons.added:len() + 2) or 2 local displayer = entry_display.create { - separator = "", - items = { - { width = col_width}, - { width = col_width}, + separator = "", + items = { + { width = col_width }, + { width = col_width }, { remaining = true }, - } + }, } local icons = vim.tbl_extend("keep", opts.git_icons or {}, git_icon_defaults) local git_abbrev = { - ["A"] = {icon = icons.added, hl = "TelescopeResultsDiffAdd"}, - ["U"] = {icon = icons.unmerged, hl = "TelescopeResultsDiffAdd"}, - ["M"] = {icon = icons.changed, hl = "TelescopeResultsDiffChange"}, - ["C"] = {icon = icons.copied, hl = "TelescopeResultsDiffChange"}, - ["R"] = {icon = icons.renamed, hl = "TelescopeResultsDiffChange"}, - ["D"] = {icon = icons.deleted, hl = "TelescopeResultsDiffDelete"}, - ["?"] = {icon = icons.untracked, hl = "TelescopeResultsDiffUntracked"}, + ["A"] = { icon = icons.added, hl = "TelescopeResultsDiffAdd" }, + ["U"] = { icon = icons.unmerged, hl = "TelescopeResultsDiffAdd" }, + ["M"] = { icon = icons.changed, hl = "TelescopeResultsDiffChange" }, + ["C"] = { icon = icons.copied, hl = "TelescopeResultsDiffChange" }, + ["R"] = { icon = icons.renamed, hl = "TelescopeResultsDiffChange" }, + ["D"] = { icon = icons.deleted, hl = "TelescopeResultsDiffDelete" }, + ["?"] = { icon = icons.untracked, hl = "TelescopeResultsDiffUntracked" }, } local make_display = function(entry) @@ -1087,24 +1095,26 @@ function make_entry.gen_from_git_status(opts) local status_x = git_abbrev[x] or {} local status_y = git_abbrev[y] or {} - local empty_space = (" ") + local empty_space = " " return displayer { - { status_x.icon or empty_space, status_x.hl}, - { status_y.icon or empty_space, status_y.hl}, + { status_x.icon or empty_space, status_x.hl }, + { status_y.icon or empty_space, status_y.hl }, entry.value, } end - return function (entry) - if entry == '' then return nil end - local mod, file = string.match(entry, '(..).*%s[->%s]?(.+)') + 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, - path = Path:new({opts.cwd, file}):absolute() + path = Path:new({ opts.cwd, file }):absolute(), } end end |
