Skip to content

feat(Editor): Add Vim mode#581

Closed
coder3101 wants to merge 152 commits intomasterfrom
fakevim-support
Closed

feat(Editor): Add Vim mode#581
coder3101 wants to merge 152 commits intomasterfrom
fakevim-support

Conversation

@coder3101
Copy link
Member

@coder3101 coder3101 commented Aug 31, 2020

Vi mode is very popular and is widely used by many programmers. It speeds up so many tasks and so those who are used to it, do not like to code on any other editor. This is stopping many from adapting CP Editor as their main Editor for competitive Programming. This PR adds support for Vi mode in the code Editor using a popular extension written by the authors of Qt Creator called FakeVim.

Related Issue

Motivation and Context

I like to code in Vim too and sometimes I don't like CP Editor because of it not having Vim Support.

How Has This Been Tested?

  • Primarily testing and being developed on Arch Linux
  • Final testing will include Windows 10

Screenshots (if appropriate)

N/A

Type of changes

  • New feature (changes which add functionality)

Checklist

  • I have read the CONTRIBUTING document.
  • I have tested these changes locally, and this fixes the bug/the new feature behaves as the expectation.
  • The settings file in the old version can be used in the new version after this change.
  • These changes only fix a single bug/introduces a single feature. (Otherwise, open multiple Pull Requests instead, unless these bugs/features are closely related.)
  • The commit messages are clear and detailed. (Otherwise, use git reset and commit again, or use git rebase -i and git commit --amend to modify the commit messages.)
  • These changes don't remove an existing feature. (Otherwise, add an option to disable this feature instead, unless it's necessary to remove this feature.)
  • If there are changes of the text displayed in the UI, I have wrapped them in tr() or QCoreApplication::translate().
  • I have documented these changes in CHANGELOG.md, or these changes are not notable.

Checklist

coder3101 and others added 11 commits August 25, 2020 18:38
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@pull-assistant
Copy link

pull-assistant bot commented Aug 31, 2020

Score: 0.88

Best reviewed: commit by commit


Optimal code review plan (18 warnings)

     Add fakevim submodule

Add initial fakevim support

src/mainwindow.cpp 90% changes removed in Add Settings for Vim...

src/mainwindow.hpp 50% changes removed in style: Format codes ...

style: Format codes (#576)

...rc/Extensions/FakeVimProxy.hpp 50% changes removed in Use VimRC from Setti...

     Fix typos by misspell-fixer (#577)

     Fix typos by misspell-fixer (#578)

Update translations

translations/ru_RU.ts 96% changes removed in Use VimRC from Setti...

translations/zh_CN.ts 96% changes removed in Use VimRC from Setti...

Fix compile error and status bar alignment

...rc/Extensions/FakeVimProxy.cpp 50% changes removed in style: Format codes ...

...rc/Extensions/FakeVimProxy.hpp 50% changes removed in style: Format codes ...

style: Format codes (#579)

...rc/Extensions/FakeVimProxy.cpp 67% changes removed in resolve conflicts

Add Settings for Vim Emulation

...rc/Extensions/FakeVimProxy.cpp 88% changes removed in Refactor FakeVimProx...

...Settings/PreferencesWindow.cpp 50% changes removed in Update settings.json

src/Settings/settings.json 71% changes removed in Use VimRC from Setti...

src/mainwindow.cpp 96% changes removed in move FakeVimProxy to...

     resolve conflicts

Format code

...rc/Extensions/FakeVimProxy.cpp 50% changes removed in Add save and quit su...

     Update submodules

Update translations

translations/ru_RU.ts 42% changes removed in Update translations

translations/zh_CN.ts 42% changes removed in Update translations

     Fix error on windows

     Fix errors

     Fix Codacy issue

Add save and quit support with Vim commands

...rc/Extensions/FakeVimProxy.cpp 53% changes removed in Refactor FakeVimProx...

src/mainwindow.hpp 50% changes removed in style: Format codes ...

style: Format codes (#582)

...rc/Extensions/FakeVimProxy.cpp 70% changes removed in Refactor FakeVimProx...

     Update translations

     Merge branch 'master' into fakevim-support

Update settings.json

src/Settings/settings.json 43% changes removed in Enable autocomplete,...

     Update translations

Update Settings apply for mainwindow

src/mainwindow.cpp 48% changes removed in Enable autocomplete,...

move FakeVimProxy to Core

src/Core/FakeVimProxy.cpp 50% changes removed in Refactor FakeVimProx...

src/mainwindow.cpp 50% changes removed in Use VimRC from Setti...

src/mainwindow.hpp 50% changes removed in Do not use nested na...

CMakeLists.txt 50% changes removed in Add Basic custom vim...

     style: Format codes (#585)

Use VimRC from Settings, disable CodeEditor upon Vim

src/Core/FakeVimProxy.cpp 75% changes removed in Use temp file to sou...

     Do not use nested namespace

     Update submodules

     Use temp file to source vimrc

     style: Format codes (#589)

     Resolve conflicts

Add overwrite mode support on INS press ans setting for default cursor

src/Util/QCodeEditorUtil.cpp 90% changes removed in Apply overwrite mode...

     Apply overwrite mode along with editor settings

     Enable autocomplete, autoremove, tabJump settings in vim mode

     Update submodule: Disable line higlighting in vim mode

     Add highlight line option and fix update of cursor color on theme chan...

     Update submodule

Add changelog

doc/CHANGELOG.md 60% changes removed in Reset changelogs

Add Basic custom vim commands

src/Core/FakeVimProxy.hpp 50% changes removed in Refactor FakeVimProx...

CMakeLists.txt 67% changes removed in Refactor file names

src/Core/FakeVimProxy.cpp 43% changes removed in Add open and new com...

     Update translations

     Merge branch 'master' into fakevim-support

     Make ctor explicit

     Merge branch 'master' into fakevim-support

     Merge branch 'master' into fakevim-support

     fix: Vim handler failed to work on new tabs

     Remove :w garbage file

     Add open and new command

     Update translations

Refactor file names

src/Core/FakeVimCommand.cpp 57% changes removed in Add Run/Compile/Deta...

     Refactor FakeVimProxy

     Add Run/Compile/Detached Run commands

     Merge branch 'master' into fakevim-support

     Add language and view mode change

     Update translations

     Add comment docs for FakeVimCommands

     Resolve conflicts

     Merge branch 'master' into fakevim-support

     Reset changelogs

     Reset changelogs

Powered by Pull Assistant. Last update f9094c6 ... df0e298. Read the comment docs.

@coder3101
Copy link
Member Author

@ouuan Please review the PR or list down the issues, So I can acknowledge them or point if those could be solved.

@ouuan
Copy link
Member

ouuan commented Sep 4, 2020

Some problems:

  1. Many shortcuts are not available, including Ctrl+O, Ctrl+P, Ctrl+T, Ctrl+K, etc. Maybe Make most shortcuts customizable #214 helps.
  2. Fake Vim doesn't some code editor settings. I suggest moving the Fake Vim settings to the Code Edit section, and add "Fake Vim is not enabled" as a dependency of the unsupported code editor settings:
        "depends": [
            {
                "name": "FakeVim/Enable",
                "check": "return !var.toBool();"
            }
        ],
  3. Add Vim Cursor QCodeEditor#28 (comment)
  4. When the cursor is at the beginning/end of a line, and moved to a character left/right, the current line highlight disappears.
  5. The settings are not well formatted:
    image

1. Statusbar now shows message in same font as Code Editor
2. Disable auto Parenthesis add/remove setting in vim mode. These
settings are not available in vim by default. Default vim does not
automatically closes or adds parenthesis. Read below
3. In QCodeEditor, *keypressEvents* are not handled in vim mode.
FakeVim automatically can handle special cases like Ctrl+Enter,
auto indenting, smart indenting. Since, parenthesis add/remove was
implemented by **intercepting keypressEvents**, it will not work.
4. Put default vimrc for users. It contains same behaving defaults as
normal editor.
    4.1 Do not replace tabs with spaces
    4.2 Tab stop is 4
    4.3 Smart indent and auto-indent
5. Fixed the issue where vimrc changes of tab sizes were not being
updated by code editor.
@coder3101 coder3101 marked this pull request as ready for review November 26, 2020 15:03
@coder3101 coder3101 requested a review from ouuan November 26, 2020 15:04
@coder3101
Copy link
Member Author

This PR is ready for final review. I have fixed most of the issues you pointed. You can give it a try again and let me know if there are more changes required.

@coder3101
Copy link
Member Author

Old documentation PR has been closed and a new one has been opened here cpeditor/cpeditor.github.io#115

@coder3101 coder3101 enabled auto-merge (squash) January 12, 2021 13:33
@ouuan ouuan disabled auto-merge February 27, 2021 12:00
@coder3101
Copy link
Member Author

Vim mode is for cpeditor 7.0 and has been ported to new code editor on #516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting for translation:CN Associated PR is waiting for chinese translations to be updated awaiting for translation:RU Associated PR is waiting for russian translations to be updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants