Skip to content

Commit

Permalink
muon fmt: editorconfig support
Browse files Browse the repository at this point in the history
  • Loading branch information
annacrombie committed Apr 24, 2023
1 parent 8ff7088 commit dc43247
Show file tree
Hide file tree
Showing 22 changed files with 544 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ insert_final_newline = true

[{*.c,*.h,*.sh}]
indent_style = tab

[{meson.build,meson_options.txt}]
indent_style = space
indent_size = 4
2 changes: 2 additions & 0 deletions doc/muon.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ All commands accept a *-h* option which prints a brief summary of their usage.
- *-q* - exit with 1 if files would be modified by muon fmt
- *-i* - format files in-place
- *-c* <muon_fmt.ini> - read configuration from _muon\_fmt.ini_
- *-e* - try to read configuration from .editorconfig. Only indentation
related settings are recognized.

*CONFIGURATION OPTIONS*
[[ *key*
Expand Down
16 changes: 16 additions & 0 deletions include/formats/editorconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: Stone Tickle <[email protected]>
* SPDX-License-Identifier: GPL-3.0-only
*/

#ifndef MUON_FORMATS_EDITORCONFIG_H
#define MUON_FORMATS_EDITORCONFIG_H

#include "platform/filesystem.h"

struct editorconfig_opts {
const char *indent_by;
};

void try_parse_editorconfig(struct source *src, struct editorconfig_opts *opts);
#endif
2 changes: 1 addition & 1 deletion include/lang/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

#include "lang/parser.h"

bool fmt(struct source *src, FILE *out, const char *cfg_path, bool check_only);
bool fmt(struct source *src, FILE *out, const char *cfg_path, bool check_only, bool editorconfig);
#endif
1 change: 1 addition & 0 deletions src/amalgam.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "external/libarchive_null.c"
#include "external/libcurl_null.c"
#include "external/samurai_null.c"
#include "formats/editorconfig.c"
#include "formats/ini.c"
#include "formats/lines.c"
#include "formats/tap.c"
Expand Down
Loading

0 comments on commit dc43247

Please sign in to comment.