Git Product home page Git Product logo

editorconfig-emacs's Introduction

Build Status MELPA MELPA Stable

EditorConfig Emacs Plugin

This is an EditorConfig plugin for Emacs.

Installation

Download the EditorConfig C Core and follow the instructions in the README and INSTALL files to install it.

This plugin also has a built-in core library implemented in Emacs-Lisp, and fallback to it when no core executable is found.

In either case, copy .el files in this repository to ~/.emacs.d/lisp and add the following to your ~/.emacs file:

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

Alternatively, you can find the package available on MELPA and MELPA Stable (The Marmalade package is deprecated).

Or if you use use-package:

(use-package editorconfig
  :ensure t
  :config
  (editorconfig-mode 1))

Supported properties

Current Emacs plugin coverage for EditorConfig's properties:

  • indent_style
  • indent_size
  • tab_width
  • end_of_line
  • charset
  • trim_trailing_whitespace
  • insert_final_newline = true is supported
  • insert_final_newline = false is not enforced (as in trailing newlines actually being removed automagically), we just buffer-locally override any preferences that would auto-add them to files .editorconfig marks as trailing-newline-free
  • max_line_length
  • root (only used by EditorConfig core)

Not yet covered properties marked with over-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, indention, we might not yet cover some mode you use, but we try to add the ones that show up on our radar. Similarly, we don't yet hook in to all different packages for whitespace trimming to inform them about editorconfig settings, but aim for better coverage of things like ws-trim.

Customize

editorconfig-custom-hooks

A list of custom hooks after loading common EditorConfig settings, where you can set some custom variables or overwrite existing properties.

For example, web-mode has several variables for indentation offset size and EditorConfig sets them at once by indent_size. You may want to stop indenting only blocks of web-mode: it can be achieved by adding following to your init.el:

(add-hook 'editorconfig-custom-hooks
  (lambda (hash) (setq web-mode-block-padding 0)))

You can also define your own custom properties and enable them here.

editorconfig-indentation-alist

Alist of indentation setting methods by modes.

For the easiest case to add a new support for a major-mode, you just need to add a pair of major-mode symbol and its indentation variables:

(add-to-list 'editorconfig-indentation-alist
  ;; Just an example, of course EditorConfig has already included this setting!
  '(c-mode c-basic-offset))

You can also modify this variable with the command M-x customize-variable [RET] editorconfig-indentation-alist [RET]. For a bit more complicated cases please take a look at the docstring of this variable.

editorconfig-exec-path

String of editorconfig executable name (command name or full path to the executable).

editorconfig-get-properties-function

Function to use to get EditorConfig properties.

For example, if you always want to use built-in core library instead of any EditorConfig executable to get properties, add following to your init.el:

(set-variable 'editorconfig-get-properties-function
              #'editorconfig-core-get-properties-hash)

Possible known values are:

  • editorconfig-get-properties (default)
    • Use editorconfig-get-properties-from-exec when editorconfig-exec-path executable is found, otherwise use editorconfig-core-get-properties-hash
  • editorconfig-get-properties-from-exec
    • Get properties by executing EditorConfig executable specified in editorconfig-exec-path
  • editorconfig-core-get-properties-hash
    • Always use built-in Emacs-Lisp implementation to get properties

Testing

Make and CMake must be installed to run the tests.

To run the tests:

$ make test

Submitting Bugs and Feature Requests

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

License

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

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

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

editorconfig-emacs's People

Contributors

501st-alpha1 avatar caleb avatar dochang avatar duncan-bayne avatar hensansi avatar hlissner avatar jacksonrayhamilton avatar jgkamat avatar jjjollyjim avatar jmiven avatar johan avatar jory avatar jupl avatar jxs avatar karbonitekream avatar koterpillar avatar kpachnis avatar mariosal avatar mgrbyte avatar ndyag avatar peterdavehello avatar singletoned avatar smikes avatar stevejordan avatar syohex avatar tarsius avatar treyhunner avatar troter avatar xuhdev avatar zonuexe avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.