r-languageserver
БесплатноБез исполняемых скриптовНе проверенUse when navigating, reading, or refactoring R code: finding where an R function is defined or called, tracing call hierarchies, finding a function's callers…
от jsperger★ 17 звёзд на GitHubОб этом скилле
R Language Server Protocol Integration
The R languageserver provides code intelligence for R files through the LSP tool. Use these capabilities as a "sensor array" for understanding R codebases—retrieving documentation, navigating definitions, and analyzing call graphs without reading entire files.
Reach for the LSP before grep
For any question about where a symbol is defined or used—call sites, callers, definitions, call hierarchies—use the LSP operations below, not Grep. This is the default, not an optimization: text search silently returns wrong answers on real codebases. Grep matches a function's name inside comments, #' roxygen lines, string literals, and unrelated identifiers, and it cannot tell a definition from a call or follow scoping. findReferences / incomingCalls resolve the symbol semantically instead.
Concretely, searching for ProcessData with Grep also matches the name inside a test_that("...") description string and the roxygen comment above its definition; findReferences reports only the real call sites. On a small file the difference may not change your answer, but on a package with reused names, S3 methods, and shadowed variables it does.
Grep remains the right tool for free-text pattern searches—a TODO, a literal string, a regex across non-R files. Use it for text, not for symbols.
Available Operations
| Operation | Purpose | Primary Use Case |
|---|---|---|
hover |
Get documentation | Understanding function contracts |
goToDefinition |
Jump to definition | Navigating to function source |
findReferences |
Find all usages | Impact analysis before changes |
documentSymbol |
List file symbols | File structure overview |
workspaceSymbol |
Search all symbols | Finding functions across project |
incomingCalls |
What calls this? | Understanding dependencies |
outgoingCalls |
What does this call? | Understanding execution flow |
prepareCallHierarchy |
Initialize call tree | Preparing for call analysis |
Not Supported
goToImplementation is not implemented by R languageserver. Use goToDefinition instead.
Critical Concept: Character Positioning
The most common cause of failed LSP operations is incorrect character positioning.
All operations require precise cursor placement ON the symbol:
# Line 15: result <- MyFunction(data, config)
# ^ ^ ^
# col 3 col 14 col 25
- Position on
result(col 3-8): References to this variable - Position on
MyFunction(col 14-23): Definition/references of the function - Position on
data(col 25-28): References to the argument
When an operation returns "no definition found" or "no hover information," adjust the character position before assuming the symbol isn't indexed.
Core Workflows
1. File Structure Before Reading
Instead of reading a 500-line file to find one function, use documentSymbol first:
LSP documentSymbol on large_file.R
→ Returns: FunctionA (Line 45), FunctionB (Line 120), FunctionC (Line 280)
→ Then: Read file with offset=118, limit=50 to see just FunctionB
This retrieves the file's "sitemap" and enables targeted reading.
Note: R languageserver also indexes comment-based section markers (# ====, # ----, # ---- Section Name ----). These appear in documentSymbol output, useful for navigating large files organized with sections.
2. Understanding External Functions
When encountering an unfamiliar function from an external package, use hover:
LSP hover on purrr::map_lgl at line 48, character 20
→ Returns: Full documentation with description, parameters, return value, examples
This retrieves package documentation without web searches or leaving the editor. Hover works for:
- Base R functions (
summary,grep,setdiff) - Tidyverse and other CRAN packages
- Locally defined functions (when called, not at definition site)
- Unexported functions accessed via
:::(shows signature only)
3. Impact Analysis Before Modifying
Before changing a function's signature or behavior, use incomingCalls to find all callers:
LSP incomingCalls on ProcessData at line 50, character 1
→ Returns:
- targets/pipeline.R: run_analysis (Line 30) [calls at: 45:5]
- R/helpers.R: batch_process (Line 80) [calls at: 92:12]
- tests/test-process.R: test cases (Lines 15, 28, 41)
This reveals the blast radius of any change. The output includes:
- File paths of callers
- Function/target names containing the calls
- Exact line and column of each call site
4. Understanding Execution Flow
To understand what a function depends on, use outgoingCalls:
LSP outgoingCalls on FitModel at line 100, character 1
→ Returns:
- validate_input (local) [called from: 105:3]
- checkmate::assert_class [called from: 106:3, 107:3]
- recipes::prep [called from: 115:12]
- parsnip::fit [called from: 120:12]
This maps the function's dependencies,
Установить r-languageserver в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл r-languageserver?
Use when navigating, reading, or refactoring R code: finding where an R function is defined or called, tracing call hierarchies, finding a function's callers before changing it (impact analysis), looking up a function's documentation, or interpreting the lint diagnostics that appear after editing R files. Prefer the LSP over text search for these — it resolves symbols semantically and avoids false matches in comments, strings, and docstrings.
Как установить скилл r-languageserver?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл r-languageserver запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic