Install and run Memgraph database.
Run the crawler on a project directory:
npm install
node index.js <path_to_your_project>You can provide a custom language configuration file:
node index.js <path_to_your_project> <path_to_config.json>Visit memgraph url and view graph.
You can override or add new language configurations by providing a JSON configuration file. The configuration maps file extensions to LSP server settings.
Create a custom-config.json file:
{
".ts": {
"serverCommand": "npx",
"serverArgs": ["typescript-language-server", "--stdio", "--log-level", "2"],
"languageId": "typescript"
},
".py": {
"serverCommand": "pylsp",
"serverArgs": ["--verbose"],
"languageId": "python"
},
".kt": {
"serverCommand": "kotlin-language-server",
"serverArgs": [],
"languageId": "kotlin"
},
".swift": {
"serverCommand": "sourcekit-lsp",
"serverArgs": [],
"languageId": "swift"
}
}Each file extension maps to an object with:
serverCommand: The LSP server executable commandserverArgs: Array of arguments to pass to the serverlanguageId: The language identifier for LSP protocol
Custom configurations are merged with defaults, with custom settings taking precedence.
The following languages are supported by default:
| Extension | Language | Server Command | Language ID |
|---|---|---|---|
.ts, .js |
TypeScript/JavaScript | npx typescript-language-server |
typescript/javascript |
.rb |
Ruby | ~/.asdf/shims/ruby-lsp |
ruby |
.rs |
Rust | rust-analyzer |
rust |
.py |
Python | python -m pylsp |
python |
.java |
Java | java |
java |
.c |
C | clangd |
c |
.cpp |
C++ | clangd |
cpp |
.cs |
C# | omnisharp |
csharp |
.go |
Go | gopls |
go |
.php |
PHP | intelephense --stdio |
php |
To add a new language to the default configuration:
-
Update
src/language-config.js: Add a new entry to thedefaultLanguageConfigobject:'.newext': { serverCommand: 'language-server-command', serverArgs: ['--stdio', '--other-args'], languageId: 'newlanguage' }
-
Update file detection (if needed): Check
src/file_utils.jsto ensure the file extension is included in the supported extensions for file discovery. -
Install the Language Server: Ensure the LSP server is installed and available in your system PATH.
- Must support the Language Server Protocol (LSP)
- Should support
textDocument/documentSymbolfor finding symbols - Should support
textDocument/referencesfor finding references - Must accept stdin/stdout communication (usually via
--stdioflag)