@@ -25,6 +25,7 @@ local make_window = function(height_percentage, width_percentage, border)
2525 height = height ,
2626 style = " minimal" ,
2727 border = border or " solid" ,
28+ zindex = 50 ,
2829 }
2930
3031 local bufnr = api .nvim_create_buf (false , true )
@@ -36,6 +37,40 @@ local make_window = function(height_percentage, width_percentage, border)
3637 return bufnr , win_id
3738end
3839
40+ local make_backdrop = function (backdrop )
41+ -- adapted from `lazy.nvim`
42+ local normal , has_bg
43+ if vim .fn .has (" nvim-0.9.0" ) == 0 then
44+ normal = vim .api .nvim_get_hl_by_name (" Normal" , true )
45+ has_bg = normal and normal .background ~= nil
46+ else
47+ normal = vim .api .nvim_get_hl (0 , { name = " Normal" })
48+ has_bg = normal and normal .bg ~= nil
49+ end
50+
51+ if has_bg and backdrop and backdrop < 100 and vim .o .termguicolors then
52+ local backdrop_buf = api .nvim_create_buf (false , true )
53+ local backdrop_win = api .nvim_open_win (backdrop_buf , false , {
54+ relative = " editor" ,
55+ width = vim .o .columns ,
56+ height = vim .o .lines ,
57+ row = 0 ,
58+ col = 0 ,
59+ style = " minimal" ,
60+ focusable = false ,
61+ zindex = 49 ,
62+ })
63+
64+ vim .api .nvim_set_hl (0 , " NullLsBackdrop" , { bg = " #000000" , default = true })
65+ vim .wo [backdrop_win ].winhighlight = " Normal:NullLsBackdrop"
66+ vim .wo [backdrop_win ].winblend = backdrop
67+ vim .bo [backdrop_buf ].buftype = " nofile"
68+ vim .bo [backdrop_buf ].filetype = " null-ls-backdrop"
69+
70+ return backdrop_buf , backdrop_win
71+ end
72+ end
73+
3974local function indent_lines (lines , offset )
4075 offset = offset or " \t "
4176 return vim .tbl_map (function (val )
@@ -159,6 +194,7 @@ M.show_window = function(opts)
159194 lines = vim .list_extend (lines , indent_lines (info_lines ))
160195 end
161196
197+ local backdrop_buf , backdrop_win = make_backdrop (opts .backdrop or c .get ().backdrop )
162198 local win_bufnr , win_id = make_window (0.8 , 0.7 , opts .border or c .get ().border )
163199 api .nvim_set_option_value (" winhl" , " FloatBorder:NullLsInfoBorder" , { win = win_id })
164200
@@ -172,6 +208,13 @@ M.show_window = function(opts)
172208 end
173209
174210 local close = function ()
211+ if backdrop_win and api .nvim_win_is_valid (backdrop_win ) then
212+ api .nvim_win_close (backdrop_win , true )
213+ end
214+ if backdrop_buf and api .nvim_buf_is_valid (backdrop_buf ) then
215+ api .nvim_buf_delete (backdrop_buf , { force = true })
216+ end
217+
175218 if api .nvim_buf_is_valid (win_bufnr ) then
176219 api .nvim_buf_delete (win_bufnr , { force = true })
177220 end
0 commit comments