Merge branch 'indentation-madness'
This commit is contained in:
commit
cf27387180
|
@ -4,4 +4,4 @@ bin
|
||||||
.dub
|
.dub
|
||||||
dub.selections.json
|
dub.selections.json
|
||||||
.gdb_history
|
.gdb_history
|
||||||
dfmt
|
bin/dfmt
|
||||||
|
|
15
README.md
15
README.md
|
@ -89,13 +89,14 @@ Property Name | Allowed Values | Default Value | Description
|
||||||
--------------|----------------|---------------|------------
|
--------------|----------------|---------------|------------
|
||||||
dfmt_brace_style | `allman`, `otbs`, or `stroustrup` | `allman` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
|
dfmt_brace_style | `allman`, `otbs`, or `stroustrup` | `allman` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
|
||||||
dfmt_soft_max_line_length | positive integers | `80` | The formatting process will usually keep lines below this length, but they may be up to max_line_length columns long.
|
dfmt_soft_max_line_length | positive integers | `80` | The formatting process will usually keep lines below this length, but they may be up to max_line_length columns long.
|
||||||
dfmt_align_switch_statements (Not yet implemented) | `true`, `false` | `true` | Align labels, cases, and defaults with their enclosing switch
|
dfmt_align_switch_statements (Not yet implemented) | `true`, `false` | `true` | Align labels, cases, and defaults with their enclosing switch.
|
||||||
dfmt_outdent_attributes (Not yet implemented) | `true`, `false` | `true` | Decrease the indentation level of attributes
|
dfmt_outdent_attributes (Not yet implemented) | `true`, `false` | `true` | Decrease the indentation level of attributes.
|
||||||
dfmt_split_operator_at_line_end | `true`, `false` | `false` | Place operators on the end of the previous line when splitting lines
|
dfmt_split_operator_at_line_end | `true`, `false` | `false` | Place operators on the end of the previous line when splitting lines.
|
||||||
dfmt_space_after_cast | `true`, `false` | `true` | Insert space after the closing paren of a `cast` expression
|
dfmt_space_after_cast | `true`, `false` | `true` | Insert space after the closing paren of a `cast` expression.
|
||||||
dfmt_space_after_keywords (Not yet implemented) | `true`, `false` | `true` | Insert space after `if`, `while`, `foreach`, etc, and before the `(`
|
dfmt_space_after_keywords (Not yet implemented) | `true`, `false` | `true` | Insert space after `if`, `while`, `foreach`, etc, and before the `(`.
|
||||||
dfmt_selective_import_space | `true`, `false` | `true` | Insert space after the module name and before the `:` for selective imports
|
dfmt_selective_import_space | `true`, `false` | `true` | Insert space after the module name and before the `:` for selective imports.
|
||||||
dfmt_compact_labeled_statements | `true`, `false` | `true` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement
|
dfmt_compact_labeled_statements | `true`, `false` | `true` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement.
|
||||||
|
dfmt_template_constraint_style | `conditional_newline_indent` `conditional_newline` `always_newline` `always_newline_indent` | `conditional_newline_indent` | Control the formatting of template constraints.
|
||||||
|
|
||||||
## Terminology
|
## Terminology
|
||||||
* Braces - `{` and `}`
|
* Braces - `{` and `}`
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Completion for dfmt
|
||||||
|
_dfmt()
|
||||||
|
{
|
||||||
|
local cur prev opts
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
opts="--help -h --inplace -i --version --align_switch_statements --brace_style\
|
||||||
|
--end_of_line --indent_size --indent_style -t --soft_max_line_length\
|
||||||
|
--max_line_length --outdent_attributes --space_after_cast\
|
||||||
|
--selective_import_space --split_operator_at_line_end\
|
||||||
|
--compact_labeled_statements --template_constraint_style"
|
||||||
|
eolOpts="lf cr crlf"
|
||||||
|
braceOpts="allman otbs stroustrup"
|
||||||
|
indentOpts="tab space"
|
||||||
|
constraintOpts="conditional_newline_indent conditional_newline always_newline always_newline_indent"
|
||||||
|
if [[ ${cur} == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
|
case "${prev}" in
|
||||||
|
"--brace_style")
|
||||||
|
COMPREPLY=($(compgen -W "${braceOpts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"--end_of_line")
|
||||||
|
COMPREPLY=($(compgen -W "${eolOpts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"-t")
|
||||||
|
;&
|
||||||
|
"--indent_style")
|
||||||
|
COMPREPLY=($(compgen -W "${indentOpts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"--template_constraint_style")
|
||||||
|
COMPREPLY=($(compgen -W "${constraintOpts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
|
}
|
||||||
|
complete -F _dfmt dfmt
|
|
@ -184,12 +184,14 @@ else
|
||||||
private string optionsToString(E)() if (is(E == enum))
|
private string optionsToString(E)() if (is(E == enum))
|
||||||
{
|
{
|
||||||
import std.traits : EnumMembers;
|
import std.traits : EnumMembers;
|
||||||
import std.conv;
|
import std.conv : to;
|
||||||
|
|
||||||
string result = "[";
|
string result = "[";
|
||||||
foreach (i, option; EnumMembers!E)
|
foreach (i, option; EnumMembers!E)
|
||||||
{
|
{
|
||||||
result ~= to!string(option) ~ "|";
|
immutable s = to!string(option);
|
||||||
|
if (s != "unspecified")
|
||||||
|
result ~= s ~ "|";
|
||||||
}
|
}
|
||||||
result = result[0 .. $ - 1] ~ "]";
|
result = result[0 .. $ - 1] ~ "]";
|
||||||
return result;
|
return result;
|
||||||
|
@ -209,7 +211,8 @@ Formatting Options:
|
||||||
--align_switch_statements
|
--align_switch_statements
|
||||||
--brace_style `,
|
--brace_style `,
|
||||||
optionsToString!(typeof(Config.dfmt_brace_style))(), `
|
optionsToString!(typeof(Config.dfmt_brace_style))(), `
|
||||||
--end_of_line
|
--end_of_line `,
|
||||||
|
optionsToString!(typeof(Config.end_of_line))(), `
|
||||||
--help|h
|
--help|h
|
||||||
--indent_size
|
--indent_size
|
||||||
--indent_style|t `,
|
--indent_style|t `,
|
||||||
|
|
Loading…
Reference in New Issue