Skip to content

Commit

Permalink
Fix extensions detection (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Feb 18, 2024
1 parent 9206d0f commit b972721
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
21 changes: 20 additions & 1 deletion data/app.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
</screenshots>
<content_rating type="oars-1.1" />
<releases>
<release version="46.0" date="2024-03-xx">
<description translatable="no">
<ul>
<li>Use GNOME 46</li>
<li>Add basic Rust diagnostics</li>
<li>Allow using the new libadwaita dialogs</li>
<li>Stop adding a superfluous newlines to end of files</li>
<li>Optimize opening Library entries</li>
<li>Open project windows maximized</li>
<li>Update Biome to 1.5.3</li>
<li>Update gst-plugin-gtk4 to 0.12.1</li>
<li>Update libshumate to 1.2</li>
<li>Update VTE to 0.76</li>
<li>Update Blueprint</li>
<li>Update GTKCssLanguageServer</li>
<li>Update icon-development-kit</li>
</ul>
</description>
</release>
<release version="45.4" date="2024-01-14">
<description translatable="no">
<ul>
Expand Down Expand Up @@ -214,7 +233,7 @@
</ul>
</description>
</release>
<release version="45" date="2023-09-22">
<release version="45.0" date="2023-09-22">
<description translatable="no">
<ul>
<li>Use GNOME 45</li>
Expand Down
25 changes: 9 additions & 16 deletions src/Extensions/Extensions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Gio from "gi://Gio";
import GLib from "gi://GLib";

import { build } from "../../troll/src/main.js";

Expand All @@ -9,16 +8,6 @@ import { settings } from "../util.js";

import "./Extension.js";

const extensions = (() => {
const keyfile = new GLib.KeyFile();

keyfile.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE);

return keyfile
.get_string_list("Instance", "runtime-extensions")
.map((extension) => extension.split("=")[0]);
})();

export const action_extensions = new Gio.SimpleAction({
name: "extensions",
parameter_type: null,
Expand Down Expand Up @@ -62,13 +51,17 @@ export default function Extensions({ application }) {
application.add_action(action_extensions);
}

let rust_enabled;
export function isRustEnabled() {
return (
extensions.includes("org.freedesktop.Sdk.Extension.rust-stable") &&
extensions.includes("org.freedesktop.Sdk.Extension.llvm16")
);
rust_enabled ??=
Gio.File.new_for_path("/usr/lib/sdk/rust-stable").query_exists(null) &&
Gio.File.new_for_path("/usr/lib/sdk/llvm16").query_exists(null);
return rust_enabled;
}

let vala_enabled;
export function isValaEnabled() {
return extensions.includes("org.freedesktop.Sdk.Extension.vala");
vala_enabled ??=
Gio.File.new_for_path("/usr/lib/sdk/vala").query_exists(null);
return vala_enabled;
}
3 changes: 3 additions & 0 deletions src/langs/rust/rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import GLib from "gi://GLib";

import { createLSPClient } from "../../common.js";
import { getLanguage } from "../../util.js";
import { isRustEnabled } from "../../Extensions/Extensions.js";

export function setup({ document }) {
if (!isRustEnabled()) return;

const { file, buffer, code_view } = document;

const lspc = createLSPClient({
Expand Down

0 comments on commit b972721

Please sign in to comment.