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

No syntax highlighting in Flatpak version #8

Closed
Akselmo opened this issue Jun 5, 2023 · 9 comments · Fixed by #9
Closed

No syntax highlighting in Flatpak version #8

Akselmo opened this issue Jun 5, 2023 · 9 comments · Fixed by #9

Comments

@Akselmo
Copy link

Akselmo commented Jun 5, 2023

Seems grammar .so files are missing:

2023-06-05T08:41:01.680 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "toml": Error opening dynamic library "/app/share/helix/runtime/grammars/toml.so"
2023-06-05T08:41:01.681 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2023-06-05T08:42:11.016 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "toml": Error opening dynamic library "/app/share/helix/runtime/grammars/toml.so"
2023-06-05T08:42:11.016 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2023-06-05T08:42:18.405 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "toml": Error opening dynamic library "/app/share/helix/runtime/grammars/toml.so"
2023-06-05T08:42:18.405 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2023-06-05T08:43:00.368 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "toml": Error opening dynamic library "/app/share/helix/runtime/grammars/toml.so"
2023-06-05T08:43:00.368 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2023-06-05T08:46:35.341 helix_term::application [WARN] failed to load theme `aksdark` - Theme: file not found for: aksdark
2023-06-05T08:46:57.905 helix_term::application [WARN] failed to load theme `aksdark` - Theme: file not found for: aksdark
2023-06-05T08:46:57.907 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "bash": Error opening dynamic library "/app/share/helix/runtime/grammars/bash.so"
2023-06-05T08:46:57.907 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path }
2023-06-05T08:47:10.749 helix_term::application [WARN] failed to load theme `aksdark` - Theme: file not found for: aksdark
2023-06-05T08:47:16.624 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "toml": Error opening dynamic library "/app/share/helix/runtime/grammars/toml.so"
2023-06-05T08:47:16.624 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2023-06-05T08:48:31.776 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "bash": Error opening dynamic library "/app/share/helix/runtime/grammars/bash.so"
2023-06-05T08:48:31.776 helix_view::editor [ERROR] Failed to initialize the LSP for `source.bash` { cannot find binary path }
2023-06-05T08:49:03.657 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "python": Error opening dynamic library "/app/share/helix/runtime/grammars/python.so"
2023-06-05T08:49:03.666 helix_view::editor [ERROR] Failed to initialize the LSP for `source.python` { cannot find binary path }
2023-06-05T08:49:36.446 helix_view::editor [ERROR] Failed to initialize the LSP for `source.python` { cannot find binary path }
2023-06-05T08:49:45.046 helix_view::theme [WARN] Theme: invalid modifier: "normal"
2023-06-05T08:49:45.047 helix_view::theme [WARN] Theme: invalid modifier: "normal"
2023-06-05T08:49:45.189 helix_view::theme [WARN] Theme: invalid modifier: "normal"
2023-06-05T08:49:45.190 helix_view::theme [WARN] Theme: invalid modifier: "normal"
2023-06-05T08:51:03.346 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "python": Error opening dynamic library "/app/share/helix/runtime/grammars/python.so"
2023-06-05T08:51:03.347 helix_view::editor [ERROR] Failed to initialize the LSP for `source.python` { cannot find binary path }
2023-06-05T08:51:12.583 helix_core::syntax [ERROR] Failed to load tree-sitter parser for language "python": Error opening dynamic library "/app/share/helix/runtime/grammars/python.so"
2023-06-05T08:51:12.584 helix_view::editor [ERROR] Failed to initialize the LSP for `source.python` { cannot find binary path }

Can't find the grammars folder: /var/lib/flatpak/app/com.helix_editor.Helix/current/active/files/share/helix/runtime

This is on Debian 11 Stable.

@blt-r
Copy link
Collaborator

blt-r commented Jun 5, 2023

This flatpak doesn't ship the tree sitter grammars, instead relying on helix's --grammar fetch and --grammar build options to fetch and build grammar in flatpak's user data folder (~/.var/app/com.helix_editor.Helix/config/helix/runtime/grammars/sources)

