Question: Should local config of formatter have higher priority than vim setting e.g. for 'sw'
I was considering to create a pull request for the formatter latexindent for tex files to adjust the defaultIndent setting according to the current return value of shiftwidth() if 'expandtab' is set:
diff --git a/autoload/neoformat/formatters/tex.vim b/autoload/neoformat/formatters/tex.vim
index 2422336..03aa3e2 100644
--- a/autoload/neoformat/formatters/tex.vim
+++ b/autoload/neoformat/formatters/tex.vim
@@ -5,7 +5,7 @@ endfunction
function! neoformat#formatters#tex#latexindent() abort
return {
\ 'exe': 'latexindent',
- \ 'args': ['-l', '-w'],
+ \ 'args': ['-l', '-w', &expandtab?"-y='defaultIndent: \"".repeat(' ', shiftwidth())."\"'": ''],
\ 'stdin': 0,
\ 'replace': 1
\ }
Note the -y switch has the highest priority for latexindent (Doc Section 4.4):

This means if a user has created a localSettings.yaml file in the same directory as the latex file, the value for defaultIndent is overwritten by the way latexindent is called by neoformat.
I am not sure if this is desired.
On the other hand I have tex files where I do not create a localSettings.yaml file and would appreciate if latexindent would respect my 'shiftwidth' and 'textwidth' setting.
What do others think about this?
I think that makes sense.
Ideally all definitions would look for local settings files so that the user doesn't have to override anything in their init.vim
Do you have a suggestion how can I use a vim setting 'sw' if I do not have a local settings file if the load order is as given by latexindent?
you can use let shiftwith = &sw or similar to get it as a variable and then just add it to array of args
I think my question was not well written:
Following works as wished
function! neoformat#formatters#tex#latexindent() abort
return {
\ 'exe': 'latexindent',
\ 'args': ['-l', '-w', &expandtab?"-y='defaultIndent: \"".repeat(' ', shiftwidth())."\"'": ''],
\ 'stdin': 0,
\ 'replace': 1
\ }
The problem is that this always sets the defaultIndent to shiftwidth() and does overwrite a local config file.
Oh, you'd need to check for the existence of the config file and not add the params when the config file exists. Probably need to walk the directories or similar.