Implement something like the VSCode TabOut extension
Describe the feature
Functionality where pressing tab will auto complete closing brackets, braces, parens, and quotes.
Like VSCode albert.TabOut extension
An exploration of the current behavior of albert.TabOut:
Includes a list of bracket pairs (customizable):
[
{"open": "[", "close": "]"},
{"open": "{", "close": "}"},
{"open": "(", "close": ")"},
{"open": "'", "close": "'"},
{"open": "\"", "close": "\""},
{"open": ":", "close": ":"},
{"open": "=", "close": "="},
{"open": ">", "close": ">"},
{"open": "<", "close": "<"},
{"open": ".", "close": "."},
{"open": "`", "close": "`"},
{"open": ";", "close": ";"}
]
Behavior:
- If there is only whitespace to the left of your cursor (you are at the indent), tab behaves normally (indent normally).
- If you are at the end of a line, tab behaves normally (inserts tab/spaces)
- If you are immediately preceding a closing bracket, tab moves one column to the right
- If you are immediately preceding an opening bracket, tab moves one column to the right
- If you are immediately following an opening bracket, tab moves to the matching closing bracket character.
Notes:
- All of this functions only apply on a single line
- For bracket pairs where open/close are the same (
:,;) but since most languages don't use them as bracket pairs tab functions as a "skip forward". - If you are between two brackets (e.g. between these two chars:
{") it just moves one column to the right (e.g. the order of that list matters)
Bugs:
- Tab-out will stop at escaped quote chars inside strings
"foo \"bar\" baz"
Any updates on this?
I don't get it, is the feature implemented already and I need to do something in the setting or is it being implemented. Can you please clarify.
I don't get it, is the feature implemented already and I need to do something in the setting or is it being implemented. Can you please clarify.
@awtawsif This is a feature request. Please 👍 above to upvote and subscribe to be notified of updates.
Is this something that makes sense to implement? @notpeter
I'm working on implementing this feature by leveraging existing tree sitter functionality. Here is my fork if anyone would like to track the progress: https://github.com/vamsi10010/zed/tree/smart-tab