Version: v1.14.0 Last Updated: 2026-03-20
- Overview
- Quick Start
- Starting the LSP Server
- Supported Features
- IDE Integration
- Error Codes
- Configuration
- Performance
- Troubleshooting
The GoSQLX Language Server Protocol (LSP) implementation provides real-time SQL validation, formatting, code completion, hover documentation, and code intelligence features for IDEs and text editors.
- Real-time Diagnostics: Syntax error detection with precise error positions
- Code Completion: 100+ SQL keywords, functions, and 23 snippet templates
- Hover Documentation: Inline help for 70+ SQL keywords
- Document Formatting: Intelligent SQL formatting with configurable options
- Document Symbols: Navigation through SQL statements
- Signature Help: Function parameter documentation for 15+ SQL functions
- Code Actions: Quick fixes for common SQL issues
- Rate Limiting: Protection against DoS (100 requests/sec)
# Start LSP server on stdio
gosqlx lsp
# Start with debug logging
gosqlx lsp --log /tmp/gosqlx-lsp.log
# Verify installation
gosqlx lsp --helpimport "github.com/ajitpratap0/GoSQLX/pkg/lsp"
// Create stdio server
server := lsp.NewStdioServer(logger)
err := server.Run()The server communicates via LSP protocol on stdin/stdout:
# Start server
gosqlx lsp
# With logging for debugging
gosqlx lsp --log /tmp/gosqlx-lsp.log1. Client connects via stdin/stdout
2. Client sends 'initialize' request
3. Server responds with capabilities
4. Client sends 'initialized' notification
5. Client sends document notifications (didOpen, didChange, etc.)
6. Server sends diagnostics and responses
7. Client sends 'shutdown' request
8. Client sends 'exit' notification
9. Server exits gracefully
Sync Mode: Incremental (full and partial updates)
{
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///path/to/query.sql",
"languageId": "sql",
"version": 1,
"text": "SELECT * FROM users WHERE id = 1"
}
}
}Severity Levels:
1= Error2= Warning3= Information4= Hint
Document Limits:
- Maximum 5MB per document
- Maximum 10MB per message
Trigger Characters: (space), . (dot), ( (paren)
Completion Types:
- Keywords: SELECT, FROM, WHERE, JOIN, etc. (90+ keywords)
- Functions: Aggregate and window functions
- Snippets: 23 SQL pattern templates
Available Snippets:
| Snippet | Description |
|---|---|
sel |
SELECT statement |
selall |
SELECT * FROM table |
seljoin |
SELECT with JOIN |
selleft |
SELECT with LEFT JOIN |
selgroup |
SELECT with GROUP BY |
ins |
INSERT statement |
upd |
UPDATE statement |
del |
DELETE statement |
cte |
Common Table Expression |
cterec |
Recursive CTE |
window |
Window function |
merge |
MERGE statement |
case |
CASE expression |
Markdown documentation for 70+ SQL keywords including:
- Clauses: SELECT, FROM, WHERE, GROUP BY, ORDER BY, HAVING
- Joins: JOIN, LEFT, RIGHT, INNER, OUTER, CROSS
- Operators: AND, OR, NOT, IN, BETWEEN, LIKE
- DDL: CREATE, DROP, ALTER, TRUNCATE
- Window functions: ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD
Options:
{
"tabSize": 2,
"insertSpaces": true,
"insertFinalNewline": true,
"trimTrailingWhitespace": true
}Lists all SQL statements with categorization:
- Method (DML: SELECT, INSERT, UPDATE, DELETE)
- Struct (DDL: CREATE, DROP, ALTER)
Trigger Characters: ( and ,
Function documentation for:
- Aggregates: COUNT, SUM, AVG, MIN, MAX
- String: COALESCE, NULLIF, CAST, SUBSTRING, TRIM
- Window: ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, NTILE
Quick fixes for common issues:
- Add missing semicolon
- Keyword case conversion
GoSQLX v1.13.0 adds textDocument/semanticTokens/full support with a 6-type legend:
| Token Type | Applies To |
|---|---|
keyword |
SQL keywords (SELECT, FROM, WHERE, etc.) |
identifier |
Table names, column names, aliases |
number |
Integer and float literals |
string |
String literals and quoted identifiers |
operator |
Operators (=, >, <, AND, OR, NOT, etc.) |
comment |
SQL line and block comments |
Editors that support semantic tokens (VS Code, Neovim with nvim-lspconfig) will use these types to apply richer syntax highlighting beyond what TextMate grammars provide.
Diagnostics are debounced 300ms per document URI. Rapid keystrokes no longer trigger a full parse on every keystroke — the parser fires 300ms after the last change. This improves performance in large SQL files and reduces flicker in the editor.
Install the official GoSQLX VSCode extension from the marketplace, or configure manually:
{
"gosqlx.lsp.enable": true,
"gosqlx.lsp.path": "gosqlx",
"[sql]": {
"editor.defaultFormatter": "gosqlx.formatter",
"editor.formatOnSave": true
}
}Using nvim-lspconfig:
require('lspconfig.configs').gosqlx = {
default_config = {
cmd = { 'gosqlx', 'lsp' },
filetypes = { 'sql' },
root_dir = function() return vim.fn.getcwd() end,
},
}
require('lspconfig').gosqlx.setup{
on_attach = function(client, bufnr)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { noremap = true })
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, { noremap = true })
end
}Using lsp-mode:
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("gosqlx" "lsp"))
:major-modes '(sql-mode)
:server-id 'gosqlx))
(add-hook 'sql-mode-hook #'lsp)Using eglot:
(add-to-list 'eglot-server-programs
'(sql-mode . ("gosqlx" "lsp")))
(add-hook 'sql-mode-hook #'eglot-ensure){
"lsp_servers": {
"gosqlx": {
"command": ["gosqlx", "lsp"],
"languages": [
{
"languageId": "sql",
"scopes": ["source.sql"],
"syntaxes": ["Packages/SQL/SQL.sublime-syntax"]
}
]
}
}
}| Code | Name | Description |
|---|---|---|
| E1001 | Unexpected Character | Invalid character in SQL |
| E1002 | Unterminated String | Unclosed string literal |
| E1003 | Invalid Number | Malformed numeric literal |
| E1004 | Invalid Operator | Incorrect operator sequence |
| E1005 | Invalid Identifier | Bad table/column name |
| E1006 | Input Too Large | Document exceeds 5MB |
| E1007 | Token Limit | Too many tokens |
| E1008 | Tokenizer Panic | Internal tokenizer error |
| Code | Name | Description |
|---|---|---|
| E2001 | Unexpected Token | Token not expected here |
| E2002 | Expected Token | Missing required token |
| E2003 | Missing Clause | Required clause missing |
| E2004 | Invalid Syntax | General syntax error |
| E2005 | Incomplete Statement | Statement cuts off |
| E2006 | Invalid Expression | Expression syntax error |
| E2007 | Recursion Depth | Nesting too deep |
| E2008-E2012 | Various | Unsupported features |
| Code | Name | Description |
|---|---|---|
| E3001 | Undefined Table | Table not found |
| E3002 | Undefined Column | Column not found |
| E3003 | Type Mismatch | Incompatible types |
| E3004 | Ambiguous Column | Column reference unclear |
{
"capabilities": {
"textDocumentSyncOptions": {
"openClose": true,
"change": 2,
"save": {"includeText": true}
},
"completionProvider": {
"triggerCharacters": [" ", ".", "("]
},
"hoverProvider": true,
"documentFormattingProvider": true,
"documentSymbolProvider": true,
"signatureHelpProvider": {
"triggerCharacters": ["(", ","]
},
"codeActionProvider": {
"codeActionKinds": ["quickfix"]
}
}
}| Limit | Value |
|---|---|
| Max Message Size | 10 MB |
| Max Document Size | 5 MB |
| Rate Limit | 100 req/sec |
| Request Timeout | 30 seconds |
- Message Processing: 100+ concurrent requests/sec
- Latency: <100ms for most operations
- Token Processing: 8M+ tokens/sec (underlying parser)
- Per Document: ~10KB baseline + document size
- Per Connection: ~1MB for internal buffers
- Pool Efficiency: 95%+ hit rate
# Check installation
which gosqlx
# Reinstall if needed
go install github.com/ajitpratap0/GoSQLX/cmd/gosqlx@latest
# Test with logging
gosqlx lsp --log /tmp/test.log
cat /tmp/test.log# Verify gosqlx command exists
command -v gosqlx
# Test LSP protocol
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | gosqlx lsp- Verify document is under 5MB
- Check for syntax errors preventing parsing
- Enable logging:
gosqlx lsp --log /tmp/lsp.log - Check log for diagnostic messages
# Enable detailed logging
gosqlx lsp --log /tmp/gosqlx-lsp.log
# Monitor real-time
tail -f /tmp/gosqlx-lsp.log | grep -E "Initialize|Document|Diagnostic"- Repository: https://github.com/ajitpratap0/GoSQLX
- Issues: https://github.com/ajitpratap0/GoSQLX/issues
- Discussions: https://github.com/ajitpratap0/GoSQLX/discussions
- LSP Specification: https://microsoft.github.io/language-server-protocol/
Last Updated: 2026-03-20 Version: v1.14.0