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 after building from source #6607

Closed
kazimir-malevich opened this issue Apr 5, 2023 · 15 comments
Closed

No syntax highlighting after building from source #6607

kazimir-malevich opened this issue Apr 5, 2023 · 15 comments
Labels
C-bug Category: This is a bug

Comments

@kazimir-malevich
Copy link
Contributor

kazimir-malevich commented Apr 5, 2023

Summary

No syntax highlighting after building from source using Debian Bullseye and wanting to write in Rust,

Reproduction Steps

adrian_lewis@penguin:~$ hx --grammar fetch
Fetching 142 grammars
142 up to date git grammars
adrian_lewis@penguin:~$ hx --grammar build
Building 142 grammars
142 grammars already built
adrian_lewis@penguin:~$ cd ~/.config/helix
drwxr-xr-x 1 adrian_lewis adrian_lewis  30 Apr  5 15:46 runtime/
adrian_lewis@penguin:~/.config/helix$ ln -s $PWD/runtime ~/.config/helix/runtime
ln: failed to create symbolic link '/home/adrian_lewis/.config/helix/runtime/runtime': File exists
adrian_lewis@penguin:~/.config/helix$ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Helix log

adrian_lewis@penguin:~/.config/helix$ cat $HOME/.cache/helix/helix.log
2023-04-05T15:33:17.742 helix_view::editor [ERROR] editor error: wrong argument count
2023-04-05T15:33:27.115 helix_view::editor [ERROR] editor error: wrong argument count
2023-04-05T15:33:37.906 helix_view::editor [ERROR] editor error: wrong argument count
2023-04-05T15:33:47.850 helix_vcs [ERROR] PeelToCommit(
    Unborn {
        name: FullName(
            "refs/heads/main",
        ),
    },
)
2023-04-05T15:33:47.850 helix_vcs [ERROR] failed to open diff base for /home/adrian_lewis/projects/goose-load-tests/src/main.rs
2023-04-05T15:33:47.851 helix_vcs [ERROR] PeelToCommit(
    Unborn {
        name: FullName(
            "refs/heads/main",
        ),
    },
)
2023-04-05T15:33:47.851 helix_vcs [ERROR] failed to obtain current head name for /home/adrian_lewis/projects/goose-load-tests/src/main.rs
2023-04-05T15:33:47.851 helix_view::editor [ERROR] Failed to initialize the LSP for `source.rust` { cannot find binary path }
2023-04-05T15:39:48.011 helix_vcs [ERROR] PeelToCommit(
    Unborn {
        name: FullName(
            "refs/heads/main",
        ),
    },
)
2023-04-05T15:39:48.011 helix_vcs [ERROR] failed to open diff base for /home/adrian_lewis/projects/goose-load-tests/src/main.rs
2023-04-05T15:39:48.012 helix_vcs [ERROR] PeelToCommit(
    Unborn {
        name: FullName(
            "refs/heads/main",
        ),
    },
)
2023-04-05T15:39:48.012 helix_vcs [ERROR] failed to obtain current head name for /home/adrian_lewis/projects/goose-load-tests/src/main.rs
2023-04-05T15:39:48.012 helix_view::editor [ERROR] Failed to initialize the LSP for `source.rust` { cannot find binary path }
2023-04-05T15:47:07.757 helix_vcs [ERROR] PeelToCommit(
    Unborn {
        name: FullName(
            "refs/heads/main",
        ),
    },
)
2023-04-05T15:47:07.757 helix_vcs [ERROR] failed to open diff base for /home/adrian_lewis/projects/goose-load-tests/src/main.rs
2023-04-05T15:47:07.758 helix_vcs [ERROR] PeelToCommit(
    Unborn {
        name: FullName(
            "refs/heads/main",
        ),
    },
)
2023-04-05T15:47:07.758 helix_vcs [ERROR] failed to obtain current head name for /home/adrian_lewis/projects/goose-load-tests/src/main.rs
2023-04-05T15:47:07.758 helix_view::editor [ERROR] Failed to initialize the LSP for `source.rust` { cannot find binary path }

Platform

Debian Buster

Terminal Emulator

$ echo $SHELL /bin/bash

Helix Version

$ hx --version helix 23.03 (531b745)

@kazimir-malevich kazimir-malevich added the C-bug Category: This is a bug label Apr 5, 2023
@kazimir-malevich
Copy link
Contributor Author

I have also added and configured the rust-analyzer without success:

adrian_lewis@penguin:~$ rustup component add rust-analyzer
info: downloading component 'rust-analyzer'
info: installing component 'rust-analyzer'
adrian_lewis@penguin:~$ sudo ln -s $(rustup which rust-analyzer ) /usr/local/bin/rust-analyzer

@the-mikedavis
Copy link
Member

The ln -s $PWD/runtime ~/.config/helix/runtime command should be run from the helix repository rather than ~/.config/helix. hx --health rust should have checkmarks for "Highlight queries" in order for syntax highlighting to work

@David-Else
Copy link
Contributor

Do you have a c++ compiler installed such as gcc-c++? Helix silently fails to build the grammar if you don't, it would be a good candidate for a fix.

@kazimir-malevich
Copy link
Contributor Author

Do you have a c++ compiler installed such as gcc-c++? Helix silently fails to build the grammar if you don't, it would be a good candidate for a fix.

I have the gcc-c++ compiler installed, but I can write a function to check whether the compiler is installed on different OS' and panic if not. However, where would be a good place to add this check? Many Thanks.

