Giter VIP home page Giter VIP logo

sublimelinter-contrib-elixirc's Introduction

SublimeLinter-contrib-elixirc

Build Status

This linter plugin for SublimeLinter provides an interface to check elixir syntax using elixirc. It will be used with files that have the “elixir” syntax.

Installation

SublimeLinter 3 must be installed in order to use this plugin. If SublimeLinter 3 is not installed, please follow the instructions here.

Linter installation

Before installing this plugin, you must ensure that elixir (>= 1.0) is installed on your system. For instructions on how to install elixir, please refer to the elixir-lang docs.

Linter configuration

In order for elixir to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. Before going any further, please read and follow the steps in “Finding a linter executable” through “Validating your PATH” in the documentation.

Once elixir is installed and configured, you can proceed to install the SublimeLinter-contrib-elixirc plugin if it is not yet installed.

Plugin installation

Please use Package Control to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.

To install via Package Control, do the following:

  1. Within Sublime Text, bring up the Command Palette and type install. Among the commands you should see Package Control: Install Package. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins.

  2. When the plugin list appears, type elixirc. Among the entries you should see SublimeLinter-contrib-elixirc. If that entry is not highlighted, use the keyboard or mouse to select it.

Settings

For general information on how SublimeLinter works with settings, please see Settings. For information on generic linter settings, please see Linter Settings.

In addition to the standard SublimeLinter settings, SublimeLinter-contrib-elixirc provides its own settings.

Setting Description
pa (list) dirs for -pa option
require (list) dirs/files to require
mix_project (bool) use mix for linting
chdir (string) run linter from the specified dir
prepend (list) will be prepended to the linter command
append (list) will be appended to the linter command

In a mix project:

  • set chdir to your mix project's root directory.
  • set mix_project to true

Example:

In your .sublime-project file:

   "SublimeLinter": {
      "linters": {
         "elixirc": {
            "mix_project": true,
            "chdir": "PROJECT_ROOT"
         }
      }
   }

Where:

  • PROJECT_ROOT is the path to the root your project (use ${project} if your sublime project is saved there)

Note: Currently, exs files within a mix project (e.g. ExUnit tests) are not linted. This is a known issue and will be resolved in a future version.

If you also use an elixir version manager, set prepend as per the example below

Outside a mix project:

  • if a file uses macros, the beam output paths must be added to code path through pa
  • files (or directories) to require prior to linting must be added through require. They are required in the given order. Directories, if given, are traversed recursively and alphabetically.

Example

In your .sublime-project file:

   "SublimeLinter": {
      "linters": {
         "elixirc": {
            "pa": ["PROJECT_ROOT/_build/dev/lib/PROJECT_WITH_MACROS/ebin"],
            "require": ["PROJECT_ROOT/deps/DEP1"]
         }
      }
   }

Where:

  • PROJECT_ROOT is the path to the root of your project (use ${project} if your sublime project is saved there)
  • PROJECT_WITH_MACROS is the project name which contains the macros. List all projects in pa
  • DEP1 is a directory with files to require. If needed, list specific files first.

Command customization

The prepend and append options allow you to modify the executed command.

A typical use-case for this would be if you use elixir version managers (e.g. kiex), which alter certain environment variables when switching between different versions of elixir.

Since sublime is very limited in terms of user-configurable environment variables, the problem could be solved with the env command on any typical UNIX-based OS.

Example

   "SublimeLinter": {
      "linters": {
        "elixirc": {
          "chdir": "/Users/foo/projects/myapp",
          "mix_project": true,
          "prepend": ["/usr/bin/env", "MIX_ARCHIVES=/Users/foo/.kiex/mix/archives/elixir-1.3.3"]
        }
      }
    }

Contributing

If you would like to contribute enhancements or fixes, please do the following:

  1. Fork the plugin repository.
  2. Hack on a separate topic branch created from the latest master.
  3. Commit and push the topic branch.
  4. Make a pull request.
  5. Be patient. ;-)

Please note that modifications should follow these coding guidelines:

  • Indent is 4 spaces.
  • Code should pass flake8 and pep257 linters.
  • Vertical whitespace helps readability, don’t be afraid to use it.
  • Please use descriptive variable names, no abbreviations unless they are very well known.

Thank you for helping out!

sublimelinter-contrib-elixirc's People

Contributors

smanolloff avatar doitian avatar prsimp avatar

Watchers

James Cloos avatar Nguyen, Manh Quoc Anh 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.