Skip to content

Commit

Permalink
feat: added config options for input() cmdline. Fixes #115
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 25, 2022
1 parent 927e754 commit b645e30
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Check the [wiki](https://github.com/folke/noice.nvim/wiki/Configuration-Recipes)
filter = { pattern = "^:%s*!", icon = "$", lang = "bash" },
lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" },
help = { pattern = "^:%s*h%s+", icon = "" },
input = {}, -- Used by input()
-- lua = false, -- to disable a format, set to `false`
},
},
Expand Down Expand Up @@ -458,16 +459,21 @@ require("telescope").load_extension("noice")
| **NoiceCmdlineIcon** | _DiagnosticSignInfo_ | Cmdline icon |
| **NoiceCmdlineIconCmdline** | _DiagnosticSignInfo_ | |
| **NoiceCmdlineIconFilter** | _DiagnosticSignInfo_ | |
| **NoiceCmdlineIconHelp** | _DiagnosticSignInfo_ | |
| **NoiceCmdlineIconIncRename** | _DiagnosticSignInfo_ | |
| **NoiceCmdlineIconInput** | _DiagnosticSignInfo_ | |
| **NoiceCmdlineIconLua** | _DiagnosticSignInfo_ | |
| **NoiceCmdlineIconSearch** | _DiagnosticSignWarn_ | Cmdline search icon (`/` and `?`) |
| **NoiceCmdlinePopup** | _Normal_ | Normal for the cmdline popup |
| **NoiceCmdlinePopupBorder** | _DiagnosticSignInfo_ | Cmdline popup border |
| **NoiceCmdlinePopupBorderCmdline** | _DiagnosticSignInfo_ | |
| **NoiceCmdlinePopupBorderFilter** | _DiagnosticSignInfo_ | |
| **NoiceCmdlinePopupBorderHelp** | _DiagnosticSignInfo_ | |
| **NoiceCmdlinePopupBorderIncRename** | _DiagnosticSignInfo_ | |
| **NoiceCmdlinePopupBorderInput** | _DiagnosticSignInfo_ | |
| **NoiceCmdlinePopupBorderLua** | _DiagnosticSignInfo_ | |
| **NoiceCmdlinePopupBorderSearch** | _DiagnosticSignWarn_ | Cmdline popup border for search |
| **NoiceCmdlinePrompt** | _Title_ | prompt for input() |
| **NoiceCompletionItemKindClass** | _NoiceCompletionItemKindDefault_ | |
| **NoiceCompletionItemKindColor** | _NoiceCompletionItemKindDefault_ | |
| **NoiceCompletionItemKindConstant** | _NoiceCompletionItemKindDefault_ | |
Expand Down
1 change: 1 addition & 0 deletions lua/noice/config/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ M.defaults = {
Cmdline = "MsgArea", -- Normal for the classic cmdline area at the bottom"
CmdlineIcon = "DiagnosticSignInfo", -- Cmdline icon
CmdlineIconSearch = "DiagnosticSignWarn", -- Cmdline search icon (`/` and `?`)
CmdlinePrompt = "Title", -- prompt for input()
CmdlinePopup = "Normal", -- Normal for the cmdline popup
CmdlinePopupBorder = "DiagnosticSignInfo", -- Cmdline popup border
CmdlinePopupBorderSearch = "DiagnosticSignWarn", -- Cmdline popup border for search
Expand Down
1 change: 1 addition & 0 deletions lua/noice/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ M.defaults = {
filter = { pattern = "^:%s*!", icon = "$", lang = "bash" },
lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" },
help = { pattern = "^:%s*h%s+", icon = "" },
input = {}, -- Used by input()
-- lua = false, -- to disable a format, set to `false`
},
},
Expand Down
9 changes: 7 additions & 2 deletions lua/noice/ui/cmdline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ end

---@return CmdlineFormat
function Cmdline:get_format()
if self.state.prompt and self.state.prompt ~= "" then
return Config.options.cmdline.format.input
end
local line = self.state.firstc .. self:get()

local formats = vim.tbl_values(Config.options.cmdline.format)
local formats = vim.tbl_values(vim.tbl_filter(function(f)
return f.pattern
end, Config.options.cmdline.format))
table.sort(formats, function(a, b)
return #a.pattern > #b.pattern
end)
Expand Down Expand Up @@ -101,7 +106,7 @@ function Cmdline:format(message)

-- FIXME: prompt
if self.state.prompt ~= "" then
message:append(self.state.prompt)
message:append(self.state.prompt, "NoiceCmdlinePrompt")
end

if not format.conceal then
Expand Down

0 comments on commit b645e30

Please sign in to comment.