1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-18 01:31:44 +02:00

Compare commits

...

483 Commits

Author SHA1 Message Date
Alex Plate
992ff97877 Use setUp function for VimOptionTestCase 2020-09-24 11:15:48 +03:00
Alex Plate
96689eab23 Update changes 2020-09-24 09:52:07 +03:00
Alex Pláte
0dd47c192b Merge pull request #252 from citizenmatt/VIM-2104
Fixes for scrolling
2020-09-24 09:45:32 +03:00
Alex Plate
5875ce58fb Update notification about missing action id 2020-09-23 10:46:21 +03:00
Alex Pláte
1c21968259 Merge branch 'master' into VIM-2104 2020-09-23 09:51:10 +03:00
Alex Plate
1d8ac4fc02 Move scroll data objects up to avoid conflicts 2020-09-23 09:50:00 +03:00
Alex Plate
0a863f32b2 Small formatting 2020-09-22 10:48:15 +03:00
Alex Plate
cd0d503402 Convert test to option test 2020-09-22 10:41:03 +03:00
Alex Plate
0bac6bf8b6 Rename tracking id action 2020-09-18 10:48:41 +03:00
Alex Plate
6436a59528 Rename "ideawaonw" to "ideawrite" 2020-09-18 10:11:01 +03:00
Matt Ellis
2dc54ea882 Use deterministic width for inlays 2020-09-17 16:15:27 +01:00
Matt Ellis
63db148aae Merge branch 'master' into VIM-2104 2020-09-17 15:29:05 +01:00
Matt Ellis
78f1c8499a Use test inlay renderer for consistent width 2020-09-17 14:55:41 +01:00
Matt Ellis
26dae9b4e0 Add zH scroll half screen width action 2020-09-17 14:35:43 +01:00
Alex Plate
10f1d75f2e Add Iain Ballard to contributors list 2020-09-17 11:22:53 +03:00
Alex Plate
5b3984ce7a Refactor test 2020-09-17 11:18:27 +03:00
Alex Plate
43810ba730 Rename moveCaretHorizontal to getOffsetOfHorizontalMotion 2020-09-17 11:18:27 +03:00
Alex Pláte
5bf2818b2a Merge pull request #242 from i-e-b/master
Partial implementation of virtualedit config
2020-09-17 11:15:14 +03:00
Alex Plate
76587d672f Refactor tests according to IdeaVim practices 2020-09-17 11:13:02 +03:00
Alex Plate
890d48769f Get rid of unused variables 2020-09-17 10:30:56 +03:00
Alex Plate
fffe8e2499 Add static import of EditorHelper 2020-09-17 10:15:09 +03:00
Alex Plate
fffc2d3b11 Use amountOfInlaysBeforeCaret function 2020-09-17 10:13:53 +03:00
Matt Ellis
007f33be0b Add zL scroll half screen width action 2020-09-17 00:01:24 +01:00
Matt Ellis
fa17af8d33 Fix keeping caret on screen with preceding inlay 2020-09-16 18:58:21 +01:00
Matt Ellis
eabe43061c Add tests and fixes for ScrollColumnLeftAction 2020-09-16 16:59:14 +01:00
Matt Ellis
64502fb31b Reformat comments 2020-09-16 12:11:48 +01:00
Matt Ellis
d693906905 Add tests and fixes for ScrollColumnRightAction 2020-09-16 11:47:28 +01:00
Alex Plate
cf25f7e201 Refactor processing of vimLastColumn 2020-09-16 12:42:43 +03:00
Matt Ellis
df3a533515 Fix arithmetic for scrolling columns 2020-09-16 09:29:43 +01:00
Matt Ellis
53a687fd53 Fix issues with side scrolling and inline inlays
Fixes VIM-1556, fixes VIM-1770, fixes VIM-2110
2020-09-15 17:07:42 +01:00
Matt Ellis
2091bbc025 Improve cursor position handling with inlay hints
E.g. navigation around Kotlin type annotations, replacing a character with a preceding parameter hint
2020-09-08 17:45:44 +01:00
Alex Plate
eb46ed8f00 Small refactorings based on inspections 2020-09-08 10:18:44 +03:00
Alex Plate
3096c2e7ad Update changelog 2020-09-08 09:58:57 +03:00
Alex Plate
f8d66f354a Fix typos in file 2020-09-08 09:56:28 +03:00
Alex Pláte
67c5601fdc Merge pull request #248 from yaohui-wyh/master
Check if project is disposed when editorDeinit
2020-09-08 09:55:58 +03:00
Matt Ellis
62601686aa Add internal action to show inline inlays 2020-09-08 00:20:54 +01:00
Alex Plate
e92c0d5098 [VIM-1968] Create and enable option to execute :wa command on :w 2020-09-07 10:55:47 +03:00
Matt Ellis
5ca0298497 Add tests for ScrollHalfPage actions
<C-D> and <C-U>
2020-09-03 17:46:30 +01:00
Matt Ellis
7321099a0f Add tests for ScrollMiddleScreenLine actions
z. and zz
2020-09-03 10:10:57 +01:00
Matt Ellis
63d9a33d80 Add tests for ScrollLastScreenLine actions
z- and zb
2020-09-03 09:57:32 +01:00
Matt Ellis
a7ba6d6004 Add tests for ScrollFirstScreenLine actions
z<CR> and zt
2020-09-03 09:55:53 +01:00
Alex Plate
5008d5c8c4 Make better notifications about tracked action id 2020-09-03 11:35:40 +03:00
Alex Plate
33f8a00679 VIM-2099 Fix operations with backward inclusive motions 2020-09-03 10:16:16 +03:00
Matt Ellis
be0adb833f Add tests for ScrollLastScreenLinePageStartAction 2020-09-03 01:10:58 +01:00
Matt Ellis
8f90ff8a65 Add tests for ScrollFirstScreenLinePageStartAction 2020-09-03 00:05:01 +01:00
Matt Ellis
c8a1938155 Add tests for ScrollPageUpAction 2020-09-02 23:27:16 +01:00
Matt Ellis
3cf42c86f3 Add tests for ScrollPageDownAction 2020-09-02 23:11:53 +01:00
Matt Ellis
632e9fad2e Remove incorrect mappings for page up/down
i_<C-Down> and i_<C-Up> are not standard Vim mappings, but can be set up in .ideavimrc if required
2020-09-02 17:18:03 +01:00
Matt Ellis
a5de935192 Add tests for ScrollLineDownAction 2020-09-02 17:05:01 +01:00
Matt Ellis
111c1ebe32 Add tests for ScrollLineUpAction 2020-09-02 15:09:11 +01:00
Matt Ellis
8a42bff6ad Add tests for scrolloff and scrolljump
Behaviour matches Vim, apart from soft wraps
2020-09-02 14:11:04 +01:00
Matt Ellis
d878c3e05d Improve handling of scrolljump
Now very closely follows Vim's somewhat unintuitive handling. Doesn't work properly with soft wraps (like a lot of other parts of IdeaVim)
2020-09-01 17:46:18 +01:00
Matt Ellis
d08da77b2f Split scrollPositionIntoView method into two 2020-09-01 17:44:24 +01:00
Alex Pláte
86d6876db4 Update README.md 2020-09-01 17:17:43 +03:00
Alex Plate
a7985e1e9b VIM-2080 Fix S command with count 2020-09-01 12:08:24 +03:00
Alex Plate
879ca456f7 Do not apply mappings in REGISTER_PENDING submode 2020-09-01 12:08:23 +03:00
Alex Plate
1863cbdef0 Add functionality to track action ids 2020-08-31 10:30:10 +03:00
Alex Plate
ac4755a6ff VIM-2071 Fix unexpected moving of caret
#VIM-2071 Request State {Ready To Release}
2020-08-28 10:17:08 +03:00
Alex Plate
61600b07a4 VIM-2084 Fix execution of plugins with existing mappings
#VIM-2084 State {Ready To Release}
2020-08-27 12:26:50 +03:00
Iain Ballard
6be6e7f173 Partial implementation of virtualedit config
This does not support all config settings,
but does add the 'onemore' option.

This partly addresses https://youtrack.jetbrains.com/issue/VIM-844
2020-08-26 08:35:00 +01:00
Alex Plate
e597e06324 Preparation for the 0.59 release 2020-08-25 10:25:32 +03:00
Matt Ellis
4cebaa865b Fix scrolljump 2020-08-20 14:21:53 +01:00
Matt Ellis
589e43f825 [VIM-2104] Use side scroll offset for horizontal scrolling 2020-08-20 11:45:39 +01:00
Yaohui Wang
61a70704c5 Check if project is disposed when editorDeinit 2020-08-03 07:21:19 +08:00
Alex Plate
174f86f91e Add gif with highlight_yank 2020-07-30 10:34:44 +03:00
Alex Plate
77a462702e Add a note about property based tests 2020-07-29 11:34:58 +03:00
Alex Plate
d20955900d Prepare to 0.58.1 EAP 2020-07-28 09:38:16 +03:00
Alex Plate
b952d2b96a Note the PR from KostkaBrukowa 2020-07-27 20:59:38 +03:00
Alex Plate
428d1d6699 Add KostkaBrukowa to contributors list 2020-07-27 20:39:16 +03:00
Alex Pláte
35863581e9 Merge pull request #245 from KostkaBrukowa/VIM-1970
VIM-1970 | Working solution of plugin vim-highlightedyank
2020-07-27 20:34:18 +03:00
Alex Plate
041f6af607 Add insert listener; small refactorings 2020-07-27 20:25:03 +03:00
Alex Plate
0e8a1bfc87 Refactor neovim tests 2020-07-27 10:07:19 +03:00
Alex Plate
442e739447 Fix propertyBased test 2020-07-27 09:57:53 +03:00
Alex Plate
47bb155989 Replace IJ pair with kotlin Pair 2020-07-26 19:09:35 +03:00
Alex Plate
bd733b72a7 Write property based test for inc/dec 2020-07-26 19:04:58 +03:00
Alex Plate
e01327ab29 Update implementation for inc/dec 2020-07-26 19:04:46 +03:00
Alex Plate
2a10247653 Update implementation for inc/dec actions 2020-07-24 21:50:04 +03:00
kostkabrukowa
e3b7ed7657 VIM-1970 | Adds yank listeners, updates tests 2020-07-24 13:36:23 +02:00
Alex Plate
d4357ce801 Start implementing property based test for increment/decrement 2020-07-24 13:54:52 +03:00
Alex Plate
5bdeaed416 Fix number change for an incorrect oct number 2020-07-24 13:53:16 +03:00
Alex Plate
a44d93283f Refactor ChangeNumberIncAction.kt 2020-07-24 10:17:36 +03:00
Alex Plate
804f69e9c8 Fix Ctrl-A for selections 2020-07-23 21:12:28 +03:00
kostkabrukowa
086c2f201b VIM-1970 | Adds feature to change highlight background color 2020-07-22 17:29:54 +02:00
Alex Plate
0b22360891 Add a couple of tests for macros 2020-07-22 11:14:49 +03:00
Alex Plate
808fb24bbc Remove unused methods 2020-07-22 10:40:35 +03:00
Alex Plate
febd8eccf0 Update changelog 2020-07-22 10:25:45 +03:00
Alex Plate
22b1209eb5 Revert the behaviour of :reg command 2020-07-22 10:21:57 +03:00
Alex Plate
485c5501b3 [VIM-2075] Fix zR command 2020-07-22 10:20:54 +03:00
Alex Plate
81ceba8926 Optimize imports 2020-07-22 10:20:54 +03:00
Alex Pláte
3edd95da4e Merge pull request #240 from rieonke/VIM-2059
add support for putting & editing macros
2020-07-22 10:20:23 +03:00
kostkabrukowa
c1bb364cbe VIM-1970 | Removes box around yank highlight 2020-07-21 15:18:00 +02:00
Alex Pláte
db8fa31503 Merge pull request #246 from gaganis/add_resources_to_contributors_md
Add resource links helpful to contributors
2020-07-21 13:09:01 +03:00
Giorgos Gaganis
1a5a65dcb1 Add resource links helpful to contributors 2020-07-20 14:40:10 +03:00
Alex Plate
1c96f4491e Comment out failing tests 2020-07-20 12:45:56 +03:00
Alex Plate
30ddb4071f Add information about neovim integration 2020-07-20 11:19:35 +03:00
kostkabrukowa
dccc793fc7 VIM-1970 | Tries to remove thread related test failure 2020-07-19 16:54:05 +02:00
kostkabrukowa
f070a57148 VIM-1970 | Tries to remove thread related test failure 2020-07-19 16:08:21 +02:00
kostkabrukowa
2dde2cfb3b VIM-1970 | Refactores some tests 2020-07-19 15:34:28 +02:00
kostkabrukowa
e0fef4f017 VIM-1970 | Adds some tests and updates plugins docs 2020-07-19 13:30:49 +02:00
kostkabrukowa
3a40b9689c VIM-1970 | Fixes register bug 2020-07-18 19:12:08 +02:00
kostkabrukowa
3937a395b7 VIM-1970 | Moves functionality to extension class, adds possibility to dynamically set highlight duration 2020-07-18 18:51:07 +02:00
kostkabrukowa
7e3d532075 VIM-1970 | Clears highlighters after its removal 2020-07-18 11:30:52 +02:00
kostkabrukowa
4f658c4734 VIM-1970 | Draft of working solution to plugin vim-highlightedyank 2020-07-18 10:14:45 +02:00
Alex Plate
26aa753d9e Update syntax of TabCloseHandler.kt 2020-07-16 11:13:20 +03:00
Alex Plate
bd9c40aabc Add Rieon Ke to contributions list 2020-07-16 11:02:45 +03:00
Alex Pláte
008edc7e33 Merge pull request #244 from rieonke/VIM-2068
Implement tabc[lose] ex command
2020-07-16 10:57:59 +03:00
Alex Plate
2901bf45b7 Update the contributing doc 2020-07-15 10:11:51 +03:00
Alex Plate
24e7f655fc Add linewise motion type 2020-07-14 11:31:29 +03:00
Alex Plate
ab8de509d9 Create visual type for the text objects 2020-07-14 02:37:54 +03:00
Alex Plate
4fc4ed7675 Remove FLAG_MOT_CHARACTERWISE flag 2020-07-14 02:10:20 +03:00
Alex Plate
b35ad2bb9d Remove FLAG_MOT_BLOCKWISE 2020-07-14 02:03:08 +03:00
Alex Plate
895c7f1af1 Remove deprecated class 2020-07-14 01:37:08 +03:00
Alex Plate
fbca5712e3 Run some tests with neovim 2020-07-14 01:24:05 +03:00
Alex Pláte
58850960b8 Merge pull request #243 from strogiyotec/master
Fix alternative XDG path in README
2020-07-13 11:37:38 +03:00
Alex Plate
1c874d3957 Assert mode in neovim testing 2020-07-13 11:23:28 +03:00
Alex Plate
a42a19a174 Add converting mode to vim notation 2020-07-13 11:21:53 +03:00
Alex Plate
bbe39d5942 Convert command state to kt 2020-07-13 10:42:43 +03:00
Alex Plate
f5fb844442 Rename .java to .kt 2020-07-13 10:42:42 +03:00
Alex Plate
cb186a686e Fix typo in readme 2020-07-13 10:21:37 +03:00
Alex Plate
0c22bb2f4f Add logging for used ideavimrc file 2020-07-13 10:05:16 +03:00
Alex Plate
49756c5c2f Split editor setup and command typing 2020-07-12 21:35:54 +03:00
Alex Plate
7efc2e1631 Enable neovim testing only for testWithNeovim task 2020-07-12 16:41:13 +03:00
Alex Plate
ed23f5958c Rename doTestWithNeovim to doTest 2020-07-12 13:14:42 +03:00
Alex Plate
0ea53f3445 Remove unused doTest method 2020-07-12 13:09:27 +03:00
Alex Plate
4531b38c89 Annotate tests with TestWithoutNeovim 2020-07-12 12:58:51 +03:00
Alex Plate
2114725dab DotToTab is now extension function 2020-07-11 21:30:21 +03:00
Alex Plate
6877ffcb47 Use neovim for tests with VimBehaviourDiffers 2020-07-11 17:55:51 +03:00
Alex Plate
c4a3cc6718 Disable neovim test for tests that are marked with VimBehaviourDiffers 2020-07-11 17:32:00 +03:00
Alex Plate
a53ed1705a Extract NeovimTesting to the separate class 2020-07-11 16:58:27 +03:00
Alex Plate
ae13eed152 Move all tests to use neovim or describe the reason why it cant 2020-07-11 16:14:48 +03:00
Alex Plate
2c2c023200 Move some tests to neovim or describe the reason 2020-07-10 12:03:54 +03:00
Alex Plate
1dbe7735df Rename api to neovimApi 2020-07-10 10:49:12 +03:00
Alex Plate
a321e77e2e Support setreg for neovim 2020-07-10 10:48:46 +03:00
Alex Plate
9b52b496b2 Convert some tests to testing with neovim 2020-07-09 22:47:41 +03:00
Alex Plate
deeddc22be More methods use neovim 2020-07-09 21:55:21 +03:00
Alex Plate
680693448f Two more tests to work with neovim 2020-07-09 19:28:44 +03:00
Alex Plate
b4b5c0c77e Convert VimTestCase to kt 2020-07-09 18:01:02 +03:00
Alex Plate
3f3305706d Rename .java to .kt 2020-07-09 18:01:01 +03:00
Alex Plate
bd942e2ea1 Add initial implementation of neovim integration for tests 2020-07-09 17:36:57 +03:00
Alex Plate
a4c3fd8f0b Removed redundant class name 2020-07-09 17:35:20 +03:00
Alex Plate
f54fc09a37 Make modes the same as in vanilla vim 2020-07-09 12:45:34 +03:00
Alex Plate
fd6bdde5b0 Add merged commits to changeslog 2020-07-09 11:17:36 +03:00
Alex Plate
85c8007084 Update authors and changes 2020-07-09 11:14:03 +03:00
Alex Pláte
8a82d60172 Merge pull request #241 from patrick-elmquist/fix/reset-operator
Properly reset when pressing Esc in the middle of command
2020-07-09 11:10:02 +03:00
Alex Pláte
8b3f5d5e81 Merge branch 'master' into fix/reset-operator 2020-07-09 11:09:41 +03:00
Alex Pláte
e222294c6e Merge pull request #237 from adriafarres/master
Reset operator-pending commands on escape
2020-07-09 11:01:03 +03:00
Alex Plate
a04b536df8 Mark codeblocks as vim script 2020-07-08 12:05:13 +03:00
Alex Plate
2a0bd8722e Check is project is disposed in isTemplateActive 2020-07-07 17:56:52 +03:00
Patrick Elmquist
742187919f Properly reset with Esc in the middle of command 2020-07-07 11:09:56 +02:00
Alex Plate
aece559400 Remove unused deprecated methods 2020-07-07 12:07:11 +03:00
Alex Plate
8b6e41afb8 Remove [To Be Released] mark 2020-07-07 09:55:08 +03:00
Alex Plate
9eed5802d6 Prepare for the 0.58 release 2020-07-07 09:28:17 +03:00
Alex Plate
437932d023 Revert and move neovim to fork 2020-07-06 19:49:27 +03:00
Alex Plate
e8dd4f2e59 Default execution amount for property based tests 2020-07-06 19:06:33 +03:00
Alex Plate
93cdf3828b Add initial implementation of neovim integration for tests 2020-07-06 19:03:07 +03:00
Alex Plate
99a91404ce Revert "Add initial implementation of neovim integration for tests"
This reverts commit 15ebcb5b
2020-07-06 16:06:09 +03:00
Alex Plate
28ae3a104a Revert "Create neovim helper"
This reverts commit bc08839b
2020-07-06 16:05:55 +03:00
Alex Plate
bc08839b16 Create neovim helper 2020-07-06 15:47:15 +03:00
Alex Plate
15ebcb5b6a Add initial implementation of neovim integration for tests 2020-07-06 12:20:02 +03:00
Alex Plate
93fd8b0ff7 More complicated texts for property based tests 2020-07-03 21:49:24 +03:00
Alex Plate
6d0f280f19 Different initial position for caret 2020-07-03 21:36:09 +03:00
Alex Plate
3b26a4c26d Unignore property based test 2020-07-03 12:37:34 +03:00
Alex Plate
60315744d1 Fix exceptions in word under caret search 2020-07-03 12:35:43 +03:00
Alex Plate
40a6617816 Reset last search during property based tests 2020-07-03 12:11:23 +03:00
Alex Plate
a6964a37ac Fix exception during sentence start search 2020-07-03 11:54:25 +03:00
Alex Plate
9249ae073c Fix bug in anyNonWhitespace 2020-07-03 11:21:03 +03:00
Alex Plate
2a216728f1 Add KtDock for property based test 2020-07-02 14:00:27 +03:00
Alex Plate
b186cb585e Rename property based test 2020-07-02 13:59:39 +03:00
Alex Plate
4e26f62391 Cleanup property based test 2020-07-02 13:58:29 +03:00
Alex Plate
ddb502acb3 Fix exception for d]] command 2020-07-02 13:48:36 +03:00
Alex Plate
89cb6867d4 Tests for exiting insert mode 2020-07-02 13:27:27 +03:00
Alex Plate
f7892b33c8 Add method doTest that accepts string instead of list of KeyStrokes 2020-07-02 12:17:22 +03:00
Alex Plate
e04e0e69f3 Enable strict mode for tests 2020-07-02 12:15:57 +03:00
Alex Plate
7172faf7b5 Revert strict mode for all normalization methods
This should be done in a more smooth way
2020-07-02 12:09:56 +03:00
Rieon Ke
6e1761a1f5 impl tabc[lose] ex command 2020-07-02 15:21:19 +08:00
Alex Plate
baa7d4f098 Fix big word motion for last word 2020-07-01 20:49:34 +03:00
Alex Plate
baa5557010 Fix bug in dollar motion at the end 2020-07-01 20:47:16 +03:00
Alex Plate
5ce25ebc23 Fix deleting from the start of document 2020-07-01 20:47:14 +03:00
Alex Plate
1f4d5b0140 Really ignore property based test 2020-07-01 19:01:51 +03:00
Alex Plate
ddd1a0a5f0 Reset digraph during propertyBased tests 2020-07-01 19:01:08 +03:00
Alex Plate
802c887b60 Well, JetCheck is accessible from IJ sources 2020-07-01 15:55:01 +03:00
Alex Plate
e15fd8fa24 Add initial implementation of property based tests 2020-07-01 15:46:52 +03:00
Alex Plate
034cc3a725 Fix sentence motion with two new lines at start 2020-07-01 15:43:24 +03:00
Alex Plate
f34dcc0386 Add test for block selection on empty file 2020-07-01 15:02:39 +03:00
Alex Plate
a7b278553f Make typeText accessible from non vim test cases 2020-07-01 14:11:14 +03:00
Alex Plate
bd52eb12bd Fix star search on the last dot 2020-06-30 23:08:09 +03:00
Alex Plate
2d9a0a7559 Fix case yk for first line 2020-06-30 22:47:19 +03:00
strogiyotec
67d3698a40 Fix alternative XDG path in README 2020-06-30 11:30:10 -07:00
Alex Plate
7b40281875 Use strict mode in normalize methods 2020-06-30 20:27:41 +03:00
Alex Plate
dc1d01c91d Use ifEmpty method 2020-06-30 19:48:53 +03:00
Alex Plate
1e2618fddc Fix missing set command in docs 2020-06-30 10:22:26 +03:00
Alex Plate
85194b772b Vim.showMessage should show localized string 2020-06-30 10:22:12 +03:00
Alex Plate
5a048139d6 Extract action names and descriptions to message bundle 2020-06-30 10:07:37 +03:00
Alex Plate
7809842348 Remove unused command flags 2020-06-30 09:55:52 +03:00
Alex Plate
c7948374fd Cleanup 2020-06-29 13:30:23 +03:00
Alex Plate
f8afdf304b Use @TestFor instead of custom annotation 2020-06-29 12:21:06 +03:00
Alex Plate
29d617f7bb Fix missing mapping to FileHandler 2020-06-29 11:00:17 +03:00
Alex Plate
0e7b05e360 Continue cleanup 2020-06-29 10:57:53 +03:00
Alex Plate
5f18e99128 Action is not nullable for Command 2020-06-29 10:49:46 +03:00
Alex Plate
b2e0af587f Continue code cleanup 2020-06-29 10:42:02 +03:00
Alex Plate
b0b0817668 Code cleanup 2020-06-29 10:29:52 +03:00
Alex Plate
a6ef654c05 Add tests for exchange plugin with unnamed register in clipboard 2020-06-26 10:43:42 +03:00
Alex Plate
e428b9fa0a IdeaVim should save to unnamed register, not default one 2020-06-26 10:34:06 +03:00
Alex Plate
7008185735 Prepare to the 0.57.1 EAP release 2020-06-26 09:32:57 +03:00
Alex Plate
e4bbc7b962 Change type of string 2020-06-26 09:27:25 +03:00
Alex Plate
68704a2e3d Oh, we have an issue for vim-exchange 2020-06-25 19:44:24 +03:00
Alex Plate
6f0222c55e IntelliJ IDEA wants this properties in this order 2020-06-25 19:43:14 +03:00
Alex Plate
e0646541e8 Revert incompatible changes 2020-06-24 18:57:25 +03:00
Alex Plate
2d1fee0516 Add [version update] marks 2020-06-24 18:17:42 +03:00
Alex Plate
149899c34e Fix fold tests 2020-06-24 18:05:54 +03:00
Alex Plate
c6573b48c2 Convert test to kt 2020-06-24 18:01:34 +03:00
Alex Plate
476ba265d2 Rename .java to .kt 2020-06-24 17:59:42 +03:00
Alex Plate
9904de1946 Use fold action names from platform 2020-06-24 17:54:04 +03:00
Alex Plate
e73aec2e9e Update gradle wrapper 2020-06-23 23:53:59 +03:00
Alex Plate
d6658a1771 Update test 2020-06-23 11:09:25 +03:00
Alex Plate
583988034b Fix incompatibility for 202 eap 2020-06-23 09:55:06 +03:00
Rieon Ke
e57d6f3d97 fix test failure after changing to key notations from printable chars 2020-06-22 22:56:47 +08:00
Rieon Ke
55e553c2a0 add support for putting & editing macros 2020-06-22 22:47:35 +08:00
Alex Plate
44a3263a86 Update CHANGES.md 2020-06-22 11:23:04 +03:00
Alex Plate
80723a6cad Use latest-eap for local builds 2020-06-22 11:16:51 +03:00
Alex Plate
ca15c60d52 Remove the ability to download EAP from notification (access to plugin download mechanism was restricted) 2020-06-22 11:16:43 +03:00
Alex Pláte
8be075b36a Merge pull request #239
Use new API for relative line numbers
2020-06-22 11:16:30 +03:00
Alex Plate
ca203f8297 Add compatibility section 2020-06-21 21:58:59 +03:00
Alex Plate
934c3065b9 Add contributions welcome badge 2020-06-21 21:56:13 +03:00
Matt Ellis
5d95917727 Do not add line numbers when caret moves
Fixes VIM-2021
2020-06-20 19:00:59 +01:00
Alex Plate
a53b67f0ef Add option to disable IdeaVim in dialogs 2020-06-20 18:20:27 +03:00
Matt Ellis
eff13180b3 Update to new line number API
Fixes VIM-1934, fixes VIM-1852
2020-06-19 23:51:46 +01:00
Alex Plate
354aec4713 Disable IdeaVim in database table cells 2020-06-19 18:55:49 +03:00
Alex Plate
d2acb88dd4 Add experimental options to disable IdeaVim in one-line editors and enable escape in dialogs 2020-06-19 16:46:37 +03:00
Alex Plate
e96ece23b8 Add strictMode to enable additional checks in dev mode 2020-06-19 09:45:46 +03:00
Alex Plate
a3a3db9bc8 Extract ListenerSuppressor from ListenerManager 2020-06-19 09:29:49 +03:00
Alex Plate
ede0737261 Update changelog 2020-06-19 07:11:54 +03:00
Alex Plate
dc7efad420 Fix links in CONTRIBUTING.md 2020-06-16 15:34:43 +03:00
Alex Plate
423d51a6f9 Update documentation and contribution section 2020-06-16 15:28:43 +03:00
Alex Plate
c350650f9c Commands work on the last line 2020-06-09 03:41:38 +03:00
Alex Plate
8c3cbc49b3 Add tests for G command 2020-06-09 03:15:16 +03:00
Alex Plate
786b7193d0 getLineCount does now respect last new line character 2020-06-09 03:04:48 +03:00
Alex Plate
2a6acba07f S is now a synonym of cc and doesn't have a separate logic 2020-06-09 03:01:45 +03:00
Alex Plate
e5a5d112ca Deprecate getFileSize method 2020-06-07 20:47:15 +03:00
Alex Plate
9e2cfe548b [WIP] Removing usages of deprecated getFileSize 2020-06-07 19:50:32 +03:00
Alex Plate
f4d595f5c2 [WIP] Removing usages of deprecated getFileSize for SearchHelper 2020-06-07 19:42:01 +03:00
Alex Plate
c1e5b7d111 Remove deprecated usage in different files 2020-06-07 19:35:25 +03:00
Alex Plate
1eccc60cb3 Remove deprecated usage in moveTextHandler 2020-06-07 19:19:29 +03:00
Alex Plate
9f8095ae52 Formatting for MoveTextHandler.kt 2020-06-07 19:17:19 +03:00
Alex Plate
3674cf4aad [WIP] Removing usages of deprecated getFileSize for MotionGroup 2020-06-07 19:17:05 +03:00
Alex Plate
6b0d2157c8 [WIP] Removing usages of deprecated getFileSize for go command 2020-06-07 19:06:04 +03:00
Alex Plate
5a629d6256 [WIP] Removing usages of deprecated getFileSize in getting file info 2020-06-07 18:37:15 +03:00
Alex Plate
b8909f97aa [WIP] Removing usages of depracated getFileSize 2020-06-07 14:13:07 +03:00
Alex Plate
8c83ed6b55 Remove usage of deprecated getFileSize 2020-06-06 18:24:24 +03:00
Alex Plate
b161346171 Trying to get rid of getFileSize with allowEnd 2020-06-06 18:07:15 +03:00
Alex Plate
330e717518 Fix offset bounds 2020-06-04 10:24:18 +03:00
Alex Plate
dafc031ef6 Add checks for selectWord 2020-06-04 10:03:43 +03:00
Alex Plate
b00a2d3b79 Do not get findManager for nullable project
Fixes EA-231806
2020-06-04 09:36:53 +03:00
Alex Plate
c64ec34a1f Fix let mapleader="\<SPACE>" 2020-06-03 11:42:39 +03:00
Alex Plate
8ed709c7bb Use different file for storing local configs 2020-06-03 11:14:37 +03:00
Alex Plate
8e8e52c6f9 Create configuration migrators for IdeaVim 2020-06-03 11:05:48 +03:00
Alex Plate
f3e806c4a6 Create config package 2020-05-28 11:14:53 +03:00
Alex Plate
3bae95ae5b Fix typo 2020-05-28 11:07:10 +03:00
Alex Plate
0adde753f4 Preparation for 0.57.1 EAP release 2020-05-28 10:39:43 +03:00
Alex Plate
5f28a22666 Notes about unsupported features of exchange plugin 2020-05-22 15:06:20 +03:00
Alex Plate
a975b53894 Fix bug in test 2020-05-22 10:27:53 +03:00
Alex Plate
98aee5d0ab Fixes and more tests for vim exchange 2020-05-22 09:59:53 +03:00
Alex Plate
f57af8bf9e new badges 2020-05-20 23:53:06 +03:00
Alex Plate
c6c3b6643e Add linewise visual test for vim exchange plugin 2020-05-20 23:44:45 +03:00
Alex Pláte
af94079b92 Merge pull request #238 from citizenmatt/bug/prioritise-startup-activity
Prioritise startup activity to initialise IdeaVim early
2020-05-15 10:27:33 +03:00
Alex Plate
7203cc5cb3 Revert "Remove dynamic loader stopper"
This reverts commit 03493e23
2020-05-15 09:48:41 +03:00
Alex Plate
028423cf58 Make exchange extension repeatable 2020-05-14 10:37:37 +03:00
Alex Plate
2ead6af96a Fix visual operator with dot command 2020-05-14 10:37:16 +03:00
Matt Ellis
bf853e3c0c Initialise as soon as possible during startup 2020-05-13 17:38:09 +01:00
Adrià Farrés
660b243056 Reset operator-pending commands on escape
Suppose we have the text "|Hello, world", with | being the position of
the cursor. Pressing `d<Esc>dw` simply moves the cursor on top of the
comma instead of leaving the text as ", world".

