# The corresponding pane needs to be _active_ in order for the keybindings to
# be read and the attached command activated.
#
# Global commands:
#
# quit: exits the application
# vault_selector_modal_toggle: toggles vault selector modal (not available in splash screen)
# help_modal_toggle: toggles help modal
# spawn: <command> spawns a new process without blocking. This is for opening external applications or URLs.
# exec: <command> runs a command in the current shell environment.
#
# Splash commands:
#
# splash_up: moves selector up
# splash_down: moves selector down
# splash_open: opens the selected vault
#
# Explorer commands:
#
# explorer_up: moves selector up
# explorer_down: moves selector down
# explorer_open: opens the selected note in note viewer
# explorer_sort: toggles note and folder sorting between A-z and Z-a
# explorer_toggle: toggles explorer pane
# explorer_toggle_outline: toggles outline pane
# explorer_toggle_input_rename: opens input modal to rename selected note or directory
# explorer_hide_pane: hides pane by steps, from full-width to regular width, to hidden
# explorer_expand_pane: explands pane by steps, from hiddent to regular width, to full-width
# explorer_switch_pane_next: switches focus to next pane
# explorer_switch_pane_previous: switches focus to previous pane
# explorer_scroll_up_one: scrolls the selector up by one
# explorer_scroll_down_one: scrolls the selector down by one
# explorer_scroll_up_half_page: scrolls the selector up half a page
# explorer_scroll_down_half_page: scrolls the selector down half a page
# explorer_scroll_to_top: jumps to the first item
# explorer_scroll_to_bottom: jumps to the last item
#
# Outline commands:
#
# outline_up: moves selector up
# outline_down: moves selector down
# outline_toggle: toggles outline panel
# outline_toggle_explorer: toggles explorer pane
# outline_switch_pane_next: switches focus to next pane
# outline_switch_pane_previous: switches focus to previous pane
# outline_expand: expands or collapses headings
# outline_select: select heading and move note editor cursor to heading location
#
# Note editor commands:
#
# note_editor_scroll_up_one: scrolls up by one
# note_editor_scroll_down_one: scrolls down by one
# note_editor_scroll_up_half_page: scrolls up by half page
# note_editor_scroll_down_half_page: scrolls down by half page
# note_editor_scroll_to_top: jumps to the top of the note
# note_editor_scroll_to_bottom: jumps to the bottom of the note
# note_editor_toggle_explorer: toggles explorer pane
# note_editor_toggle_outline: toggles outline pane
# note_editor_switch_pane_next: switches focus to next pane
# note_editor_switch_pane_previous: switches focus to previous pane

# Experimental note editor commands:
# note_editor_experimental_set_edit_view: changes to edit view
# note_editor_experimental_toggle_view: toggles between edit and read views
# note_editor_experimental_set_read_view: changes to read view
# note_editor_experimental_save: saves note changes to file
# note_editor_experimental_exit: cancels editing and changes to read
# note_editor_experimental_cursor_left: moves cursor left
# note_editor_experimental_cursor_right: moves cursor right
# note_editor_experimental_cursor_word_forward: moves cursor forward by a word
# note_editor_experimental_cursor_word_backward: moves cursor backwards by a word
# note_editor_insert_mode: enters insert mode (vim mode)
#
# Input modal commands:
#
# input_modal_edit_mode: enter edit mode for typing
# input_modal_accept: accept changes and close modal
# input_modal_cancel: cancel and close modal without saving
# input_modal_left: move cursor left
# input_modal_right: move cursor right
# input_modal_word_forward: move cursor forward by word
# input_modal_word_backward: move cursor backward by word
#
# Help modal commands:
#
# help_modal_toggle: toggles help modal
# help_modal_close: closes help modal
# help_modal_scroll_up_one: scrolls up by one
# help_modal_scroll_down_one: scrolls down by one
# help_modal_scroll_up_half_page: scrolls up by half page
# help_modal_scroll_down_half_page: scrolls down by half page
#
# Vault selector modal commands:
#
# vault_selector_modal_up: moves selector up
# vault_selector_modal_down: moves selector down
# vault_selector_modal_close: closes vault selector modal
# vault_selector_modal_open: opens the selected vault
# vault_selector_modal_toggle: toggles vault selector modal
#
# Debug log commands:
#
# debug_log_toggle: toggles the debug log overlay
# debug_log_close: closes the debug log overlay
# debug_log_clear: clears all captured log entries
# debug_log_cycle_level: cycles the minimum visible log level (trace -> error)
# debug_log_scroll_up_one: scrolls up by one
# debug_log_scroll_down_one: scrolls down by one
# debug_log_scroll_up_half_page: scrolls up by half page
# debug_log_scroll_down_half_page: scrolls down by half page

# Editor is experimental
experimental_editor = false
vim_mode = false

[symbols]
preset = "unicode"

[global]
key_bindings = [
 { key = "q", command = "quit" },
 { key = "ctrl+g", command = "vault_selector_modal_toggle" },
 { key = "?", command = "help_modal_toggle" },
 { key = "g<lt>", command = "debug_log_toggle" },
 { key = "ctrl+alt+e", command = "exec:vi %note_path" },
 { key = "ctrl+alt+o", command = "spawn:open obsidian://open?vault=%vault&file=%note" },
]

[splash]
key_bindings = [
 { key = "k", command = "splash_up" },
 { key = "j", command = "splash_down" },
 { key = "up", command = "splash_up" },
 { key = "down", command = "splash_down" },
 { key = "enter", command = "splash_open" },
]

[explorer]
key_bindings = [
 { key = "k", command = "explorer_up" },
 { key = "j", command = "explorer_down" },
 { key = "up", command = "explorer_up" },
 { key = "down", command = "explorer_down" },
 { key = "t", command = "explorer_toggle" },
 { key = "h", command = "explorer_hide_pane" },
 { key = "l", command = "explorer_expand_pane" },
 { key = "left", command = "explorer_hide_pane" },
 { key = "right", command = "explorer_expand_pane" },
 { key = "s", command = "explorer_sort" },
 { key = "n", command = "explorer_new_untitled_note" },
 { key = "shift+n", command = "explorer_new_untitled_folder" },
 { key = "r", command = "explorer_toggle_input_rename" },
 { key = "tab", command = "explorer_switch_pane_next" },
 { key = "shift+backtab", command = "explorer_switch_pane_previous" },
 { key = "enter", command = "explorer_open" },
 { key = "ctrl+b", command = "explorer_toggle" },
 { key = "ctrl+u", command = "explorer_scroll_up_half_page" },
 { key = "ctrl+d", command = "explorer_scroll_down_half_page" },
 { key = "ctrl+o", command = "explorer_toggle_outline" },
 { key = "ctrl+shift+up", command = "explorer_scroll_to_top" },
 { key = "ctrl+shift+down", command = "explorer_scroll_to_bottom" },
]

[outline]
key_bindings = [
 { key = "k", command = "outline_up" },
 { key = "j", command = "outline_down" },
 { key = "up", command = "outline_up" },
 { key = "down", command = "outline_down" },
 { key = "ctrl+o", command = "outline_toggle" },
 { key = "ctrl+b", command = "outline_toggle_explorer" },
 { key = "t", command = "outline_toggle_explorer" },
 { key = "tab", command = "outline_switch_pane_next" },
 { key = "shift+backtab", command = "outline_switch_pane_previous" },
 { key = "enter", command = "outline_expand" },
 { key = "g", command = "outline_select" },
 { key = "ctrl+shift+up", command = "explorer_scroll_to_top" },
 { key = "ctrl+shift+down", command = "explorer_scroll_to_bottom" },
]

[note_editor]
key_bindings = [
 { key = "k", command = "note_editor_cursor_up" },
 { key = "j", command = "note_editor_cursor_down" },
 { key = "up", command = "note_editor_cursor_up" },
 { key = "down", command = "note_editor_cursor_down" },
 { key = "t", command = "note_editor_toggle_explorer" },
 { key = "tab", command = "note_editor_switch_pane_next" },
 { key = "shift+backtab", command = "note_editor_switch_pane_previous" },
 { key = "ctrl+b", command = "note_editor_toggle_explorer" },
 { key = "ctrl+u", command = "note_editor_scroll_up_half_page" },
 { key = "ctrl+d", command = "note_editor_scroll_down_half_page" },
 { key = "ctrl+o", command = "note_editor_toggle_outline" },
 { key = "ctrl+shift+up", command = "note_editor_scroll_to_top" },
 { key = "ctrl+shift+down", command = "note_editor_scroll_to_bottom" },

 # Experimental editor 
 { key = "i", command = "note_editor_experimental_set_edit_view" },
 { key = "ctrl+e", command = "note_editor_experimental_toggle_view" },
 { key = "shift+r", command = "note_editor_experimental_set_read_view" },
 { key = "ctrl+x", command = "note_editor_experimental_save" },
 { key = "esc", command = "note_editor_experimental_exit" },
 { key = "h", command = "note_editor_experimental_cursor_left" },
 { key = "l", command = "note_editor_experimental_cursor_right" },
 { key = "left", command = "note_editor_experimental_cursor_left" },
 { key = "right", command = "note_editor_experimental_cursor_right" },
 # 'f' translates to arrow key right
 { key = "alt+f", command = "note_editor_experimental_cursor_word_forward" },
 # 'b' translates to arrow key left
 { key = "alt+b", command = "note_editor_experimental_cursor_word_backward" },
]

[input_modal]
key_bindings = [
 { key = "esc", command = "input_modal_cancel" },
 { key = "enter", command = "input_modal_accept" },
 { key = "i", command = "input_modal_edit_mode" },
 { key = "h", command = "input_modal_left" },
 { key = "l", command = "input_modal_right" },
 { key = "left", command = "input_modal_left" },
 { key = "right", command = "input_modal_right" },
 # 'f' translates to arrow key right
 { key = "alt+f", command = "input_modal_word_forward" },
 # 'b' translates to arrow key left
 { key = "alt+b", command = "input_modal_word_backward" },
]

[help_modal]
key_bindings = [
 { key = "esc", command = "help_modal_close" },
 { key = "k", command = "help_modal_scroll_up_one" },
 { key = "j", command = "help_modal_scroll_down_one" },
 { key = "up", command = "help_modal_scroll_up_one" },
 { key = "down", command = "help_modal_scroll_down_one" },
 { key = "ctrl+u", command = "help_modal_scroll_up_half_page" },
 { key = "ctrl+d", command = "help_modal_scroll_down_half_page" },
]

[vault_selector_modal]
key_bindings = [
 { key = "k", command = "vault_selector_modal_up" },
 { key = "j", command = "vault_selector_modal_down" },
 { key = "up", command = "vault_selector_modal_up" },
 { key = "down", command = "vault_selector_modal_down" },
 { key = "enter", command = "vault_selector_modal_open" },
 { key = "esc", command = "vault_selector_modal_close" },
]

[debug_log_modal]
key_bindings = [
 { key = "esc", command = "debug_log_close" },
 { key = "k", command = "debug_log_scroll_up_one" },
 { key = "j", command = "debug_log_scroll_down_one" },
 { key = "up", command = "debug_log_scroll_up_one" },
 { key = "down", command = "debug_log_scroll_down_one" },
 { key = "ctrl+u", command = "debug_log_scroll_up_half_page" },
 { key = "ctrl+d", command = "debug_log_scroll_down_half_page" },
 { key = "c", command = "debug_log_clear" },
 { key = "L", command = "debug_log_cycle_level" },
]
