junegunn / junegunn/vader.vim

Vader executes nofiletype text with different tab width than what you see in test file.

Open
#17 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
599
Forks
40
PR merge metrics
No merged PRs in 30d

Description

Vader test files use shiftwidth and tabstop of 2. Vim's default is 8. So if you test something that relies on virtual columns (e.g., idbrii/textobj-word-column.vim/issues/1), you get incorrect results.

I'm not sure how to resolve this. Vader could set shiftwidth and tabstop to 2 when no filetype is defined so plaintext will behave as expected, but then filetypes that set their own tab width will misbehave.

Trying to change the tab width while editing a Vader file results in mismatching tabs because Vader wants Given text to start with two spaces. If I just indent with four spaces, my input text has those extra two spaces before it. Maybe Vader could use 'tabstop' to determine the number of leading spaces (and still default it to 2)?

Simple test case for the problem and my current workaround:

```
Before (assume vim's default sw,ts=8):
set sw=8 ts=8

Given (text indented with tabs):
Given some text indented
with tabs.

Execute (check columns):
call search('with')
let vcol_with = virtcol('.')
call search('some', 'w')
# Vader's ftplugin sets sw,ts = 2 so above we see 'some' and 'with' aligned.
AssertEqual vcol_with, virtcol('.')
# There are three tabs and sw,ts = 2.
AssertEqual 3 * 2 + 1, virtcol('.')

Execute (check columns):
# We can work around this, by forcing tab width to match current file.
setlocal sw=2 ts=2
call search('with')
AssertEqual 7, virtcol('.')
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.