Skip to content

Commit 93453fa

Browse files
committed
activate environment support
as a command and in the tree-view context menu
1 parent 0bcf4f3 commit 93453fa

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

lib/package/commands.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ module.exports =
124124
'julia-client:work-in-current-folder': (ev) ->
125125
requireClient 'change working folder', ->
126126
juno.runtime.evaluation.cdHere(ev.target)
127+
'julia-client:activate-current-folder': (ev) ->
128+
requireClient 'activate an environment', ->
129+
juno.runtime.evaluation.activateProject(ev.target)
130+
'julia-client:activate-default-environment': (ev) ->
131+
requireClient 'activate an environment', ->
132+
juno.runtime.evaluation.activateDefaultProject()
127133
'julia-client:work-in-project-folder': ->
128134
requireClient 'change working folder', ->
129135
juno.runtime.evaluation.cdProject()

lib/runtime/evaluation.coffee

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ path = require 'path'
88
{processLinks} = require '../ui/docs'
99
workspace = require './workspace'
1010
modules = require './modules'
11-
{eval: evaluate, evalall, evalshow, cd, clearLazy} =
12-
client.import rpc: ['eval', 'evalall', 'evalshow'], msg: ['cd', 'clearLazy']
11+
{eval: evaluate, evalall, evalshow, cd, clearLazy, activateProject, activateDefaultProject} =
12+
client.import rpc: ['eval', 'evalall', 'evalshow'], msg: ['cd', 'clearLazy', 'activateProject', 'activateDefaultProject']
1313
searchDoc = client.import('docs')
1414

1515
module.exports =
@@ -109,19 +109,32 @@ module.exports =
109109
cd(dir)
110110

111111
cdHere: (el) ->
112+
dir = @currentDir(el)
113+
if dir
114+
@_cd(dir)
115+
116+
activateProject: (el) ->
117+
dir = @currentDir(el)
118+
if dir
119+
activateProject(dir)
120+
121+
activateDefaultProject: ->
122+
activateDefaultProject()
123+
124+
currentDir: (el) ->
112125
# invoked from tree-view context menu
113126
dirEl = el.closest('.directory')
114127
if dirEl
115128
pathEl = dirEl.querySelector('[data-path]')
116129
if pathEl
117130
path = pathEl.dataset.path
118-
return @_cd(path)
131+
return path
119132
# invoked from normal command usage
120133
file = client.editorPath(atom.workspace.getCenter().getActiveTextEditor())
121134
if !file
122135
atom.notifications.addError 'This file has no path.'
123136
else
124-
@_cd path.dirname(file)
137+
return path.dirname(file)
125138

126139
cdProject: ->
127140
dirs = atom.project.getPaths()

menus/julia-client.cson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
]
2222
'.tree-view li.directory': [
2323
{ label: 'Juno: Work in Folder', command: 'julia-client:work-in-current-folder' }
24+
{ label: 'Juno: Activate Project', command: 'julia-client:activate-current-folder' }
2425
]

0 commit comments

Comments
 (0)