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 documentation on adding the runtime variable for specific languages (go, Typescript, Rust) #85

Closed
eleijonmarck opened this issue Jun 3, 2021 · 10 comments

Comments

@eleijonmarck
Copy link
Contributor

Hello!
I love the project! ❤️

However I cannot seem to get my head around setting the runtime variable to get syntax highllighting and stuffz for my Go projects or Typescript/Javascript or Rust projects.

I move the hx binary into the different projects, however it does not seem to pickup the runtime.
Could you provide a example for let's say a Go project using go.mod and explicitly setting the HELIX_RUNTIME variable for that?

@pickfire
Copy link
Contributor

pickfire commented Jun 3, 2021

Runtime variable?

@hovsater
Copy link
Contributor

hovsater commented Jun 3, 2021

An example from my personal configuration.

/tmp $ which hx
/Users/kevinsjoberg/bin/hx
/tmp $ ls -l $HOME/.config/helix/
total 8
-rw-r--r--  1 kevinsjoberg  staff  1560 Jun  2 22:09 helix.log
drwxr-xr-x@ 3 kevinsjoberg  staff    96 Jun  3 04:07 runtime
/tmp $ echo $HELIX_RUNTIME
/Users/kevinsjoberg/.config/helix/runtime

@pickfire I believe hx will look for the runtime folder in the same directory as the binary by the default. This can be changed by setting the HELIX_RUNTIME environment variable to a different directory.

@eleijonmarck
Copy link
Contributor Author

@kevinsjoberg thx for the clear example.
I downloaded the release, but did not know where to put the things. 👯

@eleijonmarck
Copy link
Contributor Author

image
I now get highlighting and goto definition and stuffz !!

@pickfire
Copy link
Contributor

pickfire commented Jun 3, 2021

https://docs.helix-editor.com/install.html#build-from-source

Ah, so you mean

Now copy the runtime/ directory somewhere. Helix will by default look for the runtime inside the same folder as the executable, but that can be overriden via the HELIX_RUNTIME environment variable.

I was confused about that either. No wonder I didn't get syntax highlighting. Oh, I found it. Have to set HELIX_RUNTIME=$PWD. Maybe we should update the docs.

@eleijonmarck
Copy link
Contributor Author

Yea I was thinking to update the docs, with this explicit information.
So that It gets easy to open hx and start to play around and making it more frictionless.

@archseer
Copy link
Member

archseer commented Jun 3, 2021

The binary looks for runtime/ where the executable is located, or for a HELIX_RUNTIME override.

pub fn runtime_dir() -> std::path::PathBuf {
// runtime env var || dir where binary is located
std::env::var("HELIX_RUNTIME")
.map(|path| path.into())
.unwrap_or_else(|_| {
std::env::current_exe()
.ok()
.and_then(|path| path.parent().map(|path| path.to_path_buf()))
.unwrap()
})
}

If running this in development via cargo run I recommend using an .envrc file to automatically set the var. We could also try detecting that (if debug mode) and setting it to the correct path.

For packaged installs, I recommend unpacking the files somewhere, then making a hx wrapper that sets the var and runs the binary. Example from Arch Linux

@eleijonmarck
Copy link
Contributor Author

I agree with the package install that sets the VAR to some default where the default runtime is set on all comp.

@archseer
For releases or anything in the documentation, we could add commands that would make it easier to add the ENV to point to a ~/.config/helix by default if not specified.

Maybe this is what you mean by the package installs. But would be great to get this in right away.

Package installer for me did not work:
I did not get it to install for my Ubuntu 20.04 distro though. Maybe this is just me

@kirawi
Copy link
Member

kirawi commented Jun 4, 2021

I don't think it correctly detects it on Windows without the envvar.

@archseer
Copy link
Member

I think this should be solved in 0.2.0, we have more reasonable defaults now.

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

No branches or pull requests

5 participants