Ghidra Extension Development in Neovim With Lsp and Treesitter
No more wrestling with jdtls with project-local configuration :))
All config here will be placed in a project-local .nvim.lua file. Feel free
to place it in your vim.fn.stdpath("config") if you don’t like repetition.
Ghidra Extension template
This setup is tested to work with Ghidra Extension Development, it shouldn’t
differ much for other workflows. For this purpose, we’ll use the sample extension
in $GHIDRA_INSTALL_DIR/Extensions/Ghidra/Skeleton copied to a folder BetterSidebar.
Before doing anything, copy your buildTemplate.gradle to build.gradle.
treesitter
Install treesitter parser for java, and enable it in your config. That’s enough
to get great syntax highlighting. This is simple enough to be added to your global nvim config.
LSP (jdtls)
This is the tricky part. jdtls requires specific java version and GHIDRA_INSTALL_DIR
environment variable to work.
Copy over the config from https://raw.githubusercontent.com/neovim/nvim-lspconfig/292f44408498103c47996ff5c18fd366293840d8/lsp/jdtls.lua
into your .nvim.lua
note
The built-in jdtls configuration in nvim-lspconfig already handles project detection and workspace management. We only need to customize how the server is launched, so we’ll copy that configuration instead of writing one from scratch.
Make the following changes:
- Instead of returning the config, save it as a local variable
DIFF
|
|
- Set your jdtls installation’s path in config_cmd
DIFF
|
|
- Set the
JAVA_HOMEandGHIDRA_INSTALL_DIRenvironment variables.
DIFF
|
|
- Configure and enable the lsp
DIFF
|
|
Next time you open nvim, it will ask you to trust the .nvim.lua file. View
it and trust it to enable nvim config.
Full confiugration
LUA
|
|