Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WSL Idris installation compatibility #263

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add WSL Idris installation compatibility
  • Loading branch information
jmanuel1 committed Mar 31, 2024
commit 867fe8deb9e6d77c3f1edcef520c27da8e352e46
14 changes: 12 additions & 2 deletions lib/idris-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CompilerOptions } from './utils/ipkg'
import { IDECommand, SExp } from './protocol/ide-protocol'
import { ideCommandToSExp } from './protocol/to-sexp'
import Logger from './utils/Logger'
import { windowsToWsl } from 'wsl-path'

export class IdrisModel {
requestId = 0
Expand Down Expand Up @@ -130,7 +131,10 @@ export class IdrisModel {
}

changeDirectory(dir: string) {
return this.interpret(`:cd ${dir}`)
const directory = this.shouldUseWsl ? Rx.Observable.fromPromise(windowsToWsl(dir)) : Rx.Observable.of(dir)
return directory.flatMap((dir) => {
return this.interpret(`:cd ${dir}`)
})
}

load(uri: string) {
Expand All @@ -147,7 +151,9 @@ export class IdrisModel {
}
})()

return cd.flatMap((_) => {
const platformUri = this.shouldUseWsl ? Rx.Observable.fromPromise(windowsToWsl(uri)) : Rx.Observable.of(uri)

return cd.zip(platformUri).flatMap(([_, uri]) => {
return this.prepareCommand({ type: 'load-file', fileName: uri })
})
}
Expand Down Expand Up @@ -219,4 +225,8 @@ export class IdrisModel {
browseNamespace(namespace: string) {
return this.prepareCommand({ type: 'browse-namespace', namespace })
}

get shouldUseWsl(): boolean {
return atom.config.get('language-idris.idrisInWsl')
}
}
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
"type": "boolean",
"default": false,
"description": "Enable ligatures in the various idris panels"
},
"idrisInWsl": {
"title": "Integrate with an Idris installation in WSL",
"type": "boolean",
"default": false,
"description": "Enable this if you installed Idris in WSL but run the editor in Windows"
}
},
"providedServices": {
Expand Down Expand Up @@ -84,7 +90,8 @@
"preact": "10.4.4",
"rx-lite": "4.0.8",
"tslib": "1.11.1",
"typescript": "3.9.2"
"typescript": "3.9.2",
"wsl-path": "^3.0.1"
},
"devDependencies": {
"@types/atom": "1.40.4",
Expand Down