kahole / edamagit

Magit for VSCode

Home Page:https://marketplace.visualstudio.com/items?itemName=kahole.magit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Providing code command setting

happysalada opened this issue · comments

commented

Thank you for making a great plugin!

The logic for finding the codePath works in 99% of the cases I think.

function findCodePath(): string {

However I have a little bit of a special setup and my path is recognized as code even though I use codium.

Would it make sense to just add a configuration setting so that people can define that manually. Perhaps it can try to guess the path and only read from the setting if defined ?

If edamagit can't locate the binary it falls back on using just code, without a path.
This means commands will go through your PATH variable for looking for code.
You should be able to fix this by adding code to your PATH. (Although I dont know what platform you are on)

Are you able to get this working?

There os a vscode command that may be helpful:

Shell Command: Install "code" command in shell PATH
commented

Thank you for coming back so quickly!

I'm running vs-codium though. By default "code" is therefore not defined.
The equivalent vscodium command asks me to install "codium" in shell PATH

I am running fish as a shell. I can define a fish alias for code, but vscode doesn't "see" those aliases.

Then you can install codium to path and rename the resulting symlink to code.
It doesn't really install anything, you just need a symlink somewhere in a dir in your path that points to the script that fires up code/codium. And it needs to be called code :)
It's completely configurable in that regard.

commented

I was running on vscode, I'm now configuring codium. I'm keeping them both side to side to make sure I'm migrating all my settings.
I wanted to point out that the resolution might fail. I thought a configuration setting might be more robust. If you feel this adds too much complexity, no worries. Feel free to close the issue.
I'm running on nix on macos with vscodium, I understand it will be a small minority of your users.

Remove code from your path and just do:

cp /usr/local/bin/codium /usr/local/bin/code

What's special about your setup? Because vscodium has been changing it's paths and names before causing the logic in edamagit to not detect codium. That may be the case here too

commented

nix installs in a particular path
https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vscode/generic.nix#L80

❯ which codium
/Users/raphael/.nix-profile/bin/codium

and the App is available also under a particular path

~/.nix-profile/Applications🔒
❯ ls
Permissions Size User Date Modified Name
lrwxr-xr-x    86 root  1 Jan  1970  Alacritty.app -> /nix/store/kywyixps29v1pg7218rzlbng7hsw8krs-alacritty-0.8.0/Applications/Alacritty.app
lrwxr-xr-x    85 root  1 Jan  1970  VSCodium.app -> /nix/store/z4v1pcgqs2wnqbywhnmaysvw12vbbx8a-vscodium-1.56.2/Applications/VSCodium.app

That would be for everybody running nix package manager on macos.

I was having a look at the following line

if (isCodium && !isDarwin) {

Why are you checking for non darwin ?
Is that because for previously a normal install was under vscode?
It seems that a 'normal' install on macos would have a path that contains codium
https://github.com/VSCodium/vscodium/blob/master/DOCS.md#migrating

Would it make sense to remove the !Darwin there?

Is that because for previously a normal install was under vscode?

yes, exactly. It seems they like going back and forth on that :D
I'm open for a pull request removing the Darwin check (or some clever solution). But try and make sure it doesn't break everyone else's codium edamagit setup.

commented

I don't mind removing the darwin conditional. Are you sure though that you don't want a path config that can be overriden ?
I would keep the logic you have to figure out the default, however if somebody defines a specific path then use that.
The idea behind defining a config is that if it ever breaks for anybody, they have a simple way to fix it that doesn't require much effort.

I'm convinced, lets do config.
But I still want the lookup variant to get it right as much as possible.

commented

Like I said in the PR, I just made a proof of concept
#149
If you don't like it, feel free to reject, no hard feelings.
I don't mind removing the isDarwin, but if there is a potential breakage, then It feels to me that there should be an easy way for users to fix it.

Just a question around the rest of the logic. Do you think most people would not have the 'code' or 'codium' in their global path? It seems to me that you might be able to remove the logic in favor of letting people define their config. Perhaps that doesn't work for some people? You have more experience to what the default user uses.

There are historical reasons for the way it's done. A lot of broken setups and issues over time. I initially leaned on everyone having code in their path, but I wanted to make getting started using edamagit as painless as possible. But as you know it's not perfect.

v0.6.15 released now

commented

Thanks a lot for this!
I'm making the update to nixos upstream!
NixOS/nixpkgs#126437

Understood about the historical context. Will test this on my local later today.