Tree-sitter (Teradata SQL)¶
The tree-sitter-teradata parser is a dedicated Tree-sitter parser tailored to Teradata SQL. It registers its own teradata parser and does not replace the default sql parser.
What is Tree-sitter?¶
Tree-sitter is a fast, incremental parsing system built directly into Neovim.
Traditional text editors and IDE plugins rely on regular expressions to highlight keywords. Regex matching is fragile: it cannot accurately understand nested subqueries, common table expressions (CTEs), multi-line comments, string literals with escaped characters, or dialect-specific SQL constructs.
Tree-sitter solves this by compiling formal language grammars into concrete Abstract Syntax Trees (AST). As you edit a file, Tree-sitter updates the syntax tree in milliseconds without re-parsing the entire buffer.
Why Tree-sitter for Teradata SQL?¶
In vim-teradata, the Tree-sitter parser powers several essential features:
- Accurate statement boundary detection: Commands like
:[N]TDOknow exactly where a SQL statement begins and ends. Semicolons inside string literals ('value;with;semicolon') or comments never prematurely split statements. - Instant syntax diagnostics: The parser detects syntax errors (missing parentheses, unclosed strings, invalid keywords, misplaced clauses) in real time before you send queries to the Teradata server, preventing unnecessary server-side compilation errors.
- Dialect-specific understanding: The grammar recognizes Teradata-specific SQL constructs such as
QUALIFY,SAMPLE,SEL,INS,DEL,UPD,CREATE VOLATILE TABLE, and Teradata date/time calculations. - Code actions and formatting: Structured AST understanding enables automated query formatting (
:TDF), refactorings, and AST-aware cursor navigation.
Download¶
- Parser libraries (Linux/macOS/Windows): https://github.com/ErwonB/tree-sitter-teradata/releases/latest
- Queries directory: https://github.com/ErwonB/tree-sitter-teradata/tree/main/queries
Install locations¶
Neovim loads parsers from any directory on runtimepath under parser/ and queries under queries/teradata/.
Use these typical paths (create folders if they don't exist):
Linux¶
- Parser:
~/.local/share/nvim/site/parser/teradata.so - Queries:
~/.local/share/nvim/site/queries/teradata/
macOS¶
- Parser:
~/.local/share/nvim/site/parser/teradata.dylib - Queries:
~/.local/share/nvim/site/queries/teradata/
Windows¶
- Parser:
%LOCALAPPDATA%\nvim-data\site\parser\teradata.dll - Queries:
%LOCALAPPDATA%\nvim-data\site\queries\teradata\
Tip: In Neovim, you can inspect standard paths with:
:lua print(vim.fn.stdpath('data')) :lua print(vim.o.runtimepath)
Copy the released parser library file to the parser/ path and copy the entire contents of the
queries folder into queries/teradata/.
Enable per filetype (optional)¶
vim-teradata exposes an ft option to explicitly enable diagnostics for certain filetypes:
require('vim-teradata').setup({
ft = { 'sql', 'teradata' }, -- enable Teradata diagnostics in these filetypes
-- ...your other settings
})
Verify¶
Run:
:checkhealth treesitter
:checkhealth vim-teradata
You should see teradata with the Teradata parser loaded. Open a .sql file and introduce an obvious syntax
error to see a diagnostic ERROR.