@Akselmo
Copy link
Author

Akselmo commented Jun 5, 2023

I'll check that next time i am using debian, thanks.

@Akselmo
Copy link
Author

Akselmo commented Jun 6, 2023

Works well, thanks for letting me know of this feature. Mentioned it in the Helix repo as well for those who have same issue: helix-editor/helix#7161 (comment)

@Akselmo Akselmo closed this as completed Jun 6, 2023
@David-Else
Copy link

Why not ship with the grammars, and how come this vital information on --grammar fetch and --grammar build is not in the helix_first_run.txt? Even better, add it and publish the info from helix_first_run.txt in the main info area at https://flathub.org/apps/com.helix_editor.Helix, it is very difficult to find for the average user.

Just my thoughts on the matter, cheers :)

@blt-r
Copy link
Collaborator

blt-r commented Jun 6, 2023

I agree that it should probably be mentioned in first run file.

The reason why it is complicated to ship grammars is that we can't access the internet during build time. So to download sources of grammars we would need to parse the languages.toml and make flatpak-builder source definition to download them. Which I tried to do, but one of the grammars repo has a broken submodule and because of that flatpak-builder can't clone it (I made an issue ikatyang/tree-sitter-yaml#42).

Also, if that will get resolved (or we just descide to ignore tree-sitter-yaml), are we suppose to ship the grammars? All the compiled grammars weight 120 MB, not everyone might need them.

Although I guess when --grammar fetch you are downloading all the sources for the grammars, which wastes a lot more space then 120 MB. And the official way of packaging helix, the nix flake, as far as I understand, ships grammars with this grammars.nix script. So shipping them is probably the right way of packaging helix.

@David-Else
Copy link

@blt-r Thanks for the quick reply. I think shipping the grammars without tree-sitter-yaml is the way to go, if they ever sort out your issue you can add it back again. 120 MB is nothing for a flatpak, and all the others distros ship them as far as I can tell.

@blt-r
Copy link
Collaborator

blt-r commented Jun 6, 2023

I made a PR (ikatyang/tree-sitter-yaml#48) to tree-sitter-yaml which updates the submodule. If they don't merge it I guess I will just hardcode it to use my fork.

But then I also stumbled on this issue helix-editor/helix#7260

@David-Else
Copy link

I had a quick go at refactoring your first_run.txt into a markdown README with the help of ChatGPT for the main flathub repo. It has removed a bit of info ( the "see what's available" section) that you would probably want to put back, but it is much easier to understand:

Running Helix Flatpak Version

If you are running the Flatpak version of Helix, you may encounter some limitations due to the fact that it runs inside a container and cannot access tools on your host system. However, there are some workarounds that you can use to execute commands on the host system and get support for additional languages.

Opening Issues

If you encounter any issues related to the Flatpak version of Helix, you can open them at https://github.com/flathub/@FLATPAK_ID@/issues.

Executing Commands on the Host System

To execute commands on the host system, you can use the following command:

$ flatpak-spawn --host <COMMAND>

This will allow you to execute commands on the host system from within the Flatpak container.

Adding Language Server Entries

If you want to use a language server installed on your host system, you will need to add an entry to your languages.toml file. For example:

[[language]]
name = "rust"
language-server = { command = "flatpak-spawn", args = ["--host", "rust-analyzer"] }

This will allow you to use the Rust language server installed on your host system from within the Flatpak container.

Installing Flatpak SDK Extensions

By default, the Flatpak version of Helix provides access to standard development environments such as GCC and Python. However, if you need support for additional languages (including language servers), you will need to install SDK extensions.

To install SDK extensions, use the following commands:

$ flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable
$ flatpak install flathub org.freedesktop.Sdk.Extension.llvm15

This will install the Rust and LLVM SDK extensions.

Enabling SDK Extensions

After installing SDK extensions, you will need to enable them. To do this, set the FLATPAK_ENABLE_SDK_EXT environment variable to a comma-separated list of extension names. For example:

$ FLATPAK_ENABLE_SDK_EXT=rust-stable,llvm15 flatpak run @FLATPAK_ID@

This will add compilers, language servers, and other tools to your $PATH.

Checking Language Server Detection

To check which language servers have been detected, run Helix with the --health option:

$ FLATPAK_ENABLE_SDK_EXT=rust-stable,llvm15 flatpak run @FLATPAK_ID@ --health

You can also get information about a specific language:

$ FLATPAK_ENABLE_SDK_EXT=rust-stable,llvm15 flatpak run @FLATPAK_ID@ --health rust

Making Changes Persistent

To make changes to the environment variables persistent, use the flatpak override command:

$ flatpak override --user @FLATPAK_ID@ --env=FLATPAK_ENABLE_SDK_EXT="rust-stable,llvm15"

Finding Other SDK Extensions

To find other SDK extensions, use the following command:

$ flatpak search <TEXT>

Markdown to copy/paste

# Running Helix Flatpak Version

If you are running the Flatpak version of Helix, you may encounter some limitations due to the fact that it runs inside a container and cannot access tools on your host system. However, there are some workarounds that you can use to execute commands on the host system and get support for additional languages.

## Opening Issues

If you encounter any issues related to the Flatpak version of Helix, you can open them at https://github.com/flathub/@FLATPAK_ID@/issues.

## Executing Commands on the Host System

To execute commands on the host system, you can use the following command:

```sh
$ flatpak-spawn --host <COMMAND>
```

This will allow you to execute commands on the host system from within the Flatpak container.

## Adding Language Server Entries

If you want to use a language server installed on your host system, you will need to add an entry to your `languages.toml` file. For example:

```toml
[[language]]
name = "rust"
language-server = { command = "flatpak-spawn", args = ["--host", "rust-analyzer"] }
```

This will allow you to use the Rust language server installed on your host system from within the Flatpak container.

## Installing Flatpak SDK Extensions

By default, the Flatpak version of Helix provides access to standard development environments such as GCC and Python. However, if you need support for additional languages (including language servers), you will need to install SDK extensions.

To install SDK extensions, use the following commands:

```sh
$ flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable
$ flatpak install flathub org.freedesktop.Sdk.Extension.llvm15
```

This will install the Rust and LLVM SDK extensions.

## Enabling SDK Extensions

After installing SDK extensions, you will need to enable them. To do this, set the `FLATPAK_ENABLE_SDK_EXT` environment variable to a comma-separated list of extension names. For example:

```sh
$ FLATPAK_ENABLE_SDK_EXT=rust-stable,llvm15 flatpak run @FLATPAK_ID@
```

This will add compilers, language servers, and other tools to your $PATH.

## Checking Language Server Detection

To check which language servers have been detected, run Helix with the --health option:

```sh
$ FLATPAK_ENABLE_SDK_EXT=rust-stable,llvm15 flatpak run @FLATPAK_ID@ --health
```

You can also get information about a specific language:

```sh
$ FLATPAK_ENABLE_SDK_EXT=rust-stable,llvm15 flatpak run @FLATPAK_ID@ --health rust
```

## Making Changes Persistent

To make changes to the environment variables persistent, use the flatpak override command:

```sh
$ flatpak override --user @FLATPAK_ID@ --env=FLATPAK_ENABLE_SDK_EXT="rust-stable,llvm15"
```

## Finding Other SDK Extensions

To find other SDK extensions, use the following command:

```sh
$ flatpak search <TEXT>
```

@blt-r
Copy link
Collaborator

blt-r commented Jun 7, 2023

Thanks, this will be useful. We could just use a markdown file as a first run file. Considering that there will be syntax highlighting in it, I think it would be more readable than just plain text.

blt-r added a commit to blt-r/com.helix_editor.Helix that referenced this issue Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants