|
1 |
| -# xVimscript |
| 1 | +# Exercism Vim script Track |
2 | 2 |
|
3 |
| - |
| 3 | +[](https://gitter.im/exercism/vimscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
4 | 4 |
|
5 |
| -Exercism exercises in Vim script. |
6 |
| - |
7 |
| -## Contributing |
| 5 | + |
| 6 | +[](https://gitter.im/exercism/xvimscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
8 | 7 |
|
9 | 8 | We welcome any kind of contribution!
|
10 | 9 |
|
11 | 10 | If you have a suggestion or question, create a new
|
12 |
| -[issue](https://github.com/exercism/xvimscript/issues). |
| 11 | +[issue](https://github.com/exercism/vimscript/issues). |
13 | 12 |
|
14 | 13 | For code or fixing typos and similar things, open a
|
15 |
| -[pull request](https://github.com/exercism/xvimscript/pulls). |
| 14 | +[pull request](https://github.com/exercism/vimscript/pulls). |
16 | 15 |
|
17 |
| -Look at recent [commits](https://github.com/exercism/xvimscript/commits/master) |
| 16 | +Look at recent [commits](https://github.com/exercism/vimscript/commits/master) |
18 | 17 | to get a feeling on how to format your own ones.
|
19 | 18 |
|
20 | 19 | Even if there are any uncertainties, go for it nevertheless. We can straighten
|
21 | 20 | out everything in the process.
|
22 | 21 |
|
23 | 22 | Thank you for contributing! :tada:
|
| 23 | + |
| 24 | +## Linting Vim files |
| 25 | + |
| 26 | +If you add or change a Vim file, the CI will use vint to ensure best practices. |
| 27 | +Therefore it's recommended idea to run it locally first, before creating a pull |
| 28 | +request. |
| 29 | + |
| 30 | +1. Install [vint](https://github.com/Kuniwak/vint#quick-start). |
| 31 | +1. Recursively lint all Vim files: |
| 32 | + ``` |
| 33 | + $ vint . |
| 34 | + ``` |
| 35 | +
|
| 36 | +## Writing test files |
| 37 | +
|
| 38 | +#### Generating test files |
| 39 | +
|
| 40 | +Use the [generator](lib/generate.vim) to create Vader files from their canonical |
| 41 | +test data: |
| 42 | +
|
| 43 | +```vim |
| 44 | +" in Vim |
| 45 | +:source lib/generate.vim |
| 46 | +:Generate word-count |
| 47 | +``` |
| 48 | + |
| 49 | +This would fetch the [canonical test data](https://raw.githubusercontent.com/exercism/x-common/master/exercises/word-count/canonical-data.json), |
| 50 | +decode the JSON to Vim data types, iterate over the result, and put the tests in |
| 51 | +a new unnamed buffer. |
| 52 | + |
| 53 | +_This script requires Vim 7.4.1304+ for `json_decode()`. It also relies on the |
| 54 | +netrw plugin (`:h netrw`), but that one is shipped and sourced by default._ |
| 55 | + |
| 56 | +#### Type mismatch exceptions |
| 57 | + |
| 58 | +Older Vims don't like changing types for the same variable. If your tests use |
| 59 | +global variables, `unlet!` them in a `Before` block at the top of the Vader file. |
| 60 | + |
| 61 | +When each test uses `let expected = ...`, then put this at the top: |
| 62 | + |
| 63 | +```vim |
| 64 | +Before: |
| 65 | + unlet! expected |
| 66 | +``` |
| 67 | + |
| 68 | +This is patched as of |
| 69 | +[Vim 7.4.1546](https://github.com/vim/vim/commit/f6f32c38bf3319144a84a01a154c8c91939e7acf), |
| 70 | +but we shouldn't assume versions in favor of compatibility. |
0 commit comments