Skip to content

Comments

feat(config): add can_use_signcolumn callback#6

Open
barrettruth wants to merge 3 commits intomalewicz1337:mainfrom
barrettruth:fix/signcolumn-utf8-and-callback
Open

feat(config): add can_use_signcolumn callback#6
barrettruth wants to merge 3 commits intomalewicz1337:mainfrom
barrettruth:fix/signcolumn-utf8-and-callback

Conversation

@barrettruth
Copy link

@barrettruth barrettruth commented Feb 22, 2026

Problem

oil.nvim sets signcolumn=no by default. The plugin's internal check sees this and falls back to eol virtual text, which means sign_text extmarks are never placed. This makes it impossible to use symbol_position = 'signcolumn' without overriding oil's win_options.

Users with custom statuscolumn expressions need sign_text extmarks placed so they can render signs at a width of their choosing (Neovim's native sign column is hardcoded to 2 cells per sign). Users with native signcolumn need the plugin to set vim.wo.signcolumn for them.

Solution

Add a can_use_signcolumn callback that overrides the internal signcolumn check. The return value controls behavior:

  • true (boolean): place sign_text extmarks, don't manage vim.wo.signcolumn. For users who render signs themselves via a custom statuscolumn.
  • String (e.g. 'yes', 'auto:2'): place sign_text extmarks AND set vim.wo.signcolumn to the returned value. For users who want the plugin to manage signcolumn.
  • nil/false: fall through to the internal check (existing behavior).

Also fixes multi-byte sign truncation (strcharpart instead of sub).

Problem: string.sub operates on bytes, not characters. Multi-byte UTF-8
symbols (e.g. │ U+2502, 3 bytes) get corrupted by sub(1, 2), producing
invalid UTF-8 that silently fails inside pcall'd nvim_buf_set_extmark.

Solution: use vim.fn.strcharpart(hl.symbol, 0, 2) which correctly slices
by character count, preserving multi-byte sign_text symbols.
Problem: signcolumn mode requires users to configure oil's
win_options.signcolumn to yes:2+, coupling two unrelated configs. The
internal gate silently falls back to EOL when the option is missing, and
always reserves 2 columns even though only 1 is needed.

Solution: add a can_use_signcolumn config option that accepts a function
(fun(bufnr): string|false). When set, the plugin manages
vim.wo.signcolumn per-window using the returned value, bypassing the
internal gate. When nil (default), the existing gate behavior is
preserved for backwards compatibility.
@barrettruth barrettruth marked this pull request as draft February 23, 2026 05:14
Problem: can_use_signcolumn treated any truthy return as a signal to
manage vim.wo.signcolumn, including boolean true. This caused an error
when setting signcolumn to a non-string value, and made it impossible
to place sign_text extmarks without the plugin also managing the
signcolumn window option.

Solution: use type(scl_value) == "string" to distinguish boolean from
string returns. Boolean true now means "place sign_text extmarks but
don't manage signcolumn," enabling custom statuscolumn integration.
@barrettruth barrettruth changed the title fix: UTF-8 sign_text truncation, add can_use_signcolumn callback feat(config): add can_use_signcolumn callback Feb 23, 2026
@barrettruth barrettruth marked this pull request as ready for review February 23, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant