Skip to content

Commit

Permalink
Allowing the user to configure MIX_ENV.
Browse files Browse the repository at this point in the history
  • Loading branch information
edelvalle committed Jan 27, 2018
1 parent be65b21 commit 4501fe7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ Make sure you have at least Elixir 1.4.4 installed.
### Elixir interpreter settings

By default this package will use default Elixir interpreter from the `PATH`.
Also you can set different interpreter for each Sublime Project.
Also you can set different interpreter for each Sublime Project and the the mix
environment will be set to `MIX_ENV=dev`. You can change this.

To set project related Elixir interpreter you have to edit yours project config file.
By default project config name is `<project name>.sublime-project`
To set project related Elixir interpreter you have to edit yours project config
file. By default project config name is `<project name>.sublime-project`

You can set Elixir interpreter, using for example the following:
You can set Elixir interpreter and mix environment, using for example the
following:

# <project name>.sublime-project
{
Expand All @@ -49,6 +51,7 @@ You can set Elixir interpreter, using for example the following:
"settings": {
// ...
"elixir_interpreter": "~/elixir-2.4.4/bin/elixir",
"mix_env": "test",
}
}

Expand Down
18 changes: 18 additions & 0 deletions messages/0.2.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SuperElixir version 0.2.4

## What's new?

Now you can configure the `MIX_ENV`, by using the `mix_env` entry in your project setting:


# <project name>.sublime-project
{
// ...

"settings": {
// ...
"elixir_interpreter": "~/elixir-2.4.4/bin/elixir",
"mix_env": "test",
}
}

4 changes: 2 additions & 2 deletions super_elixir.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Where is the elixir command located.
"elixir_interpreter": "elixir",

// "debug", "error", "info", "warn"
"logging_level": "warn",
// "dev", "test", "prod"
"mix_env": "dev",

// how to open goto definition result with ability to show it transient
// variation (preview only. it won't have a tab assigned it until modified):
Expand Down
11 changes: 9 additions & 2 deletions super_elixir/sense_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,30 @@ def get_elixir_sense(view):
'elixir_interpreter',
'elixir'
)
elixir_env = settings.get_settings_param(
view,
'elixir_interpreter',
'dev'
).lower()
sense = SERVERS[project_path] = ElixirSense(
project_path,
elixir_exec=elixir_exec,
elixir_env=elixir_env,
)
return sense


class ElixirSense:
def __init__(self, project_path, elixir_exec='elixir'):
def __init__(self, project_path, elixir_exec='elixir', mix_env='dev'):
self.project_path = project_path
self.elixir_exec = elixir_exec
self.mix_env = mix_env
self._start_process()

def _start_process(self):
# start sub process
self._proc = subprocess.Popen(
[self.elixir_exec, ELIXIR_SENSE_EXEC, 'unix', '0', 'dev'],
[self.elixir_exec, ELIXIR_SENSE_EXEC, 'unix', '0', self.mix_env],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down

0 comments on commit 4501fe7

Please sign in to comment.