A Visual Studio Code extension that provides comprehensive language support for MARC MRK (machine-readable cataloging) files, including syntax highlighting, hover documentation, auto-completion, and validation.
- Syntax Highlighting: Color-coded MARC tags, indicators, and subfields with custom grammar
- Hover Documentation: Detailed information about MARC fields and subfields fetched from Library of Congress documentation
- Auto-completion: Intelligent suggestions for MARC tags and subfields as you type
- Real-time Validation: Syntax checking for MRK format with error highlighting
- Dynamic Documentation: Always up-to-date field definitions from Library of Congress
- Precise Hover Ranges: Accurate highlighting of individual subfields, including repeated subfields
- Python: 3.9 or higher
- MARC LSP Server: Installed via pipx or pip
-
Install the MARC LSP server (recommended with pipx for isolation):
# Install pipx if you don't have it python -m pip install --user pipx python -m pipx ensurepath # Install MARC LSP server pipx install marc-lsp-server
Alternative with pip:
pip install marc-lsp-server
-
Install this VS Code extension from the marketplace (once published)
-
Start using MARC files - the extension will automatically detect
.mrkfiles and activate
-
Install the LSP server from source:
git clone <your-marc-lsp-repo> cd marc-lsp pipx install -e .
-
Build and test the VS Code extension:
cd vscode-marc-lsp npm install npm run compile # Press F5 in VS Code to launch Extension Development Host
The extension can be configured via VS Code settings:
{
"marcLsp.serverCommand": "marc-lsp-server",
"marcLsp.trace.server": "off"
}marcLsp.serverCommand: Command to run the MARC LSP server (default: "marc-lsp-server")marcLsp.trace.server: LSP communication tracing level ("off", "messages", "verbose")
Create a .mrk file with content like this to test the extension:
=LDR 00000nam a2200000 a 4500
=001 123456789
=008 230101s2023 cau b 001 0 eng d
=020 \\$a9781234567890$qhardcover
=035 \\$a(OCoLC)123456789$z(OCoLC)987654321
=040 \\$aCLU$beng$cCLU$dNST$dDLC$dOCLCQ$dOCLCF$dOCLCO$dGILDS$dOCLCO$dOCLCQ
=100 1\$aSmith, John,$d1980-
=245 10$aExample MARC record$bfor testing language server$cby John Smith
=260 \\$aLos Angeles :$bUCLA Library,$c2023.
=300 \\$a200 pages :$billustrations ;$c24 cm
=504 \\$aIncludes bibliographical references and index.
=650 \0$aLibrary science$xAutomation.
=856 40$uhttp://example.com/resource$zOnline version
- Hover over MARC tags (=245, =040) to see field descriptions from Library of Congress
- Hover over subfields ($a, $b, $d) to see subfield definitions and descriptions
- Hover over repeated subfields (multiple $d in 040 field) - each instance highlights correctly
- Hover over indicators (10, \) to see indicator value meanings
- Type completion: Start typing
=to get tag suggestions,$for subfield suggestions - Syntax highlighting: Tags, indicators, and subfields are color-coded differently
-
Clone and setup:
git clone <repo-url> cd marc-lsp/vscode-marc-lsp npm install npm run compile
-
Open in VS Code and press F5 to launch Extension Development Host
-
In the new window, open a
.mrkfile and test all features
# Package the extension
npm install -g @vscode/vsce
vsce package
# Install locally
code --install-extension marc-lsp-0.1.0.vsixError: Launching server using command marc-lsp-server failed
Solutions:
- Install the LSP server:
pipx install marc-lsp-server - Check if it's in PATH:
which marc-lsp-server - Configure custom path: Set
marcLsp.serverCommandto full path
- Check file extension: Must be
.mrkor.mrc - Verify language mode: Bottom right of VS Code should show "MARC MRK"
- Reload window:
Ctrl+Shift+P→ "Developer: Reload Window"
- Check Output panel: View → Output → "MARC Language Server"
- Enable verbose logging:
"marcLsp.trace.server": "verbose" - Test simple line:
=245 10$aTest title - Check internet: Extension fetches documentation from Library of Congress
- Cache location: Documentation cached in
~/.cache/marc-lsp-server/ - Clear cache: Delete cache directory if needed
- Network delays: First-time field lookups may be slow
- LSP Server: Standalone Python application (
marc-lsp-server) - VS Code Extension: TypeScript client that communicates with LSP server
- Documentation Source: Live data fetched from Library of Congress
- Caching: HTML responses cached locally for performance
vscode-marc-lsp/
├── package.json # Extension manifest
├── src/extension.ts # Main extension client
├── syntaxes/mrk.tmLanguage.json # Syntax highlighting grammar
└── language-configuration.json # Language features (brackets, etc.)
npm install # Install dependencies
npm run compile # Compile TypeScript
npm run watch # Watch for changes
npx vsce package # Create .vsix package- Fork the repository
- Install development dependencies:
pipx install -e .andnpm install - Test your changes using Extension Development Host (
F5) - Submit a pull request with clear description
[Add your license here]
Keywords: MARC, MRK, cataloging, library, bibliographic, metadata, LSP, language server