2022-03-28 15:03:21 +02:00
|
|
|
#+title: :tools editorconfig
|
|
|
|
#+subtitle: Let someone else argue tabs and spaces
|
|
|
|
#+created: December 27, 2015
|
|
|
|
#+since: 0.9
|
2021-10-16 01:29:27 +02:00
|
|
|
|
|
|
|
* Description :unfold:
|
2021-03-05 23:10:27 -05:00
|
|
|
This module integrates [[https://editorconfig.org/][EditorConfig]] into Emacs, allowing users to dictate code
|
|
|
|
style on a per-project basis with an =.editorconfig= file ([[https://editorconfig-specification.readthedocs.io/][formal
|
|
|
|
specification]]).
|
2021-03-06 03:35:06 +00:00
|
|
|
|
|
|
|
** Maintainers
|
2021-10-16 01:29:27 +02:00
|
|
|
- [[doom-user:][@hlissner]]
|
|
|
|
|
|
|
|
[[doom-contrib-maintainer:][Become a maintainer?]]
|
2021-03-06 03:35:06 +00:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
** Module flags
|
|
|
|
/This module has no flags./
|
2018-05-08 19:59:08 +02:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
** Packages
|
2022-09-26 02:19:42 +08:00
|
|
|
- [[doom-package:editorconfig-emacs]]
|
2021-03-05 23:10:27 -05:00
|
|
|
|
|
|
|
** Hacks
|
2021-10-16 01:29:27 +02:00
|
|
|
- Added logic to guess an extension-less file's type from its shebang line. For
|
2021-03-05 23:10:27 -05:00
|
|
|
example, editorconfig rules for =*.py= files will apply to =bin/myscript=
|
|
|
|
assuming its first line is ~#!/usr/bin/env python~. See
|
|
|
|
~+editorconfig-mode-alist~ for adding support for more languages.
|
2021-10-16 01:29:27 +02:00
|
|
|
- *Special integration for =dtrt-indent=:* If the local editorconfig file
|
2022-09-26 02:19:42 +08:00
|
|
|
specifies ~indent_style~ or ~indent_size~, the [[doom-package:dtrt-indent]] (which tries to
|
2021-03-05 23:10:27 -05:00
|
|
|
guess your indent settings by analyzing your text file) will bow out.
|
2022-09-26 02:19:42 +08:00
|
|
|
- *Special integration for =ws-butler=:* this module will use [[doom-package:ws-butler]] to
|
2021-03-05 23:10:27 -05:00
|
|
|
enforce ~trim_trailing_whitespace~.
|
2021-03-06 03:35:06 +00:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
|
|
|
|
2021-03-05 23:10:27 -05:00
|
|
|
This module has one optional dependency: the ~editorconfig~ native binary.
|
|
|
|
Without it, a built-in elisp implementation will be used, but it has fewer
|
|
|
|
features and can be a bit slower.
|
|
|
|
|
|
|
|
The editorconfig binary has [[https://github.com/editorconfig#contributing][many implementations]] you can choose from, typically
|
|
|
|
available through your OS package manager (or build it yourself).
|
2021-03-06 03:35:06 +00:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
* Usage
|
2021-03-05 23:10:27 -05:00
|
|
|
You will need to write an ~.editorconfig~ file in your project (this is usually
|
2021-10-16 01:29:27 +02:00
|
|
|
in the root of your project) you can find out about all the properties [[https://editorconfig.org/#example-file][here]].
|
|
|
|
|
|
|
|
* TODO Configuration
|
|
|
|
#+begin_quote
|
2023-09-16 20:19:11 +02:00
|
|
|
/This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_quote
|
2018-05-08 19:59:08 +02:00
|
|
|
|
2021-03-05 23:10:27 -05:00
|
|
|
** 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:
|
2018-05-08 19:59:08 +02:00
|
|
|
|
2021-03-05 23:10:27 -05:00
|
|
|
The ~editorconfig-indentation-alist~ variable contains a list of major modes and
|
|
|
|
their indentation variables. To add coffee-mode to it:
|
2021-10-16 01:29:27 +02:00
|
|
|
#+begin_src emacs-lisp
|
|
|
|
;; in $DOOMDIR/config.el
|
2021-03-06 03:35:06 +00:00
|
|
|
(after! editorconfig
|
|
|
|
(add-to-list 'editorconfig-indentation-alist '(coffee-mode coffee-tab-width)))
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
But what if you don't know the correct indentation variable(s). Use [[kbd:][SPC h v]] ([[kbd:][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./ [[doom-report:][Report one?]]
|
2021-03-06 03:35:06 +00:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
* Frequently asked questions
|
|
|
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
2021-03-06 03:35:06 +00:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
2023-09-16 20:19:11 +02:00
|
|
|
This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_quote
|