apple / pkl-lsp

Apache License 2.0
24 stars 6 forks source link

Improve handling of native libraries #23

Closed bioball closed 3 weeks ago

bioball commented 3 weeks ago

This implements changes to put native libs in ~/.pkl/editor-support/. When loading the parser, it first looks for libraries there, and if they don't exist, they get copied from bundled resources.

When building libraries, the os name and architecture get included in the resource path.

This enables starting the jar plainly without needing any extra argument (e.g. no need for CLI flag -Djava.library.path, and no need for the LD_LIBRARY_PATH env var), and eliminates the need to copy native libraries to the current working dir.

Note: java-tree-sitter doesn't provide any way to provide the library path. To get around this, I'm doing a pretty ugly hack to rewrite the TreeSitter.java source file to make it load the tree-sitter library from our custom dir.