Skip to content

Goto definition speedup#509

Open
PMassicotte wants to merge 3 commits intomainfrom
goto-definition-speedup
Open

Goto definition speedup#509
PMassicotte wants to merge 3 commits intomainfrom
goto-definition-speedup

Conversation

@PMassicotte
Copy link
Collaborator

  • srcref_ cache (R side): Added nvim.build.srcref() in bol.R to pre-build a per-package cache (srcref_<pkg>_<version>) that maps functions to their source file, line, and column. Gets built at the same time as the objls_/args_ caches.

  • New definition.c module (C side): Goto-definition now lives in rnvimserver under a new 'G' command. It hits the in-memory srcref_ cache first, and only falls back to a live R call (nvimcom:::send_definition) if it doesn't find anything.

  • PkgData struct: Added a srcref field to load the srcref_ file into memory, same way objls_ and args_ are handled.

  • Lua cleanup: Dropped find_in_package() and handle_definition_response() from definition.lua. The handler just sends a 'G' to rnvimserver now, and it works as soon as R_Nvim_status >= 2 — no need to wait for R to be fully up (status 7) like before.

  • Formatting: Ran .clang-format on the C files. This changed code formatting in only 2-3 files.

…p functions (closes #508)

feat(bol.R): add source reference cache building for package functions

This change introduces a new function `nvim.build.srcref` to build
source reference caches for functions in R packages, enhancing the
goto definition feature.

fix(Makefile): include definition.c in source files for build

This ensures that the new definition handling logic is compiled
into the rnvimserver application.

fix(data_structures.c): add srcref file reading and validation

This change allows the application to read and validate source
reference files, supporting the new goto definition functionality.

fix(data_structures.h): add srcref field to PkgData struct

This addition supports storing source reference data for R packages.

feat(definition): add symbol definition resolution feature

Introduce a new feature to resolve symbol definitions using cached
data or fallback to R for lookup. This enhances the ability to locate
symbols efficiently within packages, improving the overall
functionality of the application.
Add .clang-format file to enforce code style based on LLVM style.
Adjust line breaks and indentation in C files for better readability.
I ran clang-format on all c files for consistency.

In my `conform.lua`, I have this now:

```lua
clang_format = {},
```
@PMassicotte PMassicotte force-pushed the goto-definition-speedup branch from f7b944d to 4b06caf Compare February 25, 2026 14:53
@PMassicotte PMassicotte marked this pull request as ready for review February 25, 2026 14:54
@jalvesaq
Copy link
Member

Is it ready for review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants