-- lx-bundle:true

local common = require("core.common")

local config = {}

config.plugins = config.plugins or {}

-- Allow any fallback font files beyond the primary UI fonts
config.use_fallback_fonts = true

-- Allow fallback font entries tagged with these explicit tags
-- Platform-specific tags "windows", "linux", "macos" are automatically enabled
config.enabled_fallback_font_tags = {
	"emoji",		-- Monochrome emoji (recommended if you want raw speed)
	"coloremoji",	-- Color emoji (enable if you absolutely must have color emoji)
	"symbols",		-- General symbols
	"music",		-- Music notation symbols
	"cjk",			-- Combines Chinese/Japanese/Korean coverage
--	"japanese",		-- Japanese coverage
--	"korean",		-- Korean coverage
--	"chinese",		-- Simplified Chinese coverage
--	"chinesetr",	-- Traditional Chinese coverage
	"arabic",		-- Arabic-script coverage
	"thai",			-- Thai-script coverage
	"indic",		-- Combines Indic-script coverage
--	"devanagari",	-- Devanagari Indic script
--	"kannada",		-- Kannada Indic script
--	"tamil",		-- Tamil Indic script
--	"telugu",		-- Telugu Indic script
--	"bengali",		-- Bengali Indic script
}

-- Enable font bitmap glyphs such as fixed-strike emoji fonts
config.allow_font_bitmap_glyphs = true

-- Enable font SVG glyphs such as OT-SVG color emoji fonts
config.allow_font_svg_glyphs = true

-- Renderer font quality controls applied before style fonts are loaded
config.font_quality = {
	hinting = "light",
	render_mode = "normal",
	alpha_gamma = 0.9,
	alpha_contrast = 0.2,
	embolden = 0.0,
}

-- Enable syntax highlighter tokenization and colored token rendering in doc views
config.syntax_highlighting = true

-- Default text-doc surface mode: 'editor' or 'viewer'
config.text_view_mode = "editor"

-- Default syntax draw mode for TextViewer
config.text_viewer_syntax_highlighting = false

-- Keep TextViewer wrap opt-in until the wrapped path settles
config.text_viewer_word_wrap = true

-- Keep TextEditor wrap opt-in until the wrapped editor path settles
config.text_editor_word_wrap = true

-- Keep wrapped continuation rows aligned with leading indentation
config.text_wrap_preserve_indent = true

-- Keep at least this many monospace columns available after continuation indent
config.text_wrap_min_columns = 8

-- Collect wrapped layout and draw timing counters only when profiling is enabled
config.text_wrap_profile_enabled = true

-- Synthetic wrap benchmark line count used by the wrap profiling command
config.text_wrap_profile_bench_lines = 25000

-- Synthetic wrap benchmark line width used by the wrap profiling command
config.text_wrap_profile_bench_columns = 180

-- Repeat count used for cached wrap benchmark passes
config.text_wrap_profile_bench_repeats = 5

-- Collect syntax and render perf counters for manual debugging snapshots
config.debug_syntax_render_perf = false

-- TextViewer keeps a clean reading layout without a gutter by default
config.text_viewer_gutter = false

-- TextViewer line numbers stay off unless the gutter is explicitly enabled
config.text_viewer_line_numbers = false

-- TextEditor keeps the shared gutter visible for change markers and bookmarks
config.text_editor_gutter = true

-- TextEditor shows line numbers inside the visible gutter by default
config.text_editor_line_numbers = true


config.project_scan_rate = 5

-- Background recursive project scan is opt-in and starts only on demand
config.project_scan_enabled = false

-- Hard cap for recursive background project scan entries
config.project_scan_limit_files = 2000

-- Treeview scans each root only once; rescan only when root changes
config.treeview_scan_once = true
config.fps = 60
config.max_log_items = 500

-- Minimum status-message visibility duration in seconds (clamped to 1..5)
config.message_timeout_min = 1

-- Maximum status-message visibility duration in seconds (clamped to 1..5)
config.message_timeout_max = 5

-- Message length floor for timeout scaling; <= this uses min timeout
config.message_timeout_min_chars = 15

-- Message length cap for timeout scaling; >= this uses max timeout
config.message_timeout_max_chars = 80

-- Delay in seconds before status-item tooltips appear on hover
config.status_tooltip_delay = 0.5

-- Grace period in seconds before a visible tooltip is hidden after hover leaves
config.tooltip_hide_grace = 0.2

-- Legacy pixel-based wheel delta (used when line-based mode is not available)
config.mouse_wheel_scroll = 50 * SCALE

-- Optional line-based wheel delta; when set, uses N * line_height per notch
config.mouse_wheel_scroll_lines = nil

-- Keep Ctrl+Wheel zoom opt-in to avoid collisions with wheel-bound workflows
config.zoom_bind_ctrl_wheel = false

-- Enable cache for generated zoomed code-font handles
config.zoom_cache_scaled_fonts = true

-- Max number of cached zoomed font entries kept alive at once
config.zoom_cache_scaled_fonts_max = 2

-- Max total cache bytes for zoomed fonts, 0 means unlimited
config.zoom_cache_scaled_fonts_max_bytes = 400 * 1024 * 1024

-- Debounce delay for repeated zoom input in milliseconds
config.zoom_debounce_ms = 40

-- Max visible delay while repeated zoom input is active in milliseconds
config.zoom_debounce_max_wait_ms = 20

-- Absolute content zoom levels in percent used for deterministic stepping
config.zoom_levels = {
	25,
	40,
	60,
	75,
	90,
	100,
	115,
	125,
	150,
	175,
	200,
	250,
	300,
	350,
	400,
	500,
	600,
	700,
	800,
	900,
	1000,
}

--for percent = 25, 1000, 25 do
--	config.zoom_levels[#config.zoom_levels + 1] = percent
--end

table.sort(config.zoom_levels)

-- Status-bar format for the visible document zoom value
config.zoom_status_format = "%.0f%%"

config.file_size_limit = 10
config.ignore_files = "^%."
config.symbol_pattern = "[%a_][%w_]*"

-- Primary word divider set (whitespace is handled separately by navigation)
config.word_dividers = [[~!%^&*()+|{}:"<>?`-=\[];',./]]
config.undo_merge_timeout = 0.3

-- Default debounce (seconds) for project-wide line-change subscribers
config.line_change_hook_delay = 0.15
config.max_undos = 10000
config.highlight_current_line = true

-- 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
config.line_height = 1.05

-- Cursor blink period in seconds for doc views (0: off)
config.cursor_blink_period = 1.0

-- Indent size (spaces) for the shared text grid
config.indent_size = 4

config.tab_type = "soft"
config.line_limit = 120

-- Title used for unsaved docs without an explicit filename
config.default_doc_title = "untitled"

-- Default options used by Doc.create and core:new-doc
config.new_doc_default_options = {
	name = nil,
	syntax = nil,
	indent_size = nil,
	encoding = "utf8",
	codepage = "none",
	newline = "lf",
}

-- Default options used when opening existing files
config.open_doc_default_options = {
	encoding = "auto",
	codepage = "auto",
}

-- Used only when automatic codepage detection finds non-binary invalid UTF-8 and no syntax-specific codepage
config.fallback_codepage = "cp1252"

-- Monitor open docs for external on-disk changes
config.doc_monitor_enabled = true

-- Polling interval in seconds for the active document
config.doc_monitor_active_interval = 1.0

-- Polling interval in seconds for passive documents
config.doc_monitor_passive_interval = 2.0

-- Show reload prompt when stale document becomes active
config.doc_monitor_prompt_on_focus = true

-- Show notices for changed passive documents
config.doc_monitor_notify_passive = true

-- Auto-create a new doc when startup would otherwise show only the empty root view
config.new_doc_auto_create_on_startup = false

-- Missing file open behavior: "log" | "message" | "new"
config.missing_file_open_behavior = "message"

-- Vertical rulers (character columns); nil/{} disables ruler drawing
config.rulers = {}

-- Vertical viewport anchor for line jumps (0=top, 0.5=center, 1=bottom)
config.scroll_to_line_vertical_position = 1 / 4

-- Animate viewport-relative page scrolling ('doc:scroll-page-*' and
-- 'doc:scroll-cursor-page-*') instead of jumping instantly
config.animated_page_scroll = true

-- Preserve cursor x position across vertical movement until x changes
config.persistent_cursor_col = true

-- Highlight EOL markers: "all" or "trailing"
config.highlight_eol = "trailing"

-- Shared threshold for long-line guards in rendering/plugins
config.long_line_threshold = 5000

-- Separate syntax-tokenization threshold (can be higher than shared threshold)
config.long_line_syntax_line_length = 10000

-- Syntax state checkpoint spacing in lines for faster far-line resume
config.syntax_state_checkpoint_interval = 200

-- Maximum lines to tokenize synchronously from checkpoint during on-demand draw
config.syntax_state_sync_max_lines = 32

-- Background syntax worker per-frame budget in milliseconds
config.syntax_worker_budget_ms = 0.8

-- Hard cap of lines processed by syntax worker per frame
config.syntax_worker_max_lines_per_frame = 60

-- Visible-priority syntax worker per-frame budget in milliseconds
config.syntax_worker_priority_budget_ms = 3.0

-- Hard cap of visible-priority lines processed by syntax worker per frame
config.syntax_worker_priority_max_lines_per_frame = 160

-- Lines to start before visible-priority target when rebasing after jumps
config.syntax_worker_priority_backtrack_lines = 5

-- Canonical syntax replay requested ahead from first invalid line
config.syntax_worker_linear_ahead_lines = 120

-- Horizontal autoscroll left trigger ratio (0..1)
config.hscroll_left_margin_ratio = 0.1

-- Horizontal autoscroll right trigger ratio (0..1)
config.hscroll_right_margin_ratio = 0.9

-- Outline navigation wraps between first/last points when true
config.outline_wrap_around = false

-- Enable transient line flash overlays (shared by outline, plugins, etc.)
config.line_flash = true

-- Shared line flash duration in seconds
config.line_flash_duration = 0.16

-- Shared line flash peak opacity (0..1)
config.line_flash_opacity = 0.35

-- Flash jumped-to line for outline navigation
config.outline_jump_flash = true

-- Legacy alias for line flash duration (used as fallback when line_flash_duration is nil)
config.outline_jump_flash_duration = 0.16

-- Legacy alias for line flash opacity (used as fallback when line_flash_opacity is nil)
config.outline_jump_flash_opacity = 0.35

-- When true, flash only for outline boundary errors (no success flash)
config.outline_jump_flash_only_error = true

-- Animate viewport movement for outline jumps
config.outline_jump_animated_scroll = true

-- When true, exiting interactive replace keeps cursor at the start of the
-- last visited match; when false, restore cursor to pre-replace position
config.find_replace_keep_last_match_on_exit = true

-- BinaryViewer master switch
config.binary_viewer_enabled = true

-- Session default mode on first open: 'hex' or 'symbols'
config.binary_viewer_default_mode = "hex"

-- Hex bytes-per-row can be a number or 'auto'
config.binary_viewer_hex_bytes_per_row = "auto"

-- Allowed values used by 'auto' width fitting
config.binary_viewer_hex_bytes_per_row_allowed = {
	4, 8, 16, 24, 32,
	40, 48, 56, 64, 72,
	80, 88, 96, 104, 112,
	120, 128, 136, 144, 152,
	160, 168, 176, 184, 192,
	200, 208, 216, 224, 232,
	240, 248, 256,
}
-- Lower bound for symbol mode row width
config.binary_viewer_symbols_min_bytes_per_row = 48

-- Group size used for visual separators
config.binary_viewer_group_bytes = 8

-- Offset prefix visibility per mode
config.binary_viewer_show_offset_hex = true
config.binary_viewer_show_offset_binary = false

-- Separator visibility controls
config.binary_viewer_hex_separator = true
config.binary_viewer_char_separator = false

-- Symbol shown for 0x00 when rendering binary character cells
config.binary_viewer_nul_symbol = '.'

-- Character mapping mode: 'printable' | 'full'
config.binary_viewer_char_mode = "full"

-- Codepage table name in data/cp/<name>.lua
config.binary_viewer_codepage = "cp437"

-- Number of off-screen rows to prefetch around visible range
config.binary_viewer_prefetch_rows = 80

-- Top ruler visibility
config.binary_viewer_show_ruler = true

-- Smooth lerp scroll toggle
config.binary_viewer_smooth_scroll = true

-- Dim zero byte text overlay toggle
config.binary_viewer_dim_nul_bytes = true

return config
