Files
doomemacs/modules/tools/editorconfig
2025-09-18 00:24:21 -04:00
..
2024-09-14 20:47:39 -04:00
2019-04-24 18:16:04 -04:00
2025-09-14 16:25:12 -04:00

:tools editorconfig

Description   unfold

This module adds EditorConfig support to Emacs, allowing users to dictate code style on a per-project basis with .editorconfig files (formal specification), with or without the native editorconfig binary.

Module flags

This module has no flags.

Hacks

  • Special integration for dtrt-indent: If the local editorconfig file specifies indent_style or indent_size, the doom-package:dtrt-indent (which tries to guess your indent settings by analyzing your text file) will bow out.
  • Special integration for ws-butler: this module will use doom-package:ws-butler to enforce trim_trailing_whitespace.

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module has one optional dependency: the native editorconfig binary. Without it, a built-in elisp implementation will be used, which is claimed to be faster and more secure.

If you choose to install the binary, many implementations are available, usually through your OS package manager (if not built from source yourself).

Usage

A .editorconfig file in your project (usually in the root directory of the project) is needed to configure code style for files in the same directory or below. Documentation on editorconfig's properties can be found here.

TODO Configuration

󱌣 This module's configuration documentation is incomplete. Complete it?

Adding support for more major modes

Out the box, the editorconfig plugin supports many Emacs major modes, but it's possible you'll find one it doesn't support. Adding support is easy so long as you know that mode's indentation variables. For example, coffee-mode has a coffee-tab-width variable that controls indentation width in CoffeeScript files. Editorconfig already supports this language, but let's pretend it doesn't:

The editorconfig-indentation-alist variable contains a list of major modes and their indentation variables. To add coffee-mode to it:

;; in $DOOMDIR/config.el
(after! editorconfig
  (add-to-list 'editorconfig-indentation-alist '(coffee-mode coffee-tab-width)))

But what if you don't know the correct indentation variable(s). Use SPC h v (C-h v for non-evil users) to peruse all the available variables in your current session of Emacs. Look for variables that have the words indent, offset or tab-width in them. They will be prefixed with the plugin they belong to (e.g. rustic-indent-offset).

Troubleshooting

There are no known problems with this module. Report one?

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

󱌣 This module has no appendix yet. Write one?