mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(picker.input): search syntax highlighting
This commit is contained in:
parent
ac76e8ea36
commit
4242f90268
1 changed files with 14 additions and 0 deletions
|
@ -27,6 +27,9 @@ function M.new(picker)
|
|||
vim.fn.prompt_setprompt(win.buf, "")
|
||||
vim.bo[win.buf].modified = false
|
||||
end,
|
||||
on_win = function()
|
||||
self:highlights()
|
||||
end,
|
||||
bo = {
|
||||
filetype = "snacks_picker_input",
|
||||
buftype = "prompt",
|
||||
|
@ -74,6 +77,17 @@ function M.new(picker)
|
|||
return self
|
||||
end
|
||||
|
||||
function M:highlights()
|
||||
local m = vim.fn.matchadd
|
||||
vim.api.nvim_win_call(self.win.win, function()
|
||||
m("@punctuation.delimiter", "\\v(^|\\s|:|\\!)\\zs['^]")
|
||||
m("@punctuation.delimiter", "\\v['$]\\ze(\\s|$)")
|
||||
m("DiagnosticWarn", "\\v(^|\\s|:)\\zs\\!")
|
||||
m("@keyword", "\\v(^|\\s)\\zs\\w+:")
|
||||
m("@operator", "\\v\\s\\zs\\|\\ze\\s")
|
||||
end)
|
||||
end
|
||||
|
||||
function M:close()
|
||||
self.win:destroy()
|
||||
self.picker = nil -- needed for garbage collection of the picker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue