feat(config): add can_use_signcolumn callback#6
Open
barrettruth wants to merge 3 commits intomalewicz1337:mainfrom
Open
feat(config): add can_use_signcolumn callback#6barrettruth wants to merge 3 commits intomalewicz1337:mainfrom
barrettruth wants to merge 3 commits intomalewicz1337:mainfrom
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
oil.nvim sets
signcolumn=noby default. The plugin's internal check sees this and falls back to eol virtual text, which meanssign_textextmarks are never placed. This makes it impossible to usesymbol_position = 'signcolumn'without overriding oil'swin_options.Users with custom
statuscolumnexpressions needsign_textextmarks 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 setvim.wo.signcolumnfor them.Solution
Add a
can_use_signcolumncallback that overrides the internal signcolumn check. The return value controls behavior:true(boolean): placesign_textextmarks, don't managevim.wo.signcolumn. For users who render signs themselves via a customstatuscolumn.'yes','auto:2'): placesign_textextmarks AND setvim.wo.signcolumnto 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 (
strcharpartinstead ofsub).