Add options to customize vim indentation options #17
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.
Hello.
I have added an option to set any vim option when indentation is detected.
Right now the options to set are hard coded, but I do not think this is appropriate from a customizability standpoint.
Because vim's indentation-related settings are so complex, I thought it best to allow users to set them freely.
There are many vim users who have the tab width set to 8 or have not changed it.
I do not think it is good from the user's point of view to change the 'tabstop' when spaces are detected.
For example, projects such as gcc and vim use an indentation style that mixes tabs and spaces, but only assumes that the tab width is 8.
The old-fashioned GNU style seems to use this indent style.
Therefore, making the tab width the same as the indent width will mess up the layout.
You can see this by opening the following code in vim. (Please disable modeline in vim project)
https://github.com/gcc-mirror/gcc/blob/8f8db5553935edcb4731db32279418ca37e1f094/libgomp/config/posix/sem.c#L73-L76
https://github.com/vim/vim/blob/1bf1bf569b96d2f9b28e0cce0968ffbf2fb80aac/src/alloc.c#L97-L102
Another advantage of separating 'tabstop' from 'shiftwidth' is that if a tab is mistakenly entered, it is easier to tell that it is a tab without using :set list. The same size makes it impossible to distinguish between tabs and spaces.
For example, vim-sleuth does not change it.
The vim help below explains why.
I am going to define the default values as follows and change the following options.
default: 2 spaces, 8-width tab
This is advantageous from a performance standpoint because it reduces the number of options to be set as much as possible.
Currently the same value is set for 'tabstop', 'softtabstop', and 'shiftwidth' when spaces are detected, but If 'softtabstop' is set to -1, there is no need to set it. or if 'tabstop' and 'softabstop' are equal, 'softtabstop' is almost no point, so it can be set to 0 or 1 instead.
BTW, The editorconfig that comes with neovim has almost the same configuration values.
(The fact that 'tabstop' is also changed is a result of following the editorconfig specification.)
https://github.com/neovim/neovim/blob/master/runtime/lua/editorconfig.lua#L50-L71
Also, the specific options to be set will be written in the README, which will make it easier to understand.
Default values are to be taken over from the current settings for compatibility reason.
This PR also fixes
PR: #9
Issue: #12
also related
PR: #14