repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim/lua/bugabinga/cmdline/format.lua
Rawlocal icon = require 'std.icon'
local HELP_PATTERNS = { '^h$', '^he$', '^hel$', '^help$', '^h%s', '^help%s' }
local BORDER_HIGHLIGHT_MAP = {
search_down = { border = 'CmdlineBorderSearch', corner = 'CmdlineBorderCornerSearch' },
search_up = { border = 'CmdlineBorderSearch', corner = 'CmdlineBorderCornerSearch' },
shell = { border = 'CmdlineBorderShell', corner = 'CmdlineBorderCornerShell' },
help = { border = 'CmdlineBorderHelp', corner = 'CmdlineBorderCornerHelp' },
lua = { border = 'CmdlineBorderLua', corner = 'CmdlineBorderCornerLua' },
input = { border = 'CmdlineBorderInput', corner = 'CmdlineBorderCornerInput' },
cmdline = { border = 'CmdlineBorderCmdline', corner = 'CmdlineBorderCornerCmdline' },
}
return {
detect = function(firstc, content, prompt)
if prompt and prompt ~= '' then
return { type = 'input', icon = icon.prompt_prefix, lang = nil }
end
if firstc == '/' then
return { type = 'search_down', icon = icon.search, lang = 'regex' }
end
if firstc == '?' then
return { type = 'search_up', icon = icon.search_up, lang = 'regex' }
end
if firstc == '!' or (firstc == ':' and content and content:match '^!') then
return { type = 'shell', icon = icon.shell, lang = 'bash' }
end
if firstc == ':' and content then
for _, pat in ipairs(HELP_PATTERNS) do
if content:match(pat) then
return { type = 'help', icon = icon.help, lang = nil }
end
end
if content:match '^lua%s' or content:match '^lua$' or content:match '^=' then
return { type = 'lua', icon = icon.vim, lang = 'lua' }
end
return { type = 'cmdline', icon = icon.command, lang = 'vim' }
end
return { type = 'cmdline', icon = icon.command, lang = 'vim' }
end,
border_highlight_map = BORDER_HIGHLIGHT_MAP,
}