Description:
I've been using cmp-bee and noticed that the column completion has very restrictive trigger conditions. Currently, it only triggers when:
- The alias is preceded by whitespace or a left parenthesis [%s%(]
- The alias is followed immediately by a dot and nothing else (end of line)
This prevents column completion in many common SQL patterns, for example:
-- 1. After a comma in SELECT list
SELECT id, t. -- Doesn't trigger (missing comma in pattern)
-- 2. After operators in WHERE clause
WHERE a.id = t. -- Doesn't trigger (missing operators in pattern)
-- 3. When continuing to type after the dot
SELECT t.column_name -- Only triggers at t., not when typing t.c (requires $ at end)
Affected Code:
File: /cmp-dbee/lua/cmp-dbee/handler.lua
Method: function Handler:get_completion()
if m.alias and cursor_before_line:match("[%s%(]" .. m.alias .. "%.$") then
-- column completion logic
end
Expected behavior:
Column completion should trigger in all common SQL contexts where a table alias is valid, including:
- After commas, operators, and other SQL delimiters
- When the dot is not at the end of line (while typing column names)
Questions:
- What was the reasoning behind restricting the alias pattern to only [%s%(]? Was this intentional for a specific use case?
- Why require the dot to be at the end of line ($anchor), preventing completion while typing column names?
Proposed solution:
The regex pattern could be made more flexible. Currently it's:
if m.alias and cursor_before_line:match("[%s%(]" .. m.alias .. "%.$") then
Could be changed to something like:
if m.alias and cursor_before_line:match("([^%w_])" .. m.alias .. "%." .. "(.*)$") then
This would:
- Allow any non-word character before the alias [^%w_](including space, comma, operators, parentheses, etc.)
- Allow the dot to be anywhere in the line, not just at the end (removing the $anchor)
Additional context:
The current implementation makes the plugin less useful for everyday SQL writing, especially when working with complex queries that involve multiple joins and conditions. Making the completion trigger more liberal would significantly improve the developer experience.
Description:
I've been using cmp-bee and noticed that the column completion has very restrictive trigger conditions. Currently, it only triggers when:
This prevents column completion in many common SQL patterns, for example:
Affected Code:
File: /cmp-dbee/lua/cmp-dbee/handler.lua
Method: function Handler:get_completion()
Expected behavior:
Column completion should trigger in all common SQL contexts where a table alias is valid, including:
Questions:
Proposed solution:
The regex pattern could be made more flexible. Currently it's:
Could be changed to something like:
This would:
Additional context:
The current implementation makes the plugin less useful for everyday SQL writing, especially when working with complex queries that involve multiple joins and conditions. Making the completion trigger more liberal would significantly improve the developer experience.