CSV Colorizer
A Visual Studio Code extension that colors different parts of CSV files based on column position and content types, making it easier to read and analyze CSV data.
Features
- Automatically colorizes CSV files based on column position
- Intelligently detects and colors:
- ID columns (usually numbers in the first column)
- Name columns
- Email columns (detects @ symbol)
- Department/category columns
- Customizable colors for each column type
- Works with any CSV file format
Example
When viewing a CSV file like:
1,edwin,edwin@example.com,Engineering
2,maria,maria@example.com,Marketing
3,john,john@example.com,Sales
Each column will be colored differently, making it easier to visually scan and understand the data.
Requirements
- Visual Studio Code 1.60.0 or higher
- Go 1.16 or higher (needed to build the language server)
Extension Settings
This extension provides the following settings:
csvColorizer.idColor
: Color for ID columns (default: #FF5555)
csvColorizer.nameColor
: Color for name columns (default: #50FA7B)
csvColorizer.emailColor
: Color for email columns (default: #8BE9FD)
csvColorizer.departmentColor
: Color for department columns (default: #BD93F9)
Installation
- Install the extension from the VS Code Marketplace
- Open any CSV file
- The extension will automatically colorize the columns
How It Works
This extension uses a combination of:
- Semantic token providers in VS Code to apply colors
- A Go-based language server that analyzes CSV structure
- TextMate grammar for basic syntax highlighting
- Content-based heuristics to identify column types
Building the Extension
Prerequisites
- Node.js and npm
- Go programming language
- Visual Studio Code Extension CLI (
vsce
)
Build Steps
- Clone the repository
- Run
npm install
to install dependencies
- The Go binary will be automatically built during installation
- Run
npm run compile
to compile the TypeScript code
- Run
npm run package
to create a VSIX package
Development
The extension consists of two main parts:
- TypeScript Extension: Handles the VS Code integration
- Go Language Server: Analyzes CSV structure and determines column types
The Go server can be run in two modes:
- As a directly called binary (default implementation)
- As an HTTP server (more robust for long-running analysis)
License
MIT