This fixes issue VIM-1421.
2020-05-13 05:03:49 +02:00
Alex Plate
c85f41e65b Fix tests 2020-05-12 10:43:04 +03:00
Alex Plate
2759bed1b2 Update changelog 2020-05-12 10:15:55 +03:00
Alex Pláte
89c2a8ec9b Merge pull request #229 from fan-tom/VIM-921_exchange
VIM-921 vim-exchange plugin emulation
2020-05-12 10:08:53 +03:00
Alexey Gerasimov
aa2c1257ac Use ${c} instead of <caret> 2020-05-10 17:55:55 +05:00
Alexey Gerasimov
f9fa15b7ac Parenthesize command names 2020-05-10 14:51:16 +05:00
Alex Plate
93a9be41bc Update changes image 2020-05-09 23:16:02 +03:00
Alex Plate
ecd2f2032c Update changes 2020-05-09 23:08:15 +03:00
Alex Plate
de5ce5f635 Update ideavimrc reload implementation 2020-05-09 22:56:10 +03:00
Alex Plate
2eb6fd6819 Convert VimParser to kt 2020-05-09 22:56:10 +03:00
Alex Plate
22ea4e7ffa Rename .java to .kt 2020-05-09 22:56:10 +03:00
Alex Plate
3d98f3035f Reload vimrc 2020-05-09 22:56:10 +03:00
Alex Plate
ec1d6ac477 Update changelog 2020-05-08 11:51:29 +03:00
Alex Pláte
0dc236cb5b Merge pull request #231 from citizenmatt/feature/smooth-scrolling
Support smooth scrolling
2020-05-08 11:44:18 +03:00
Alex Plate
98349a49fd Temporally remove changelog 2020-05-08 11:40:27 +03:00
Alex Plate
ab8be2cada Update changes 2020-05-08 10:35:28 +03:00
Alex Pláte
b8c22d0928 Merge pull request #230 from fan-tom/VIM-1924_select_next_occurrence
VIM-1924
2020-05-08 10:30:34 +03:00
Alex Plate
c6cf77e4b8 Remove some deprecations 2020-05-06 09:53:04 +03:00
Alex Plate
6c0511a898 Update IdeaVim icons class 2020-05-06 09:38:47 +03:00
Alex Plate
366c862bcf Add loading/unloading to manual tests 2020-05-06 09:38:11 +03:00
Alex Plate
03493e2390 Remove dynamic loader stopper 2020-05-06 09:36:41 +03:00
Alex Plate
8f9c71dd55 Correct ex command and update changes 2020-05-06 08:49:07 +03:00
Alex Plate
11beb1e331 Add Piotr Mikulski to contributors list 2020-05-06 08:47:10 +03:00
Alex Pláte
01b4dc233a Merge pull request #227 from angelbot/buffer_command
Add support for buffer command
2020-05-06 08:46:41 +03:00
Alex Pláte
9f1e80e969 Merge pull request #224 from pmnoxx/master
Populate intelij navigation history together with ideavim jumplist
2020-05-06 08:30:06 +03:00
Alex Plate
7e319e11c6 Add valis to contributors list 2020-05-06 08:20:48 +03:00
Alex Plate
d11bf1c4d2 Update api 2020-05-06 08:14:34 +03:00
Alex Plate
3e2f18b757 Take back dynamic loader stopper 2020-05-06 08:14:33 +03:00
Alex Pláte
61677aa811 Merge pull request #233
Fix #VIM-1994
2020-05-06 08:13:40 +03:00
Alex Plate
fb04e835ef Update vimBehaviourDiffers annotation description 2020-05-02 13:13:51 +03:00
Alex Plate
bb133922d6 Update scheduledForRemoval because of quickfix release 2020-05-01 11:30:26 +03:00
Alex Plate
44dd5ef872 Convert VimExtensionRegistrar to kt 2020-05-01 11:16:28 +03:00
Alex Plate
bcc8e1c055 Rename .java to .kt 2020-05-01 11:13:54 +03:00
Alex Plate
71117ed335 Update registration of extension pointers 2020-05-01 11:06:29 +03:00
Alex Plate
de07fb3b74 Well, the status bar icon should be configurable 2020-05-01 10:38:23 +03:00
Alex Plate
e31d5a4dcf Initial cleanup after IJ requirements update 2020-04-30 11:43:24 +03:00
Alex Plate
e14aae761d Java plugin is always required 2020-04-30 11:33:11 +03:00
Alex Plate
47db2a247c Remove unused labels 2020-04-30 11:20:24 +03:00
Alex Plate
e449bb9692 Refactor ChangeGroup listeners 2020-04-30 10:41:29 +03:00
Alex Plate
b8fc72b6a7 Do not create project manager if it doesn't exist yet 2020-04-30 10:28:03 +03:00
Alex Plate
64c01c1bd1 Cleanup timer for java tests 2020-04-30 10:23:14 +03:00
Alex Plate
0a0e3df42b Extract statistic reporter into the separate file 2020-04-28 11:41:33 +03:00
Alex Plate
949c69a7e9 Refactor EditorGroup listeners 2020-04-28 11:41:33 +03:00
Alex Plate
69caf7a604 Refactor MotionGroup listeners 2020-04-28 11:41:32 +03:00
Alex Plate
23860ad5f9 Use project-level service as parent disposable 2020-04-28 11:41:32 +03:00
Alex Plate
ace5234d8d Update showcmd widget 2020-04-28 11:41:32 +03:00
Alex Plate
4654f821a9 Fix issue with listener removing 2020-04-28 11:41:32 +03:00
Alex Plate
927e0e7865 Update status bar widget to the new API 2020-04-28 11:41:32 +03:00
Alex Plate
d47c9735b5 Use concurrent list to store listeners 2020-04-28 11:41:31 +03:00
Alex Plate
6100433636 Move StatusBar.kt to a different package 2020-04-28 11:41:31 +03:00
Alex Plate
43f79e8183 Update minimal required version of IJ 2020-04-28 11:41:31 +03:00
Alex Plate
f58fda0c87 Add .DS_Store to gitignore 2020-04-28 11:41:31 +03:00
Alex Plate
64b49e37d7 Add link to gitter chat 2020-04-28 11:41:31 +03:00
Alex Plate
e44418d410 Add icon in .idea 2020-04-28 11:41:30 +03:00
Alex Plate
ca8d05ff13 Clear keymap on reset 2020-04-28 11:41:30 +03:00
Alex Plate
626871e34d Register topics via xml file 2020-04-28 11:41:29 +03:00
Alex Plate
4b659fe643 Prepare for 0.57 release 2020-04-28 11:18:56 +03:00
Alex Plate
d5055506b0 Fix regex for slack notification 2020-04-22 09:56:39 +03:00
Alex Plate
55f54b2e82 Prepare for 0.56.1 release 2020-04-22 09:31:38 +03:00
Alex Plate
1b18065e68 Small refactoring of handlers 2020-04-18 17:43:50 +03:00
Alex Plate
053dc02152 EditorActionHandlerBase doesn't take null as caret 2020-04-18 16:40:07 +03:00
Alex Plate
b8cb4a1295 Move IdeaVim icon in the README 2020-04-17 11:34:28 +03:00
Alex Plate
cd2cbf68a1 Update README 2020-04-17 11:31:17 +03:00
Alex Plate
73f3be8af0 Include copyright into repository 2020-04-17 11:17:34 +03:00
Alex Plate
8cce059fb4 Write tests for yanking and pasting with number register 2020-04-17 10:48:09 +03:00
Alex Plate
db641ec6f6 Add runforprogram to contributors list 2020-04-17 10:27:11 +03:00
Alex Plate
9d8239b68d Update changelog 2020-04-17 10:19:56 +03:00
Alex Pláte
4ec0bac275 Merge pull request #234 from runforprogram/master
[VIM-1991] fix >0 number register not work
2020-04-17 10:19:49 +03:00
Alex Plate
613c234cfb Fix related tests 2020-04-16 11:31:22 +03:00
Alex Plate
83dca71f69 [VIM-1992] Fix shift-letter mappings 2020-04-16 11:20:26 +03:00
Alex Plate
f7ea9cdb6e Convert mapping tests to kotlin 2020-04-16 11:03:40 +03:00
Alex Plate
762cb1804f Rename .java to .kt 2020-04-16 11:02:38 +03:00
run
962cfb7ae2 [VIM-1991] fix >0 number register not work 2020-04-16 15:45:57 +08:00
Valery Isaev
9bc2ec7d8a Fix #VIM-1994 2020-04-13 15:02:49 +03:00
Alex Plate
8415d104e9 Clear registers before test 2020-04-10 11:03:14 +03:00
Alex Plate
abd0f9b961 Update dependencies 2020-04-10 11:00:47 +03:00
Alex Plate
0a4683d908 Clean up repository for the release 2020-04-09 11:06:21 +03:00
Alex Plate
4c280b0193 Run manual tests 2020-04-09 10:51:32 +03:00
Alex Plate
e88a3deafd Fix replace with clipboard register 2020-04-09 10:25:42 +03:00
Matt Ellis
7de08e08d0 Support smooth scrolling 2020-04-07 17:30:18 +01:00
Alex Plate
bd172b3300 Run manual tests 2020-04-07 11:35:58 +03:00
Alex Plate
95c7a13cb5 Turning plugin on should be performed after commands registration 2020-04-07 11:27:24 +03:00
Alex Plate
b1ddf03385 Add notes to changelog about Keep a Changelog and Semantic Versioning. 2020-04-06 10:25:50 +03:00
Alex Plate
a83c326736 Add logging for activating ex panel 2020-04-03 08:23:55 +03:00
Alex Plate
b1acb56247 Fix exception for ciw on last char in file 2020-03-28 15:57:54 +03:00
Alex Plate
caa4731a13 Fix exception when using text objects on empty files 2020-03-28 15:39:06 +03:00
Alex Plate
5b0ece7a91 ReplaceWithRegister for clipboard registers 2020-03-23 10:34:53 +03:00
Alexey Gerasimov
a4cd94847e Return VISUAL_BLOCK submode from autodetect only if 'Add Selection for NextOccurrence' was not performed previously 2020-03-22 16:45:45 +05:00
Alexey Gerasimov
a0a7386b51 Remove highlight after command is executed or canceled 2020-03-21 20:08:57 +05:00
Alexey Gerasimov
535a72000f Cleanup 2020-03-21 20:08:37 +05:00
Alexey Gerasimov
60531b9cd2 Add methods in RegisterGroup and VimExtensionFacade to setRegister with specified selection type 2020-03-21 20:04:30 +05:00
Alexey Gerasimov
8f86ad696d Register VimExchange extension 2020-03-21 20:04:30 +05:00
Alexey Gerasimov
c9bda98a6a Add VimExchange extension tests 2020-03-21 20:04:30 +05:00
Alexey Gerasimov
9ea08da133 Add VimExchange extension 2020-03-21 17:09:02 +05:00
Alexey Gerasimov
5762ec0518 Add marks last changed end position test 2020-03-21 17:09:02 +05:00
Alexey Gerasimov
7db74460fa Fix marks range end position handling, as excluded 2020-03-21 17:09:02 +05:00
Alex Plate
c8d64e0a06 Update changelog 2020-03-20 11:44:27 +03:00
Alex Plate
1a3dea0de6 Update slack notification format 2020-03-20 11:42:40 +03:00
Alex Plate
17b642280e Update gradle wrapper properties 2020-03-20 11:42:14 +03:00
Alex Plate
1c1717b78b Add kk to the contributions list 2020-03-20 10:38:30 +03:00
Alex Plate
4bbbdf8108 Fix ReplaceWithRegister to the empty line 2020-03-20 10:35:08 +03:00
Alex Pláte
04a193309d Merge pull request #228 from kevin70/master
fixed #VIM-570
2020-03-20 10:34:58 +03:00
Alex Plate
f106ffa176 Support ReplaceWithRegister plugin emulation 2020-03-19 11:25:30 +03:00
Alex Plate
8d5d099542 Update icon on ideastatusicon option change 2020-03-19 09:13:49 +03:00
kk
4849992ca9 fixed #VIM-570 2020-03-18 18:49:55 +08:00
Alex Plate
623105650e PutTextAction refactor 2020-03-17 09:43:40 +03:00
Alex Plate
5e2c01daa6 Rename PutTextAction.kt 2020-03-17 09:32:46 +03:00
Alex Plate
58bf3a4d30 Merge Put actions into one file 2020-03-17 09:28:49 +03:00
Alex Plate
2d434c38b9 Move test to correct directory 2020-03-15 16:53:57 +03:00
Alex Plate
246f5cd8cf VIM-1911 Lookup keys respect IDE handler 2020-03-14 23:03:42 +03:00
Alex Plate
5a174d21f1 Update CHANGES 2020-03-14 18:06:58 +03:00
Alex Plate
e632c653f6 Add showcmd text to widget label 2020-03-14 18:05:38 +03:00
Alex Plate
174d17b088 VIM-1958 Fix X command for linewise selection 2020-03-14 18:00:45 +03:00
Alex Plate
3a35c931e4 Unignore some tests 2020-03-14 17:42:33 +03:00
Alex Plate
b768b26c85 Remove some warnings 2020-03-14 17:28:14 +03:00
Alex Plate
123ce6ebaf Get rid of deprecated KeyEvents 2020-03-14 15:55:01 +03:00
Alex Plate
276c8db512 Fix some tests 2020-03-12 11:48:24 +03:00
Alex Plate
f898b8d181 Fix mappings to <S-Space> 2020-03-12 11:25:14 +03:00
Alex Plate
e9f9e531e4 Convert vim typed action to kt 2020-03-12 11:04:35 +03:00
Alex Plate
a7d813cb86 Rename .java to .kt 2020-03-12 11:04:35 +03:00
Alex Plate
75b6eedb12 Remove unused class 2020-03-12 10:33:52 +03:00
Alex Plate
ec6860aa90 Change the label of showcmd widget 2020-03-12 10:03:39 +03:00
Alex Plate
5cf661c6ae Fix exception during command typing 2020-03-10 14:58:35 +03:00
Alex Plate
8c62caae7c Fix compilation errors 2020-03-10 11:30:10 +03:00
Alex Plate
cc6fe21af6 Update CHANGES.md 2020-03-10 10:28:17 +03:00
Alex Pláte
1902151efa Merge pull request #220 from citizenmatt/feature/showcmd
Implement showcmd
2020-03-10 10:24:36 +03:00
Alex Pláte
b7af1e6289 Merge branch 'master' into feature/showcmd 2020-03-10 10:24:06 +03:00
Alex Plate
0c77b320db VIM-570 Print non-ascii characters in ex panel 2020-03-06 13:03:28 +03:00
Alex Plate
ee41adc4e9 Update kotlin version 2020-03-06 09:54:57 +03:00
Alex Pláte
93462d7505 Merge pull request #221 from igrekster/master
argtextobj: support bracket pairs configuration via let g:argtextobj_pairs="..."
2020-03-06 09:54:33 +03:00
Alex Plate
2f5946640e Update changelog 2020-03-04 10:44:28 +03:00
Alex Plate
7cdb7dc308 Fix some tests for older versions of IDE 2020-03-04 10:32:05 +03:00
John Weigel
2f148255f7 Cleanup 2020-03-03 23:14:11 -06:00
John Weigel
cb00b8b335 Merge remote-tracking branch 'upstream/master' into buffer_command 2020-03-03 23:10:00 -06:00
John Weigel
559b56c8a2 Minor updates 2020-03-03 23:05:32 -06:00
Alex Plate
c0038d0373 Add John Weigel to contributors list 2020-03-03 11:11:09 +03:00
Alex Plate
2820decb5e Rename variable 2020-03-03 11:07:07 +03:00
Alex Pláte
c64f368e6a Merge pull request #217 from angelbot/master
Add support for buffer list (buffers, files, ls)
2020-03-03 11:05:43 +03:00
Alex Plate
b7c8e84f5e Minor cleanup 2020-03-03 11:03:36 +03:00
Alex Plate
5acf6c9158 Convert VimPlugin to service 2020-02-28 21:11:12 +03:00
Alex Plate
a8197b0c84 Convert runnableHelper to kt 2020-02-28 18:15:40 +03:00
Alex Plate
2e03062c24 Rename .java to .kt 2020-02-28 18:15:39 +03:00
Alex Plate
7fb60a185b Update gradle version 2020-02-28 17:35:46 +03:00
Alex Plate
0327ea972b Make Open ideavimrc dumb aware 2020-02-28 10:29:38 +03:00
Alex Plate
561cc77ecc Move related methods closer to each other 2020-02-28 09:42:22 +03:00
Alex Plate
a1ab4acd14 Add comment for EPs 2020-02-28 09:39:33 +03:00
Alex Plate
d4939803da Update changelist 2020-02-27 14:27:13 +03:00
Alex Pláte
730ce3aca9 Merge pull request #226 from agrison/master
Implement the vim-textobj-entire plugin emulation.
2020-02-27 14:23:31 +03:00
Alexandre Grison
1893dc6afd Fixes from feedback.
Renamed `entiretextobj` to `textobj-entire` including packages and class name.
Renamed `<Plug>IncludingLeadingTrailing` to `<Plug>textobj-entire-a`.
Renamed `<Plug>IgnoringLeadingTrailing` to `<Plug>textobj-entire-i`.
Avoid iterating too much the buffer content.
2020-02-27 11:46:23 +01:00
igrekster
6ec39314ee argtextobj: support bracket pairs configuration via let g:argtextobj_pairs="..."
argtextobj by default only handles arguments inside parenthesis. This is
very limiting when editing C++ source files. This change allows the list
of bracket pairs to be configurable via a global IdeaVim variable. The
variable takes effect immediately.
2020-02-26 10:32:21 +11:00
John Weigel
158cea51db Add override test 2020-02-23 22:02:06 -06:00
John Weigel
33d34f35e9 Merge branch 'master' into buffer_command 2020-02-23 21:49:22 -06:00
John Weigel
1f4f40fd7c Merge remote-tracking branch 'upstream/master' 2020-02-23 21:48:30 -06:00
John Weigel
7c908b247e Merge branch 'master' into buffer_command 2020-02-23 21:14:21 -06:00
John Weigel
c87528939b Fix buffer numbering bug with filters.
Update test to cover fix.
2020-02-23 21:11:36 -06:00
John Weigel
41c822fde1 Add support for buffer command. 2020-02-23 20:45:06 -06:00
Alex Plate
e56646105d Add test bages 2020-02-21 12:05:05 +03:00
Alex Plate
b8a40d93f7 Now every service handles it's state separately. VimLocalConfig is a service 2020-02-21 12:03:02 +03:00
Alexandre Grison
4bfc025248 Fixes typo 2020-02-20 12:24:38 +01:00
Alexandre Grison
36f6027b0e Implement the vim-textobj-entire plugin emulation. 2020-02-20 12:13:55 +01:00
Alex Plate
e032377e68 Update annotations 2020-02-20 10:35:09 +03:00
Alex Plate
929eee4a12 Add comments for NotificationService.kt 2020-02-20 10:13:47 +03:00
Alex Plate
61ce50264a Add Alexey Gerasimov to contributors list 2020-02-19 12:02:10 +03:00
Alex Plate
48927b1207 Small corrections after merge 2020-02-19 11:58:37 +03:00
Alex Plate
0820893dc6 Update annotations to java 8 style 2020-02-19 11:58:27 +03:00
Alex Pláte
dd6079cfa6 Merge pull request #219 from fan-tom/bugifx/1008
Fix block actions (i.e ci{) in presence of quotes (VIM-1008)
2020-02-19 11:53:19 +03:00
Piotr Mikulski
2a6569742d populate intelij navigation history together with ideavim jumplist 2020-02-17 17:55:45 -08:00
John Weigel
3d7d75bae4 Merge remote-tracking branch 'upstream/master' 2020-02-16 21:11:02 -06:00
John Weigel
6da4d0ce5e Rework buffer list to more closely mimic vim. 2020-02-16 20:40:17 -06:00
Alex Plate
4994d70b1a Update changelog 2020-02-14 12:42:22 +03:00
Alex Plate
c873081dc3 Merge pull request #133 from igrekster/master
Add argtextobj.vim plugin emulation
2020-02-14 12:30:13 +03:00
Alex Plate
070237f77f Add [To Be Released] label 2020-02-14 12:24:34 +03:00
Alex Plate
eb01b25f35 Fix some cases by disabling [, { and < support (what is not supported in the original plugin) 2020-02-14 12:23:32 +03:00
Alex Plate
c0c9cfaf86 Get rid of several getText methods 2020-02-14 10:54:22 +03:00
Alex Plate
304f860eb2 Use java 8 JetBrains annotations 2020-02-14 10:32:18 +03:00
Alex Plate
2f18b25593 Update gradle dependencies 2020-02-14 10:17:00 +03:00
Matt Ellis
14c8b6a248 Fix nullability compile error on 2019.2 2020-02-11 10:29:02 +00:00
Alex Plate
adaa683e58 Use 2020.1 build for README label 2020-02-11 10:11:52 +03:00
Matt Ellis
9b71215cde Merge branch 'master' into feature/showcmd 2020-02-11 00:24:29 +00:00
Matt Ellis
8be572f976 Update set-commands and changes 2020-02-11 00:22:29 +00:00
Matt Ellis
4f43bcffb9 Replace SelectRegisterAction with direct parsing
It's not a command, but part of a command
2020-02-11 00:08:08 +00:00
Matt Ellis
29e4dc5fb5 Show digraph entry in showcmd 2020-02-10 23:38:02 +00:00
Matt Ellis
0dc95cb13c [VIM-434] Display showcmd in status bar
IdeaVim has showcmd enabled by default. Vim has it enabled by default, but disabled for Unix, with concerns about slow terminals. It is enabled by defaults.vim
2020-02-10 11:35:52 +00:00
igrekster
5ee0a93675 Add argtextobj.vim plugin emulation 2020-02-09 11:57:54 +11:00
Alex Plate
767b3c4a39 Add some scheduled for removal annotations 2020-02-08 20:57:44 +03:00
Alex Plate
bb948a463c Add option to make status bar icon gray 2020-02-08 20:56:13 +03:00
Alex Plate
e4e9a03d0a Add information about why EPs are used to register actions and ex handlers. 2020-02-08 18:14:04 +03:00
Alex Plate
50ba386f59 Write tests for dynamic extensions 2020-02-08 18:07:20 +03:00
Alex Plate
79d0565c2d Update some tests 2020-02-08 16:09:39 +03:00
Alex Plate
bcc9b0a7b1 Remove plugin owner after extension removal 2020-02-08 15:38:54 +03:00
Alex Plate
2c8f4940b9 Support EasyMotion extension 2020-02-08 15:25:24 +03:00
Alex Plate
41876cf8fd Make vimExtension dynamic 2020-02-08 14:56:39 +03:00
Alex Plate
f6fd0b52f0 Rename RequiredShortcutOwner to MappingOwner 2020-02-08 14:36:35 +03:00
Alex Plate
843faa7cc6 Make plugins disposable 2020-02-08 14:36:01 +03:00
Alexey Gerasimov
a8af2c3242 Fix Set creation 2020-02-07 22:24:46 +05:00
Alexey Gerasimov
e5bfad974e Copyright and comment 2020-02-07 21:50:06 +05:00
Alexey Gerasimov
59d87e0c94 More tests 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
50c2d04503 Migrate to new checkInString 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
480de62686 Improve existing checkInString 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
955b501058 Make Direction enum public 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
d985527624 Rewrite checkInString in Kotlin 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
afbe7f0e69 Add findPositionOfFirstCharacter function 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
94e65ddce6 Use isQuoteWithoutEscape when findCharacterPosition to detect escaped char 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
cb9f144255 isQuoteWithoutEscape small improvement 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
ac84624faa Use Direction enum instead of int 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
c2196785e7 Add tests 2020-02-07 19:48:40 +05:00
Alexey Gerasimov
30097fbae6 Assume that caret is in string/char only if there is closing char 2020-02-07 19:48:40 +05:00
Alex Plate
c295dd5c62 Use special class for storing requiredShortcuts 2020-02-07 16:07:14 +03:00
Alex Plate
373fef2824 Refactor MappingInfo 2020-02-07 12:42:36 +03:00
Alex Plate
cfc255bf2b Rename .java to .kt 2020-02-07 12:41:57 +03:00
Alex Plate
ea7e58535b Fix tests 2020-02-07 12:41:47 +03:00
Matt Ellis
9fad4a74ed Remove keys from Command
Also refactors PutVisualTextAction
2020-02-04 00:36:59 +00:00
John Weigel
ff209d0120 Merge remote-tracking branch 'origin/master' 2020-02-01 22:38:18 -06:00
John Weigel
ea2fe618b5 Add support for buffer list (buffers, files, ls). 2020-02-01 22:33:12 -06:00
458 changed files with 21152 additions and 7247 deletions

9
.gitignore vendored
View File

@@ -1,6 +1,13 @@
*.swp
/.gradle/
/.idea/
!/.idea/scopes
!/.idea/copyright
!/.idea/icon.png
/build/
/out/
/tmp/
/tmp/
*.DS_Store

6
.idea/copyright/IdeaVim.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="IdeaVim - Vim emulator for IDEs based on the IntelliJ platform&#10;Copyright (C) 2003-&amp;#36;today.year The IdeaVim authors&#10;&#10;This program is free software: you can redistribute it and/or modify&#10;it under the terms of the GNU General Public License as published by&#10;the Free Software Foundation, either version 2 of the License, or&#10;(at your option) any later version.&#10;&#10;This program is distributed in the hope that it will be useful,&#10;but WITHOUT ANY WARRANTY; without even the implied warranty of&#10;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#10;GNU General Public License for more details.&#10;&#10;You should have received a copy of the GNU General Public License&#10;along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt;." />
<option name="myName" value="IdeaVim" />
</copyright>
</component>

7
.idea/copyright/profiles_settings.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<component name="CopyrightManager">
<settings>
<module2copyright>
<element module="Copyright" copyright="IdeaVim" />
</module2copyright>
</settings>
</component>

BIN
.idea/icon.png generated Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

3
.idea/scopes/Copyright.xml generated Normal file
View File

@@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="Copyright" pattern="file[IdeaVIM.main]:com//*||file[IdeaVIM.test]:*/" />
</component>

View File

@@ -271,6 +271,58 @@ Contributors:
[![icon][github]](https://github.com/igrekster)
&nbsp;
igrekster
* [![icon][mail]](mailto:lokomot476@gmail.com)
[![icon][github]](https://github.com/fan-tom)
&nbsp;
Alexey Gerasimov
* [![icon][mail]](mailto:a.grison+github@gmail.com)
[![icon][github]](https://github.com/agrison)
&nbsp;
Alexandre Grison
* [![icon][mail]](mailto:angel@knight-industries.com)
[![icon][github]](https://github.com/angelbot)
&nbsp;
John Weigel
* [![icon][mail]](mailto:kevinz@weghst.com)
[![icon][github]](https://github.com/kevin70)
&nbsp;
kk
* [![icon][mail]](mailto:runforprogram@163.com)
[![icon][github]](https://github.com/runforprogram)
&nbsp;
runforprogram
* [![icon][mail]](mailto:valery.isaev@jetbrains.com)
[![icon][github]](https://github.com/valis)
&nbsp;
valis
* [![icon][mail]](mailto:pmikulski@voleon.com)
[![icon][github]](https://github.com/pmnoxx)
&nbsp;
Piotr Mikulski
* [![icon][mail]](mailto:14farresa@gmail.com)
[![icon][github]](https://github.com/adriafarres)
&nbsp;
Adrià Farrés
* [![icon][mail]](mailto:patrick.j.elmquist@gmail.com)
[![icon][github]](https://github.com/patrick-elmquist)
&nbsp;
Patrick Elmquist
* [![icon][mail]](mailto:rieon@rieon.cn)
[![icon][github]](https://github.com/rieonke)
&nbsp;
Rieon Ke
* [![icon][mail]](mailto:jiirra@gmail.com)
[![icon][github]](https://github.com/KostkaBrukowa)
&nbsp;
KostkaBrukowa
* [![icon][mail]](mailto:wangyaohuicn@gmail.com)
[![icon][github]](https://github.com/yaohui-wyh)
&nbsp;
Yaohui Wang
* [![icon][mail]](mailto:iain.ballard@bjss.com)
[![icon][github]](https://github.com/i-e-b)
&nbsp;
Iain Ballard
If you are a contributor and your name is not listed here, feel free to
contact the maintainers.

View File

@@ -3,6 +3,12 @@ The Changelog
History of changes in IdeaVim for the IntelliJ platform.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project DOES NOT adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Stable versions use X.Y format.
EAP versions use X.Y.Z format.
Get an Early Access
-------------------
@@ -17,17 +23,131 @@ Please note that the quality of EAP versions may at times be way below even
usual beta standards.
To Be Released
--------------
-----------
_Available since 0.55.1 EAP:_
**Features:**
* Support of `virtualedit=onemore` ([VIM-844](https://youtrack.jetbrains.com/issue/VIM-844))
**Fixes:**
* [VIM-1284](https://youtrack.jetbrains.com/issue/VIM-1284) Fix mapping of digits
* Fix handling of counts on both operator and motion, e.g. `3d2w` deletes 6 words, instead of 32
* Allow mapping of `<C-K>` and `<C-V>`/`<C-Q>`
* [VIM-1899](https://youtrack.jetbrains.com/issue/VIM-1899) Add argument to `:registers` command
* [VIM-1835](https://youtrack.jetbrains.com/issue/VIM-1835) Macros record input keystrokes instead of mapped keystrokes
* [VIM-1900](https://youtrack.jetbrains.com/issue/VIM-1900) Ensure non-printable output for `:registers`, `:marks` and `:jumps` is encoded correctly
* [VIM-2097](https://youtrack.jetbrains.com/issue/VIM-2097) Do not apply mappings for register selecting
* [VIM-2080](https://youtrack.jetbrains.com/issue/VIM-2080) Fix S command with count
* [VIM-2099](https://youtrack.jetbrains.com/issue/VIM-2099) Fix operations with backward inclusive motions
* [VIM-2104](https://youtrack.jetbrains.com/issue/VIM-2104) Use `sidescrolloff` for horizontal offset
* [VIM-1080](https://youtrack.jetbrains.com/issue/VIM-1080) Fix `zt` for virtual space enabled
* [VIM-1556](https://youtrack.jetbrains.com/issue/VIM-1556) Fix horizontal scrolling
* [VIM-1770](https://youtrack.jetbrains.com/issue/VIM-1770) Fix goto end with large inline hints
* [VIM-2110](https://youtrack.jetbrains.com/issue/VIM-2110) Fix scrolling for non-monospaced fonts
**Changes:**
* `:w` works as `:wa` by default. This can be disabled with `ideawrite` option.
Now features like `Prettier on save` or `Run on save for files` would work with `:w` command as well.
See [VIM-1968](https://youtrack.jetbrains.com/issue/VIM-1968).
**Merged PRs:**
* [248](https://github.com/JetBrains/ideavim/pull/248) by [Yaohui Wang](https://github.com/yaohui-wyh): Check if project is disposed when editorDeinit
* [242](https://github.com/JetBrains/ideavim/pull/242) by [Iain Ballard](https://github.com/i-e-b): Partial implementation of virtualedit config
* [252](https://github.com/JetBrains/ideavim/pull/252) by [Matt Ellis](https://github.com/citizenmatt): Fixes for scrolling
0.59, 2020-08-25
------------
**Features:**
* `vim-highlightedyank` plugin emulation ([VIM-1970](https://youtrack.jetbrains.com/issue/VIM-1970) | [vim-highlightedyank](https://github.com/machakann/vim-highlightedyank)).
* <details>
<summary><strong>Click to see details</strong></summary>
<img src="resources/changes/0.59/highlight_yank.gif" alt="highlight yank"/>
</details>
* [VIM-2068](https://youtrack.jetbrains.com/issue/VIM-2068) `:tabclose` command
**Fixes:**
* [VIM-1421](https://youtrack.jetbrains.com/issue/VIM-1421) Escape key finishes `t` and `f` motions
* [VIM-2075](https://youtrack.jetbrains.com/issue/VIM-2075) Fix zR command
* [VIM-2059](https://youtrack.jetbrains.com/issue/VIM-2059) Fixed macro editing
**Merged PRs:**
* [237](https://github.com/JetBrains/ideavim/pull/237) by [Adrià Farrés](https://github.com/adriafarres): Reset operator-pending commands on escape
* [241](https://github.com/JetBrains/ideavim/pull/241) by [Patrick Elmquist](https://github.com/patrick-elmquist): Properly reset when pressing Esc in the middle of command
* [244](https://github.com/JetBrains/ideavim/pull/244) by [Rieon Ke](https://github.com/rieonke): Implement tabc[lose] ex command
* [240](https://github.com/JetBrains/ideavim/pull/240) by [Rieon Ke](https://github.com/rieonke): add support for putting & editing macros
* [245](https://github.com/JetBrains/ideavim/pull/245) by [KostkaBrukowa](https://github.com/KostkaBrukowa): VIM-1970 | Working solution of plugin vim-highlightedyank
0.58, 2020-07-07
-------------
**Features:**
* `exchange` plugin emulation ([VIM-921](https://youtrack.jetbrains.com/issue/VIM-921) | [vim-exchange](https://github.com/tommcdo/vim-exchange)).
* `~/.ideavimrc` file can be reloaded using the new floating action.
* <details>
<summary><strong>Click to see details</strong></summary>
<img src="resources/changes/0.58/reload_ideavimrc.png" alt="IdeaVimRc reload"/>
</details>
* Add `:buffer` command.
**Changes:**
* Support IntelliJ's smooth scrolling. Use "Enable smooth scrolling" checkbox in _Preferences | Editor | General_ to disable.
**Fixes:**
* [VIM-1994](https://youtrack.jetbrains.com/issue/VIM-1994) Correct paste after `y}P` command.
* [VIM-1924](https://youtrack.jetbrains.com/issue/VIM-1924) Select next occurrence doesn't become block selection.
* [VIM-2038](https://youtrack.jetbrains.com/issue/VIM-2038) Last line is now accessible in normal mode
* [VIM-1934](https://youtrack.jetbrains.com/issue/VIM-1934) Line number is not clipped for relative line numbers
* [VIM-1852](https://youtrack.jetbrains.com/issue/VIM-1852) Line number doesn't flickers for relative line numbers
* [VIM-2021](https://youtrack.jetbrains.com/issue/VIM-2021) Line numbers don't reactivating
* Fix mappings to `"\<SPACE>"` including `let mapleader="\<SPACE>"`
**Merged PRs:**
* [233](https://github.com/JetBrains/ideavim/pull/233) by [valis](https://github.com/valis): [VIM-1994] Correct paste after `y}P` command.
* [224](https://github.com/JetBrains/ideavim/pull/224) by [pmnoxx](https://github.com/pmnoxx): Populate intelij navigation history together with ideavim jumplist.
* [227](https://github.com/JetBrains/ideavim/pull/227) by [angelbot](https://github.com/angelbot): Add support for buffer command.
* [230](https://github.com/JetBrains/ideavim/pull/230) by [fan-tom](https://github.com/fan-tom): VIM-1924.
* [231](https://github.com/JetBrains/ideavim/pull/231) by [citizenmatt](https://github.com/citizenmatt): Support smooth scrolling.
* [239](https://github.com/JetBrains/ideavim/pull/239) by [citizenmatt](https://github.com/citizenmatt): Use new API for relative line numbers
0.57, 2020-04-28
-------------
**Fixes:**
* [VIM-1992](https://youtrack.jetbrains.com/issue/VIM-1992) Fix mappings to `<S-Letter>`
* [VIM-1991](https://youtrack.jetbrains.com/issue/VIM-1991) Fix working with number registers
**Merged PRs:**
* [234](https://github.com/JetBrains/ideavim/pull/234) by [runforprogram](https://github.com/runforprogram): [VIM-1991] fix >0 number register not work
0.56, 2020-04-09
--------------
**Features:**
* `ReplaceWithRegister` plugin emulation ([ReplaceWithRegister](https://www.vim.org/scripts/script.php?script_id=2703)).
* `argtextobj.vim` plugin emulation ([argtextobj.vim](https://vim.sourceforge.io/scripts/script.php?script_id=2699)).
* `vim-textobj-entire` plugin emulation ([vim-textobj-entire](https://github.com/kana/vim-textobj-entire)).
* [VIM-434](https://youtrack.jetbrains.com/issue/VIM-434) Add `'showcmd'` support, on by default.
* Support `ls/buffers/files` commands.
**Changes:**
* Replace `ideastatusbar` option with `ideastatusicon`. Now you can make the icon gray.
**Deprecations:**
* `ideastatusbar` option is deprecated now. See `ideastatusicon`.
**Fixes:**
* [VIM-1284](https://youtrack.jetbrains.com/issue/VIM-1284) Fix mapping of digits.
* Fix handling of counts on both operator and motion, e.g. `3d2w` deletes 6 words, instead of 32.
* Allow mapping of `<C-K>` and `<C-V>`/`<C-Q>`.
* [VIM-1899](https://youtrack.jetbrains.com/issue/VIM-1899) Add argument to `:registers` command.
* [VIM-1835](https://youtrack.jetbrains.com/issue/VIM-1835) Macros record input keystrokes instead of mapped keystrokes.
* [VIM-1900](https://youtrack.jetbrains.com/issue/VIM-1900) Ensure non-printable output for `:registers`, `:marks` and `:jumps` is encoded correctly.
* [VIM-570](https://youtrack.jetbrains.com/issue/VIM-570) Print non-ascii characters in ex panel.
* [VIM-926](https://youtrack.jetbrains.com/issue/VIM-926) Fix `<S-Space>` mapping.
* [VIM-1958](https://youtrack.jetbrains.com/issue/VIM-1958) Fix `X` command for linewise selection.
* [VIM-1911](https://youtrack.jetbrains.com/issue/VIM-1911) Lookup keys respect `IDE` handler.
* [VIM-1008](https://youtrack.jetbrains.com/issue/VIM-1008) Correct `ci{` behavior.
0.55, 2020-01-20
--------------

View File

@@ -1,112 +1,140 @@
<div>
<a href="https://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_TestsForIntelliJ20183&guest=1">
<img src="https://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_TestsForIntelliJ20183)/statusIcon.svg?guest=1"/>
</a>
<span>2018.3 Tests</span>
</div>
<div>
<a href="https://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_TestsForIntelliJ20191&guest=1">
<img src="https://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_TestsForIntelliJ20191)/statusIcon.svg?guest=1"/>
</a>
<span>2019.1 Tests</span>
</div>
<div>
<a href="https://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_TestsForIntelliJ20192&guest=1">
<img src="https://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_TestsForIntelliJ20192)/statusIcon.svg?guest=1"/>
</a>
<span>2019.2 Tests</span>
</div>
[![TeamCity Build][teamcity-build-status-svg]][teamcity-build-status]
IdeaVim is an open source project created by 60+ contributors. Would you like to make it even better? Thats wonderful!
### Where to Start
This page is created to help you start contributing. And who knows, maybe in a few days this project will be brighter than ever!
In order to contribute to IdeaVim, you should have some understanding of [Kotlin](https://kotlinlang.org/) or Java.
## Before you begin
See also these docs on the IntelliJ API:
- The project is written in Kotlin and Java. Choose whichever language you feel more comfortable with,
or maybe one that youd like to get to know better (why not start [learning Kotlin](https://kotlinlang.org/docs/tutorials/) right now?).
* [IntelliJ architectural overview](https://www.jetbrains.org/intellij/sdk/docs/platform/fundamentals.html)
* [IntelliJ plugin development resources](https://www.jetbrains.org/intellij/sdk/docs/welcome.html)
- If you come across some IntelliJ Platform code, these links may prove helpful:
You can start by:
* [IntelliJ architectural overview](https://www.jetbrains.org/intellij/sdk/docs/platform/fundamentals.html)
* [IntelliJ plugin development resources](https://www.jetbrains.org/intellij/sdk/docs/welcome.html)
- Picking relatively simple tasks that are tagged with
- Having any difficulties?
Join the brand new
[![Join the chat at https://gitter.im/JetBrains/ideavim](https://badges.gitter.im/JetBrains/ideavim.svg)](https://gitter.im/JetBrains/ideavim?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
for IdeaVim developers and contributors!
OK, ready to do some coding?
## Yes, I'm ready for some coding
* Fork the repository and clone it to the local machine.
* Open the project with IntelliJ IDEA.
Yoo hoo! Youre all set to begin contributing. Here are some useful gradle commands:
* `./gradlew runIde` — start the dev version of IntelliJ IDEA with IdeaVim installed.
* `./gradlew test` — run tests.
* `./gradlew buildPlugin` — build the plugin. The result will be located in `build/distributions`. This file can be
installed by using `Settings | Plugin | >Gear Icon< | Install Plugin from Disk...`. You can stay with your personal build
for a few days or send it to a friend for testing.
## Warmup
- Pick a few relatively simple tasks that are tagged with
[#patch_welcome](https://youtrack.jetbrains.com/issues/VIM?q=%23patch_welcome%20%23Unresolved%20sort%20by:%20votes%20)
in the issue tracker.
- Read about the `@VimBehaviorDiffers` annotation and fix the corresponding functionality.
in the issue tracker.
- Read the javadoc for the `@VimBehaviorDiffers` annotation in the source code and fix the corresponding functionality.
- Implement one of the requested [#vim plugin](https://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved%20tag:%20%7Bvim%20plugin%7D%20sort%20by:%20votes%20)s.
> :small_orange_diamond: Selected an issue to work on? Leave a comment in a YouTrack ticket or create a draft PR
> to indicate that you've started working on it so that you might get additional guidance and feedback from the maintainers.
## Where to start in the codebase
If you are looking for:
- Vim commands (`w`, `<C-O>`, `p`, etc.):
- Any particular command: `package-info.java`.
- How commands are executed in common: `EditorActionHandlerBase`.
- Key mapping: `KeyHandler.handleKey()`.
- Ex commands (`:set`, `:s`, `:nohlsearch`):
- Any particular ex command: package `com.maddyhome.idea.vim.ex.handler`.
- Ex command executor: `CommandHandler`.
- Extensions:
- Extensions handler: `VimExtensionHandler`.
- Available extensions: package `com/maddyhome/idea/vim/extension`.
- Common features:
- State machine. How every particular keystroke is parsed in IdeaVim: `KeyHandler.handleKey()`.
- Options (`incsearch`, `iskeyword`, `relativenumber`): `OptionsManager`.
- Plugin startup: `PluginStartup`.
- Notifications: `NotificationService`.
- Status bar icon: `StatusBar.kt`.
- On/off switch: `VimPlugin.setEnabled()`.
### Development Environment
## Testing
1. Fork IdeaVim on GitHub and clone the repository on your local machine.
Here are some guides for testing:
2. Import the project from the existing sources in IntelliJ IDEA 2018.1 or newer (Community or
Ultimate), by selecting "File | New | Project from Existing Sources..." or selecting "Import
Project" from the Welcome screen.
1. Read the javadoc for the `@VimBehaviorDiffers` annotation in the source code.
* In the project wizard, select "Import project from external model | Gradle".
2. Please avoid senseless text like "dhjkwaldjwa", "asdasdasd", "123 123 123 123", etc. Try to choose an example
text that is easy to read and understand what is wrong if the test fails. For example, take a few lines from your
favorite poem, or use Vladimir Nabokovs “A Discovery" if you don't have one.
* Select your Java 8+ JDK as the Gradle JVM; leave other parameters unchanged.
3. Don't forget to test your functionality with line start, line end, file start, file end, empty line, multiple
carets, dollar motion, etc.
##### Neovim
IdeaVim has an experimental integration with neovim in tests. Tests that are performed with `doTest` also executed in
neovim instance, and the state of IdeaVim is asserted to be the same as the state of neovim.
- Only tests that use `doTest` are checked with neovim.
- Tests with `@VimBehaviorDiffers` or `@TestWithoutNeovim` annotations don't use neovim.
3. Run your IdeaVim plugin within IntelliJ via a Gradle task:
#### Property-based tests
Property-based tests are located under `propertybased` package. These tests a flaky by nature
although in most cases they are stable. If the test fails on your TeamCity run, try to check the test output and understand
if the fail is caused by your changes. If it's not, just ignore the test.
* Select the "View | Tool Windows | Gradle" tool window.
* Launch "ideavim | intellij | runIde" from the tool window.
4. Run IdeaVim tests via a Gradle task:
## A common direction
* Select the "View | Tool Windows | Gradle" tool window.
* Launch "ideavim | verification | test" from the tool window.
Were trying to make IdeaVim close to the original Vim both in terms of functionality and architecture.
5. Build the plugin distribution by running `./gradlew clean buildPlugin` in the
terminal in your project root.
- Vim motions can be [either inclusive, exclusive, or linewise](http://vimdoc.sourceforge.net/htmldoc/motion.html#inclusive).
In IdeaVim, you can use `MotionType` for that.
- Have you read the [interesting things](https://github.com/JetBrains/ideavim#some-facts-about-vim) about IdeaVim?
Do you remember how `dd`, `yy`, and other similar commands work? `DuplicableOperatorAction` will help you with that.
And we also translate it to `d_` and `y_`: `KeyHandler.mapOpCommand()`.
- All IdeaVim extensions use the same command names as the originals (e.g. `<Plug>(CommentMotion)`, `<Plug>ReplaceWithRegisterLine`),
so you can reuse your `.vimrc` settings.
We also support proper command mappings (functions are mapped to `<Plug>...`), the operator function (`OperatorFunction`), and so on.
- Magic is supported as well. See `Magic`.
* The resulting distribution file will be located at build/distributions/IdeaVim-VERSION.zip
-----
* You can install this file by selecting "Settings | Plugins | Install plugin
from disk...".
### I read the whole page but something is still unclear.
### Copyright
Oh no! No cookies for the maintainers today! Please [tell us](https://github.com/JetBrains/ideavim#contact-maintainers) about it so we can help.
1. Go to `Preferences | Appearance & Behavior | Scopes`, press "+" button, `Shared`.
Name: Copyright scope
Pattern: `file[IdeaVIM.main]:com//*||file[IdeaVIM.test]:*/`
2. Go to `Preferences | Editor | Copyright | Copyright Profiles` and click the "+" button.
Name: IdeaVim
Text:
IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
Copyright (C) 2003-$today.year The IdeaVim authors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
3. Go to `Preferences | Editor | Copyright`, click the "+" button.
Scope: Copyright scope
Copyright: IdeaVim
### Testing
### Ive found a bug in this documentation.
1. Read about the `@VimBehaviorDiffers` annotation.
No beer in the bar for us unless it's fixed. [Let us know](https://github.com/JetBrains/ideavim#contact-maintainers) situation so we might be able to fix it.
2. Please avoid senseless text like "dhjkwaldjwa", "asdasdasd",
"123 123 123 123", etc. Try to choose an example text that is easy to
read and understand what is wrong if the test fails.
For example, take a few lines from your favorite poem, or use
"Vladimir Nabokov A Discovery" if you don't have one.
3. Test your functionality properly.
Especially check whether your command works with:
line start, line end, file start, file end, empty line, multiple carets, dollar motion, etc.
### The lack of documentation or a javadoc/ktdoc makes it difficult to start contributing.
This is just terrible. [You know what to do](https://github.com/JetBrains/ideavim#contact-maintainers).
### Resources:
* [Continuous integration builds](https://teamcity.jetbrains.com/project.html?projectId=IdeaVim&guest=1)
* [Bug tracker](https://youtrack.jetbrains.com/issues/VIM)
* [Chat on gitter](https://gitter.im/JetBrains/ideavim)
* [Unofficial discord server](https://jb.gg/bi6zp7)
* [Plugin homepage](https://plugins.jetbrains.com/plugin/164-ideavim)
* [Changelog](CHANGES.md)
* [Contributors listing](AUTHORS.md)
[teamcity-build-status]: https://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_TestsForIntelliJ20201&guest=1
[teamcity-build-status-svg]: https://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_TestsForIntelliJ20201)/statusIcon.svg?guest=1

300
README.md
View File

@@ -1,47 +1,49 @@
<img src="resources/META-INF/pluginIcon.svg" width="80" height="80" alt="icon" align="left"/>
<img src="resources/META-INF/pluginIcon.svg" width="80" height="80" alt="icon" align="left"/>
IdeaVim
===
<div>
<a href="https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub">
<img src="https://jb.gg/badges/official.svg" alt="official JetBrains project"/>
</a>
<a href="https://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaVim_TestsForIntelliJ20191&guest=1">
<img src="https://teamcity.jetbrains.com/app/rest/builds/buildType:(id:IdeaVim_TestsForIntelliJ20191)/statusIcon.svg?guest=1"/>
</a>
</div>
[![Official JetBrains Project][jb-official-svg]][jb-official]
[![Contributions welcome][contributions-welcome-svg]][contributions-welcome]
[![Downloads][plugin-downloads-svg]][plugin-repo]
[![Rating][plugin-rating-svg]][plugin-repo]
[![Version][plugin-version-svg]][plugin-repo]
[![Gitter][gitter-svg]][gitter]
[![Twitter][twitter-svg]][twitter]
IdeaVim is a Vim emulation plugin for IDEs based on the IntelliJ Platform.
IdeaVim can be used with IntelliJ IDEA, PyCharm, CLion, PhpStorm, WebStorm,
RubyMine, AppCode, DataGrip, GoLand, Rider, Cursive, and Android Studio.
Resources:
##### Contact maintainers:
* [Bug tracker](https://youtrack.jetbrains.com/issues/VIM)
* [@IdeaVim](https://twitter.com/ideavim) on Twitter
* [Chat on gitter](https://gitter.im/JetBrains/ideavim)
* [Unofficial discord server](https://jb.gg/bi6zp7)
##### Resources:
* [Plugin homepage](https://plugins.jetbrains.com/plugin/164-ideavim)
* [Changelog](CHANGES.md)
* [Bug tracker](https://youtrack.jetbrains.com/issues/VIM)
* [Continuous integration builds](https://teamcity.jetbrains.com/project.html?projectId=IdeaVim&guest=1)
* [@IdeaVim](https://twitter.com/ideavim) in Twitter
#### Compatibility
Installation
IntelliJ IDEA, PyCharm, CLion, PhpStorm, WebStorm, RubyMine, AppCode, DataGrip, GoLand, Rider, Cursive,
Android Studio and other IntelliJ platform based IDEs.
Setup
------------
Use the IDE's plugin manager to install the latest version of the plugin.
Start the IDE normally and enable the Vim emulation using "Tools | Vim
Emulator" menu item. At this point you must use Vim keystrokes in all editors.
- IdeaVim can be installed via `Settings | Plugins`.
See the [detailed instructions](https://www.jetbrains.com/help/idea/managing-plugins.html#).
If you wish to disable the plugin, select the "Tools | Vim Emulator" menu so
it is unchecked. At this point your IDE will work with its regular keyboard
shortcuts.
- Use `Tools | Vim Emulator` to enable or disable emulation.
Keyboard shortcut conflicts between the Vim emulation and the IDE can be
resolved via "File | Settings | Editor | Vim Emulation", "File | Settings |
Keymap" on Linux & Windows, and via "Preferences | Editor | Vim Emulation",
"Preferences | Keymap" on macOS. They can also be resolved by key-mapping
commands in your ~/.ideavimrc file.
- Use the `~/.ideavimrc` file as an analog of `~/.vimrc` ([learn more](#Files)). The XDG standard is supported, as well.
- Shortcut conflicts can be resolved by using:
- On Linux & Windows: `File | Settings | Editor | Vim Emulation` & `File | Settings | Keymap`,
- On macOS: `Preferences | Editor | Vim Emulation` & `Preferences | Keymap`,
- Regular Vim mappings in the `~/.ideavimrc` file.
Get Early Access
-------------------
@@ -49,7 +51,9 @@ Get Early Access
Would you like to try new features and fixes? Join the Early Access Program and
receive EAP builds as updates!
1. Click the IdeaVim icon in the status bar | `EAP` | `Get Early Access...`
1. Click the IdeaVim icon <img src="resources/META-INF/pluginIcon_noBorders.svg" width="16" height="16" alt="icon"/>
in the status bar | `EAP` | `Get Early Access...`
Or subscribe to EAP updates manually:
@@ -57,7 +61,7 @@ Or subscribe to EAP updates manually:
2. Click the gear icon :gear:, select `Manage Plugin Repositories`, and add the following url:
`https://plugins.jetbrains.com/plugins/eap/ideavim`
See [the changelog](CHANGES.md) for the list of hot unreleased features.
See [the changelog](CHANGES.md) for the list of unreleased features.
It is important to distinguish EAP builds from traditional pre-release software.
Please note that the quality of EAP versions may at times be way below even
@@ -71,104 +75,140 @@ You can always leave your feedback with:
Summary of Supported Vim Features
---------------------------------
Supported:
Here are some examples of supported vim features and commands:
* Motion keys
* Deletion/changing
* Insert mode commands
* Marks
* Registers
* Undo/redo
* Visual mode commands
* Some Ex commands
* Some [:set options](doc/set-commands.md)
* Full Vim regexps for search and search/replace
* Normal / insert / visual / select / etc. modes
* Motion / deletion / change / window / etc. commands
* Key mappings
* Macros
* Digraphs
* Command line and search history
* Window commands
* Marks / Macros / Digraphs / Registers
* Some [set commands](doc/set-commands.md)
* Full Vim regexps for search and search/replace
* Vim web help
* Select mode
* `~/.ideavimrc` configuration file
Emulated Vim plugins:
[Emulated Vim plugins](doc/emulated-plugins.md):
* vim-easymotion
* vim-surround
* vim-multiple-cursors
* vim-commentary
Not supported (yet):
* Jump lists
* Various less-used commands
* argtextobj.vim
* vim-textobj-entire
* ReplaceWithRegister
* vim-exchange
* vim-highlightedyank
See also:
* [The list of all supported commands](src/com/maddyhome/idea/vim/package-info.java)
* [Top features and bugs](https://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+sort+by%3A+votes)
* [Top feature requests and bugs](https://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+sort+by%3A+votes)
Files
-----
* ~/.ideavimrc
* `~/.ideavimrc`
* Your IdeaVim-specific Vim initialization commands
<details>
<summary><strong>Example</strong> (click to see)</summary>
You can read your ~/.vimrc file from ~/.ideavimrc with this command:
```vim
""" Map leader to space ---------------------
let mapleader=" "
""" Plugins --------------------------------
set surround
set multiple-cursors
set commentary
set argtextobj
set easymotion
set textobj-entire
set ReplaceWithRegister
""" Plugin settings -------------------------
let g:argtextobj_pairs="[:],(:),<:>"
""" Common settings -------------------------
set showmode
set so=5
set incsearch
set nu
""" Idea specific settings ------------------
set ideajoin
set ideastatusicon=gray
set idearefactormode=keep
""" Mappings --------------------------------
map <leader>f <Plug>(easymotion-s)
map <leader>e <Plug>(easymotion-f)
map <leader>d :action Debug<CR>
map <leader>r :action RenameElement<CR>
map <leader>c :action Stop<CR>
map <leader>z :action ToggleDistractionFreeMode<CR>
map <leader>s :action SelectInProjectView<CR>
map <leader>a :action Annotate<CR>
map <leader>h :action Vcs.ShowTabbedFileHistory<CR>
map <S-Space> :action GotoNextError<CR>
map <leader>b :action ToggleLineBreakpoint<CR>
map <leader>o :action FileStructurePopup<CR>
```
</details>
You can read your `~/.vimrc` file from `~/.ideavimrc` with this command:
source ~/.vimrc
Note, that IdeaVim currently parses ~/.ideavimrc file via simple pattern matching.
Please note that IdeaVim currently parses `~/.ideavimrc` & `~/.vimrc` files via simple pattern-matching.
See [VIM-669](https://youtrack.jetbrains.com/issue/VIM-669) for proper parsing
of VimL files.
Also note that if you have overridden the `user.home` JVM option, this
will affect where IdeaVim looks for your .ideavimrc file. For example, if you
will affect where IdeaVim looks for your `.ideavimrc` file. For example, if you
have `-Duser.home=/my/alternate/home` then IdeaVim will source
`/my/alternate/home/.ideavimrc` instead of `~/.ideavimrc`.
Alternatively, you can set up initialization commands using [XDG](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) standard.
Put your settings to `$XDG_CONFIG_HOME$/ideavim/ideavimrc` file.
Put your settings to `$XDG_CONFIG_HOME/ideavim/ideavimrc` file.
Emulated Vim Plugins
--------------------
IdeaVim extensions emulate some plugins of the original Vim. In order to use
IdeaVim extensions, you have to enable them via this command in your `~/.ideavimrc`:
set <extension-name>
Available extensions:
* easymotion
* Setup:
* Install [IdeaVim-EasyMotion](https://plugins.jetbrains.com/plugin/13360-ideavim-easymotion/)
and [AceJump](https://plugins.jetbrains.com/plugin/7086-acejump/) plugins.
* `set easymotion`
* Emulates [vim-easymotion](https://github.com/easymotion/vim-easymotion)
* Commands: All commands with the mappings are supported. See the [full list of supported commands](https://github.com/AlexPl292/IdeaVim-EasyMotion#supported-commands).
* surround
* Setup: `set surround`
* Emulates [vim-surround](https://github.com/tpope/vim-surround)
* Commands: `ys`, `cs`, `ds`, `S`
* multiple-cursors
* Setup: `set multiple-cursors`
* Emulates [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors)
* Commands: `<A-n>`, `<A-x>`, `<A-p>`, `g<A-n>`
* commentary
* Setup: `set commentary`
* Emulates [commentary.vim](https://github.com/tpope/vim-commentary)
* Commands: `gcc`, `gc + motion`, `v_gc`
See [doc/emulated-plugins.md](doc/emulated-plugins.md)
Changes to the IDE
------------------
### Executing IDE Actions
IdeaVim adds two commands for listing and executing arbitrary IDE actions as
Ex commands or via `:map` command mappings:
* `:actionlist [pattern]`
* Find IDE actions by name or keymap pattern (E.g. `:actionlist extract`, `:actionlist <C-D`)
* `:action {name}`
* Execute an action named `NAME`
Examples:
```vim
" Map \r to the Reformat Code action
:map \r :action ReformatCode<CR>
" Map <leader>d to start debug
:map <leader>d :action Debug<CR>
" Map \b to toggle the breakpoint on the current line
:map \b :action ToggleLineBreakpoint<CR>
```
### Undo/Redo
The IdeaVim plugin uses the undo/redo functionality of the IntelliJ Platform,
@@ -187,25 +227,12 @@ improvement.
See also [unresolved escape issues](https://youtrack.jetbrains.com/issues/VIM?q=%23Unresolved+Help+topic%3A+i_Esc).
### Executing IDE Actions
IdeaVim adds two commands for listing and executing arbitrary IDE actions as
Ex commands or via `:map` command mappings:
* `:actionlist [pattern]`
* Find IDE actions by name or keymap pattern (E.g. `:actionlist extract`, `:actionlist <C-D`)
* `:action {name}`
* Execute an action named `NAME`
For example, here `\r` is mapped to the Reformat Code action:
:map \r :action ReformatCode<CR>
Contributing
:gem: Contributing
------------
See [CONTRIBUTING.md](CONTRIBUTING.md)
The power of contributing drives IdeaVim :muscle:. Even small contributions matter!
See [CONTRIBUTING.md](CONTRIBUTING.md) to start bringing your value to the project.
Authors
-------
@@ -213,9 +240,76 @@ Authors
See [AUTHORS.md](AUTHORS.md)
for a list of authors and contributors.
IdeaVim tips and tricks
-------
- Use the power of IJ and Vim:
- `set ideajoin` to enable join via the IDE. See the [examples](https://jb.gg/f9zji9).
- Make sure `ideaput` is enabled for `clipboard` to enable native IJ insertion in Vim.
- Sync IJ bookmarks and Vim marks: `set ideamarks`
- Check out more [ex commands](doc/set-commands.md).
- Use your vim settings with IdeaVim. Put `source ~/.vimrc` in `~/.ideavimrc`.
> :warning: Please note that IdeaVim currently parses `~/.ideavimrc` & `~/.vimrc` files via simple pattern-matching.
See [VIM-669](https://youtrack.jetbrains.com/issue/VIM-669) for proper parsing
of VimL files.
- Control the status bar icon via the [`ideastatusicon` option](doc/set-commands.md).
- Not familiar with the default behaviour during a refactoring? See the [`idearefactormode` option](doc/set-commands.md).
Some facts about Vim
-------
Lets relax and have some fun now! Here are a few things we've found interesting during development
and would like to share with you.
- There are no such commands as `dd`, `yy`, or `cc`. For example, `dd` is not a separate command for deleting the line,
but a `d` command with a `d` motion.
Wait, but there isn't a `d` motion in Vim! Thats right, and thats why Vim has a dedicated set of commands
for which it checks whether the
[command equals to motion](https://github.com/vim/vim/blob/759d81549c1340185f0d92524c563bb37697ea88/src/normal.c#L6468)
and if so, it executes `_` motion instead.
`_` is an interesting motion that isn't even documented in vi, and it refers to the current line.
So, commands like `dd`, `yy`, and similar ones are simply translated to `d_`, `y_`, etc.
[Here](https://github.com/vim/vim/blob/759d81549c1340185f0d92524c563bb37697ea88/src/normal.c#L6502)
is the source of this knowledge.
- `x`, `D`, and `&` are not separate commands either. They are synonyms of `dl`, `d$`, and `:s\r`, respectively.
[Here](https://github.com/vim/vim/blob/759d81549c1340185f0d92524c563bb37697ea88/src/normal.c#L5365)
is the full list of synonyms.
- Have you ever used `U` after `dd`? [Don't even try](https://github.com/vim/vim/blob/759d81549c1340185f0d92524c563bb37697ea88/src/ops.c#L874).
- A lot of variables that refers to visual mode start with two uppercase letters, e.g. `VIsual_active`. [Some examples](https://github.com/vim/vim/blob/master/src/normal.c#L17).
- Other [strange things](https://github.com/vim/vim/blob/759d81549c1340185f0d92524c563bb37697ea88/src/ex_docmd.c#L1845) from vi:
* ":3" jumps to line 3
* ":3|..." prints line 3
* ":|" prints current line
- Vim script doesn't skip white space before comma. `F(a ,b)` => E475.
License
-------
IdeaVim is licensed under the terms of the GNU Public License version 2
or any later version.
<!-- Badges -->
[jb-official]: https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub
[jb-official-svg]: https://jb.gg/badges/official.svg
[plugin-repo]: https://plugins.jetbrains.com/plugin/164-ideavim
[plugin-downloads-svg]: http://img.shields.io/jetbrains/plugin/d/IdeaVIM
[plugin-rating-svg]: http://img.shields.io/jetbrains/plugin/r/rating/IdeaVIM
[plugin-version-svg]: https://img.shields.io/jetbrains/plugin/v/ideavim?label=version
[gitter-svg]: https://badges.gitter.im/JetBrains/ideavim.svg
[gitter]: https://gitter.im/JetBrains/ideavim?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[twitter]: https://twitter.com/ideavim
[twitter-svg]: https://img.shields.io/twitter/follow/ideavim?label=twitter%20%40ideavim
[contributions-welcome-svg]: http://img.shields.io/badge/contributions-welcome-brightgreen
[contributions-welcome]: https://github.com/JetBrains/ideavim/blob/master/CONTRIBUTING.md

View File

@@ -9,7 +9,7 @@ buildscript {
}
plugins {
id 'org.jetbrains.intellij' version '0.4.9'
id 'org.jetbrains.intellij' version '0.4.18'
}
apply plugin: 'java'
@@ -37,11 +37,7 @@ intellij {
downloadSources Boolean.valueOf(downloadIdeaSources)
instrumentCode Boolean.valueOf(instrumentPluginCode)
intellijRepo = "https://www.jetbrains.com/intellij-repository"
if (!Boolean.valueOf(legacyNoJavaPlugin)) {
// Since 192 version of IJ java plugin should be defined separately
// Set `legacyNoJavaPlugin` to true if you are going to run tests under idea version < 192
plugins = ['java']
}
plugins = ['java']
publishPlugin {
channels publishChannels.split(',')
@@ -56,7 +52,10 @@ repositories {
dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compileOnly "org.jetbrains:annotations:17.0.0"
compileOnly "org.jetbrains:annotations:19.0.0"
// https://mvnrepository.com/artifact/com.ensarsarajcic.neovim.java/neovim-api
compile group: 'com.ensarsarajcic.neovim.java', name: 'neovim-api', version: '0.1.16'
}
compileKotlin {
@@ -70,19 +69,65 @@ compileTestKotlin {
}
}
task testWithNeovim(type : Test) {
group = "verification"
systemProperty "ideavim.neovim.test", 'true'
}
tasks.register("slackEapNotification") {
doLast {
if (!slackUrl) return
def post = new URL(slackUrl).openConnection()
def message = "{\"text\":\"New EAP released: $version\"}"
def changeLog = extractChangelog()
changeLog = changeLog.replace("* ", "• ") // Replace stars with bullets
changeLog = changeLog.replace("**", "*") // Enable bold text
changeLog = changeLog.replaceAll("\\[([^]]+)]\\(([^)]+)\\)", '<$2|$1>') // Enable links
def message ="""
{
"text": "New version of IdeaVim",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "IdeaVim EAP $version has been released\\n$changeLog"
}
}
]
}
"""
post.setRequestMethod("POST")
post.setDoOutput(true)
post.setRequestProperty("Content-Type", "application/json")
post.getOutputStream().write(message.getBytes("UTF-8"))
def postRC = post.getResponseCode()
println(postRC)
if(postRC.equals(200)) {
if(postRC == 200) {
println(post.getInputStream().getText())
}
}
}
// Very primitive changelog extraction code
def extractChangelog() {
def startLine = "_Available since $version EAP:_"
def endLine = "_To Be Released..._"
def startSaving = false
def res = new StringBuilder()
new File("./CHANGES.md").eachLine { line ->
if (startSaving) {
if (line == endLine) {
startSaving = false
}
else {
res.append(line).append('\n')
}
}
else {
if (line == startLine) {
startSaving = true
}
}
}
return res.toString()
}

84
doc/emulated-plugins.md Normal file
View File

@@ -0,0 +1,84 @@
Emulated Vim Plugins
--------------------
IdeaVim extensions emulate plugins of the original Vim. In order to use
IdeaVim extensions, you have to enable them via this command in your `~/.ideavimrc`:
set <extension-name>
Available extensions:
## easymotion
* Setup:
* Install [IdeaVim-EasyMotion](https://plugins.jetbrains.com/plugin/13360-ideavim-easymotion/)
and [AceJump](https://plugins.jetbrains.com/plugin/7086-acejump/) plugins.
* `set easymotion`
* Emulates [vim-easymotion](https://github.com/easymotion/vim-easymotion)
* Commands: All commands with the mappings are supported. See the [full list of supported commands](https://github.com/AlexPl292/IdeaVim-EasyMotion#supported-commands).
## surround
* Setup: `set surround`
* Emulates [vim-surround](https://github.com/tpope/vim-surround)
* Commands: `ys`, `cs`, `ds`, `S`
## multiple-cursors
* Setup: `set multiple-cursors`
* Emulates [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors)
* Commands: `<A-n>`, `<A-x>`, `<A-p>`, `g<A-n>`
## commentary
* Setup: `set commentary`
* Emulates [commentary.vim](https://github.com/tpope/vim-commentary)
* Commands: `gcc`, `gc + motion`, `v_gc`
* By [Daniel Leong](https://github.com/dhleong)
## ReplaceWithRegister
* Setup: `set ReplaceWithRegister`
* Emulates [ReplaceWithRegister](https://github.com/vim-scripts/ReplaceWithRegister)
* Commands: `gr`, `grr`
* By [igrekster](https://github.com/igrekster)
## argtextobj
* Setup:
* `set argtextobj`
* By default, only the arguments inside parenthesis are considered. To extend the functionality
to other types of brackets, set `g:argtextobj_pairs` variable to a comma-separated
list of colon-separated pairs (same as VIM's `matchpairs` option), like
`let g:argtextobj_pairs="(:),{:},<:>"`. The order of pairs matters when
handling symbols that can also be operators: `func(x << 5, 20) >> 17`. To handle
this syntax parenthesis, must come before angle brackets in the list.
* Emulates [argtextobj.vim](https://www.vim.org/scripts/script.php?script_id=2699)
* Additional text objects: `aa`, `ia`
## exchange
* Setup: `set exchange`
* Emulates [vim-exchange](https://github.com/tommcdo/vim-exchange)
* Commands: `cx`, `cxx`, `X`, `cxc`
* By [fan-tom](https://github.com/fan-tom)
## textobj-entire
* Setup: `set textobj-entire`
* Emulates [vim-textobj-entire](https://github.com/kana/vim-textobj-entire)
* Additional text objects: `ae`, `ie`
* By [Alexandre Grison](https://github.com/agrison)
## highlightedyank
* Setup:
* `set highlightedyank`
* if you want to optimize highlight duration, assign a time in milliseconds:
`let g:highlightedyank_highlight_duration = "1000"`
A negative number makes the highlight persistent.
`let g:highlightedyank_highlight_duration = "-1"`
* if you want to change background color of highlight you can provide the rgba of the color you want e.g.
`let g:highlightedyank_highlight_color = "rgba(160, 160, 160, 155)"`
* Emulates [vim-highlightedyank](https://github.com/machakann/vim-highlightedyank)
* By [KostkaBrukowa](https://github.com/KostkaBrukowa)

View File

@@ -38,6 +38,7 @@ The following `:set` commands can appear in `~/.ideavimrc` or be set manually in
acts like startsel is enabled
'matchpairs' 'mps' pairs of characters that "%" can match
'more' 'more' When on, listings pause when the whole screen is filled.
'nrformats' 'nf' number formats recognized for CTRL-A command
'number' 'nu' print the line number in front of each line
'relativenumber' 'rnu' show the line number relative to the line with
@@ -65,6 +66,7 @@ The following `:set` commands can appear in `~/.ideavimrc` or be set manually in
same as ideaselection - IdeaVim ONLY
'showmode' 'smd' message on the status line to show current mode
'showcmd' 'sc' show (partial) command in the status bar
'sidescroll' 'ss' minimum number of columns to scroll horizontally
'sidescrolloff' 'siso' min. number of columns to left and right of cursor
'smartcase' 'scs' no ignore case when pattern is uppercase
@@ -104,10 +106,27 @@ The following `:set` commands can appear in `~/.ideavimrc` or be set manually in
See wiki/`ideajoin` examples
`ideastatusbar` `ideastatusbar` Boolean (default true)
DEPRECATED. Please use `ideastatusicon`
If false, IdeaVim icon won't be shown in the status bar.
Works only from `~/.ideavimrc` after the IDE restart.
`ideastatusicon` `ideastatusicon` String(default "enabled")
Define the behavior of IdeaVim icon in the status bar.
Use one of the following values:
- enabled - icon is shown in the status bar
- gray - use the gray version of the icon
- disabled - hide the icon
`ideawrite` `ideawrite` String (default "all") [To Be Released]
"file" or "all". Defines the behaviour of ":w" command.
Value "all" enables execution of ":wa" (save all) command on ":w" (save).
This feature exists because some IJ options like "Prettier on save" or "ESlint on save"
work only with "save all" action. If this option is set to "all", these actions work
also with ":w" command.
`lookupkeys` `lookupkeys` List of strings
List of keys that should be processed by the IDE during the active lookup (autocompletion).

View File

@@ -1,16 +1,13 @@
# suppress inspection "UnusedProperty" for whole file
ideaVersion=201-EAP-SNAPSHOT
ideaVersion=LATEST-EAP-SNAPSHOT
downloadIdeaSources=true
instrumentPluginCode=true
version=SNAPSHOT
javaVersion=1.8
kotlinVersion=1.3.61
javaVersion=11
kotlinVersion=1.3.71
publishUsername=username
publishToken=token
publishChannels=eap
# Since 192 version of IJ java plugin should be defined separately
# Set this value to true if you are going to run tests under idea version < 192
legacyNoJavaPlugin=false
slackUrl=

Binary file not shown.

View File

@@ -1,5 +1,5 @@
#Fri Nov 22 14:42:01 MSK 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
#Thu Jun 25 19:36:41 MSK 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists

51
gradlew vendored
View File

@@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -138,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -159,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

21
gradlew.bat vendored
View File

@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@@ -150,6 +150,8 @@
<vimAction implementation="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollLastScreenColumnAction" mappingModes="NXO" keys="ze"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnLeftAction" mappingModes="NXO" keys="zl,z«Right»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnRightAction" mappingModes="NXO" keys="zh,z«Left»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollHalfWidthLeftAction" mappingModes="NXO" keys="zL"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.scroll.MotionScrollHalfWidthRightAction" mappingModes="NXO" keys="zH"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.updown.MotionShiftDownAction" mappingModes="NV" keys="«S-Down»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.updown.MotionShiftUpAction" mappingModes="NV" keys="«S-Up»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.motion.leftright.MotionShiftRightAction" mappingModes="NV" keys="«S-Right»"/>
@@ -197,8 +199,8 @@
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.InsertSingleCommandAction" mappingModes="I" keys="«C-O»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.VisualBlockInsertAction" mappingModes="X" keys="I"/>
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.VisualBlockAppendAction" mappingModes="X" keys="A"/>
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.StartInsertDigraphAction" mappingModes="IC" keys="«C-K»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.StartInsertLiteralAction" mappingModes="IC" keys="«C-V»,«C-Q»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.InsertCompletedDigraphAction" mappingModes="IC" keys="«C-K»"/>
<vimAction implementation="com.maddyhome.idea.vim.action.change.insert.InsertCompletedLiteralAction" mappingModes="IC" keys="«C-V»,«C-Q»"/>
<!-- Delete -->
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteCharacterAction" mappingModes="N" keys="«DEL»"/>
@@ -260,14 +262,16 @@
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutTextBeforeCursorNoIndentAction" mappingModes="N" keys="[P,]P,[p"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutTextAfterCursorActionMoveCursor" mappingModes="N" keys="gp"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutTextBeforeCursorActionMoveCursor" mappingModes="N" keys="gP"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.SelectRegisterAction" mappingModes="NXO" keys='"'/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankLineAction" mappingModes="N" keys="Y"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankMotionAction" mappingModes="N" keys="y"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankVisualAction" mappingModes="X" keys="y"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankVisualLinesAction" mappingModes="X" keys="Y"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextAction" mappingModes="X" keys="p,P"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextNoIndentAction" mappingModes="X" keys="[p,]p,]P,[P"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextMoveCursorAction" mappingModes="X" keys="gp,gP"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextBeforeCursorAction" mappingModes="X" keys="P"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextAfterCursorAction" mappingModes="X" keys="p"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextBeforeCursorNoIndentAction" mappingModes="X" keys="]P,[P"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextAfterCursorNoIndentAction" mappingModes="X" keys="[p,]p"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextBeforeCursorMoveCursorAction" mappingModes="X" keys="gP"/>
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutVisualTextAfterCursorMoveCursorAction" mappingModes="X" keys="gp"/>
<!-- File -->
<vimAction implementation="com.maddyhome.idea.vim.action.file.FileSaveCloseAction" mappingModes="N" keys="ZQ,ZZ"/>

View File

@@ -15,6 +15,7 @@
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.ActionHandler" names="action"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.EchoHandler" names="ec[ho]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.ExitHandler" names="qa[ll],quita[ll],wqa[ll],xa[ll]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.FileHandler" names="f[ile]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.FindClassHandler" names="cla[ss]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.FindFileHandler" names="fin[d]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.FindSymbolHandler" names="sym[bol]"/>
@@ -60,5 +61,8 @@
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.NextTabHandler" names="tabn[ext]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.PreviousTabHandler" names="tabp[revious],tabN[ext]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.TabOnlyHandler" names="tabo[nly]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.TabCloseHandler" names="tabc[lose]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.BufferListHandler" names="buffers,ls,files"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.BufferHandler" names="b[uffer]"/>
</extensions>
</idea-plugin>

View File

@@ -3,5 +3,10 @@
<vimExtension implementation="com.maddyhome.idea.vim.extension.surround.VimSurroundExtension"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.multiplecursors.VimMultipleCursorsExtension"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.commentary.CommentaryExtension"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.textobjentire.VimTextObjEntireExtension"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.argtextobj.VimArgTextObjExtension"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.replacewithregister.ReplaceWithRegister"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.exchange.VimExchangeExtension"/>
<vimExtension implementation="com.maddyhome.idea.vim.extension.highlightedyank.VimHighlightedYank"/>
</extensions>
</idea-plugin>

View File

@@ -0,0 +1,25 @@
<idea-plugin>
<applicationListeners>
<listener class="com.maddyhome.idea.vim.ui.ExEntryPanel$LafListener"
topic="com.intellij.ide.ui.LafManagerListener"/>
</applicationListeners>
<projectListeners>
<listener class="com.maddyhome.idea.vim.ui.ExOutputPanel$LafListener"
topic="com.intellij.ide.ui.LafManagerListener"/>
<listener class="com.maddyhome.idea.vim.listener.VimListenerManager$VimFileEditorManagerListener"
topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
<listener class="com.maddyhome.idea.vim.listener.IdeaSpecifics$VimActionListener"
topic="com.intellij.openapi.actionSystem.ex.AnActionListener"/>
<listener class="com.maddyhome.idea.vim.listener.IdeaSpecifics$VimTemplateManagerListener"
topic="com.intellij.codeInsight.template.TemplateManagerListener"/>
<listener class="com.maddyhome.idea.vim.group.MarkGroup$MarkListener"
topic="com.intellij.ide.bookmarks.BookmarksListener"/>
<listener class="com.maddyhome.idea.vim.listener.IdeaSpecifics$VimFindModelListener"
topic="com.intellij.find.FindModelListener"/>
</projectListeners>
</idea-plugin>

View File

@@ -3,10 +3,8 @@
<id>IdeaVIM</id>
<change-notes><![CDATA[
<ul>
<li>Support dot command for Surround and Commentary extensions</li>
<li>Support XDG settings standard</li>
<li>Add option to remove the status bar icon</li>
<li>Various bug fixes</li>
<li>Support of `virtualedit=onemore`</li>
<li>A lot of fixes for scrolling</li>
</ul>
<p>See also the complete <a href="https://github.com/JetBrains/ideavim/blob/master/CHANGES.md">changelog</a>.</p>
]]></change-notes>
@@ -24,7 +22,7 @@
<!-- Please search for "[VERSION UPDATE]" in project in case you update the since-build version -->
<!-- Check for [Version Update] tag in YouTrack as well -->
<idea-version since-build="183.4284.148"/>
<idea-version since-build="201.5985.32"/>
<!-- Mark the plugin as compatible with RubyMine and other products based on the IntelliJ platform -->
<depends>com.intellij.modules.lang</depends>
@@ -34,25 +32,16 @@
<component>
<implementation-class>com.maddyhome.idea.vim.DynamicLoaderStopper</implementation-class>
</component>
<component>
<implementation-class>com.maddyhome.idea.vim.VimPlugin</implementation-class>
</component>
<component>
<implementation-class>com.maddyhome.idea.vim.VimLocalConfig</implementation-class>
</component>
</application-components>
<project-components>
<component>
<implementation-class>com.maddyhome.idea.vim.VimProjectComponent</implementation-class>
</component>
</project-components>
<extensionPoints>
<extensionPoint name="vimExtension" interface="com.maddyhome.idea.vim.extension.VimExtension"/>
<extensionPoint name="vimExtension" interface="com.maddyhome.idea.vim.extension.VimExtension" dynamic="true"/>
<!-- For internal use only -->
<extensionPoint name="vimExCommand" beanClass="com.maddyhome.idea.vim.ex.ExBeanClass" dynamic="true">
<with attribute="implementation" implements="com.maddyhome.idea.vim.ex.CommandHandler"/>
</extensionPoint>
<!-- For internal use only -->
<extensionPoint name="vimAction" beanClass="com.maddyhome.idea.vim.handler.ActionBeanClass" dynamic="true">
<with attribute="implementation" implements="com.maddyhome.idea.vim.handler.EditorActionHandlerBase"/>
</extensionPoint>
@@ -61,24 +50,54 @@
<extensions defaultExtensionNs="com.intellij">
<applicationConfigurable groupId="editor" instance="com.maddyhome.idea.vim.ui.VimEmulationConfigurable"/>
<projectService serviceImplementation="com.maddyhome.idea.vim.group.NotificationService"/>
<statusBarWidgetProvider implementation="com.maddyhome.idea.vim.StatusBarIconProvider"/>
<statusBarWidgetFactory implementation="com.maddyhome.idea.vim.ui.StatusBarIconFactory"/>
<statusBarWidgetFactory implementation="com.maddyhome.idea.vim.ui.ShowCmdStatusBarWidgetFactory" order="first"/>
<applicationService serviceImplementation="com.maddyhome.idea.vim.config.VimLocalConfig"/>
<applicationService serviceImplementation="com.maddyhome.idea.vim.VimPlugin"/>
<!-- Initialise as early as possible so that we're ready to edit quickly. This is especially important for Rider,
which (at least for 2020.1) has some long running activities that block other startup extensions. None of the
core platform activities have IDs, so we can't use "before ID". We have to use "first" -->
<postStartupActivity implementation="com.maddyhome.idea.vim.PluginStartup" order="first"/>
<editorFloatingToolbarProvider implementation="com.maddyhome.idea.vim.ui.ReloadFloatingToolbar"/>
</extensions>
<xi:include href="/META-INF/includes/ApplicationServices.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/includes/VimActions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/includes/VimExCommands.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/includes/VimExtensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/includes/VimListeners.xml" xpointer="xpointer(/idea-plugin/*)"/>
<actions>
<action id="VimPluginToggle" class="com.maddyhome.idea.vim.action.VimPluginToggleAction" text="Vim Emulator" description="Toggle the vim plugin On/off">
<action id="VimPluginToggle" class="com.maddyhome.idea.vim.action.VimPluginToggleAction">
<add-to-group group-id="ToolsMenu" anchor="last"/>
</action>
<!-- Internal -->
<action id="VimInternalAddInlays" class="com.maddyhome.idea.vim.action.internal.AddInlaysAction" text="Add Test Inlays | IdeaVim Internal" internal="true"/>
<action id="VimInternalAddBlockInlays" class="com.maddyhome.idea.vim.action.internal.AddBlockInlaysAction" text="Add Test Block Inlays | IdeaVim Internal" internal="true"/>
<action id="VimInternalAddInlineInlays" class="com.maddyhome.idea.vim.action.internal.AddInlineInlaysAction" text="Add Test Inline Inlays | IdeaVim Internal" internal="true"/>
<action id="VimShortcutKeyAction" class="com.maddyhome.idea.vim.action.VimShortcutKeyAction" text="Shortcuts"/>
<action id="VimActions" class="com.maddyhome.idea.vim.VimActions" text="Vim Actions"/>
<action id="VimShortcutKeyAction" class="com.maddyhome.idea.vim.action.VimShortcutKeyAction"/>
<action id="VimActions" class="com.maddyhome.idea.vim.ui.VimActions"/>
<!-- [Version Update] 202+ use-shortcut-of="ExternalSystem.ProjectRefreshAction" -->
<group id="IdeaVim.ReloadVimRc.group" class="com.maddyhome.idea.vim.ui.ReloadFloatingToolbarActionGroup">
<action id="IdeaVim.ReloadVimRc.reload" class="com.maddyhome.idea.vim.ui.ReloadVimRc">
<keyboard-shortcut first-keystroke="control shift O" keymap="$default"/>
<keyboard-shortcut first-keystroke="control shift O" keymap="Eclipse" remove="true"/>
<keyboard-shortcut first-keystroke="control shift O" keymap="NetBeans 6.5" remove="true"/>
<keyboard-shortcut first-keystroke="control shift O" keymap="Visual Studio" remove="true"/>
<keyboard-shortcut first-keystroke="meta shift O" keymap="Mac OS X" replace-all="true"/>
<keyboard-shortcut first-keystroke="meta shift O" keymap="Eclipse (Mac OS X)" replace-all="true" remove="true"/>
<keyboard-shortcut first-keystroke="meta shift O" keymap="Xcode" replace-all="true" remove="true"/>
<keyboard-shortcut first-keystroke="meta shift I" keymap="Mac OS X 10.5+" replace-all="true"/>
</action>
</group>
<action id="VimFindActionIdAction"
class="com.maddyhome.idea.vim.listener.FindActionIdAction" text="IdeaVim: Track Action Ids"
description="Starts tracking ids of executed actions"/>
</actions>
</idea-plugin>

View File

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<defs>
<linearGradient id="ideavim_plugin-a" x1="-6.748%" x2="47.286%" y1="33.61%" y2="85.907%">
<stop offset="0%" stop-color="#3BEA62"/>
<stop offset="100%" stop-color="#087CFA"/>
</linearGradient>
</defs>
<polygon fill="url(#ideavim_plugin-a)" fill-rule="evenodd" points="29.019 0 13.988 26.119 13.988 0 0 0 0 40 16.953 40 40 0"/>
</svg>

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

View File

@@ -70,3 +70,10 @@ unkopt=Unknown option: {0}
e_invarg=Invalid argument: {0}
E475=E475: Invalid argument: {0}
E774=E774: 'operatorfunc' is empty
action.VimPluginToggle.text=Vim Emulator
description.VimPluginToggle.description=Toggle the vim plugin On/off
action.VimShortcutKeyAction.text=Shortcuts
action.VimActions.text=Vim Actions

View File

@@ -19,15 +19,9 @@
package com.maddyhome.idea.vim;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.TemplateManagerListener;
import com.intellij.find.FindManager;
import com.intellij.find.FindModelListener;
import com.intellij.ide.bookmarks.BookmarksListener;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.ex.AnActionListener;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
@@ -35,10 +29,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,23 +37,19 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Map;
/**
* @author vlan
*/
public class EventFacade {
@NotNull private static final EventFacade ourInstance = new EventFacade();
private static final @NotNull EventFacade ourInstance = new EventFacade();
@Nullable private TypedActionHandler myOriginalTypedActionHandler;
private Map<Project, MessageBusConnection> connections = new HashMap<>();
private @Nullable TypedActionHandler myOriginalTypedActionHandler;
private EventFacade() {
}
@NotNull
public static EventFacade getInstance() {
public static @NotNull EventFacade getInstance() {
return ourInstance;
}
@@ -89,35 +76,10 @@ public class EventFacade {
action.registerCustomShortcutSet(shortcutSet, component, disposable);
}
public void unregisterCustomShortcutSet(@NotNull AnAction action, @Nullable JComponent component) {
public void unregisterCustomShortcutSet(@NotNull AnAction action, @NotNull JComponent component) {
action.unregisterCustomShortcutSet(component);
}
public void connectFileEditorManagerListener(@NotNull Project project, @NotNull FileEditorManagerListener listener) {
final MessageBusConnection connection = getConnection(project);
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
}
public void connectAnActionListener(@NotNull Project project, @NotNull AnActionListener listener) {
final MessageBusConnection connection = getConnection(project);
connection.subscribe(AnActionListener.TOPIC, listener);
}
public void connectTemplateStartedListener(@NotNull Project project, @NotNull TemplateManagerListener listener) {
final MessageBusConnection connection = getConnection(project);
connection.subscribe(TemplateManager.TEMPLATE_STARTED_TOPIC, listener);
}
public void connectBookmarkListener(@NotNull Project project, @NotNull BookmarksListener bookmarksListener) {
final MessageBusConnection connection = getConnection(project);
connection.subscribe(BookmarksListener.TOPIC, bookmarksListener);
}
public void connectFindModelListener(@NotNull Project project, @NotNull FindModelListener findModelListener) {
final MessageBusConnection connection = getConnection(project);
connection.subscribe(FindManager.FIND_MODEL_TOPIC, findModelListener);
}
public void addDocumentListener(@NotNull Document document, @NotNull DocumentListener listener) {
document.addDocumentListener(listener);
}
@@ -169,32 +131,15 @@ public class EventFacade {
}
public void registerLookupListener(@NotNull Project project, @NotNull PropertyChangeListener propertyChangeListener) {
LookupManager.getInstance(project).addPropertyChangeListener(propertyChangeListener, project);
VimProjectService parentDisposable = VimProjectService.getInstance(project);
LookupManager.getInstance(project).addPropertyChangeListener(propertyChangeListener, parentDisposable);
}
public void removeLookupListener(@NotNull Project project, @NotNull PropertyChangeListener propertyChangeListener) {
LookupManager.getInstance(project).removePropertyChangeListener(propertyChangeListener);
}
public void disableBusConnection() {
connections.values().forEach(MessageBusConnection::disconnect);
connections.clear();
}
private MessageBusConnection getConnection(Project project) {
if (!connections.containsKey(project)) {
final MessageBusConnection connection = project.getMessageBus().connect();
connections.put(project, connection);
Disposer.register(project, () -> {
connection.disconnect();
connections.remove(project);
});
}
return connections.get(project);
}
@NotNull
private TypedAction getTypedAction() {
private @NotNull TypedAction getTypedAction() {
return EditorActionManager.getInstance().getTypedAction();
}
}

View File

@@ -35,6 +35,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.maddyhome.idea.vim.action.change.VimRepeater;
import com.maddyhome.idea.vim.action.change.insert.InsertCompletedDigraphAction;
import com.maddyhome.idea.vim.action.change.insert.InsertCompletedLiteralAction;
import com.maddyhome.idea.vim.action.macro.ToggleRecordingAction;
import com.maddyhome.idea.vim.command.*;
import com.maddyhome.idea.vim.extension.VimExtensionHandler;
@@ -48,6 +50,7 @@ import com.maddyhome.idea.vim.key.*;
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor;
import com.maddyhome.idea.vim.listener.VimListenerSuppressor;
import com.maddyhome.idea.vim.option.OptionsManager;
import com.maddyhome.idea.vim.ui.ShowCmd;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -56,8 +59,10 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -74,8 +79,7 @@ public class KeyHandler {
*
* @return A reference to the singleton
*/
@NotNull
public static KeyHandler getInstance() {
public static @NotNull KeyHandler getInstance() {
if (instance == null) {
instance = new KeyHandler();
}
@@ -154,16 +158,6 @@ public class KeyHandler {
return false;
}
public void startDigraphSequence(@NotNull Editor editor) {
final CommandState editorState = CommandState.getInstance(editor);
editorState.startDigraphSequence();
}
public void startLiteralSequence(@NotNull Editor editor) {
final CommandState editorState = CommandState.getInstance(editor);
editorState.startLiteralSequence();
}
/**
* This is the main key handler for the Vim plugin. Every keystroke not handled directly by Idea is sent here for
* processing.
@@ -220,7 +214,7 @@ public class KeyHandler {
try {
if (!allowKeyMappings || !handleKeyMapping(editor, key, context)) {
if (isCommandCountKey(chKey, editorState)) {
commandBuilder.addCountCharacter(chKey);
commandBuilder.addCountCharacter(key);
} else if (isDeleteCommandCountKey(key, editorState)) {
commandBuilder.deleteCountCharacter();
} else if (isEditorReset(key, editorState)) {
@@ -231,21 +225,29 @@ public class KeyHandler {
else if (isExpectingCharArgument(commandBuilder)) {
handleCharArgument(key, chKey, editorState);
}
else if (editorState.getSubMode() == CommandState.SubMode.REGISTER_PENDING) {
commandBuilder.addKey(key);
handleSelectRegister(editorState, chKey);
}
// If we are this far, then the user must be entering a command or a non-single-character argument
// to an entered command. Let's figure out which it is.
else if (!handleDigraph(editor, key, context, editorState)) {
commandBuilder.addKey(key);
// Ask the key/action tree if this is an appropriate key at this point in the command and if so,
// return the node matching this keystroke
final Node node = mapOpCommand(key, commandBuilder.getChildNode(key), editorState);
if (node instanceof CommandNode) {
handleCommandNode(editor, context, key, (CommandNode) node, editorState);
commandBuilder.addKey(key);
} else if (node instanceof CommandPartNode) {
commandBuilder.setCurrentCommandPartNode((CommandPartNode) node);
} else {
commandBuilder.addKey(key);
} else if (isSelectRegister(key, editorState)) {
editorState.pushModes(CommandState.Mode.COMMAND, CommandState.SubMode.REGISTER_PENDING);
commandBuilder.addKey(key);
}
else { // node == null
// If we are in insert/replace mode send this key in for processing
if (editorState.getMode() == CommandState.Mode.INSERT || editorState.getMode() == CommandState.Mode.REPLACE) {
shouldRecord &= VimPlugin.getChange().processKey(editor, context, key);
@@ -270,10 +272,11 @@ public class KeyHandler {
// Do we have a fully entered command at this point? If so, let's execute it.
if (commandBuilder.isReady()) {
executeCommand(editor, key, context, editorState);
executeCommand(editor, context, editorState);
}
else if (commandBuilder.isBad()) {
editorState.resetOpPending();
editorState.resetRegisterPending();
VimPlugin.indicateError();
reset(editor);
}
@@ -282,6 +285,9 @@ public class KeyHandler {
if (shouldRecord && editorState.isRecording()) {
VimPlugin.getRegister().recordKeyStroke(key);
}
// This will update immediately, if we're on the EDT (which we are)
ShowCmd.INSTANCE.update();
}
/**
@@ -306,7 +312,7 @@ public class KeyHandler {
return true;
}
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, @NotNull final DataContext context, @NotNull CommandState editorState) {
private void handleEditorReset(@NotNull Editor editor, @NotNull KeyStroke key, final @NotNull DataContext context, @NotNull CommandState editorState) {
if (editorState.getCommandBuilder().isAtDefaultState()) {
RegisterGroup register = VimPlugin.getRegister();
if (register.getCurrentRegister() == register.getDefaultRegister()) {
@@ -321,9 +327,9 @@ public class KeyHandler {
ChangeGroup.resetCaret(editor, false);
}
private boolean handleKeyMapping(@NotNull final Editor editor,
@NotNull final KeyStroke key,
@NotNull final DataContext context) {
private boolean handleKeyMapping(final @NotNull Editor editor,
final @NotNull KeyStroke key,
final @NotNull DataContext context) {
final CommandState commandState = CommandState.getInstance(editor);
final MappingState mappingState = commandState.getMappingState();
@@ -331,7 +337,8 @@ public class KeyHandler {
if (commandBuilder.isAwaitingCharOrDigraphArgument()
|| commandBuilder.isBuildingMultiKeyCommand()
|| isMappingDisabledForKey(key, commandState)) {
|| isMappingDisabledForKey(key, commandState)
|| commandState.getSubMode() == CommandState.SubMode.REGISTER_PENDING) {
return false;
}
@@ -430,10 +437,8 @@ public class KeyHandler {
final EditorDataContext currentContext = new EditorDataContext(editor);
final List<KeyStroke> toKeys = mappingInfo.getToKeys();
final VimExtensionHandler extensionHandler = mappingInfo.getExtensionHandler();
if (toKeys != null) {
if (mappingInfo instanceof ToKeysMappingInfo) {
final List<KeyStroke> toKeys = ((ToKeysMappingInfo)mappingInfo).getToKeys();
final boolean fromIsPrefix = isPrefix(mappingInfo.getFromKeys(), toKeys);
boolean first = true;
for (KeyStroke keyStroke : toKeys) {
@@ -442,7 +447,8 @@ public class KeyHandler {
first = false;
}
}
else if (extensionHandler != null) {
else if (mappingInfo instanceof ToHandlerMappingInfo) {
final VimExtensionHandler extensionHandler = ((ToHandlerMappingInfo)mappingInfo).getExtensionHandler();
final CommandProcessor processor = CommandProcessor.getInstance();
// Cache isOperatorPending in case the extension changes the mode while moving the caret
@@ -555,22 +561,59 @@ public class KeyHandler {
return true;
}
@SuppressWarnings("RedundantIfStatement")
private boolean isCommandCountKey(char chKey, @NotNull CommandState editorState) {
// Make sure to avoid handling '0' as the start of a count.
final CommandBuilder commandBuilder = editorState.getCommandBuilder();
return (editorState.getMode() == CommandState.Mode.COMMAND || editorState.getMode() == CommandState.Mode.VISUAL)
&& commandBuilder.isExpectingCount() && Character.isDigit(chKey) && (commandBuilder.getCount() > 0 || chKey != '0');
boolean notRegisterPendingCommand = editorState.getMode() == CommandState.Mode.COMMAND &&
editorState.getSubMode() != CommandState.SubMode.REGISTER_PENDING;
boolean visualMode = editorState.getMode() == CommandState.Mode.VISUAL;
boolean opPendingMode = editorState.getMode() == CommandState.Mode.OP_PENDING;
if (notRegisterPendingCommand || visualMode || opPendingMode) {
if (commandBuilder.isExpectingCount() &&
Character.isDigit(chKey) &&
(commandBuilder.getCount() > 0 || chKey != '0')) {
return true;
}
}
return false;
}
private boolean isDeleteCommandCountKey(@NotNull KeyStroke key, @NotNull CommandState editorState) {
// See `:help N<Del>`
final CommandBuilder commandBuilder = editorState.getCommandBuilder();
return (editorState.getMode() == CommandState.Mode.COMMAND || editorState.getMode() == CommandState.Mode.VISUAL)
&& commandBuilder.isExpectingCount() && commandBuilder.getCount() > 0 && key.getKeyCode() == KeyEvent.VK_DELETE;
return (editorState.getMode() == CommandState.Mode.COMMAND ||
editorState.getMode() == CommandState.Mode.VISUAL ||
editorState.getMode() == CommandState.Mode.OP_PENDING) &&
commandBuilder.isExpectingCount() &&
commandBuilder.getCount() > 0 &&
key.getKeyCode() == KeyEvent.VK_DELETE;
}
private boolean isEditorReset(@NotNull KeyStroke key, @NotNull CommandState editorState) {
return (editorState.getMode() == CommandState.Mode.COMMAND) && StringHelper.isCloseKeyStroke(key);
return editorState.getMode() == CommandState.Mode.COMMAND && StringHelper.isCloseKeyStroke(key);
}
private boolean isSelectRegister(@NotNull KeyStroke key, @NotNull CommandState editorState) {
if (editorState.getMode() != CommandState.Mode.COMMAND && editorState.getMode() != CommandState.Mode.VISUAL) {
return false;
}
if (editorState.getSubMode() == CommandState.SubMode.REGISTER_PENDING) {
return true;
}
return key.getKeyChar() == '"' && !editorState.isOperatorPending() && editorState.getCommandBuilder().getExpectedArgumentType() == null;
}
private void handleSelectRegister(@NotNull CommandState commandState, char chKey) {
commandState.resetRegisterPending();
if (VimPlugin.getRegister().isValid(chKey)) {
commandState.getCommandBuilder().pushCommandPart(chKey);
}
else {
commandState.getCommandBuilder().setCommandState(CurrentCommandState.BAD_COMMAND);
}
}
private boolean isExpectingCharArgument(@NotNull CommandBuilder commandBuilder) {
@@ -615,10 +658,12 @@ public class KeyHandler {
if (commandBuilder.getExpectedArgumentType() == Argument.Type.DIGRAPH) {
if (DigraphSequence.isDigraphStart(key)) {
editorState.startDigraphSequence();
editorState.getCommandBuilder().addKey(key);
return true;
}
if (DigraphSequence.isLiteralStart(key)) {
editorState.startLiteralSequence();
editorState.getCommandBuilder().addKey(key);
return true;
}
}
@@ -626,7 +671,7 @@ public class KeyHandler {
DigraphResult res = editorState.processDigraphKey(key, editor);
switch (res.getResult()) {
case DigraphResult.RES_HANDLED:
case DigraphResult.RES_BAD:
editorState.getCommandBuilder().addKey(key);
return true;
case DigraphResult.RES_DONE:
@@ -637,10 +682,20 @@ public class KeyHandler {
if (stroke == null) {
return false;
}
editorState.getCommandBuilder().addKey(key);
handleKey(editor, stroke, context);
return true;
case DigraphResult.RES_BAD:
// BAD is an error. We were expecting a valid character, and we didn't get it.
if (commandBuilder.getExpectedArgumentType() != null) {
commandBuilder.setCommandState(CurrentCommandState.BAD_COMMAND);
}
return true;
case DigraphResult.RES_UNHANDLED:
// UNHANDLED means the key stroke made no sense in the context of a digraph, but isn't an error in the current
// state. E.g. waiting for {char} <BS> {char}. Let the key handler have a go at it.
if (commandBuilder.getExpectedArgumentType() == Argument.Type.DIGRAPH) {
commandBuilder.fallbackToCharacterArgument();
handleKey(editor, key, context);
@@ -653,7 +708,6 @@ public class KeyHandler {
}
private void executeCommand(@NotNull Editor editor,
@NotNull KeyStroke key,
@NotNull DataContext context,
@NotNull CommandState editorState) {
final Command command = editorState.getCommandBuilder().buildCommand();
@@ -676,7 +730,7 @@ public class KeyHandler {
}
if (ApplicationManager.getApplication().isDispatchThread()) {
Runnable action = new ActionRunner(editor, context, command, key);
Runnable action = new ActionRunner(editor, context, command);
EditorActionHandlerBase cmdAction = command.getAction();
String name = cmdAction.getId();
@@ -714,7 +768,7 @@ public class KeyHandler {
}
else {
final Argument.Type argumentType = action.getArgumentType();
startWaitingForArgument(editor, context, key.getKeyChar(), argumentType, editorState);
startWaitingForArgument(editor, context, key.getKeyChar(), action, argumentType, editorState);
partialReset(editor);
}
@@ -751,6 +805,7 @@ public class KeyHandler {
private void startWaitingForArgument(Editor editor,
DataContext context,
char key,
@NotNull EditorActionHandlerBase action,
@NotNull Argument.Type argument,
CommandState editorState) {
final CommandBuilder commandBuilder = editorState.getCommandBuilder();
@@ -759,7 +814,18 @@ public class KeyHandler {
if (editorState.isDotRepeatInProgress() && VimRepeater.Extension.INSTANCE.getArgumentCaptured() != null) {
commandBuilder.completeCommandPart(VimRepeater.Extension.INSTANCE.getArgumentCaptured());
}
editorState.pushModes(editorState.getMode(), CommandState.SubMode.OP_PENDING);
editorState.pushModes(CommandState.Mode.OP_PENDING, CommandState.SubMode.NONE);
break;
case DIGRAPH:
// Command actions represent the completion of a command. Showcmd relies on this - if the action represents a
// part of a command, the showcmd output is reset part way through. This means we need to special case entering
// digraph/literal input mode. We have an action that takes a digraph as an argument, and pushes it back through
// the key handler when it's complete.
if (action instanceof InsertCompletedDigraphAction) {
editorState.startDigraphSequence();
} else if (action instanceof InsertCompletedLiteralAction) {
editorState.startLiteralSequence();
}
break;
case EX_STRING:
// The current Command expects an EX_STRING argument. E.g. SearchEntry(Fwd|Rev)Action. This won't execute until
@@ -810,8 +876,7 @@ public class KeyHandler {
editorState.getCommandBuilder().resetAll(getKeyRoot(editorState.getMappingState().getMappingMode()));
}
@NotNull
private CommandPartNode getKeyRoot(MappingMode mappingMode) {
private @NotNull CommandPartNode getKeyRoot(MappingMode mappingMode) {
return VimPlugin.getKey().getKeyRoot(mappingMode);
}
@@ -825,7 +890,10 @@ public class KeyHandler {
VimPlugin.clearError();
CommandState.getInstance(editor).reset();
reset(editor);
VimPlugin.getRegister().resetRegister();
RegisterGroup registerGroup = VimPlugin.getRegisterIfCreated();
if (registerGroup != null) {
registerGroup.resetRegister();
}
if (editor != null) {
VisualGroupKt.updateCaretState(editor);
editor.getSelectionModel().removeSelection();
@@ -833,9 +901,8 @@ public class KeyHandler {
}
// This method is copied from com.intellij.openapi.editor.actionSystem.EditorAction.getProjectAwareDataContext
@NotNull
private static DataContext getProjectAwareDataContext(@NotNull final Editor editor,
@NotNull final DataContext original) {
private static @NotNull DataContext getProjectAwareDataContext(final @NotNull Editor editor,
final @NotNull DataContext original) {
if (PROJECT.getData(original) == editor.getProject()) {
return new DialogAwareDataContext(original);
}
@@ -853,7 +920,7 @@ public class KeyHandler {
}
// This class is copied from com.intellij.openapi.editor.actionSystem.DialogAwareDataContext.DialogAwareDataContext
private final static class DialogAwareDataContext implements DataContext {
private static final class DialogAwareDataContext implements DataContext {
@SuppressWarnings("rawtypes")
private static final DataKey[] keys = {PROJECT, PROJECT_FILE_DIRECTORY, EDITOR, VIRTUAL_FILE, PSI_FILE};
private final Map<String, Object> values = new HashMap<>();
@@ -865,9 +932,8 @@ public class KeyHandler {
}
}
@Nullable
@Override
public Object getData(@NotNull @NonNls String dataId) {
public @Nullable Object getData(@NotNull @NonNls String dataId) {
if (values.containsKey(dataId)) {
return values.get(dataId);
}
@@ -884,11 +950,10 @@ public class KeyHandler {
*/
static class ActionRunner implements Runnable {
@Contract(pure = true)
ActionRunner(Editor editor, DataContext context, Command cmd, KeyStroke key) {
ActionRunner(Editor editor, DataContext context, Command cmd) {
this.editor = editor;
this.context = context;
this.cmd = cmd;
this.key = key;
}
@Override
@@ -897,6 +962,11 @@ public class KeyHandler {
editorState.getCommandBuilder().setCommandState(CurrentCommandState.NEW_COMMAND);
final Character register = cmd.getRegister();
if (register != null) {
VimPlugin.getRegister().selectRegister(register);
}
executeVimAction(editor, cmd.getAction(), context);
if (editorState.getMode() == CommandState.Mode.INSERT || editorState.getMode() == CommandState.Mode.REPLACE) {
VimPlugin.getChange().processCommand(editor, cmd);
@@ -905,10 +975,8 @@ public class KeyHandler {
// Now the command has been executed let's clean up a few things.
// By default, the "empty" register is used by all commands, so we want to reset whatever the last register
// selected by the user was to the empty register - unless we just executed the "select register" command.
if (cmd.getType() != Command.Type.SELECT_REGISTER) {
VimPlugin.getRegister().resetRegister();
}
// selected by the user was to the empty register
VimPlugin.getRegister().resetRegister();
// If, at this point, we are not in insert, replace, or visual modes, we need to restore the previous
// mode we were in. This handles commands in those modes that temporarily allow us to execute normal
@@ -925,7 +993,6 @@ public class KeyHandler {
private final Editor editor;
private final DataContext context;
private final Command cmd;
private final KeyStroke key;
}
private TypedActionHandler origHandler;

View File

@@ -0,0 +1,45 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import com.maddyhome.idea.vim.listener.VimListenerManager
/**
* @author Alex Plate
*/
class PluginStartup : StartupActivity.DumbAware {
private var firstInitializationOccurred = false
override fun runActivity(project: Project) {
if (firstInitializationOccurred && VimPlugin.isEnabled()) {
// This code should be executed on every project open
// Project listeners are self-disposable, so there is no need to unregister them on project close
VimListenerManager.ProjectListeners.add(project)
}
if (firstInitializationOccurred) return
firstInitializationOccurred = true
// This code should be executed once
VimPlugin.getInstance().initialize()
}
}

View File

@@ -17,12 +17,11 @@
*/
package com.maddyhome.idea.vim;
import com.intellij.openapi.extensions.ExtensionPointListener;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.maddyhome.idea.vim.group.KeyGroup;
import com.maddyhome.idea.vim.handler.ActionBeanClass;
import com.maddyhome.idea.vim.handler.EditorActionHandlerBase;
import com.maddyhome.idea.vim.key.MappingOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,58 +32,41 @@ public class RegisterActions {
public static final ExtensionPointName<ActionBeanClass> VIM_ACTIONS_EP =
ExtensionPointName.create("IdeaVIM.vimAction");
private static boolean initialRegistration = false;
static {
// IdeaVim doesn't support contribution to VIM_ACTIONS_EP extension point, so technically we can skip this update,
// but let's support dynamic plugins in a more classic way and reload actions on every EP change.
// TODO: [VERSION UPDATE] since 191 use
// ExtensionPoint.addExtensionPointListener(ExtensionPointListener<T>, boolean, Disposable)
// TODO: [VERSION UPDATE] since 201 use
// ExtensionPoint.addExtensionPointListener(ExtensionPointChangeListener, boolean, Disposable)
VIM_ACTIONS_EP.getPoint(null).addExtensionPointListener(new ExtensionPointListener<ActionBeanClass>() {
@Override
public void extensionAdded(@NotNull ActionBeanClass extension, @NotNull PluginDescriptor pluginDescriptor) {
// Suppress listener before the `VimPlugin.turnOn()` function execution. This logic should be rewritten after
// version update (or earlier).
if (!initialRegistration) return;
unregisterActions();
registerActions();
}
@Override
public void extensionRemoved(@NotNull ActionBeanClass extension, @NotNull PluginDescriptor pluginDescriptor) {
if (!initialRegistration) return;
unregisterActions();
registerActions();
}
});
}
/**
* Register all the key/action mappings for the plugin.
*/
static void registerActions() {
public static void registerActions() {
registerVimCommandActions();
registerEmptyShortcuts();
initialRegistration = true;
registerEpListener();
}
@Nullable
public static EditorActionHandlerBase findAction(@NotNull String id) {
private static void registerEpListener() {
// IdeaVim doesn't support contribution to VIM_ACTIONS_EP extension point, so technically we can skip this update,
// but let's support dynamic plugins in a more classic way and reload actions on every EP change.
VIM_ACTIONS_EP.getPoint(null).addExtensionPointListener(() -> {
unregisterActions();
registerActions();
}, false, VimPlugin.getInstance());
}
public static @Nullable EditorActionHandlerBase findAction(@NotNull String id) {
return VIM_ACTIONS_EP.extensions().filter(vimActionBean -> vimActionBean.getActionId().equals(id)).findFirst()
.map(ActionBeanClass::getAction).orElse(null);
}
@NotNull
public static EditorActionHandlerBase findActionOrDie(@NotNull String id) {
public static @NotNull EditorActionHandlerBase findActionOrDie(@NotNull String id) {
EditorActionHandlerBase action = findAction(id);
if (action == null) throw new RuntimeException("Action " + id + " is not registered");
return action;
}
public static void unregisterActions() {
VimPlugin.getKey().unregisterCommandActions();
KeyGroup keyGroup = VimPlugin.getKeyIfCreated();
if (keyGroup != null) {
keyGroup.unregisterCommandActions();
}
}
private static void registerVimCommandActions() {
@@ -97,6 +79,6 @@ public class RegisterActions {
// The {char1} <BS> {char2} shortcut is handled directly by KeyHandler#handleKey, so doesn't have an action. But we
// still need to register the shortcut, to make sure the editor doesn't swallow it.
parser.registerShortcutWithoutAction(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
parser.registerShortcutWithoutAction(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), MappingOwner.IdeaVim.INSTANCE);
}
}

View File

@@ -1,278 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim
import com.intellij.ide.BrowserUtil
import com.intellij.ide.DataManager
import com.intellij.ide.plugins.InstalledPluginsState
import com.intellij.ide.plugins.PluginManager
import com.intellij.ide.plugins.PluginManagerMain
import com.intellij.ide.plugins.RepositoryHelper
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.progress.PerformInBackgroundOption
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.ui.popup.ListPopup
import com.intellij.openapi.updateSettings.impl.PluginDownloader
import com.intellij.openapi.updateSettings.impl.UpdateChecker
import com.intellij.openapi.updateSettings.impl.UpdateInstaller
import com.intellij.openapi.updateSettings.impl.UpdateSettings
import com.intellij.openapi.util.Ref
import com.intellij.openapi.wm.StatusBar
import com.intellij.openapi.wm.StatusBarWidget
import com.intellij.openapi.wm.StatusBarWidgetProvider
import com.intellij.ui.awt.RelativePoint
import com.intellij.util.Consumer
import com.intellij.util.text.VersionComparatorUtil
import com.maddyhome.idea.vim.group.NotificationService
import com.maddyhome.idea.vim.option.OptionsManager
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable
import icons.VimIcons
import java.awt.Point
import java.awt.event.MouseEvent
import javax.swing.Icon
import javax.swing.SwingConstants
private class StatusBarIconProvider : StatusBarWidgetProvider {
override fun getWidget(project: Project): VimStatusBar? = if (OptionsManager.ideastatusbar.isSet) VimStatusBar else null
}
object VimStatusBar : StatusBarWidget, StatusBarWidget.IconPresentation {
private var statusBar: StatusBar? = null
override fun ID(): String = "IdeaVim-Icon"
override fun install(statusBar: StatusBar) {
this.statusBar = statusBar
}
override fun dispose() {}
override fun getTooltipText() = "IdeaVim"
override fun getIcon(): Icon = if (VimPlugin.isEnabled()) VimIcons.IDEAVIM else VimIcons.IDEAVIM_DISABLED
override fun getClickConsumer() = Consumer<MouseEvent> { event ->
val component = event.component
val popup = VimActionsPopup.getPopup(DataManager.getInstance().getDataContext(component))
val dimension = popup.content.preferredSize
val at = Point(0, -dimension.height)
popup.show(RelativePoint(component, at))
}
// TODO [VERSION UPDATE] After 193 use `getPresentation()`
@Suppress("DEPRECATION", "UnstableApiUsage")
override fun getPresentation(type: StatusBarWidget.PlatformType): StatusBarWidget.WidgetPresentation? = this
fun update() {
statusBar?.updateWidget(this.ID())
}
}
class VimActions : DumbAwareAction() {
companion object {
const val actionPlace = "VimActionsPopup"
}
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
VimActionsPopup.getPopup(e.dataContext).showCenteredInCurrentWindow(project)
}
override fun update(e: AnActionEvent) {
val project = e.project
e.presentation.isEnabledAndVisible = project != null && !project.isDisposed
}
}
private object VimActionsPopup {
fun getPopup(dataContext: DataContext): ListPopup {
val actions = getActions()
val popup = JBPopupFactory.getInstance()
.createActionGroupPopup("IdeaVim", actions,
dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false,
VimActions.actionPlace)
popup.setAdText("Version ${VimPlugin.getVersion()}", SwingConstants.CENTER)
return popup
}
private fun getActions(): DefaultActionGroup {
val actionGroup = DefaultActionGroup()
actionGroup.isPopup = true
actionGroup.add(ActionManager.getInstance().getAction("VimPluginToggle"))
actionGroup.addSeparator()
actionGroup.add(NotificationService.OpenIdeaVimRcAction(null))
actionGroup.add(ShortcutConflictsSettings)
actionGroup.addSeparator()
val eapGroup = DefaultActionGroup("EAP" + if (JoinEap.eapActive()) " (Active)" else "", true)
eapGroup.add(JoinEap)
eapGroup.add(HelpLink("About EAP...", "https://github.com/JetBrains/ideavim#get-early-access", null))
actionGroup.add(eapGroup)
val helpGroup = DefaultActionGroup("Contacts && Help", true)
helpGroup.add(HelpLink("Contact on Twitter", "https://twitter.com/ideavim", VimIcons.TWITTER))
helpGroup.add(HelpLink("Create an Issue", "https://youtrack.jetbrains.com/issues/VIM", VimIcons.YOUTRACK))
helpGroup.add(HelpLink("Contribute on GitHub", "https://github.com/JetBrains/ideavim", VimIcons.GITHUB))
actionGroup.add(helpGroup)
return actionGroup
}
}
private class HelpLink(
name: String,
val link: String,
icon: Icon?
) : DumbAwareAction(name, null, icon) {
override fun actionPerformed(e: AnActionEvent) {
BrowserUtil.browse(link)
}
}
private object ShortcutConflictsSettings : DumbAwareAction("Settings...") {
override fun actionPerformed(e: AnActionEvent) {
ShowSettingsUtil.getInstance().editConfigurable(e.project, VimEmulationConfigurable())
}
}
private object JoinEap : DumbAwareAction() {
private const val EAP_LINK = "https://plugins.jetbrains.com/plugins/eap/ideavim"
fun eapActive() = EAP_LINK in UpdateSettings.getInstance().storedPluginHosts
override fun actionPerformed(e: AnActionEvent) {
if (eapActive()) {
UpdateSettings.getInstance().storedPluginHosts -= EAP_LINK
VimPlugin.getNotifications(e.project).notifyEapFinished()
} else {
UpdateSettings.getInstance().storedPluginHosts += EAP_LINK
checkForUpdates(e.project)
}
}
override fun update(e: AnActionEvent) {
if (eapActive()) {
e.presentation.text = "Finish EAP"
} else {
e.presentation.text = "Get Early Access..."
}
}
private fun checkForUpdates(project: Project?) {
val notificator = VimPlugin.getNotifications(project)
val pluginRef = Ref.create<PluginDownloader>()
// [VERSION UPDATE] 193+ remove suppressing
@Suppress("UnstableApiUsage")
object : Task.Backgroundable(null, "Checking for IdeaVim EAP version", true) {
override fun run(indicator: ProgressIndicator) {
val downloaders = mutableListOf<PluginDownloader>()
val build = ApplicationInfo.getInstance().build
for (host in RepositoryHelper.getPluginHosts()) {
val newPluginDescriptor = RepositoryHelper
.loadPlugins(host, null, indicator)
.filter { it.pluginId == VimPlugin.getPluginId() }
.maxWith(java.util.Comparator { o1, o2 -> VersionComparatorUtil.compare(o1.version, o2.version) })
?: continue
downloaders += PluginDownloader.createDownloader(newPluginDescriptor, host, build)
}
val plugin = downloaders.maxWith(java.util.Comparator { o1, o2 -> VersionComparatorUtil.compare(o1.pluginVersion, o2.pluginVersion) })
pluginRef.set(plugin)
}
// [VERSION UPDATE] 193+ remove suppressing
@Suppress("MissingRecentApi", "UnstableApiUsage")
override fun onSuccess() {
val downloader: PluginDownloader = pluginRef.get() ?: run {
notificator.notifySubscribedToEap()
return
}
val currentVersion = PluginManager.getPlugin(VimPlugin.getPluginId())?.version ?: ""
if (VersionComparatorUtil.compare(downloader.pluginVersion, currentVersion) <= 0) {
notificator.notifySubscribedToEap()
return
}
val version = downloader.pluginVersion
val message = "Do you want to install the EAP version of IdeaVim?"
@Suppress("MoveVariableDeclarationIntoWhen")
val res = Messages.showYesNoCancelDialog(project, message, "IdeaVim $version", null)
when (res) {
Messages.YES -> updatePlugin(project, downloader)
Messages.NO -> notificator.notifySubscribedToEap()
Messages.CANCEL -> if (eapActive()) UpdateSettings.getInstance().storedPluginHosts -= EAP_LINK
}
}
override fun onCancel() {
notificator.notifySubscribedToEap()
}
override fun onThrowable(error: Throwable) {
notificator.notifySubscribedToEap()
}
}.queue()
}
private fun updatePlugin(project: Project?, downloader: PluginDownloader) {
val notificator = VimPlugin.getNotifications(project)
return object : Task.Backgroundable(null, "Plugin Updates", true, PerformInBackgroundOption.DEAF) {
private var updated = false
override fun run(indicator: ProgressIndicator) {
val state = InstalledPluginsState.getInstance()
state.onDescriptorDownload(downloader.descriptor)
UpdateChecker.checkAndPrepareToInstall(downloader, state, mutableMapOf(VimPlugin.getPluginId() to downloader), mutableListOf(), indicator)
updated = UpdateInstaller.installPluginUpdates(listOf(downloader), indicator)
}
override fun onSuccess() {
if (updated) {
PluginManagerMain.notifyPluginsUpdated(null)
} else {
notificator.notifyFailedToDownloadEap()
}
}
override fun onCancel() {
notificator.notifyFailedToDownloadEap()
}
override fun onThrowable(error: Throwable) {
notificator.notifyFailedToDownloadEap()
}
}.queue()
}
}

View File

@@ -19,14 +19,15 @@ package com.maddyhome.idea.vim;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PermanentInstallationID;
import com.intellij.openapi.components.*;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.keymap.Keymap;
@@ -36,12 +37,12 @@ import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.util.io.HttpRequests;
import com.maddyhome.idea.vim.config.VimLocalConfig;
import com.maddyhome.idea.vim.config.VimState;
import com.maddyhome.idea.vim.config.migration.ApplicationConfigurationMigrator;
import com.maddyhome.idea.vim.ex.CommandParser;
import com.maddyhome.idea.vim.ex.vimscript.VimScriptParser;
import com.maddyhome.idea.vim.extension.VimExtensionRegistrar;
@@ -53,18 +54,21 @@ import com.maddyhome.idea.vim.helper.MacKeyRepeat;
import com.maddyhome.idea.vim.listener.VimListenerManager;
import com.maddyhome.idea.vim.option.OptionsManager;
import com.maddyhome.idea.vim.ui.ExEntryPanel;
import com.maddyhome.idea.vim.ui.StatusBarIconFactory;
import com.maddyhome.idea.vim.ui.VimEmulationConfigurable;
import com.maddyhome.idea.vim.ui.VimRcFileState;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.concurrent.TimeUnit;
import java.util.List;
import static com.maddyhome.idea.vim.group.EditorGroup.EDITOR_STORE_ELEMENT;
import static com.maddyhome.idea.vim.group.KeyGroup.SHORTCUT_CONFLICTS_ELEMENT;
/**
* This plugin attempts to emulate the key binding and general functionality of Vim and gVim. See the supplied
@@ -75,11 +79,9 @@ import java.util.concurrent.TimeUnit;
* Registers and marks are shared across open projects so you can copy and paste between files of different projects.
*/
@State(name = "VimSettings", storages = {@Storage("$APP_CONFIG$/vim_settings.xml")})
public class VimPlugin implements BaseComponent, PersistentStateComponent<Element>, Disposable {
private static final String IDEAVIM_COMPONENT_NAME = "VimPlugin";
public class VimPlugin implements PersistentStateComponent<Element>, Disposable {
private static final String IDEAVIM_PLUGIN_ID = "IdeaVIM";
private static final String IDEAVIM_STATISTICS_TIMESTAMP_KEY = "ideavim.statistics.timestamp";
public static final int STATE_VERSION = 5;
public static final int STATE_VERSION = 7;
private static long lastBeepTimeMillis;
@@ -94,21 +96,29 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
private static final Logger LOG = Logger.getInstance(VimPlugin.class);
@NotNull
@Override
public String getComponentName() {
return IDEAVIM_COMPONENT_NAME;
private final @NotNull VimState state = new VimState();
VimPlugin() {
ApplicationConfigurationMigrator.getInstance().migrate();
}
@NotNull private final VimState state = new VimState();
// [VERSION UPDATE] 193+ replace with com.intellij.openapi.components.PersistentStateComponent.initializeComponent
@Override
public void initComponent() {
public void initialize() {
LOG.debug("initComponent");
if (enabled) turnOnPlugin();
// Initialize a legacy local config.
if (previousStateVersion == 5) {
//noinspection deprecation
VimLocalConfig.Companion.initialize();
}
if (enabled) {
Application application = ApplicationManager.getApplication();
if (application.isUnitTestMode()) {
application.invokeAndWait(this::turnOnPlugin);
}
else {
application.invokeLater(this::turnOnPlugin);
}
}
LOG.debug("done");
}
@@ -123,174 +133,105 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
/**
* @return NotificationService as applicationService if project is null and projectService otherwise
*/
@NotNull
public static NotificationService getNotifications(@Nullable Project project) {
public static @NotNull NotificationService getNotifications(@Nullable Project project) {
if (project == null) {
return ServiceManager.getService(NotificationService.class);
} else {
}
else {
return ServiceManager.getService(project, NotificationService.class);
}
}
@NotNull
public static VimState getVimState() {
public static @NotNull VimState getVimState() {
return getInstance().state;
}
@NotNull
public static MotionGroup getMotion() {
public static @NotNull MotionGroup getMotion() {
return ServiceManager.getService(MotionGroup.class);
}
/**
* Reports statistics about installed IdeaVim and enabled Vim emulation.
* <p>
* See https://github.com/go-lang-plugin-org/go-lang-idea-plugin/commit/5182ab4a1d01ad37f6786268a2fe5e908575a217
*/
public static void statisticReport() {
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
final long lastUpdate = propertiesComponent.getOrInitLong(IDEAVIM_STATISTICS_TIMESTAMP_KEY, 0);
final boolean outOfDate =
lastUpdate == 0 || System.currentTimeMillis() - lastUpdate > TimeUnit.DAYS.toMillis(1);
if (outOfDate && isEnabled()) {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
final String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
final String version = URLEncoder.encode(getVersion(), CharsetToolkit.UTF8);
final String os =
URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8);
final String uid = PermanentInstallationID.get();
final String url = "https://plugins.jetbrains.com/plugins/list" +
"?pluginId=" + IDEAVIM_PLUGIN_ID +
"&build=" +
buildNumber +
"&pluginVersion=" +
version +
"&os=" +
os +
"&uuid=" +
uid;
PropertiesComponent.getInstance()
.setValue(IDEAVIM_STATISTICS_TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
HttpRequests.request(url).connect(request -> {
LOG.info("Sending statistics: " + url);
try {
JDOMUtil.load(request.getInputStream());
}
catch (JDOMException e) {
LOG.warn(e);
}
return null;
});
}
catch (IOException e) {
LOG.warn(e);
}
});
}
}
@NotNull
public static ChangeGroup getChange() {
public static @NotNull ChangeGroup getChange() {
return ServiceManager.getService(ChangeGroup.class);
}
@NotNull
public static CommandGroup getCommand() {
public static @NotNull CommandGroup getCommand() {
return ServiceManager.getService(CommandGroup.class);
}
@NotNull
public static MarkGroup getMark() {
public static @NotNull MarkGroup getMark() {
return ServiceManager.getService(MarkGroup.class);
}
@NotNull
public static RegisterGroup getRegister() {
public static @NotNull RegisterGroup getRegister() {
return ServiceManager.getService(RegisterGroup.class);
}
@NotNull
public static FileGroup getFile() {
public static @Nullable RegisterGroup getRegisterIfCreated() {
return ServiceManager.getServiceIfCreated(RegisterGroup.class);
}
public static @NotNull FileGroup getFile() {
return ServiceManager.getService(FileGroup.class);
}
@NotNull
public static SearchGroup getSearch() {
public static @NotNull SearchGroup getSearch() {
return ServiceManager.getService(SearchGroup.class);
}
@NotNull
public static ProcessGroup getProcess() {
public static @Nullable SearchGroup getSearchIfCreated() {
return ServiceManager.getServiceIfCreated(SearchGroup.class);
}
public static @NotNull ProcessGroup getProcess() {
return ServiceManager.getService(ProcessGroup.class);
}
@NotNull
public static MacroGroup getMacro() {
public static @NotNull MacroGroup getMacro() {
return ServiceManager.getService(MacroGroup.class);
}
@NotNull
public static DigraphGroup getDigraph() {
public static @NotNull DigraphGroup getDigraph() {
return ServiceManager.getService(DigraphGroup.class);
}
@NotNull
public static HistoryGroup getHistory() {
public static @NotNull HistoryGroup getHistory() {
return ServiceManager.getService(HistoryGroup.class);
}
@NotNull
public static KeyGroup getKey() {
public static @NotNull KeyGroup getKey() {
return ServiceManager.getService(KeyGroup.class);
}
@NotNull
public static WindowGroup getWindow() {
public static @Nullable KeyGroup getKeyIfCreated() {
return ServiceManager.getServiceIfCreated(KeyGroup.class);
}
public static @NotNull WindowGroup getWindow() {
return ServiceManager.getService(WindowGroup.class);
}
@NotNull
public static EditorGroup getEditor() {
public static @NotNull EditorGroup getEditor() {
return ServiceManager.getService(EditorGroup.class);
}
@NotNull
public static VisualMotionGroup getVisualMotion() {
public static @Nullable EditorGroup getEditorIfCreated() {
return ServiceManager.getServiceIfCreated(EditorGroup.class);
}
public static @NotNull VisualMotionGroup getVisualMotion() {
return ServiceManager.getService(VisualMotionGroup.class);
}
@NotNull
public static YankGroup getYank() {
public static @NotNull YankGroup getYank() {
return ServiceManager.getService(YankGroup.class);
}
@NotNull
public static PutGroup getPut() {
public static @NotNull PutGroup getPut() {
return ServiceManager.getService(PutGroup.class);
}
@Override
public Element getState() {
LOG.debug("Saving state");
final Element element = new Element("ideavim");
// Save whether the plugin is enabled or not
final Element state = new Element("state");
state.setAttribute("version", Integer.toString(STATE_VERSION));
state.setAttribute("enabled", Boolean.toString(enabled));
element.addContent(state);
getKey().saveData(element);
getEditor().saveData(element);
this.state.saveData(element);
return element;
}
@NotNull
private static NotificationService getNotifications() {
private static @NotNull NotificationService getNotifications() {
return getNotifications(null);
}
@@ -301,22 +242,27 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
ideavimrcRegistered = true;
if (!ApplicationManager.getApplication().isUnitTestMode()) {
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
if (ideaVimRc != null) {
VimScriptParser.executeFile(ideaVimRc);
}
executeIdeaVimRc();
}
}
@NotNull
public static PluginId getPluginId() {
public void executeIdeaVimRc() {
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
if (ideaVimRc != null) {
LOG.info("Execute ideavimrc file: " + ideaVimRc.getAbsolutePath());
List<String> parsedLines = VimScriptParser.executeFile(ideaVimRc);
VimRcFileState.INSTANCE.saveFileState(ideaVimRc.getAbsolutePath(), parsedLines);
}
else {
LOG.info("ideavimrc file isn't found");
}
}
public static @NotNull PluginId getPluginId() {
return PluginId.getId(IDEAVIM_PLUGIN_ID);
}
// [VERSION UPDATE] 193+ remove suppress
@SuppressWarnings({"MissingRecentApi", "UnstableApiUsage"})
@NotNull
public static String getVersion() {
public static @NotNull String getVersion() {
final IdeaPluginDescriptor plugin = PluginManager.getPlugin(getPluginId());
if (!ApplicationManager.getApplication().isInternal()) {
return plugin != null ? plugin.getVersion() : "SNAPSHOT";
@@ -343,7 +289,7 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
getInstance().turnOnPlugin();
}
VimStatusBar.INSTANCE.update();
StatusBarIconFactory.Companion.updateIcon();
}
public static boolean isError() {
@@ -381,7 +327,7 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
showMessage(msg);
}
public static void showMessage(@Nullable String msg) {
public static void showMessage(@Nls @Nullable String msg) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
getInstance().message = msg;
}
@@ -400,18 +346,13 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
}
}
@NotNull
private static VimPlugin getInstance() {
return ApplicationManager.getApplication().getComponent(VimPlugin.class);
public static @NotNull VimPlugin getInstance() {
return ServiceManager.getService(VimPlugin.class);
}
private void turnOnPlugin() {
ApplicationManager.getApplication().invokeLater(this::updateState);
getEditor().turnOn();
getSearch().turnOn();
VimListenerManager.INSTANCE.turnOn();
// Register vim actions in command mode
RegisterActions.registerActions();
@@ -423,21 +364,27 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
// Execute ~/.ideavimrc
registerIdeavimrc();
// Turing on should be performed after all commands registration
getSearch().turnOn();
VimListenerManager.INSTANCE.turnOn();
}
private void turnOffPlugin() {
KeyHandler.getInstance().fullReset(null);
SearchGroup searchGroup = getSearchIfCreated();
if (searchGroup != null) {
searchGroup.turnOff();
}
VimListenerManager.INSTANCE.turnOff();
ExEntryPanel.fullReset();
// Unregister vim actions in command mode
RegisterActions.unregisterActions();
// Unregister ex handlers
CommandParser.getInstance().unregisterHandlers();
getEditor().turnOff();
getSearch().turnOff();
VimListenerManager.INSTANCE.turnOff();
ExEntryPanel.fullReset();
}
private boolean stateUpdated = false;
@@ -485,7 +432,7 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
}
@Override
public void loadState(@NotNull final Element element) {
public void loadState(final @NotNull Element element) {
LOG.debug("Loading state");
// Restore whether the plugin is enabled or not
@@ -500,6 +447,27 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
previousKeyMap = state.getAttributeValue("keymap");
}
legacyStateLoading(element);
this.state.readData(element);
}
@Override
public Element getState() {
LOG.debug("Saving state");
final Element element = new Element("ideavim");
// Save whether the plugin is enabled or not
final Element state = new Element("state");
state.setAttribute("version", Integer.toString(STATE_VERSION));
state.setAttribute("enabled", Boolean.toString(enabled));
element.addContent(state);
this.state.saveData(element);
return element;
}
private void legacyStateLoading(@NotNull Element element) {
if (previousStateVersion > 0 && previousStateVersion < 5) {
// Migrate settings from 4 to 5 version
getMark().readData(element);
@@ -507,8 +475,11 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
getSearch().readData(element);
getHistory().readData(element);
}
getKey().readData(element);
getEditor().readData(element);
this.state.readData(element);
if (element.getChild(SHORTCUT_CONFLICTS_ELEMENT) != null) {
getKey().readData(element);
}
if (element.getChild(EDITOR_STORE_ELEMENT) != null) {
getEditor().readData(element);
}
}
}

View File

@@ -18,17 +18,22 @@
package com.maddyhome.idea.vim
import com.intellij.openapi.components.ProjectComponent
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import com.maddyhome.idea.vim.listener.VimListenerManager
/**
* @author Alex Plate
*/
class VimProjectComponent(private val project: Project) : ProjectComponent {
override fun projectOpened() {
if (!VimPlugin.isEnabled()) return
// Project listeners are self-disposable, so there is no need to unregister them on project close
VimListenerManager.ProjectListeners.add(project)
@Service
class VimProjectService(val project: Project) : Disposable {
override fun dispose() {}
companion object {
@JvmStatic
fun getInstance(project: Project): VimProjectService {
return ServiceManager.getService(project, VimProjectService::class.java)
}
}
}
val Project.vimDisposable
get() = VimProjectService.getInstance(this)

View File

@@ -1,61 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.ActionPlan;
import com.intellij.openapi.editor.actionSystem.TypedActionHandler;
import com.intellij.openapi.editor.actionSystem.TypedActionHandlerEx;
import com.maddyhome.idea.vim.helper.EditorDataContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* Accepts all regular keystrokes and passes them on to the Vim key handler.
*
* IDE shortcut keys used by Vim commands are handled by {@link com.maddyhome.idea.vim.action.VimShortcutKeyAction}.
*/
public class VimTypedActionHandler implements TypedActionHandlerEx {
private static final Logger logger = Logger.getInstance(VimTypedActionHandler.class.getName());
@NotNull private final KeyHandler handler;
public VimTypedActionHandler(TypedActionHandler origHandler) {
handler = KeyHandler.getInstance();
handler.setOriginalHandler(origHandler);
}
@Override
public void beforeExecute(@NotNull Editor editor, char charTyped, @NotNull DataContext context, @NotNull ActionPlan plan) {
handler.beforeHandleKey(editor, KeyStroke.getKeyStroke(charTyped), context, plan);
}
@Override
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext context) {
try {
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), new EditorDataContext(editor));
}
catch (Throwable e) {
logger.error(e);
}
}
}

View File

@@ -0,0 +1,85 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.actionSystem.ActionPlan
import com.intellij.openapi.editor.actionSystem.TypedActionHandler
import com.intellij.openapi.editor.actionSystem.TypedActionHandlerEx
import com.maddyhome.idea.vim.helper.EditorDataContext
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import java.awt.event.KeyAdapter
import java.awt.event.KeyEvent
import javax.swing.KeyStroke
/**
* Accepts all regular keystrokes and passes them on to the Vim key handler.
*
* IDE shortcut keys used by Vim commands are handled by [com.maddyhome.idea.vim.action.VimShortcutKeyAction].
*/
class VimTypedActionHandler(origHandler: TypedActionHandler?) : TypedActionHandlerEx {
private val handler = KeyHandler.getInstance()
init {
handler.originalHandler = origHandler
}
override fun beforeExecute(editor: Editor, charTyped: Char, context: DataContext, plan: ActionPlan) {
if (editor.isIdeaVimDisabledHere) {
(handler.originalHandler as? TypedActionHandlerEx)?.beforeExecute(editor, charTyped, context, plan)
return
}
val modifiers = if (charTyped == ' ' && VimKeyListener.isSpaceShift) KeyEvent.SHIFT_DOWN_MASK else 0
val keyStroke = KeyStroke.getKeyStroke(charTyped, modifiers)
handler.beforeHandleKey(editor, keyStroke, context, plan)
}
override fun execute(editor: Editor, charTyped: Char, context: DataContext) {
if (editor.isIdeaVimDisabledHere) {
handler.originalHandler.execute(editor, charTyped, context)
return
}
try {
val modifiers = if (charTyped == ' ' && VimKeyListener.isSpaceShift) KeyEvent.SHIFT_DOWN_MASK else 0
val keyStroke = KeyStroke.getKeyStroke(charTyped, modifiers)
handler.handleKey(editor, keyStroke, EditorDataContext(editor))
} catch (e: Throwable) {
logger.error(e)
}
}
companion object {
private val logger = logger<VimTypedActionHandler>()
}
}
/**
* A nasty workaround to handle `<S-Space>` events. Probably all the key events should go trough this listener.
*/
object VimKeyListener : KeyAdapter() {
var isSpaceShift = false
override fun keyPressed(e: KeyEvent) {
isSpaceShift = e.modifiersEx and KeyEvent.SHIFT_DOWN_MASK != 0 && e.keyChar == ' '
}
}

View File

@@ -25,7 +25,7 @@ import com.maddyhome.idea.vim.handler.VimActionHandler
import com.maddyhome.idea.vim.helper.getTopLevelEditor
class ResetModeAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.RESET
override val type: Command.Type = Command.Type.OTHER_WRITABLE
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.getInstance().fullReset(editor.getTopLevelEditor())

View File

@@ -20,8 +20,8 @@ package com.maddyhome.idea.vim.action
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareToggleAction
import com.maddyhome.idea.vim.VimActions
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.ui.VimActions
/**
* This class is used to handle the Vim Plugin enabled/disabled toggle. This is most likely used as a menu option

View File

@@ -26,8 +26,6 @@ import com.intellij.openapi.actionSystem.EmptyAction
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.ex.util.EditorUtil
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.Key
@@ -39,6 +37,8 @@ import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.StringHelper
import com.maddyhome.idea.vim.helper.inInsertMode
import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.isPrimaryEditor
import com.maddyhome.idea.vim.key.ShortcutOwner
import com.maddyhome.idea.vim.listener.IdeaSpecifics.aceJumpActive
import com.maddyhome.idea.vim.option.OptionsManager
@@ -82,31 +82,31 @@ class VimShortcutKeyAction : AnAction(), DumbAware {
val editor = getEditor(e)
val keyStroke = getKeyStroke(e)
if (editor != null && keyStroke != null) {
if (editor.isIdeaVimDisabledHere) return false
// Workaround for smart step into
@Suppress("DEPRECATION")
val SMART_STEP_INPLACE_DATA = Key.findKeyByName("SMART_STEP_INPLACE_DATA")
if (SMART_STEP_INPLACE_DATA != null && editor.getUserData(SMART_STEP_INPLACE_DATA) != null) return false
if (aceJumpActive()) return false
val keyCode = keyStroke.keyCode
if (LookupManager.getActiveLookup(editor) != null) {
return LookupKeys.isEnabledForLookup(keyStroke)
}
if (keyCode == KeyEvent.VK_ESCAPE) {
return isEnabledForEscape(editor)
}
if (LookupManager.getActiveLookup(editor) != null && !LookupKeys.isEnabledForLookup(keyStroke)) return false
if (keyCode == KeyEvent.VK_ESCAPE) return isEnabledForEscape(editor)
if (editor.inInsertMode) { // XXX: <Tab> won't be recorded in macros
if (keyCode == KeyEvent.VK_TAB) {
VimPlugin.getChange().tabAction = true
return false
}
// Debug watch, Python console, etc.
if (NON_FILE_EDITOR_KEYS.contains(keyStroke) && !EditorHelper.isFileEditor(editor)) {
return false
}
}
if (VIM_ONLY_EDITOR_KEYS.contains(keyStroke)) {
return true
if (keyStroke in NON_FILE_EDITOR_KEYS && !EditorHelper.isFileEditor(editor)) return false
}
if (keyStroke in VIM_ONLY_EDITOR_KEYS) return true
val savedShortcutConflicts = VimPlugin.getKey().savedShortcutConflicts
return when (savedShortcutConflicts[keyStroke]) {
ShortcutOwner.VIM -> true
@@ -123,16 +123,8 @@ class VimShortcutKeyAction : AnAction(), DumbAware {
}
private fun isEnabledForEscape(editor: Editor): Boolean {
return isPrimaryEditor(editor) || EditorHelper.isFileEditor(editor) && !editor.inNormalMode
}
/**
* Checks if the editor is a primary editor in the main editing area.
*/
private fun isPrimaryEditor(editor: Editor): Boolean {
val project = editor.project ?: return false
val fileEditorManager = FileEditorManagerEx.getInstanceEx(project) ?: return false
return fileEditorManager.allEditors.any { fileEditor -> editor == EditorUtil.getEditorEx(fileEditor) }
return (editor.isPrimaryEditor() || EditorHelper.isFileEditor(editor) && !editor.inNormalMode) ||
(OptionsManager.dialogescape.value == "on" && !editor.inNormalMode)
}
private fun isShortcutConflict(keyStroke: KeyStroke): Boolean {
@@ -191,15 +183,15 @@ class VimShortcutKeyAction : AnAction(), DumbAware {
companion object {
@JvmField
val VIM_ONLY_EDITOR_KEYS: Set<KeyStroke> = ImmutableSet.builder<KeyStroke>().addAll(getKeyStrokes(KeyEvent.VK_ENTER, 0)).addAll(getKeyStrokes(KeyEvent.VK_ESCAPE, 0))
.addAll(getKeyStrokes(KeyEvent.VK_TAB, 0)).addAll(getKeyStrokes(KeyEvent.VK_BACK_SPACE, 0, InputEvent.CTRL_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_INSERT, 0)).addAll(getKeyStrokes(KeyEvent.VK_DELETE, 0, InputEvent.CTRL_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_UP, 0, InputEvent.CTRL_MASK, InputEvent.SHIFT_MASK)).addAll(getKeyStrokes(KeyEvent.VK_DOWN, 0, InputEvent.CTRL_MASK, InputEvent.SHIFT_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_LEFT, 0, InputEvent.CTRL_MASK, InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK or InputEvent.SHIFT_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_RIGHT, 0, InputEvent.CTRL_MASK, InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK or InputEvent.SHIFT_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_HOME, 0, InputEvent.CTRL_MASK, InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK or InputEvent.SHIFT_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_END, 0, InputEvent.CTRL_MASK, InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK or InputEvent.SHIFT_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_PAGE_UP, 0, InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK or InputEvent.SHIFT_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_PAGE_DOWN, 0, InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK or InputEvent.SHIFT_MASK)).build()
.addAll(getKeyStrokes(KeyEvent.VK_TAB, 0)).addAll(getKeyStrokes(KeyEvent.VK_BACK_SPACE, 0, InputEvent.CTRL_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_INSERT, 0)).addAll(getKeyStrokes(KeyEvent.VK_DELETE, 0, InputEvent.CTRL_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_UP, 0, InputEvent.CTRL_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK)).addAll(getKeyStrokes(KeyEvent.VK_DOWN, 0, InputEvent.CTRL_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_LEFT, 0, InputEvent.CTRL_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_RIGHT, 0, InputEvent.CTRL_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_HOME, 0, InputEvent.CTRL_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_END, 0, InputEvent.CTRL_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_PAGE_UP, 0, InputEvent.SHIFT_DOWN_MASK, InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK))
.addAll(getKeyStrokes(KeyEvent.VK_PAGE_DOWN, 0, InputEvent.SHIFT_DOWN_MASK, InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK)).build()
private const val ACTION_ID = "VimShortcutKeyAction"

View File

@@ -45,14 +45,17 @@ class OperatorAction : VimActionHandler.SingleExecution() {
if (!editor.commandState.isDotRepeatInProgress) {
VimRepeater.Extension.argumentCaptured = argument
}
val saveRepeatHandler = VimRepeater.repeatHandler
val motion = argument.motion
val range = MotionGroup
.getMotionRange(editor, editor.caretModel.primaryCaret, context, cmd.count, cmd.rawCount, argument)
if (range != null) {
VimPlugin.getMark().setChangeMarks(editor, range)
val selectionType = SelectionType.fromCommandFlags(motion.flags)
val selectionType = if (motion.isLinewiseMotion()) SelectionType.LINE_WISE else SelectionType.CHARACTER_WISE
KeyHandler.getInstance().reset(editor)
return operatorFunction.apply(editor, context, selectionType)
val result = operatorFunction.apply(editor, context, selectionType)
VimRepeater.repeatHandler = saveRepeatHandler
return result
}
}
return false

View File

@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.action.motion.updown.MotionDownLess1FirstNonSpaceAction
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
@@ -39,6 +40,9 @@ class ChangeLineAction : ChangeEditorActionHandler.ForEachCaret() {
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
return VimPlugin.getChange().changeLine(editor, caret, count, context)
// `S` command is a synonym of `cc`
val motion = MotionDownLess1FirstNonSpaceAction()
val command = Command(1, motion, motion.type, motion.flags)
return VimPlugin.getChange().changeMotion(editor, caret, context, count, rawCount, Argument(command))
}
}

View File

@@ -25,15 +25,13 @@ import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
class ChangeNumberIncAction : ChangeEditorActionHandler.ForEachCaret() {
sealed class IncAction(val inc: Int) : ChangeEditorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE
override fun execute(editor: Editor,
caret: Caret,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
return VimPlugin.getChange().changeNumber(editor, caret, count)
override fun execute(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): Boolean {
return VimPlugin.getChange().changeNumber(editor, caret, inc * count)
}
}
class ChangeNumberIncAction : IncAction(1)
class ChangeNumberDecAction : IncAction(-1)

View File

@@ -1,44 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.change.change.number
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class ChangeVisualNumberAvalancheDecAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeAction(editor: Editor,
caret: Caret,
context: DataContext,
cmd: Command,
range: VimSelection): Boolean {
return VimPlugin.getChange()
.changeNumberVisualMode(editor, caret, range.toVimTextRange(false), -cmd.count, true)
}
}

View File

@@ -1,44 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.change.change.number
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class ChangeVisualNumberAvalancheIncAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeAction(editor: Editor,
caret: Caret,
context: DataContext,
cmd: Command,
range: VimSelection): Boolean {
return VimPlugin.getChange()
.changeNumberVisualMode(editor, caret, range.toVimTextRange(false), cmd.count, true)
}
}

View File

@@ -1,44 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.change.change.number
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class ChangeVisualNumberDecAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeAction(editor: Editor,
caret: Caret,
context: DataContext,
cmd: Command,
range: VimSelection): Boolean {
return VimPlugin.getChange()
.changeNumberVisualMode(editor, caret, range.toVimTextRange(false), -cmd.count, false)
}
}

View File

@@ -28,17 +28,16 @@ import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class ChangeVisualNumberIncAction : VisualOperatorActionHandler.ForEachCaret() {
sealed class IncNumber(val inc: Int, val avalanche: Boolean) : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeAction(editor: Editor,
caret: Caret,
context: DataContext,
cmd: Command,
range: VimSelection): Boolean {
return VimPlugin.getChange()
.changeNumberVisualMode(editor, caret, range.toVimTextRange(false), cmd.count, false)
override fun executeAction(editor: Editor, caret: Caret, context: DataContext, cmd: Command, range: VimSelection): Boolean {
return VimPlugin.getChange().changeNumberVisualMode(editor, caret, range.toVimTextRange(false), inc * cmd.count, avalanche)
}
}
class ChangeVisualNumberIncAction : IncNumber(1, false)
class ChangeVisualNumberDecAction : IncNumber(-1, false)
class ChangeVisualNumberAvalancheIncAction : IncNumber(1, true)
class ChangeVisualNumberAvalancheDecAction : IncNumber(-1, true)

View File

@@ -23,14 +23,12 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.CommandState.SubMode
import com.maddyhome.idea.vim.command.SelectionType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.enumSetOf
import com.maddyhome.idea.vim.helper.subMode
import java.util.*
/**
@@ -46,15 +44,18 @@ class DeleteVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() {
context: DataContext,
cmd: Command,
range: VimSelection): Boolean {
val mode = editor.subMode
val textRange = range.toVimTextRange(false)
return if (mode == SubMode.VISUAL_BLOCK) {
VimPlugin.getChange()
.deleteRange(editor, editor.caretModel.primaryCaret, textRange, SelectionType.fromSubMode(mode), false)
} else {
val lineRange = TextRange(EditorHelper.getLineStartForOffset(editor, textRange.startOffset),
EditorHelper.getLineEndForOffset(editor, textRange.endOffset) + 1)
VimPlugin.getChange().deleteRange(editor, caret, lineRange, SelectionType.LINE_WISE, false)
val (usedCaret, usedRange, usedType) = when (range.type) {
SelectionType.BLOCK_WISE -> Triple(editor.caretModel.primaryCaret, textRange, range.type)
SelectionType.LINE_WISE -> Triple(caret, textRange, SelectionType.LINE_WISE)
SelectionType.CHARACTER_WISE -> {
val lineRange = TextRange(
EditorHelper.getLineStartForOffset(editor, textRange.startOffset),
EditorHelper.getLineEndForOffset(editor, textRange.endOffset) + 1
)
Triple(caret, lineRange, SelectionType.LINE_WISE)
}
}
return VimPlugin.getChange().deleteRange(editor, usedCaret, usedRange, usedType, false)
}
}

View File

@@ -0,0 +1,21 @@
package com.maddyhome.idea.vim.action.change.insert
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.handler.VimActionHandler
import javax.swing.KeyStroke
class InsertCompletedDigraphAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT
override val argumentType: Argument.Type? = Argument.Type.DIGRAPH
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
// The converted digraph character has been captured as an argument, push it back through key handler
val keyStroke = KeyStroke.getKeyStroke(cmd.argument!!.character)
KeyHandler.getInstance().handleKey(editor, keyStroke, context)
return true
}
}

View File

@@ -0,0 +1,21 @@
package com.maddyhome.idea.vim.action.change.insert
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.handler.VimActionHandler
import javax.swing.KeyStroke
class InsertCompletedLiteralAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT
override val argumentType: Argument.Type? = Argument.Type.DIGRAPH
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
// The converted literal character has been captured as an argument, push it back through key handler
val keyStroke = KeyStroke.getKeyStroke(cmd.argument!!.character)
KeyHandler.getInstance().handleKey(editor, keyStroke, context)
return true
}
}

View File

@@ -29,9 +29,9 @@ import javax.swing.KeyStroke
class InsertPreviousInsertExitAction : ChangeEditorActionHandler.SingleExecution(), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_MASK or KeyEvent.SHIFT_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_AT, KeyEvent.CTRL_MASK))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_DOWN_MASK or KeyEvent.SHIFT_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_AT, KeyEvent.CTRL_DOWN_MASK))
)
override val type: Command.Type = Command.Type.INSERT

View File

@@ -1,16 +0,0 @@
package com.maddyhome.idea.vim.action.change.insert
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.handler.VimActionHandler
class StartInsertDigraphAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.getInstance().startDigraphSequence(editor)
return true
}
}

View File

@@ -1,16 +0,0 @@
package com.maddyhome.idea.vim.action.change.insert
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.handler.VimActionHandler
class StartInsertLiteralAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.getInstance().startLiteralSequence(editor)
return true
}
}

View File

@@ -25,18 +25,29 @@ import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.copy.PutData.TextData
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.helper.StringHelper
class PutTextBeforeCursorAction : ChangeEditorActionHandler.SingleExecution() {
sealed class PutTextBaseAction(
private val insertTextBeforeCaret: Boolean,
private val indent: Boolean,
private val caretAfterInsertedText: Boolean
) : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute(editor: Editor,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
override fun execute(editor: Editor, context: DataContext, count: Int, rawCount: Int, argument: Argument?): Boolean {
val lastRegister = VimPlugin.getRegister().lastRegister
val textData = if (lastRegister != null) TextData(lastRegister.text, lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, insertTextBeforeCaret = true, _indent = true, caretAfterInsertedText = false, putToLine = -1)
val textData = if (lastRegister != null) TextData(lastRegister.text ?: StringHelper.toKeyNotation(lastRegister.keys), lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, insertTextBeforeCaret, indent, caretAfterInsertedText, -1)
return VimPlugin.getPut().putText(editor, context, putData)
}
}
class PutTextAfterCursorAction : PutTextBaseAction(insertTextBeforeCaret = false, indent = true, caretAfterInsertedText = false)
class PutTextAfterCursorActionMoveCursor : PutTextBaseAction(insertTextBeforeCaret = false, indent = true, caretAfterInsertedText = true)
class PutTextAfterCursorNoIndentAction : PutTextBaseAction(insertTextBeforeCaret = false, indent = false, caretAfterInsertedText = false)
class PutTextBeforeCursorNoIndentAction : PutTextBaseAction(insertTextBeforeCaret = true, indent = false, caretAfterInsertedText = false)
class PutTextBeforeCursorAction : PutTextBaseAction(insertTextBeforeCaret = true, indent = true, caretAfterInsertedText = false)
class PutTextBeforeCursorActionMoveCursor : PutTextBaseAction(insertTextBeforeCaret = true, indent = true, caretAfterInsertedText = true)

View File

@@ -1,42 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.copy.PutData.TextData
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
class PutTextAfterCursorAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute(editor: Editor,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
val lastRegister = VimPlugin.getRegister().lastRegister
val textData = if (lastRegister != null) TextData(lastRegister.text, lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, insertTextBeforeCaret = false, _indent = true, caretAfterInsertedText = false, putToLine = -1)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -1,42 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.copy.PutData.TextData
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
class PutTextAfterCursorActionMoveCursor : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute(editor: Editor,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
val lastRegister = VimPlugin.getRegister().lastRegister
val textData = if (lastRegister != null) TextData(lastRegister.text, lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, false, _indent = true, caretAfterInsertedText = true, putToLine = -1)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -1,42 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.copy.PutData.TextData
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
class PutTextAfterCursorNoIndentAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute(editor: Editor,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
val lastRegister = VimPlugin.getRegister().lastRegister
val textData = if (lastRegister != null) TextData(lastRegister.text, lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, insertTextBeforeCaret = false, _indent = false, caretAfterInsertedText = false, putToLine = -1)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -1,42 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.copy.PutData.TextData
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
class PutTextBeforeCursorActionMoveCursor : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute(editor: Editor,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
val lastRegister = VimPlugin.getRegister().lastRegister
val textData = if (lastRegister != null) TextData(lastRegister.text, lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, insertTextBeforeCaret = true, _indent = true, caretAfterInsertedText = true, putToLine = -1)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -1,42 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.copy.PutData.TextData
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
class PutTextBeforeCursorNoIndentAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute(editor: Editor,
context: DataContext,
count: Int,
rawCount: Int,
argument: Argument?): Boolean {
val lastRegister = VimPlugin.getRegister().lastRegister
val textData = if (lastRegister != null) TextData(lastRegister.text, lastRegister.type, lastRegister.transferableData) else null
val putData = PutData(textData, null, count, insertTextBeforeCaret = true, _indent = false, caretAfterInsertedText = false, putToLine = -1)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -33,23 +33,33 @@ import java.util.*
/**
* @author vlan
*/
class PutVisualTextAction : VisualOperatorActionHandler.SingleExecution() {
sealed class PutVisualTextBaseAction(
private val insertTextBeforeCaret: Boolean,
private val indent: Boolean,
private val caretAfterInsertedText: Boolean
) : VisualOperatorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeForAllCarets(editor: Editor,
context: DataContext,
cmd: Command,
caretsAndSelections: Map<Caret, VimSelection>): Boolean {
override fun executeForAllCarets(editor: Editor, context: DataContext, cmd: Command, caretsAndSelections: Map<Caret, VimSelection>): Boolean {
if (caretsAndSelections.isEmpty()) return false
val textData = VimPlugin.getRegister().lastRegister?.let { PutData.TextData(it.text, it.type, it.transferableData) }
VimPlugin.getRegister().resetRegister()
val insertTextBeforeCaret = cmd.keys[0].keyChar == 'P'
val selection = PutData.VisualSelection(caretsAndSelections, caretsAndSelections.values.first().type)
val putData = PutData(textData, selection, cmd.count, insertTextBeforeCaret, _indent = true, caretAfterInsertedText = false)
val putData = PutData(textData, selection, cmd.count, insertTextBeforeCaret, indent, caretAfterInsertedText)
return VimPlugin.getPut().putText(editor, context, putData)
}
}
class PutVisualTextBeforeCursorAction: PutVisualTextBaseAction(insertTextBeforeCaret = true, indent = true, caretAfterInsertedText = false)
class PutVisualTextAfterCursorAction: PutVisualTextBaseAction(insertTextBeforeCaret = false, indent = true, caretAfterInsertedText = false)
class PutVisualTextBeforeCursorNoIndentAction: PutVisualTextBaseAction(insertTextBeforeCaret = true, indent = false, caretAfterInsertedText = false)
class PutVisualTextAfterCursorNoIndentAction: PutVisualTextBaseAction(insertTextBeforeCaret = false, indent = false, caretAfterInsertedText = false)
class PutVisualTextBeforeCursorMoveCursorAction: PutVisualTextBaseAction(insertTextBeforeCaret = true, indent = true, caretAfterInsertedText = true)
class PutVisualTextAfterCursorMoveCursorAction: PutVisualTextBaseAction(insertTextBeforeCaret = false, indent = true, caretAfterInsertedText = true)

View File

@@ -1,53 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
/**
* @author vlan
*/
class PutVisualTextMoveCursorAction : VisualOperatorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeForAllCarets(editor: Editor, context: DataContext, cmd: Command, caretsAndSelections: Map<Caret, VimSelection>): Boolean {
if (caretsAndSelections.isEmpty()) return false
val textData = VimPlugin.getRegister().lastRegister?.let { PutData.TextData(it.text, it.type, it.transferableData) }
VimPlugin.getRegister().resetRegister()
val insertTextBeforeCaret = cmd.keys[1].keyChar == 'P'
val selection = PutData.VisualSelection(caretsAndSelections, caretsAndSelections.values.first().type)
val putData = PutData(textData, selection, cmd.count, insertTextBeforeCaret, _indent = true, caretAfterInsertedText = true)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -1,53 +0,0 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.copy
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.group.copy.PutData
import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
/**
* @author vlan
*/
class PutVisualTextNoIndentAction : VisualOperatorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
override fun executeForAllCarets(editor: Editor, context: DataContext, cmd: Command, caretsAndSelections: Map<Caret, VimSelection>): Boolean {
if (caretsAndSelections.isEmpty()) return false
val textData = VimPlugin.getRegister().lastRegister?.let { PutData.TextData(it.text, it.type, it.transferableData) }
VimPlugin.getRegister().resetRegister()
val insertBeforeCaret = cmd.keys[1].keyChar == 'P'
val selection = PutData.VisualSelection(caretsAndSelections, caretsAndSelections.values.first().type)
val putData = PutData(textData, selection, cmd.count, insertBeforeCaret, _indent = false, caretAfterInsertedText = false)
return VimPlugin.getPut().putText(editor, context, putData)
}
}

View File

@@ -34,7 +34,7 @@ class VimEditorBackSpace : VimActionHandler.SingleExecution(), ComplicatedKeysAc
private val actionName: String = "EditorBackSpace"
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0))
)
@@ -85,7 +85,7 @@ class VimEditorTab : VimActionHandler.SingleExecution(), ComplicatedKeysAction {
private val actionName: String = "EditorTab"
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))
)

View File

@@ -28,8 +28,8 @@ import javax.swing.KeyStroke
class FilePreviousAction : VimActionHandler.SingleExecution(), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_6, KeyEvent.CTRL_MASK or KeyEvent.SHIFT_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_CIRCUMFLEX, KeyEvent.CTRL_MASK))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_6, KeyEvent.CTRL_DOWN_MASK or KeyEvent.SHIFT_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_CIRCUMFLEX, KeyEvent.CTRL_DOWN_MASK))
)
override val type: Command.Type = Command.Type.OTHER_READONLY

View File

@@ -19,73 +19,72 @@
package com.maddyhome.idea.vim.action.fold
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.IdeActions.ACTION_COLLAPSE_ALL_REGIONS
import com.intellij.openapi.actionSystem.IdeActions.ACTION_COLLAPSE_REGION
import com.intellij.openapi.actionSystem.IdeActions.ACTION_COLLAPSE_REGION_RECURSIVELY
import com.intellij.openapi.actionSystem.IdeActions.ACTION_EXPAND_ALL_REGIONS
import com.intellij.openapi.actionSystem.IdeActions.ACTION_EXPAND_REGION
import com.intellij.openapi.actionSystem.IdeActions.ACTION_EXPAND_REGION_RECURSIVELY
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.handler.VimActionHandler
class VimCollapseAllRegions : VimActionHandler.SingleExecution() {
val actionName: String = "CollapseAllRegions"
override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.executeAction(actionName, context)
KeyHandler.executeAction(ACTION_COLLAPSE_ALL_REGIONS, context)
return true
}
}
class VimCollapseRegion : VimActionHandler.SingleExecution() {
private val actionName: String = "CollapseRegion"
override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.executeAction(actionName, context)
KeyHandler.executeAction(ACTION_COLLAPSE_REGION, context)
return true
}
}
class VimCollapseRegionRecursively : VimActionHandler.SingleExecution() {
private val actionName: String = "CollapseRegionRecursively"
override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.executeAction(actionName, context)
KeyHandler.executeAction(ACTION_COLLAPSE_REGION_RECURSIVELY, context)
return true
}
}
class VimExpandAllRegions : VimActionHandler.SingleExecution() {
private val actionName: String = "ExpandAllRegions"
override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.executeAction(actionName, context)
KeyHandler.executeAction(ACTION_EXPAND_ALL_REGIONS, context)
return true
}
}
class VimExpandRegion : VimActionHandler.SingleExecution() {
private val actionName: String = "ExpandRegion"
override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.executeAction(actionName, context)
KeyHandler.executeAction(ACTION_EXPAND_REGION, context)
return true
}
}
class VimExpandRegionRecursively : VimActionHandler.SingleExecution() {
private val actionName: String = "ExpandRegionRecursively"
override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
KeyHandler.executeAction(actionName, context)
KeyHandler.executeAction(ACTION_EXPAND_REGION_RECURSIVELY, context)
return true
}
}

View File

@@ -39,8 +39,9 @@ import java.awt.RenderingHints
import java.awt.font.FontRenderContext
import java.util.*
import javax.swing.UIManager
import kotlin.math.max
class AddInlaysAction : AnAction() {
class AddBlockInlaysAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val dataContext = e.dataContext
val editor = getEditor(dataContext) ?: return
@@ -94,7 +95,7 @@ class AddInlaysAction : AnAction() {
private fun getFontMetrics(editor: Editor): MyFontMetrics {
val familyName = UIManager.getFont("Label.font").family
val size = (Math.max(1, editor.colorsScheme.editorFontSize - 1) * factor).toInt()
val size = (max(1, editor.colorsScheme.editorFontSize - 1) * factor).toInt()
var metrics = editor.getUserData(HINT_FONT_METRICS)
if (metrics != null && !metrics.isActual(editor, familyName, size)) {
metrics = null
@@ -110,7 +111,7 @@ class AddInlaysAction : AnAction() {
return if (text == null) 0 else fontMetrics.stringWidth(text)
}
private inner class MyFontMetrics internal constructor(editor: Editor, familyName: String?, size: Int) {
private inner class MyFontMetrics(editor: Editor, familyName: String?, size: Int) {
val metrics: FontMetrics
fun isActual(editor: Editor, familyName: String, size: Int): Boolean {
val font = metrics.font

View File

@@ -0,0 +1,58 @@
/*
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
* Copyright (C) 2003-2020 The IdeaVim authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.maddyhome.idea.vim.action.internal
import com.intellij.codeInsight.daemon.impl.HintRenderer
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.VisualPosition
import com.maddyhome.idea.vim.helper.EditorHelper
import java.util.*
import kotlin.math.max
class AddInlineInlaysAction : AnAction() {
companion object {
private val random = Random()
}
override fun actionPerformed(e: AnActionEvent) {
val dataContext = e.dataContext
val editor = getEditor(dataContext) ?: return
val inlayModel = editor.inlayModel
val currentVisualLine = editor.caretModel.primaryCaret.visualPosition.line
var i = random.nextInt(10)
val lineLength = EditorHelper.getLineLength(editor, EditorHelper.visualLineToLogicalLine(editor, currentVisualLine))
while (i < lineLength) {
val relatesToPrecedingText = random.nextInt(10) > 7
val text = "a".repeat(max(1, random.nextInt(7)))
val offset = EditorHelper.visualPositionToOffset(editor, VisualPosition(currentVisualLine, i))
// We don't need a custom renderer, just use the standard parameter hint renderer
inlayModel.addInlineElement(offset, relatesToPrecedingText, HintRenderer(if (relatesToPrecedingText) ":$text" else "$text:"))
// Every 20 chars +/- 5 chars
i += 20 + (random.nextInt(10) - 5)
}
}
private fun getEditor(dataContext: DataContext): Editor? {
return CommonDataKeys.EDITOR.getData(dataContext)
}
}

View File

@@ -23,12 +23,9 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
import javax.swing.KeyStroke
/**
* @author Alex Plate
@@ -36,7 +33,7 @@ import javax.swing.KeyStroke
class GnNextTextObject : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
if (caret != editor.caretModel.primaryCaret) return null

View File

@@ -23,11 +23,9 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
/**
* @author Alex Plate
@@ -35,7 +33,8 @@ import java.util.*
class GnPreviousTextObject : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
if (caret != editor.caretModel.primaryCaret) return null
val range = VimPlugin.getSearch().getNextSearchRange(editor, count, false)

View File

@@ -36,7 +36,7 @@ class MotionArrowLeftAction : NonShiftedSpecialKeyHandler(), ComplicatedKeysActi
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(parseKeys("<Left>"), listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0)))
override fun offset(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretHorizontal(editor, caret, -count, false)
return VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, -count, false)
}
}

View File

@@ -27,6 +27,8 @@ import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.MotionType
import com.maddyhome.idea.vim.handler.NonShiftedSpecialKeyHandler
import com.maddyhome.idea.vim.helper.StringHelper.parseKeys
import com.maddyhome.idea.vim.helper.commandState
import com.maddyhome.idea.vim.helper.isEndAllowed
import java.awt.event.KeyEvent
import javax.swing.KeyStroke
@@ -39,7 +41,8 @@ class MotionArrowRightAction : NonShiftedSpecialKeyHandler(), ComplicatedKeysAct
)
override fun offset(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretHorizontal(editor, caret, count, false)
val allowPastEnd = editor.commandState.mode.isEndAllowed
return VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, count, allowPastEnd)
}
}

View File

@@ -38,7 +38,7 @@ class MotionLeftAction : MotionActionHandler.ForEachCaret() {
count: Int,
rawCount: Int,
argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretHorizontal(editor, caret, -count, false)
return VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, -count, false)
}
}
@@ -56,6 +56,6 @@ class MotionLeftInsertModeAction : MotionActionHandler.ForEachCaret(), Complicat
count: Int,
rawCount: Int,
argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretHorizontal(editor, caret, -count, false)
return VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, -count, false)
}
}

View File

@@ -38,7 +38,7 @@ class MotionRightAction : MotionActionHandler.ForEachCaret() {
count: Int,
rawCount: Int,
argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretHorizontal(editor, caret, count, true)
return VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, count, true)
}
}
@@ -56,6 +56,6 @@ class MotionRightInsertAction : MotionActionHandler.ForEachCaret(), ComplicatedK
count: Int,
rawCount: Int,
argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretHorizontal(editor, caret, count, true)
return VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, count, true)
}
}

View File

@@ -36,7 +36,7 @@ class MotionShiftLeftAction : ShiftedArrowKeyHandler() {
override fun motionWithKeyModel(editor: Editor, context: DataContext, cmd: Command) {
editor.vimForEachCaret { caret ->
val vertical = VimPlugin.getMotion().moveCaretHorizontal(editor, caret, -cmd.count, true)
val vertical = VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, -cmd.count, true)
MotionGroup.moveCaret(editor, caret, vertical)
}
}

View File

@@ -36,7 +36,7 @@ class MotionShiftRightAction : ShiftedArrowKeyHandler() {
override fun motionWithKeyModel(editor: Editor, context: DataContext, cmd: Command) {
editor.vimForEachCaret { caret ->
val vertical = VimPlugin.getMotion().moveCaretHorizontal(editor, caret, cmd.count, true)
val vertical = VimPlugin.getMotion().getOffsetOfHorizontalMotion(editor, caret, cmd.count, true)
MotionGroup.moveCaret(editor, caret, vertical)
}
}

View File

@@ -29,11 +29,11 @@ import com.maddyhome.idea.vim.handler.MotionActionHandler
import java.util.*
class MotionGotoFileMarkLineAction : MotionActionHandler.ForEachCaret() {
override val motionType: MotionType = MotionType.INCLUSIVE
override val motionType: MotionType = MotionType.LINE_WISE
override val argumentType: Argument.Type = Argument.Type.CHARACTER
override val flags: EnumSet<CommandFlags> = EnumSet.of(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_SAVE_JUMP)
override val flags: EnumSet<CommandFlags> = EnumSet.of(CommandFlags.FLAG_SAVE_JUMP)
override fun getOffset(editor: Editor,
caret: Caret,
@@ -49,12 +49,10 @@ class MotionGotoFileMarkLineAction : MotionActionHandler.ForEachCaret() {
}
class MotionGotoFileMarkLineNoSaveJumpAction : MotionActionHandler.ForEachCaret() {
override val motionType: MotionType = MotionType.INCLUSIVE
override val motionType: MotionType = MotionType.LINE_WISE
override val argumentType: Argument.Type = Argument.Type.CHARACTER
override val flags: EnumSet<CommandFlags> = EnumSet.of(CommandFlags.FLAG_MOT_LINEWISE)
override fun getOffset(editor: Editor,
caret: Caret,
context: DataContext,

View File

@@ -29,11 +29,11 @@ import com.maddyhome.idea.vim.handler.MotionActionHandler
import java.util.*
class MotionGotoMarkLineAction : MotionActionHandler.ForEachCaret() {
override val motionType: MotionType = MotionType.INCLUSIVE
override val motionType: MotionType = MotionType.LINE_WISE
override val argumentType: Argument.Type = Argument.Type.CHARACTER
override val flags: EnumSet<CommandFlags> = EnumSet.of(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_SAVE_JUMP)
override val flags: EnumSet<CommandFlags> = EnumSet.of(CommandFlags.FLAG_SAVE_JUMP)
override fun getOffset(editor: Editor,
caret: Caret,
@@ -49,12 +49,10 @@ class MotionGotoMarkLineAction : MotionActionHandler.ForEachCaret() {
}
class MotionGotoMarkLineNoSaveJumpAction : MotionActionHandler.ForEachCaret() {
override val motionType: MotionType = MotionType.INCLUSIVE
override val motionType: MotionType = MotionType.LINE_WISE
override val argumentType: Argument.Type = Argument.Type.CHARACTER
override val flags: EnumSet<CommandFlags> = EnumSet.of(CommandFlags.FLAG_MOT_LINEWISE)
override fun getOffset(editor: Editor,
caret: Caret,
context: DataContext,

View File

@@ -23,15 +23,13 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class MotionInnerBigWordAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor,
caret: Caret,

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionInnerBlockAngleAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor,
caret: Caret,

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionInnerBlockBackQuoteAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor,
caret: Caret,

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionInnerBlockBraceAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor,
caret: Caret,

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionInnerBlockBracketAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor,
caret: Caret,

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionInnerBlockDoubleQuoteAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor,
caret: Caret,

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionInnerBlockParenAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockRange(editor, caret, count, false, '(')

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionInnerBlockSingleQuoteAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockQuoteRange(editor, caret, '\'', false)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionInnerBlockTagAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockTagRange(editor, caret, count, false)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionInnerParagraphAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.LINE_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getParagraphRange(editor, caret, count, false)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -34,6 +35,8 @@ class MotionInnerSentenceAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getSentenceRange(editor, caret, count, false)
}

View File

@@ -23,15 +23,13 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class MotionInnerWordAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getWordRange(editor, caret, count, false, false)

View File

@@ -23,16 +23,14 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class MotionOuterBigWordAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getWordRange(editor, caret, count, true, true)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionOuterBlockAngleAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockRange(editor, caret, count, true, '<')

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionOuterBlockBackQuoteAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockQuoteRange(editor, caret, '`', true)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionOuterBlockBraceAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockRange(editor, caret, count, true, '{')

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionOuterBlockBracketAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockRange(editor, caret, count, true, '[')

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionOuterBlockDoubleQuoteAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockQuoteRange(editor, caret, '"', true)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionOuterBlockParenAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockRange(editor, caret, count, true, '(')

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionOuterBlockSingleQuoteAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockQuoteRange(editor, caret, '\'', true)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -31,7 +32,9 @@ import java.util.*
class MotionOuterBlockTagAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getBlockTagRange(editor, caret, count, true)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -32,7 +33,9 @@ import java.util.*
class MotionOuterParagraphAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_TEXT_BLOCK)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.LINE_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getParagraphRange(editor, caret, count, true)

View File

@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
@@ -34,6 +35,8 @@ class MotionOuterSentenceAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_TEXT_BLOCK)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getSentenceRange(editor, caret, count, true)
}

View File

@@ -23,16 +23,14 @@ import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.CommandFlags
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class MotionOuterWordAction : TextObjectActionHandler() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_CHARACTERWISE)
override val visualType: TextObjectVisualType = TextObjectVisualType.CHARACTER_WISE
override fun getRange(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): TextRange? {
return VimPlugin.getMotion().getWordRange(editor, caret, count, true, false)

View File

@@ -29,7 +29,9 @@ import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.*
class MotionFirstScreenLineAction : MotionActionHandler.ForEachCaret() {
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_SAVE_JUMP)
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_JUMP)
override val motionType: MotionType = MotionType.LINE_WISE
override fun getOffset(editor: Editor,
caret: Caret,
@@ -39,6 +41,4 @@ class MotionFirstScreenLineAction : MotionActionHandler.ForEachCaret() {
argument: Argument?): Int {
return VimPlugin.getMotion().moveCaretToFirstScreenLine(editor, count)
}
override val motionType: MotionType = MotionType.INCLUSIVE
}

Some files were not shown because too many files have changed in this diff Show More