Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

EditorConfig plugin for Emacs

License

NotificationsYou must be signed in to change notification settings

editorconfig/editorconfig-emacs

Repository files navigation

buildMELPAMELPA StableNonGNU ELPA

EditorConfig Emacs Plugin

This is anEditorConfig plugin forEmacs.

Getting Started

package.el

This package is available fromMELPA,MELPA Stable andNonGNU ELPA.Install from these repositories and enable global minor-modeeditorconfig-mode:

(editorconfig-mode1)

Normally, enablingeditorconfig-mode should be enough for this plugin to work:all other configurations are optional.This mode sets up hooks so that EditorConfig properties will beloaded and applied to the new buffers automatically when visiting files.

use-package

If you useuse-package, add the following to yourinit.el file:

(use-package editorconfig:ensuret:config  (editorconfig-mode1))

Manual installation

Copy all.el files in this repository to~/.emacs.d/lisp and add thefollowing:

(add-to-list'load-path"~/.emacs.d/lisp")(require'editorconfig)(editorconfig-mode1)

Supported properties

Current Emacs plugin coverage for EditorConfig'sproperties:

  • indent_style
  • indent_size
  • tab_width
  • end_of_line
  • charset
  • trim_trailing_whitespace
  • insert_final_newline
  • max_line_length
  • file_type_ext (Experimental) (See below)
  • file_type_emacs (Experimental) (See below)
  • root (only used by EditorConfig core)

Not yet covered properties marked withover-strike– pull requests implementing missing features warmly welcomed!Typically, you will want to tie these to native functionality,or the configuration of existing packages handling the feature.

As several packages have their own handling of, say, indentation,we might not yet cover some mode you use, but we try to add theones that show up on our radar.

File Type (file_type_ext, file_type_emacs)

File-type feature is currently disabled, because this package is now undergoingbig internal refactoring.For those who want this functionality,please consider usingeditorconfig-custom-majormode.

Customize

editorconfig-emacs provides some customize variables.

Here are some of these variables: for the full list of available variables,typeM-x customize-group [RET] editorconfig [RET].

editorconfig-trim-whitespaces-mode

Buffer local minor-mode to use to trim trailing whitespaces.

If set, editorconfig will enable/disable this mode in accord withtrim_trailing_whitespace property in.editorconfig.Otherwise, use Emacs built-indelete-trailing-whitespace function.

One possible value isws-butler-mode, with whichonly lines touched get trimmed. To use it, add following to yourinit.el:

(setq editorconfig-trim-whitespaces-mode'ws-butler-mode)

editorconfig-after-apply-functions

(Formerlyeditorconfig-custom-hooks)

A list of functions which will be called after loading common EditorConfig settings,when you can set some custom variables.

For example,web-mode has several variables for indentation offset size andEditorConfig sets them at once byindent_size. You can stop indentingonly blocks ofweb-mode by adding following to your init.el:

(add-hook'editorconfig-after-apply-functions  (lambda (props) (setq web-mode-block-padding0)))

Troubleshooting

Enablingeditorconfig-mode should be enough for normal cases.

When EditorConfig properties are not effective for unknown reason, we recommendfirst tryingM-x editorconfig-display-current-properties.

This command will open a new buffer and display the EditorConfig propertiesloaded for current buffer.You can check if EditorConfig properties were not read for buffers at all,or they were loaded but did not take effect for some other reasons.

Indentation for new major-modes

Because most Emacs major-modes have their own indentation settings, this pluginrequires explicit support for each major-mode forindent_size property.

By default this plugin ships with settings for many major-modes, but,sorry to say, it cannot be perfect. Especially it is difficult to supportbrand-new major-modes.Please feel free to submit issue or pull-request for such major-mode!

Supported major-modes and their indentation configs are defined in the variableeditorconfig-indentation-alist.

Not work at all for FOO-mode!

Most cases properties are loaded just after visiting files wheneditorconfig-mode is enabled.But it is known that there are major-modes that this mechanism does not workfor and require explicit call ofeditorconfig-apply.

Typically it will occur when the major-mode is not defined usingdefine-derived-mode (rpm-spec-mode is an example for this).Please feel free to submit issues if you find such modes!

editorconfig-format-buffer does not work well with lsp-mode

By default,lsp-mode configures indent-region-function so that Emacs useslanguage servers'textDocument/rangeFormatting request to format text inbuffers.So EditorConfig settings are ignored unless language serversthemselves support loading configs from.editorconfig.

To avoid this behavior ad-hocly, setlsp-enable-indentation to nil.

Submitting Bugs and Feature Requests

Bugs, feature requests, and other issues should be submitted to the issuetracker:https://github.com/editorconfig/editorconfig-emacs/issues

Development

To run the test locally, you will need the following tools:

If you are onLinux ormacOS:

$ make check-unix

OnWindows:

$ make check-dos

To start a new Emacs process with current*.el and without loading user initfile, run:

$ make sandbox

License

EditorConfig Emacs Plugin is free software: you can redistribute itand/or modify it under the terms of the GNU General Public License aspublished by the Free Software Foundation, either version 3 of theLicense, or (at your option) any later version.

This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.

You should have received a copy of the GNU General Public License alongwith this program. If not, seehttps://www.gnu.org/licenses/.


[8]ページ先頭

©2009-2025 Movatter.jp