Skip to content

Commit dd91a1d

Browse files
committed
add configuration to disable parts of the UI
Some users do not like to see parts of the UI. While the diff window will not be displayed if there is nothing to preview, the details window always pops up. To allow for better customization, global variables have been added to control the visibility of each window, except the main menu.
1 parent 27ff26e commit dd91a1d

File tree

2 files changed

+51
-24
lines changed

2 files changed

+51
-24
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,18 @@ files yourself and get the full power of customization.
8686
At the current state of documentation I must redirect you to the syntax files in
8787
the source code of the plugin to get a list of available highlight groups. The
8888
user can simply overwrite any of the default mappings to his liking.
89+
90+
### Disable parts of the UI
91+
92+
The following global variables can be set to disable parts of the user
93+
interface:
94+
95+
```lua
96+
vim.g.code_action_menu_show_details = false
97+
vim.g.code_action_menu_show_diff = false
98+
```
99+
100+
```vim
101+
let g:code_action_menu_show_details = v:false
102+
let g:code_action_menu_show_diff = v:false
103+
```

lua/code_action_menu.lua

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,47 @@ local function open_code_action_menu()
6262
end
6363
end
6464

65-
local function update_selected_action()
66-
local selected_action = menu_window_instance:get_selected_action()
67-
68-
if details_window_instance == nil then
69-
details_window_instance = DetailsWindow:new(selected_action)
70-
else
71-
details_window_instance:set_action(selected_action)
65+
local function update_details_window(selected_action)
66+
if
67+
vim.g.code_action_menu_show_details == nil
68+
or vim.g.code_action_menu_show_details
69+
then
70+
if details_window_instance == nil then
71+
details_window_instance = DetailsWindow:new(selected_action)
72+
else
73+
details_window_instance:set_action(selected_action)
74+
end
75+
76+
local window_stack = { anchor_window_instance, menu_window_instance }
77+
78+
details_window_instance:open({ window_stack = window_stack })
7279
end
80+
end
7381

74-
details_window_instance:open({
75-
window_stack = {
76-
anchor_window_instance,
77-
menu_window_instance,
78-
},
79-
})
82+
local function update_diff_window(selected_action)
83+
if
84+
vim.g.code_action_menu_show_diff == nil or vim.g.code_action_menu_show_diff
85+
then
86+
if diff_window_instance == nil then
87+
diff_window_instance = DiffWindow:new(selected_action)
88+
else
89+
diff_window_instance:set_action(selected_action)
90+
end
8091

81-
if diff_window_instance == nil then
82-
diff_window_instance = DiffWindow:new(selected_action)
83-
else
84-
diff_window_instance:set_action(selected_action)
92+
local window_stack = { anchor_window_instance, menu_window_instance }
93+
94+
if details_window_instance ~= nil then
95+
table.insert(window_stack, details_window_instance)
96+
end
97+
98+
diff_window_instance:open({ window_stack = window_stack })
8599
end
100+
end
86101

87-
diff_window_instance:open({
88-
window_stack = {
89-
anchor_window_instance,
90-
menu_window_instance,
91-
details_window_instance,
92-
},
93-
})
102+
local function update_selected_action()
103+
local selected_action = menu_window_instance:get_selected_action()
104+
update_details_window(selected_action)
105+
update_diff_window(selected_action)
94106
end
95107

96108
local function execute_selected_action()

0 commit comments

Comments
 (0)