Configuration¶
All options are passed to require('vim-teradata').setup({ ... }). All fields are optional except users.
require('vim-teradata').setup({
users = {
{ log_mech = 'TD2', user = 'USER', tdpid = 'HOST' },
},
-- optional settings shown with their defaults:
retlimit = 100,
replacements = {},
ft = { 'sql', 'teradata' },
picker = 'auto',
sql_detection = 'always',
timeout_ms = nil,
history_max = nil,
sep = '~',
edit_enabled = true,
preview_updates = true,
null_token = 'NULL',
edit_keymaps = { toggle = 'E', save = 'S', cancel = 'C' },
rerun_keymaps = { sql = 'g.', result = '.' },
filter_db = nil,
-- history_dir = vim.fn.stdpath('data') .. '/teradata/history',
-- bookmarks_dir = vim.fn.stdpath('data') .. '/teradata/bookmarks',
-- data_dir = vim.fn.stdpath('data') .. '/teradata',
})
users (table[])¶
Default: {}
List of connection profiles. The first profile is the default active user.
users = {
{
log_mech = 'TD2', -- logon mechanism (e.g. 'TD2', 'LDAP', 'KRB5')
user = 'USER', -- username backed by tdwallet
tdpid = 'HOST', -- Teradata host or IP address
},
}
Security Note: Passwords are NEVER stored by
vim-teradataor written to disk. They are retrieved at logon time fromtdwalletusing$tdwallet(<user>).
replacements (table)¶
Default: {}
String substitutions applied to every query before it is sent to BTEQ. Useful for portable scripts and environment-specific database names:
replacements = {
['${DB_NAME}'] = 'PROD_DB',
['${WORK_DB}'] = 'WORK_DB_001',
}
retlimit (number)¶
Default: 100
Maximum number of rows returned per :TDO / :TDV query. Controls memory and latency.
retlimit = 100
ft (string[])¶
Default: { "sql", "teradata" }
File extensions and filetypes that activate vim-teradata. The plugin registers each extension via vim.filetype.add. See Filetypes.
ft = { 'sql', 'teradata', 'btq' }
picker (string)¶
Default: "auto"
Picker backend used by :TDR and selection dialogs:
"auto": detect automatically in order of preference (fzf-lua,snacks,telescope,fzf.vim,native)."native": built-invim.ui.select(zero external dependencies)."fzf_lua": ibhagwan/fzf-lua."snacks": folke/snacks.nvim."telescope": nvim-telescope/telescope.nvim."fzf_vim": junegunn/fzf.vim.
picker = 'auto'
sql_detection (string)¶
Default: "always"
Controls whether .sql files are treated as teradata:
"always": all.sqlbuffers get filetypeteradata."never": do not map.sqltoteradata."modeline": inspect first/last 5 lines forteradataorbteq.
sql_detection = 'always'
timeout_ms (number | nil)¶
Default: nil (disabled)
BTEQ job execution timeout in milliseconds. Set to nil or 0 to disable the timeout.
timeout_ms = 30000 -- 30 seconds
history_max (number | nil)¶
Default: nil (unlimited)
Maximum number of query history runs kept on disk before pruning older entries. Set to nil to disable pruning.
history_max = 500
keymaps (table)¶
Default: see below
Normal-mode mappings registered in every Teradata buffer to invoke node-aware editing functions ("OPE operations"). Each entry maps a key sequence to either:
- A string: name of an OPE function applied at the cursor node.
- A table
{ "func_name", { "node_type", ... } }: function plus the tree-sitter node type to act on around the cursor.
Default keymaps:
keymaps = {
["gcu"] = "uncomment_node",
["gcq"] = { "comment_node", { "statement" } },
["gcs"] = { "comment_node", { "select_expression" } },
["gcw"] = { "comment_node", { "where" } },
["gcf"] = { "comment_node", { "term" } },
["gcb"] = { "comment_node", { "binary_expression" } },
["gdq"] = { "delete_node", { "statement" } },
["gds"] = { "delete_node", { "select_expression" } },
["gdw"] = { "delete_node", { "where" } },
["gdf"] = { "delete_node", { "term" } },
["gdb"] = { "delete_node", { "binary_expression" } },
["grs"] = { "copy_node", { "select_expression" } },
["]s"] = { "jump_to_next", { "statement" } },
["[s"] = { "jump_to_prev", { "statement" } },
}
See Editing & Formatting for the full list of available OPE functions and node types.
sep (string)¶
Default: "~"
Field separator used in BTEQ result CSV files. Change only if your data regularly contains ~.
sep = '~'
edit_enabled (boolean)¶
Default: true
Enables in-grid editing of query results. See Editing results.
edit_enabled = true
preview_updates (boolean)¶
Default: true
When true, saving edits in a result buffer opens the generated UPDATE statements in a scratch buffer for review; nothing is sent to BTEQ until you press <CR> in that buffer.
preview_updates = true
null_token (string)¶
Default: "NULL"
Text BTEQ uses to render NULL in result exports (.set null). The same token typed into a cell in edit mode means SQL NULL.
null_token = 'NULL'
edit_keymaps (table)¶
Default: { toggle = "E", save = "S", cancel = "C" }
Result-buffer local mappings for in-grid editing mode:
edit_keymaps = {
toggle = 'E', -- toggle edit mode
save = 'S', -- stage / preview updates
cancel = 'C', -- discard pending edits
}
rerun_keymaps (table)¶
Default: { sql = "g.", result = "." }
Mappings that re-run the latest query (see :TDRerun):
rerun_keymaps = {
sql = 'g.', -- installed in every Teradata buffer
result = '.', -- installed in every result buffer
}
The two defaults differ on purpose: in a Teradata buffer . must keep its normal meaning (repeat the last change), so the mnemonic g. is used instead. A result buffer is nofile and non-modifiable, so . is free there.
Set either entry to nil or "" to skip that mapping:
rerun_keymaps = { sql = '<leader>rr', result = '.' }
filter_db (string | nil)¶
Default: nil
Optional Lua pattern that limits which database names are imported by :TDSync. Useful on systems with thousands of irrelevant catalogs.
filter_db = '^PROD_' -- only import databases starting with PROD_
Directory paths¶
history_dir(string): Directory for query history files (queries/andresultsets/). Defaults tovim.fn.stdpath('data') .. '/teradata/history'.bookmarks_dir(string): Directory for global and user bookmarks. Defaults tovim.fn.stdpath('data') .. '/teradata/bookmarks'.data_dir(string): Directory for the autocomplete metadata cache (sql-autocomplete). Defaults tovim.fn.stdpath('data') .. '/teradata'.