Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

MS WIndows #17

Open
jqfeld opened this issue Mar 9, 2021 · 4 comments
Open

MS WIndows #17

jqfeld opened this issue Mar 9, 2021 · 4 comments

Comments

@jqfeld
Copy link

jqfeld commented Mar 9, 2021

Is there a recommended way of using the plugin under WIn10? I have neuron installed under WSL2 and its working quite well on its own. Only the interplay between neuron and the plugin does not work for my setup, yet. My first impession after looking at the code is, that the problems should not be too hard to solve. Maybe I will do a corresponding pull request in the next days, if I have the time.

But before I start working on this I wanted to ask, if you already solved this without modifying the plugin.

@oberblastmeister
Copy link
Owner

Could you explain what issues you encountered? I would also suggest you not work on a pull request yet because there are some large changes in plenary notably async await. We will probably be converting to async await jobs after async await is merged in plenary.

@jqfeld
Copy link
Author

jqfeld commented Mar 10, 2021

Sure!

One thing is that the autocmds do not work, because the path in neuron_dir contains backslashes and autocmd only accepts /.
Simply doing

local pathpattern = string.format("%s/*.md", config.neuron_dir):gsub("\\","/")

in setup_autocmds() and something equivalent for the setup of the keymappings, seems to solve it under Win10 and should not break anything on linux, I think (didn't test it yet). Maybe, these changes are ok, as they don't touch any code related to plenary.Jobs?

The other issues are related to running neuron in WSL. You can start neuron from the WIndows side by calling:

wsl.exe /bin/bash --login -c neuron

Since neuron.nvim has the command "neuron" hardcoded, I tried to make a CMD file "neuron.cmd" and put it somewhere in PATH:

@echo off
wsl.exe /bin/bash --login -c 'neuron %*'

This lets me call it by simply typing "neuron ..." in CMD or Powershell just fine, the plenary.Jobs only work with "neuron.cmd" as command (means they don't seem to see my script without the .cmd extension). I was thinking, about adding another config variable to neuron.nvim. Somthing like neuron_cmd, where you can specify the command to invoke neuron. But if you don't want to do any changes at jobs related code for now (also I don't know if you want to bloat the config with another variable), I will probably compile a small wrapper around the WSL call as EXE file. I tried to compile neuron itself under windows, but couldn't succeed.

This might also be a way to solve my last problem: As neuron is running in WSL it return paths as they are mounted there. Of course those are not valid in the Win environment. I could translate the WSL paths in the wrapper.

I hope this gives some insights into the current situation under Windows.

@oberblastmeister
Copy link
Owner

Thanks for explaining. If you want to work on a pr that adds a configuration variable to change the neuron executable path, I will accept it. For the paths we could probably use plenary.path which adds os specific separators.

@jqfeld
Copy link
Author

jqfeld commented Mar 14, 2021

Ok, I will try to do that, when I have some free time on my hands. Currently, I am a little busy with work.

For now, I got it to work, with the little gsub "hack" and a simple Rust program which essentially emulates the CMD file from above + a simple regex substitution for the paths in the output.
Also I had to modify find_backlinks, because other wise under windows I would be able to search for backlinks, but as soon as I try to open them neovim would just open a file simply called C (I guess this is again path related somehow). To "fix" it I simply copied an else branch from the find_zettels function which "kinda looked like it was missing".
I have really no idea what this code is actually doing, as I am not familiar with the telescope api yet, but it got the backlinks search working under Windows for now and did not break the plugin on my Linux machine 😄.
When I have time for the pull request, I will also try to figure out how to fix that problem properly... If you are interested you can take a look at the latest commit in my win_compat branch.

Btw. I really want to thank you, for this amazing plugin. It extremely enhanced my note taking experience so far 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants