feat: 文件编辑器支持 vim 键位(设置开关,默认关闭) - #528
Open
CashQian-com wants to merge 1 commit into
Open
Conversation
接入 @replit/codemirror-vim:新增 editorVim 设置(默认 false),Side 卡片设置页「代码」viewer 行下渲染开关;编辑器用 Compartment 承载 vim 扩展,翻转开关就地重配置(文档、撤销历史、滚动位置保留)。中英文案 + 全部 19 个第三方语言词典补齐,测试夹具同步。
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.
Summary
为侧边栏的代码 / Markdown 编辑器(CodeMirror 6)接入
@replit/codemirror-vim,在 Side 卡片设置页的「代码」viewer 行下新增「编辑器 vim 键位」开关。默认关闭,开启后已打开的编辑器即时生效(compartment 就地重配置,文档、撤销历史与滚动位置全部保留)。Motivation
vim 党在 DSH 里快速改文件时非常需要 vim 键位;目前编辑器只有默认键绑定。CodeMirror 6 生态有成熟的 vim 模拟层(
@replit/codemirror-vim,CodeMirror 官方推荐的 CM5 vim 移植),接入成本极低、零侵入——不开启开关时行为与现状完全一致。Changes
package.json:新增依赖@replit/codemirror-vim@^6.4.0(只进 editor chunk,按需懒加载,不增加核心包体积)src/config.ts/src/prefs-shared.ts/src/client/prefs.ts:新 prefeditorVim(boolean,默认false,schema / 类型 / 默认值 / 归一化四处对齐既有模式)src/client/builtins/viewers.tsx:codeviewer 声明settings.toggles,设置页渲染开关行src/client/TextEditor.tsx:Compartment承载 vim 扩展,置于扩展数组首位(keymap 优先级最高)vimMode翻转时view.dispatch({ effects: vimComp.reconfigure(...) })就地切换src/client/locales.ts:中英文设置文案(settingsEditorVimTitle/Desc)README.md/README_EN.md:文件工作台功能点补一句「设置可选 vim 键位」tests/:全量 prefs 字面量夹具补editorVim: false行为细节
i/Esc插入/普通模式、hjkl gg G dd yy p / v等标准 vim 操作与可视模式可用;保存仍走Ctrl/Cmd+S(vim 的:w不联动文件保存,这是上游 vim 扩展的边界)Testing
pnpm run typecheck✅pnpm test:与本改动相关的 spec(prefs / builtins / plugin-shape / side-card-section-rows / editor-host / sandbox-views / smoke 的 prefs 部分)全部通过 ✅Screenshots
(待补:设置页开关行 + 编辑器 vim 操作 gif;如维护者需要我再补)