Commit bd3040c
committed
Make vim respect the tab width settings
Somehow the dune filetype in neovim ends up with the "lisp" option set
despite this not being explicitly configured. Without this setting
indentation of dune files does not happen at all, as it's needed for vim
to indent lines based on parentheses. Unfortunately when "lisp" is set,
it also causes the softtabstop and shiftwidth settings to be ignored,
presumably to allow for indentation conventions in lisp where elements
of lists are aligned to the first element of the list, regardless of its
indentation. The default behaviour with "lisp" enabled also effectively
uses a softtabstop of 2, and this can't be overriden by setting the
softtabstop variable.
This makes it frustrating to edit dune files in vim, as the indentation
inserted by the editor won't match the 1-space indentation commonly
found in dune files. The workaround is to to set lispoptions=expr:1
which allows vim to use a custom indentexpr when "lisp" is set, and
to supply a custom indentexpr function which changes the indentation
based on unmatched parentheses, which is an approximation of the
behaviour of `dune format-dune-file`.
Signed-off-by: Stephen Sherratt <[email protected]>1 parent 81be9d0 commit bd3040c
1 file changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
12 | 30 | | |
13 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
14 | 36 | | |
15 | 37 | | |
0 commit comments