Hello everyone. I am attempting to use the MuPDF C library in nim to manipulate pdf files. MuPDF is a large and constantly changing library and I decided to use PMunch's futhark to wrap it and it works great! Thank you PMunch!
However, the futhark generated code really messes up the editor tools that I use in VSCode (I've tried both the official nim VSCode extension and the vscode-nim-lsp extension by bung87). If I build a simple program using the mupdf library wrapped by futhark, it just works. But if I open the code in VSCode, there are lots of red squigglies complaining of undeclared identifiers. I am assuming this is because of the way futhark generates the wrapper makes it hard for the tooling to show anything useful.
It would be nice to have working auto completion. Am I doing something incorrectly? Or should I pull the generated wrapper from the .cache into the codebase itself? Any suggestions would be extremely helpful!
Happy to hear that Futhark is working out for you :)
I've found that structuring the code like the "Shipping wrappers" section suggests greatly helps editor support. You might have to restart the plugin/editor after the first build if it doesn't pick up the file automatically though. Here's the relevant code snippet:
when defined(useFuthark) or defined(useFutharkForExample):
import futhark, os
importc:
outputPath currentSourcePath.parentDir / "generated.nim"
path "<path to library>"
"libfile.h"
else:
include "generated.nim"