Make vim respect the tab width settings #108
Open
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.
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
.