Skip to content

Commit

Permalink
add transparency support
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhongjia committed Jan 30, 2024
1 parent efe81c1 commit 293b850
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lua/LspUI/_meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--- @field command_enable boolean? whether enable command for `rename`
--- @field auto_select boolean? whether select all string in float window
--- @field key_binding { exec: string?, quit: string? }? keybind for `rename`
--- @field transparency number? transparency for rename

--- @class LspUI_lightbulb_config
--- @field enable boolean? whether enable `lightbulb` module
Expand All @@ -15,23 +16,36 @@
--- @field command_enable boolean? whether enable command for `lightbulb`
--- @field gitsigns boolean? whether enable gitsigns support?
--- @field key_binding { exec: string?, prev: string?, next: string?, quit: string? }? keybind for `code_action`
--- @field transparency number? transparency for code action

--- @class LspUI_diagnostic_config
--- @field enable boolean? whether enable `diagnostic` module
--- @field command_enable boolean? whether enable command for `diagnostic`
--- @field transparency number? transparency for diagnostic

--- @class LspUI_hover_config
--- @field enable boolean? whether enable `hover` module
--- @field command_enable boolean? whether enable command for `hover`
--- @field key_binding { prev: string?, next: string?, quit: string? }? keybind for `hover`
--- @field transparency number? transparency for hover

--- @class LspUI_inlay_hint_config
--- @field enable boolean? whether enable `inlay_hint` module
--- @field command_enable boolean? whether enable command for `inlay_hint`
--- @field filter { whitelist: string[]?, blacklist:string[]? }? the filter of blacklist and whitelist, should be filetype list

-- this is just for some keybind like definition, type definition, declaration, reference, implementation
--- @alias LspUI_pos_keybind_config { secondary: { jump: string?, jump_tab: string?, jump_split: string?, jump_vsplit: string?, quit:string?, hide_main:string?, fold_all:string?, expand_all:string?, enter: string? }?, main: { back: string?, hide_secondary: string? }? }
--- @alias LspUI_pos_keybind_config { secondary: { jump: string?, jump_tab: string?, jump_split: string?, jump_vsplit: string?, quit:string?, hide_main:string?, fold_all:string?, expand_all:string?, enter: string? }?, main: { back: string?, hide_secondary: string? }? , transparency: number? }
-- TODO: change this

-- TODO: replace above LspUI_pos_keybind_config with LspUI_pos_config
-- this will be a refector
--
-- this is just some config for definition, type definition, declaration, reference, implementation
--- @class LspUI_pos_config
--- @field secondary_keybind { jump: string?, jump_tab: string?, jump_split: string?, jump_vsplit: string?, quit:string?, hide_main:string?, fold_all:string?, expand_all:string?, enter: string? }?
--- @field main_keybind { back: string?, hide_secondary: string? }?
--- @field transparency number

--- @class LspUI_definition_config
--- @field enable boolean? whether enable `definition` module
Expand Down Expand Up @@ -70,4 +84,5 @@
--- @field implementation LspUI_implementation_config? `implementation` module
--- @field reference LspUI_reference_config? `reference` module
--- @field pos_keybind LspUI_pos_keybind_config? keybind for `definition`, `type definition`, `declaration`, `reference`, implementation
--- @field pos_config LspUI_pos_config? keybind for `definition`, `type definition`, `declaration`, `reference`, implementation
--- @field call_hierarchy LspUI_call_hierarchy_config? `call_hierarchy` module
8 changes: 8 additions & 0 deletions lua/LspUI/code_action/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ M.render = function(action_tuples)
win = window_id,
})

api.nvim_set_option_value(
"winblend",
config.options.code_action.transparency,
{
win = window_id,
}
)

keybinding_autocmd(new_buffer, window_id, action_tuples)
end

Expand Down
30 changes: 30 additions & 0 deletions lua/LspUI/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local lib_notify = require("LspUI.lib.notify")

local default_transparency = 60

--- @type LspUI_rename_config
local default_rename_config = {
enable = true,
Expand All @@ -9,6 +11,7 @@ local default_rename_config = {
exec = "<CR>",
quit = "<ESC>",
},
transparency = default_transparency,
}

--- @type LspUI_lightbulb_config
Expand All @@ -31,12 +34,14 @@ local default_code_action_config = {
next = "j",
quit = "q",
},
transparency = default_transparency,
}

--- @type LspUI_diagnostic_config
local default_diagnostic_config = {
enable = true,
command_enable = true,
transparency = default_transparency,
}

--- @type LspUI_hover_config
Expand All @@ -48,6 +53,7 @@ local default_hover_config = {
next = "n",
quit = "q",
},
transparency = default_transparency,
}

--- @type LspUI_inlay_hint_config
Expand Down Expand Up @@ -107,6 +113,30 @@ local default_pos_keybind_config = {
expand_all = "e",
enter = "<leader>l",
},
transparency = default_transparency,
}

-- Now, this is not available
-- TODO: replace pos_keybind_config with pos_config
--
--- @type LspUI_pos_config
local default_pos_config = {
main_keybind = {
back = "<leader>l",
hide_secondary = "<leader>h",
},
secondary_keybind = {
jump = "o",
jump_split = "sh",
jump_vsplit = "sv",
jump_tab = "t",
quit = "q",
hide_main = "<leader>h",
fold_all = "w",
expand_all = "e",
enter = "<leader>l",
},
transparency = default_transparency,
}

--- @type LspUI_call_hierarchy_config
Expand Down
8 changes: 8 additions & 0 deletions lua/LspUI/diagnostic/util.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local api, fn = vim.api, vim.fn
local config = require("LspUI.config")
local lib_notify = require("LspUI.lib.notify")
local lib_util = require("LspUI.lib.util")
local lib_windows = require("LspUI.lib.windows")
Expand Down Expand Up @@ -276,6 +277,13 @@ M.render = function(action)
api.nvim_set_option_value("concealcursor", "n", {
win = window_id,
})
api.nvim_set_option_value(
"winblend",
config.options.diagnostic.transparency,
{
win = window_id,
}
)

vim.schedule(function()
M.autocmd(current_buffer, new_buffer, window_id)
Expand Down
3 changes: 3 additions & 0 deletions lua/LspUI/hover/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ M.base_render = function(hover_tuple, hover_tuple_number)
api.nvim_set_option_value("concealcursor", "n", {
win = window_id,
})
api.nvim_set_option_value("winblend", config.options.hover.transparency, {
win = window_id,
})

return window_id, hover_tuple.buffer_id
end
Expand Down
15 changes: 15 additions & 0 deletions lua/LspUI/pos_abstract.lua
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,14 @@ M.main_view_render = function()
win = M.main_view_window(),
}
)

api.nvim_set_option_value(
"winblend",
config.options.pos_keybind.transparency,
{
win = M.main_view_window(),
}
)
end

do
Expand Down Expand Up @@ -864,6 +872,13 @@ M.secondary_view_render = function()
api.nvim_set_option_value("winhighlight", "Normal:Normal", {
win = M.secondary_view_window(),
})
api.nvim_set_option_value(
"winblend",
config.options.pos_keybind.transparency,
{
win = M.secondary_view_window(),
}
)
end)

api.nvim_win_set_config(M.secondary_view_window(), {
Expand Down
3 changes: 3 additions & 0 deletions lua/LspUI/rename/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ M.render = function(clients, buffer_id, current_win, old_name)
api.nvim_set_option_value("winhighlight", "Normal:Normal", {
win = window_id,
})
api.nvim_set_option_value("winblend", config.options.rename.transparency, {
win = window_id,
})

if config.options.rename.auto_select then
vim.cmd([[normal! V]])
Expand Down
Empty file added lua/LspUI/signature/init.lua
Empty file.

0 comments on commit 293b850

Please sign in to comment.