artempyanykh / marksman

Write Markdown with code assist and intelligence in the comfort of your favourite editor.
MIT License
1.98k stars 35 forks source link

Add a code action to create nonexistent linked files #239

Closed jparoz closed 1 year ago

jparoz commented 1 year ago

Here's my first pass at a new code action to create files which are linked, but don't exist in the workspace (i.e. a goto-def on the link would error). Choosing the code action creates the file in the root of the workspace folder.

Closes #219.

A few notes:

The major problem that I still have with this implementation is that once the file is created, Marksman doesn't notice that fact straight away. In particular, if I try to goto-def on the link to the just-created file, it still gives an error. If I manually open the file (using Neovim's e command in my case), then the link works with goto-def. I think the workspace state isn't being updated when we do this code action; I would have thought that this might be triggered by the client when it creates the file upon receiving the CreateFile request, but it seems not. It's possible that this could be a bug in Neovim, that it's not sending DidCreateFiles notifications, but I don't have any other client configured at the moment to be able to test for that. If you have any knowledge of what might be the path forward, that would be super helpful.

artempyanykh commented 1 year ago

Thanks for the PR @jparoz! I'll have a closer look shortly. Meantime, could you look into CI failures -- there are some type issues in tests.

jparoz commented 1 year ago

This now passes on my machine. Sorry I didn't check this earlier!

jparoz commented 1 year ago

Thanks for this feedback! I’ll incorporate the changes (and run make check and make fmt 🤦🏼‍♂️). Thanks for helping me through learning F#! 😁

jparoz commented 1 year ago

I think I've taken all the feedback into account in the last commit, and hopefully the workflow should pass this time. 😅

artempyanykh commented 1 year ago

Looking great, thanks @jparoz! I'm going to cut a new release shortly.

Would you like to create an issue in neovim regarding the missing file notifications?