Skip to content

Commit

Permalink
feat: add extra toggle_fold
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhongjia committed Jul 31, 2024
1 parent 111f821 commit 0eaedd7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/LspUI/_meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
--- @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? }? , transparency: number? }
--- @alias LspUI_pos_keybind_config { secondary: { jump: string?, jump_tab: string?, jump_split: string?, jump_vsplit: string?, toggle_fold: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
Expand Down
1 change: 1 addition & 0 deletions lua/LspUI/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ local default_pos_keybind_config = {
jump_split = "sh",
jump_vsplit = "sv",
jump_tab = "t",
toggle_fold = "<Cr>",
quit = "q",
hide_main = "<leader>h",
fold_all = "w",
Expand Down
22 changes: 22 additions & 0 deletions lua/LspUI/pos_abstract.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,20 @@ local secondary_view_keybind = function()
}
)

api.nvim_buf_set_keymap(
M.secondary_view_buffer(),
"n",
config.options.pos_keybind.secondary.toggle_fold,
"",
{
nowait = true,
noremap = true,
callback = function()
M.action.toggle_fold()
end,
}
)

api.nvim_buf_set_keymap(
M.secondary_view_buffer(),
"n",
Expand Down Expand Up @@ -998,6 +1012,11 @@ local action_jump = function(cmd)
end
end

local action_toggle_fold = function()
datas[current_item.uri].fold = not M.datas()[current_item.uri].fold
M.secondary_view_render()
end

local action_enter_main = function()
if not M.main_view_hide() then
api.nvim_set_current_win(M.main_view_window())
Expand Down Expand Up @@ -1102,6 +1121,9 @@ M.action = {
jump_tab = function()
action_jump("tabe")
end,
toggle_fold = function()
action_toggle_fold()
end,
enter_main = function()
action_enter_main()
end,
Expand Down

0 comments on commit 0eaedd7

Please sign in to comment.