feat: #206 add configurable SQL formatting with formatSQL API#226
Open
Cythia828 wants to merge 1 commit into
Open
feat: #206 add configurable SQL formatting with formatSQL API#226Cythia828 wants to merge 1 commit into
Cythia828 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat
#206
能力概览
setupLanguageFeatures(..., { format }),默认关闭Ctrl/Cmd + Alt + FformatSQL(纯文本)、formatEditorSQL(写回编辑器)sql-formatter;失败可走用户fallbackLanguageIdEnum均有映射实现分层
src/format.ts:核心纯函数formatSQL(code, languageId, options?)src/formatEditor.ts:formatEditorSQL+registerFormatActionFeatureConfiguration.format/ModeConfiguration.formatmain.ts导出formatSQL、formatEditorSQL及相关类型配置方式
format: false/ 不传:不注册菜单与快捷键(默认)format: true:开启,无兜底format: { enable, fallback? }:开启并可配兜底与
completionItems一样支持增量合并。格式化链路
formatSQL:languageId映射到sql-formatter方言并格式化options.fallback(支持 sync/async)formatEditorSQL:formatSQLexecuteEdits+ undo stop右键 Format 会带上配置里的
fallback。方言映射
mysqlpostgresqlsparkhivetrinosqlsql外部调用示例
website demo:各方言
format: formatFeatureOptions,顶部工具栏同样调formatEditorSQL并传入同一formatFallback。未做的事
DocumentFormattingEditProvider(避免出现双菜单项)