aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/ui/display.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-05-17 16:56:25 +0200
committerGitHub <noreply@github.com>2023-05-17 16:56:25 +0200
commit3b59f25d435fb1b8d36c4cc26410c3569f0bd795 (patch)
treed6f26f5af0627fb2ec6b6229111780e789b65cd1 /lua/mason-core/ui/display.lua
parentfeat(ui): display "update all" hint (#1296) (diff)
downloadmason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.tar
mason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.tar.gz
mason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.tar.bz2
mason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.tar.lz
mason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.tar.xz
mason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.tar.zst
mason-3b59f25d435fb1b8d36c4cc26410c3569f0bd795.zip
feat(ui): add search mode (#1306)
Diffstat (limited to 'lua/mason-core/ui/display.lua')
-rw-r--r--lua/mason-core/ui/display.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/lua/mason-core/ui/display.lua b/lua/mason-core/ui/display.lua
index 009fb580..4c6a06c2 100644
--- a/lua/mason-core/ui/display.lua
+++ b/lua/mason-core/ui/display.lua
@@ -1,3 +1,4 @@
+local EventEmitter = require "mason-core.EventEmitter"
local log = require "mason-core.log"
local settings = require "mason.settings"
local state = require "mason-core.ui.state"
@@ -212,6 +213,8 @@ function M.new_view_only_win(name, filetype)
---@type WindowOpts
local window_opts = {}
+ local events = EventEmitter.new()
+
vim.diagnostic.config({
virtual_text = {
severity = { min = vim.diagnostic.severity.HINT, max = vim.diagnostic.severity.ERROR },
@@ -367,6 +370,24 @@ function M.new_view_only_win(name, filetype)
bufnr = vim.api.nvim_create_buf(false, true)
win_id = vim.api.nvim_open_win(bufnr, true, create_popup_window_opts(window_opts, false))
+ vim.api.nvim_create_autocmd("CmdLineEnter", {
+ buffer = bufnr,
+ callback = function()
+ if vim.v.event.cmdtype == "/" or vim.v.event.cmdtype == "?" then
+ events:emit "search:enter"
+ end
+ end,
+ })
+
+ vim.api.nvim_create_autocmd("CmdLineLeave", {
+ buffer = bufnr,
+ callback = function(args)
+ if vim.v.event.cmdtype == "/" or vim.v.event.cmdtype == "?" then
+ events:emit("search:leave", vim.fn.getcmdline())
+ end
+ end,
+ })
+
registered_effect_handlers = window_opts.effects
registered_keybinds = {}
registered_keymaps = {}
@@ -455,6 +476,7 @@ function M.new_view_only_win(name, filetype)
end
return {
+ events = events,
---@param _renderer fun(state: table): table
view = function(_renderer)
renderer = _renderer