vim-dutyl
vim-dutyl copied to clipboard
dfmt and indentation
I've been having problems with the dfmt integration for indentation. There are two problems with it:
- it doesn't integrate well with vim indentation settings (I guess this is just unavoidable)
- dfmt doesn't seem to be picking up on .editorconfig files correctly when used through dutyl
Is there a convenient way to turn off using dfmt for indentation and let vim handle it normally?
You can try :call dutyl#register#tool('dfmt', '') to disable dfmt completely, but then you won't get it for formatting(gq) either. I'll add separate flags for disabling it for each feature.
As for .editorconfig support - it works fine for me, but I try and help you debug. dfmt should be picking the config file by itself(no help from dutyl required), so it shouldn't be causing dutyl-specific problems, unless...
There is one scenario I know of where dfmt won't recognize .editorconfig when used via dutyl. Say your working directory(:pwd) is /a and you are editing /a/b/c.d and your .editorconfig is at /a/b/.editorconfig. Dutyl is not invoking dfmt directly on your file - it pipes your code to it through STDIN. This means that dfmt will think it's in /a and won't be able to use the .editorconfig in the /a/b subdirectory.
Is this you scenario?
Pull the latest develop and put in your .vimrc:
let g:dutyl_dontHandleFormat = 1
let g:dutyl_dontHandleIndent = 1
(or just one of them)
So this is what I have:
% cd test
% cat .editorconfig
root = true
[*.{d,js,es6,json,sdl}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
tab_width = 4
% cat blah.d
struct S
{
int a;
}
% dfmt blah.d
struct S
{
int a;
}
so as you can see, dfmt correctly indents with a single tab (also works if I do dfmt < blah.d so it's not a stdin v.s. file argument problem in dfmt).
However, when I do vim blah.d and then =G to indent everything, I get this:
struct S
{
int a;
}
which is just a single space. If I add
let g:dutyl_dontHandleFormat = 1
let g:dutyl_dontHandleIndent = 1
to my .vimrc the indenting matches my vim settings, as expected.