@David-Else
Copy link
Contributor

Hello @kazimir-malevich, I am not familiar with the C programming language ecosystem, so I am unsure about certain aspects. It might be advisable to verify whether the grammar has compiled successfully at the end of the Helix building process. If the compilation fails, the directory of compiled grammar will be empty. However, it's worth noting that some distributions may not provide the grammar, and users may have to build it themselves, which could make things more complicated. Ultimately, @the-mikedavis would be better equipped to provide a definitive answer to this question.

@kazimir-malevich
Copy link
Contributor Author

Hi @David-Else I was just thinking of writing a check on whether gcc-c++ was installed on the system precompilation, because at the moment we just (I think) have it specified in the docs. I can maybe grep for any other checks and submit a PR?

@David-Else
Copy link
Contributor

David-Else commented Apr 6, 2023

@kazimir-malevich I am not qualified to answer, I am sure someone else will respond soon who is, then you can submit a PR, which would be awesome :)

@gabydd
Copy link
Member

gabydd commented Apr 6, 2023

Looking at this line:

ln: failed to create symbolic link '/home/adrian_lewis/.config/helix/runtime/runtime': File exists

It seems to have been a problem when linking the runtime. I would suggest removing the .config/helix/runtime folder and linking again. This time from the helix git repository to .config/helix/runtime as Michael Davis pointed out.

@kazimir-malevich
Copy link
Contributor Author

kazimir-malevich commented Apr 6, 2023

Thanks for your input @the-mikedavis and @gabydd however:

adrian_lewis@penguin:~/projects/helix$ ln -s $PWD/runtime ~/.config/helix/runtime
adrian_lewis@penguin:~/projects/helix$ hx --health rust
Configured language server: rust-analyzer
Binary for language server: /usr/local/bin/rust-analyzer
Configured debug adapter: lldb-vscode
Binary for debug adapter: 'lldb-vscode' not found in $PATH
Highlight queries: ✘
Textobject queries: ✘
Indent queries: ✘

I am guessing the debug adaptor doesn't affect syntax highlighting.

And tried:

adrian_lewis@penguin:~$ tail -n 1 .bashrc 
HELIX_RUNTIME=$HOME/projects/helix/runtime

Following: https://docs.helix-editor.com/install.html#configuring-helixs-runtime-files

adrian_lewis@penguin:~/projects/helix$ find . -type d -name "runtime"
./runtime

@David-Else
Copy link
Contributor

@kazimir-malevich I suggest you delete everything and use my install script, I know that works. You must ensure you have gcc-c++ installed first, that is vital! Forget about the debugger, it doesn't really work yet, only shows memory addresses not variables, you don't need to worry about that! Here is the part you want, delete the rest apart from the variables you need.

https://github.com/David-Else/developer-workstation-setup-script/blob/f2c880b3bde018c428ecddba22ee307a6f91251b/install-setup.bash#LL56C1-L66C3

That will build and install the latest released version (as of today). If you just want the latest master, then just delete the line that has git -C "$helix_src_folder" checkout 23.03

Hope that works!

@kazimir-malevich
Copy link
Contributor Author

Thanks @David-Else. Is there a functions.bash script I will also need?

adrian_lewis@penguin:~$ ./install-setup.bash 
./install-setup.bash: line 5: functions.bash: No such file or directory

As a side note I think I need to update the docs around the runtime dir config, which are either incorrect or could be a bit clearer.

adrian_lewis@penguin:~$ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@David-Else
Copy link
Contributor

@kazimir-malevich I wrote https://docs.helix-editor.com/install.html#building-from-source , I assume you are refering to that section? Please can you tell me what is incorrect or can be improved, I would be happy to take any suggestions.

I expected you to edit the install script, no worries, I have extracted what you want, just make this script and run it, nothing else needed, make sure to run as a user:

    #!/bin/bash

    helix_src_folder="$HOME/src/helix"
    helix_config_folder="$HOME/.config/helix"

    mkdir -p "$helix_src_folder"
    git clone https://github.com/helix-editor/helix "$helix_src_folder"
    git -C "$helix_src_folder" checkout 23.03
    cargo install --locked --path "$helix_src_folder"/helix-term
    [ ! -e "$helix_config_folder"/runtime ] && ln -s "$helix_src_folder"/runtime "$helix_config_folder" # if there is no symlink create one to the source directory

    cp "$helix_src_folder"/contrib/helix.png "$HOME/.icons"
    cp "$helix_src_folder"/contrib/Helix.desktop "$HOME/.local/share/applications"
    sed -i "s|Exec=hx %F|Exec=$terminal_program hx %F|g;s|Terminal=true|Terminal=false|g" "$HOME/.local/share/applications/Helix.desktop"

@kazimir-malevich
Copy link
Contributor Author

@David-Else It may (and probably is) my misunderstanding of the docs, but I have created a small PR that can be accepted, rejected or amended. I am running off a ChromeOS Debian container ATM that can make things a little difficult. Thanks for the script, which I will use very soon. And thanks everyone for their help.

@David-Else
Copy link
Contributor

@kazimir-malevich No problem, I have added a comment. I am going away for a week now so won't be able to add any more to this, but I expect more people will chime in on your pull request.

@kazimir-malevich
Copy link
Contributor Author

@David-Else The script works, even though I don't have a Linux desktop. Thank you very much. Does it have something to do with the unconventional installation path /home/user_name/src/helix? Have a good holiday and I hope to contribute while I have time off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

4 participants