Skip to content

Commit

Permalink
Integrate with Vala sdk extension
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Mar 2, 2022
1 parent 3529d7e commit f57b9d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ A very simple VSCode extension that detects a Flatpak manifest and offers variou

## Integrations

### Rust Analyzer
### [Rust Analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer)

- Overrides `rust-analyzer.server.path` to utilize SDK's rust-analyzer and `rust-analyzer.runnables.overrideCargo` to utilize SDK's cargo. This make sures that rust-analyzer and cargo uses package from the runtime instead of the host packages.
- Overrides `rust-analyzer.server.path` to use the SDK's rust-analyzer and `rust-analyzer.runnables.overrideCargo` to use the SDK's cargo. This make sures that rust-analyzer and cargo uses package from the runtime instead of the host packages.
- Overrides `rust-analyzer.runnables.cargoExtraArgs` to set cargo's `--target-dir` to `_build/src`. Identical target dir must be set on your build system to prevent rebuilding when running rust-analyzer runnables.
- Overrides `rust-analyzer.files.excludeDirs` to set rust-analyzer to ignore `.flatpak` folder.


### [Vala](https://marketplace.visualstudio.com/items?itemName=prince781.vala)

- Overrides `vls.languageServerPath` to use the SDK's vls.

## Contributing

Click [here](CONTRIBUTING.md) to find out how to contribute.
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ensureDocumentsPortal } from './utils'
import { FinishedTask, Runner } from './runner'
import { TaskMode } from './taskMode'
import { loadRustAnalyzerConfigOverrides, restoreRustAnalyzerConfigOverrides } from './integration/rustAnalyzer'
import { loadVLSConfigOverrides, restoreVLSConfigOverrides } from './integration/vls'
import { OutputTerminal } from './outputTerminal'
import { ManifestManager } from './manifestManager'
import { Manifest } from './manifest'
Expand Down Expand Up @@ -312,6 +313,9 @@ class Extension {
case 'rust':
await loadRustAnalyzerConfigOverrides(manifest)
break
case 'vala':
await loadVLSConfigOverrides(manifest)
break
}
}

Expand All @@ -320,6 +324,9 @@ class Extension {
case 'rust':
await restoreRustAnalyzerConfigOverrides(manifest)
break
case 'vala':
await restoreVLSConfigOverrides(manifest)
break
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/integration/vls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Manifest } from '../manifest'

export async function loadVLSConfigOverrides(manifest: Manifest): Promise<void> {
await manifest.overrideWorkspaceCommandConfig('vls', 'languageServerPath', 'vls', '/usr/lib/sdk/vala/bin/')
}

export async function restoreVLSConfigOverrides(manifest: Manifest): Promise<void> {
await manifest.restoreWorkspaceConfig('vls', 'languageServerPath')
}
6 changes: 4 additions & 2 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ export class Manifest {
}

sdk(): string | null {
const sdkPath = this.manifest['build-options']?.['append-path']
if (sdkPath?.toString().includes('rust')) {
const sdkPath = this.manifest['build-options']?.['append-path']?.toString()
if (sdkPath?.includes('rust')) {
return 'rust'
} else if (sdkPath?.includes('vala')) {
return 'vala'
}
return null
}
Expand Down

0 comments on commit f57b9d5

Please sign in to comment.