Closed jparoz closed 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.
This now passes on my machine. Sorry I didn't check this earlier!
Thanks for this feedback! I’ll incorporate the changes (and run make check
and make fmt
🤦🏼♂️). Thanks for helping me through learning F#! 😁
I think I've taken all the feedback into account in the last commit, and hopefully the workflow should pass this time. 😅
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?
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:
LanguageServerProtocol/Types.fs
to support the create file operation (and other file resource changes). I added a new type for each type of resource operation, and added them all to a new[<ErasedUnion>]
sum typeDocumentChange
. This type then replacedTextDocumentEdit
where appropriate. I'm not 100% sure that this is the best way to go about this, but it works and is fairly neat.Kind: string
; I would rather use the existing typeResourceOperationKind
, but I couldn't figure out how to get those to be serialised into JSON in lowercase (i.e. they would become"Create"
instead of"create"
). Any pointers on how to make this happen usingResourceOperationKind
would be awesome; in particular, I tried using JSON.NET'sJsonPropertyAttribute
andNamingStrategy
with no change in the output.createNonexistentLink
inCodeActions.fs
is the function which carries out the main logic for this action. I've used theStart
of therange
parameter given to the code action as the position which checks for a link; I'm not sure if this should use the start, or the end of the range, or something else? I'm also happy to take any style feedback, especially as I'm pretty fresh to F#.ensureMarkdownExt
toMisc.fs
which ensures that a path has a configured Markdown extension, or adds the first configured extension if there is none. This is similar tochopMarkdownExt
.Server.fs
; keen for style advice here as well.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 theCreateFile
request, but it seems not. It's possible that this could be a bug in Neovim, that it's not sendingDidCreateFiles
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.