-- put user settings here
-- this module will be loaded after everything else when the application starts

-- sat may 16, 2020 -two

local keymap = require("core.keymap")
local config = require("core.config")
local style = require("core.style")

-- Debug
config.debug_auto_run_tests = false
config.debug_keymap = false
config.debug_keymap_strokes = { "ctrl+return" }
config.debug_doc_load = true
config.debug_font_load = true
config.font_glyph_page_size = 64

-- include custom theme
require("styles.liqube")

config.indent_size = 4
config.fps = 140
config.minimap_enabled = true
config.line_limit = 120
config.rulers = { config.line_limit }

config.new_doc_auto_create_on_startup = true

-- Scroll wheel by line count instead of pixels
config.mouse_wheel_scroll_lines = 12

-- Use Ctrl+Wheel for fastscroll
config.treeview_size = 250 * SCALE
config.treeview_init_visible = false

-- Show EOL markers (trailing whitespace only) by default
config.highlight_eol = "trailing"

-- Comments plugin line style
config.comments_place_after_indent = false -- true: after indent, false: beginning of line
config.comments_block_pad_inline = true -- true: /* text */, false: /*text*/
config.comments_keep_selection = true -- true: keep selection, false: clear selection

-- Highlight current word matches when no selection
config.highlight_current_word = false

-- Highlight matches of the current selection
config.highlight_selection_matches = true

-- Draw boxes around selection match candidates
config.highlight_selection_boxes = false

-- replace keys in keymap
keymap.add({
	["f1"] = "treeview:toggle",

	-- close tabs on f4
--	["f4"] = "root:close",

	-- toggle treeview
--	["ctrl+f4"] = "treeview:toggle",

	-- search
--	["f7"] = "find-replace:find",
--	["ctrl+f7"] = "find-replace:replace",

	-- goto line
--	["alt+f8"] = "doc:go-to-line",

	["f9"] = "core:repeat-last-command",

	-- Escape closes panels/selection/doc before quitting
	["escape"] = "core:escape2",
	--	["escape"] 			= "core:escape",
	--	["escape"] 			= "root:close",

	-- Split view shortcuts
	["ctrl+alt+shift+right"] = "workspace:split-right",
	["ctrl+alt+shift+down"] = "workspace:split-down",

	-- disable default move lines, set to auto complete navigation
--	["ctrl+up"] = "command:select-previous",
--	["ctrl+down"] = "command:select-next",

	-- disable default auto complete navigation
--	["up"] = {
--	    "command:select-previous",
--	    "doc:move-to-previous-line",
--	},
--	["down"] = {
--	    "command:select-next",
--	    "doc:move-to-next-line",
--	},
	-- Alt+Up/Down: autocomplete navigation
	-- Alt+Up/Down: Outline navigation
	["alt+up"] = {
	    "autocomplete:previous",
	    "doc:outline-previous",
	},
	["alt+down"] = {
	    "autocomplete:next",
	    "doc:outline-next",
	},
	["alt+home"] = "doc:outline-first",
	["alt+end"] = "doc:outline-last",
	["alt+wheelup"] = "doc:outline-previous",
	["alt+wheeldown"] = "doc:outline-next",

	["ctrl+alt+j"] = "tidyjson:format",
	["shift+ctrl+alt+j"] = "tidyjson:minimize",

	-- comments plugin bindings
	["alt+c"] = "comment:toggle-smart",
	["ctrl+alt+c"] = "comment:toggle-block",
	["ctrl+shift+c"] = "comment:toggle-guard",

	-- Fastscroll on Ctrl+Wheel
--	["ctrl+wheelup"] = "doc:fastscroll-up",
--	["ctrl+wheeldown"] = "doc:fastscroll-down",

	-- move lines
	["ctrl+shift+up"] = "doc:move-lines-up",
	["ctrl+shift+down"] = "doc:move-lines-down",

	-- find next word under cursor
	["ctrl+shift+d"] = {
		"find-replace:select-next",
		"doc:select-word",
	},

	["ctrl+d"] = "outlinelist:toggle",

	["ctrl+alt+pageup"] = "doc:scroll-page-up",
	["ctrl+alt+pagedown"] = "doc:scroll-page-down",
}, {
	layer = "user",
	overwrite = true,
})

local core = require("core")
local command = require("core.command")

keymap.add({
	["ctrl+shift+alt+o"] = "core:edit-user-settings",
})
