added vscode extensions

This commit is contained in:
tomit4 2021-11-05 11:26:45 -07:00
parent 7cde0829be
commit 26e2a50441
316 changed files with 37301 additions and 0 deletions

View file

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [asvetliakov, theol0403]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View file

@ -0,0 +1,66 @@
name: Code Check & Test
on:
pull_request:
branches:
- master
jobs:
build:
name: Build & Test
strategy:
matrix:
# os: [macos-latest, ubuntu-latest, windows-latest]
# CI windows have some issues, i'm not sure why
os: [macos-latest, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "12"
- name: Install Neovim
uses: rhysd/action-setup-vim@v1
id: vim
with:
neovim: true
version: nightly
- name: Yarn install
run: yarn --silent --frozen-lockfile
- name: Build
run: yarn run test-compile
- name: Webpack
run: yarn run webpack
- name: Lint
run: yarn run lint
- name: Test
uses: GabrielBB/xvfb-action@v1.4
env:
NEOVIM_PATH: ${{ steps.vim.outputs.executable }}
NEOVIM_DEBUG: 1
NEOVIM_DEBUG_HOST: 127.0.0.1
NEOVIM_DEBUG_PORT: 4000
with:
run: yarn run test
create:
name: Create extension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "12"
- name: Yarn install
run: yarn --silent --frozen-lockfile
- name: Install VSCE
run: yarn add vsce
- name: Create extension
run: yarn run vsce package -o vscode-neovim-${{github.sha}}.vsix
- name: Upload extension
if: runner.os == 'Linux'
uses: actions/upload-artifact@v2
with:
name: vscode-neovim
path: vscode-neovim-${{github.sha}}.vsix

View file

@ -0,0 +1,10 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
printWidth: 120,
tabWidth: 4,
singleQuote: false,
proseWrap: "always"
};

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Language="en-US" Id="vscode-neovim" Version="0.0.82" Publisher="asvetliakov"/>
<DisplayName>VSCode Neovim</DisplayName>
<Description xml:space="preserve">VSCode Neovim Integration</Description>
<Tags>keybindings,vi,vim,neovim</Tags>
<Categories>Other,Keymaps</Categories>
<GalleryFlags>Public</GalleryFlags>
<Badges></Badges>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.54.0" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="ui" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/asvetliakov/vscode-neovim" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/asvetliakov/vscode-neovim" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/asvetliakov/vscode-neovim" />
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/asvetliakov/vscode-neovim/issues" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
</Properties>
<License>extension/LICENSE.txt</License>
<Icon>extension/images/icon.png</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.txt" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/images/icon.png" Addressable="true" />
</Assets>
</PackageManifest>

View file

@ -0,0 +1,278 @@
# Change Log
## [0.0.82]
- Big updates to keybindings ! ( [#513](https://github.com/asvetliakov/vscode-neovim/issues/513) , [#654](https://github.com/asvetliakov/vscode-neovim/issues/654) , [#557](https://github.com/asvetliakov/vscode-neovim/issues/557) , [#585](https://github.com/asvetliakov/vscode-neovim/issues/585) , [#655](https://github.com/asvetliakov/vscode-neovim/issues/655) )
## [0.0.81]
- Revert ( [#649](https://github.com/asvetliakov/vscode-neovim/issues/649) )
## [0.0.80]
- Improve cursor position behaviour ( [#649](https://github.com/asvetliakov/vscode-neovim/issues/649) )
## [0.0.79]
- Fix infinity file opened loop on recent neovim versions ( [#632](https://github.com/asvetliakov/vscode-neovim/issues/632) )
## [0.0.78]
- Fix init error with no workspace folders open ( [#526](https://github.com/asvetliakov/vscode-neovim/issues/526) )
- Update README.md ( [#527](https://github.com/asvetliakov/vscode-neovim/issues/527) )
## [0.0.77]
- Fix cursor with tab indentation ( [#516](https://github.com/asvetliakov/vscode-neovim/issues/516) , [#515](https://github.com/asvetliakov/vscode-neovim/issues/515) )
- Handle correctly WSL path with spaces ( [#509](https://github.com/asvetliakov/vscode-neovim/issues/509) )
## [0.0.76]
- Fix mutli-column character handling ( [#503](https://github.com/asvetliakov/vscode-neovim/issues/503) )
## [0.0.75]
- Improvements to cursor logic ( [#501](https://github.com/asvetliakov/vscode-neovim/issues/501) )
- Cancel current mode when switching editor ( [#156](https://github.com/asvetliakov/vscode-neovim/issues/156) )
## [0.0.74]
- Fix cursor logic ( [#467](https://github.com/asvetliakov/vscode-neovim/issues/467) , [#488](https://github.com/asvetliakov/vscode-neovim/issues/488) )
- Trigger matching word highlight after movement ( [#159](https://github.com/asvetliakov/vscode-neovim/issues/159) )
- VIM highlight adjustments ( [#482](https://github.com/asvetliakov/vscode-neovim/issues/482) )
## [0.0.73]
- Improve cursor reveailing logic ( [#479](https://github.com/asvetliakov/vscode-neovim/issues/479) )
- Hook g0 / g\$ ( [#455](https://github.com/asvetliakov/vscode-neovim/issues/455) )
## [0.0.72]
- Fix undo regression introduced in `0.0.70`
## [0.0.71]
- Fix `Unable to determine neovim windows id` error spam ( [#418](https://github.com/asvetliakov/vscode-neovim/issues/418) )
## [0.0.70]
- Use vscode jumplist actions instead of neovim
- Fix uppercase marks ( [#228](https://github.com/asvetliakov/vscode-neovim/issues/228) )
- Various cursor & buffer management fixes ( [#404](https://github.com/asvetliakov/vscode-neovim/issues/404) , [#392](https://github.com/asvetliakov/vscode-neovim/issues/392) , [#386](https://github.com/asvetliakov/vscode-neovim/issues/386) )
- Implement manageEditorHeight and manageEditorWidth ( [#444](https://github.com/asvetliakov/vscode-neovim/issues/444) )
- Fix `<C-a>` in insert mode ( [#283](https://github.com/asvetliakov/vscode-neovim/issues/283) )
- Set vim cwd as vscode workspace ( [#429](https://github.com/asvetliakov/vscode-neovim/issues/429) )
- Fix shell-agnostic WSL integration ( [#147](https://github.com/asvetliakov/vscode-neovim/issues/147) )
- Map :x to Wq ( [#396](https://github.com/asvetliakov/vscode-neovim/issues/396) )
- Various docs contributions
- Improve build ( [#378](https://github.com/asvetliakov/vscode-neovim/issues/378) )
## [0.0.63]
- Allow to put text decorations (usually EasyMotion ones) at top setting (`vscode-neovim.textDecorationsAtTop`) ( [#358](https://github.com/asvetliakov/vscode-neovim/issues/358) ), contributed by @jhgarner
- Fix incorrect `<C-w><C-w>/<C-w>w` mappings ( [#359](https://github.com/asvetliakov/vscode-neovim/issues/359) ), contributed by @tschaei
- Replace/modernize neovim vscode command line interop mappings by `<Cmd>call` ( [#362](https://github.com/asvetliakov/vscode-neovim/issues/362) ), contributed by @theol0403
- Fix incorrect `<C-w>gf` mapping ( [#365](https://github.com/asvetliakov/vscode-neovim/issues/365) ), contributed by @Yuuki77
- Fix applying vim HL (such as `MatchParen`) at end of a line ( [#371](https://github.com/asvetliakov/vscode-neovim/issues/371) )
- Fix incorrect cursor position when selecting next/prev search result ( [#366](https://github.com/asvetliakov/vscode-neovim/issues/366) )
- Fix/improve behavior of auto-accepting vim return prompt `Press enter to continue`. In some cases it was excess ( [#372](https://github.com/asvetliakov/vscode-neovim/issues/372) )
- Bundle extension by webpack ( [#377](https://github.com/asvetliakov/vscode-neovim/issues/377) )
## [0.0.62]
- Fix jumplist ( [#350](https://github.com/asvetliakov/vscode-neovim/issues/350) )
- Add `K` and `gO` mappings (mapped to `showHover` and `goToSymbol`) ( [#108](https://github.com/asvetliakov/vscode-neovim/issues/108) ) (@Shatur95)
- Fix images/icon (@Shatur95)
## [0.0.60/61]
Started from this version `neovim 0.5` nightly version is required
Many things have been refactored/changed internally in this release. So if you see any regression - please fill an issue
- Turn on VIM smartindenting/autoindenting and remove custom vscode bindings to `o`/`O` (so it uses VIM ones)
- New buffer,window and cursor management. This makes the extension finally work with git diff view, peek views, search editor views and even in output channels! ( [#53](https://github.com/asvetliakov/vscode-neovim/issues/53) , [#187](https://github.com/asvetliakov/vscode-neovim/issues/187) , [#220](https://github.com/asvetliakov/vscode-neovim/issues/220) , [#223](https://github.com/asvetliakov/vscode-neovim/issues/223), [#226](https://github.com/asvetliakov/vscode-neovim/issues/226))
- Implement multi-line messages pager. Things like `:registers`, `:changes`, `:jumps`, `:messages` are working correctly now ( [#202](https://github.com/asvetliakov/vscode-neovim/issues/202) , [#78](https://github.com/asvetliakov/vscode-neovim/issues/78) , [#296](https://github.com/asvetliakov/vscode-neovim/issues/296) )
- Fix tab indent problems and sync vscode tab settings with neovim ( [#275](https://github.com/asvetliakov/vscode-neovim/issues/275) , [#239](https://github.com/asvetliakov/vscode-neovim/issues/239) , [#264](https://github.com/asvetliakov/vscode-neovim/issues/264) , [#167](https://github.com/asvetliakov/vscode-neovim/issues/167) , [#100](https://github.com/asvetliakov/vscode-neovim/issues/100) , [#152](https://github.com/asvetliakov/vscode-neovim/issues/152) , [#289](https://github.com/asvetliakov/vscode-neovim/issues/289) )
- Fix few macro recording problems ( [#207](https://github.com/asvetliakov/vscode-neovim/issues/207) )
- Fix ghost keys after exiting insert mode ( [#324](https://github.com/asvetliakov/vscode-neovim/issues/324) ). For `jj` / `jk` users there are still few problems ( [#330](https://github.com/asvetliakov/vscode-neovim/issues/330) ) but they will be sorted in next releases
- Fix few command line problems ( [#155](https://github.com/asvetliakov/vscode-neovim/issues/155) , [#288](https://github.com/asvetliakov/vscode-neovim/issues/288) )
- Fix some buffer desync issues ( [#312](https://github.com/asvetliakov/vscode-neovim/issues/312) )
- Fix `<C-w>v/<C-w>s` split shortcuts ( [#331](https://github.com/asvetliakov/vscode-neovim/issues/331) )
- Fix brackets for substitute command ( [#300](https://github.com/asvetliakov/vscode-neovim/issues/300) )
- Add logger and log-related configuration to options
- Change some default code-actions mappings ( [#339](https://github.com/asvetliakov/vscode-neovim/issues/339) )
- Add extension icon. Many thanks to https://github.com/ngscheurich
## [0.0.52]
- Implement dot repeat (`.`) command ( [#209](https://github.com/asvetliakov/vscode-neovim/issues/209) , [#173](https://github.com/asvetliakov/vscode-neovim/issues/173) ). Also fixes `<count>` insert comamnds, like [#255](https://github.com/asvetliakov/vscode-neovim/issues/255) , [#249](https://github.com/asvetliakov/vscode-neovim/issues/249)
- Removed file name from statusbar ( [#291](https://github.com/asvetliakov/vscode-neovim/issues/291) , [#230](https://github.com/asvetliakov/vscode-neovim/issues/230) ), thanks @Shatur95
- Fix visual selection conversion ( [#233](https://github.com/asvetliakov/vscode-neovim/issues/233) ), thanks @Shatur95
- Fix wrong string comparsions ( [#308](https://github.com/asvetliakov/vscode-neovim/issues/308) ), thanks @Shatur95
- Make espace keys work only when editor has focus ( [#290](https://github.com/asvetliakov/vscode-neovim/issues/290) ) , thanks @David-Else
- Added some file name completion in commandline ( [#192](https://github.com/asvetliakov/vscode-neovim/issues/192) ), thanks @ppwwyyxx
- Fix missing `<C-w>c` mapping ( [#180](https://github.com/asvetliakov/vscode-neovim/issues/180) ), thanks @trkoch
- Add operating system dependent path settings ( [#137](https://github.com/asvetliakov/vscode-neovim/issues/137) ), thanks @3nuc
- bind gh to mousehover ( [#107](https://github.com/asvetliakov/vscode-neovim/issues/107) ), thanks @kwonoj
## [0.0.50]
- Fix cursor & extension hang for some cases ( [#153](https://github.com/asvetliakov/vscode-neovim/issues/153) )
## [0.0.49]
- Use command line completion only for command line originated via `:` command ( [#146](https://github.com/asvetliakov/vscode-neovim/issues/146) )
## [0.0.48]
- Fix incorrect cursor for multibyte single column width characters ( [#142](https://github.com/asvetliakov/vscode-neovim/issues/142) )
- Fix vim-easymotion decorators drifting when text has multi-byte characters ( [#144](https://github.com/asvetliakov/vscode-neovim/issues/144) )
- Disabled vim modeline processing
- Force vim folds to be always opened to prevent problems
- Fix vim-easymotion decorators drifting to the end of line ( [#60](https://github.com/asvetliakov/vscode-neovim/issues/60) )
- Fix incorrect cursor positions after commands/mappings such as `>gv` ( [#141](https://github.com/asvetliakov/vscode-neovim/issues/141) )
- Fix double command prompt ( [#120](https://github.com/asvetliakov/vscode-neovim/issues/120) )
## [0.0.47]
- Fix the problem when cursor/extension stucks for second+ editor columns ( [#126](https://github.com/asvetliakov/vscode-neovim/issues/126) )
## [0.0.46]
- Update `neovim-client` to latest version. This should eliminate delay between operations and generally improve the performance. Kudos to @kwonoj for impressive work here
- Fix cursor movement for 2-byte chars ( [#127](https://github.com/asvetliakov/vscode-neovim/issues/127) )
## [0.0.45]
- Fix VIM filetype detection ( [#115](https://github.com/asvetliakov/vscode-neovim/issues/115) ). This means `FileType` autocmd should work correctly now. Also fixes `vim-matchup` plugin. This may introduce some side effects from previously disabled filetype plugins - just fill an issue if something doesn't work
- Fix broken cursor position in insert mode for special keys (such as `del`/`backspace`/etc) if you had recorded a macro in insert mode previously
## [0.0.44]
- Hotfix broken `VSCodeCallRange` (commenting/formatting didn't work because of this)
## [0.0.43]
- Visual modes DON'T produce vscode selections right now. These were implemented through various workarounds, gave really small value and were constant origin of headache. Also this fixes few issues related to visual modes ( [#105](https://github.com/asvetliakov/vscode-neovim/issues/105), [#118](https://github.com/asvetliakov/vscode-neovim/issues/118) ). To round the corners, invoking vscode's command palette (by using default vscode hotkeys) from visual mode will convert neovim visual selection to vscode visual selection, this should cover most use cases. Also, there are `VScodeNotifyRange`/`VSCodeCallRange`/`VSCodeNotifyRangePos`/`VSCodeCallRangePos` vim functions if you need to call vscode command with selection. See [this for example](https://github.com/asvetliakov/vscode-neovim/blob/e61832119988bb1e73b81df72956878819426ce2/vim/vscode-code-actions.vim#L42-L54) and [mapping](https://github.com/asvetliakov/vscode-neovim/blob/e61832119988bb1e73b81df72956878819426ce2/vim/vscode-code-actions.vim#L98) if you're doing custom mappings and assuming there is some vscode selection exist. Use `VSCodeNotifyRange` when you don't need a column pos (e.g. for visual line mode) and `VSCodeNotifyRangePos` when you need them (e.g for visual mode).
- Refactored vscode<->neovim cursor syncrhonization
- Fix `ma`/`mi` not working when selecting lines upward ( [#117](https://github.com/asvetliakov/vscode-neovim/issues/117) )
- Changed `ma`/`mi` to skip empty lines. Added `mA`/`mI` for the previous behavior
- Macro recording fixes
- Refactored & optimized HL provider (highlight should be faster now)
- Override default keybindings only when neovim was initialized succesfully ( [#112](https://github.com/asvetliakov/vscode-neovim/issues/112) )
- Don't preselect `'<,'>` marks when invoking cmdline from visual line ( [#111](https://github.com/asvetliakov/vscode-neovim/issues/111) )
- Implemented commandline history ( [#88](https://github.com/asvetliakov/vscode-neovim/issues/88) )
- Add the option to start the visual mode with mouse selection ( [#94](https://github.com/asvetliakov/vscode-neovim/issues/94) )
## [0.0.42]
- Disabled jj/jk escape keys by default
## [0.0.40]
- Fix cursor/highlight not working with multi-byte width characters (Russian, Chinese, Japanese, etc...), i.e the extension should work normally with them (#68, [#91](https://github.com/asvetliakov/vscode-neovim/issues/91))
- Fix incorrect vim highlight when using tab indentation (#81)
- Removed multiple cursors by default from visual line/block modes (visual block mode still spawns cursors but they are pruly visual) (#59, [#61](https://github.com/asvetliakov/vscode-neovim/issues/61)). Previous behavior is still accessible by `mi` or `ma` keybindings while in visual line/block modes
- Allow to override keys/mappings set by extension (previously they have been set after user config loaded)
- Allow to identify if neovim is running through vscode extension by checking `if exists('g:vscode')` (#83)
- Added `<C-[>` and `Escape` as escape keys (#74)
- Added `<C-n>` and `<C-p>` to select next autocomplete suggestion/show next/prev parameter hint
- Added `jj` and `jk` as escape keys from the insert mode (#75)
- Pass `<C-/>` to neovim and call VSCodeCommentary (still recommended to bind it to own keys) (#89)
- Pass `<S-Tab>` to neovim
- Allow to pass additional ctrl keys to neovim (see Readme)
- Added workaround for `gk`/`gj` motions
- Corrected `gf`/`gF` keybindings. Add `<C-]>` as go-to-def (works in help too) (#77). Add `gd`/`gD` as secondary mappings to go-to-def/peek-def. Add `<C-w>gd` to reveal definition aside
## [0.0.39]
- Fix bug with incorrect buffer edits
- Fix cursor jumping after pressing something like `cw` and fast typing text in large file
## [0.0.38]
- Fix cursor position after deleting a line and possibly other operations
## [0.0.37]
- Fix performance of o/O. If you're using custom bindings for them, you might need to rebind them to call new action. See vscode-insert.vim
## [0.0.36]
- Fix macros with insert mode
- Big performance improvements, fix undo & macros performance
- Allow to use neovim installed in WSL. Tick useWSL conf checkbox and specify linux path to neovim
## [0.0.35]
- Use VIM jumplist for `<C-o>`/`<C-i>`/`<Tab>`
## [0.0.33-0.0.34]
- Fix extension for linux/macos users
- Fix buffer-vscode desynchornization after redo
## [0.0.32]
- Cmdline fixes/improvements (#50, [#51](https://github.com/asvetliakov/vscode-neovim/issues/51))
## [0.0.31]
- Fix crazy cursor jumping when having opened multiple editors panes
## [0.0.30]
- Implemented nvim's ext_multigrid support. This solves almost all problems with vim highlighting and potentially enables easymotion's overwin motions (they still don't work however). Window management still should be performed by vscode
- Removed vim-style cursor following on editor scrolling. This totally screwed vscode jumplist, so better to have working jumplist than such minor feature.
- Cursor position fixes
- `:e [filepath]` works again
## [0.0.29]
- Fix selection is being reset in visual mode after typing `vk$` (#48)
- Fix not cleaning incsearch highlight after canceling the incsearch (#46)
- Fix incorrect cursor after switching the editor to the same document but in different editor column (#49)
## [0.0.28]
- Use non-blocking rpc requests when communicatings with vscode for file management operations (closing, opening, etc...). Should eliminate the issue when vim is 'stuck' and doesn't respond anymore
- Fix incorrect cursor positions after opening `:help something` (#44)
- Fix visual block selection for single column in multiple rows (#42)
- Enable VIM syntax highlighting for help files and external buffers like `:PlugStatus`. It's slow and sometimes buggy but better than nothing in meantime
## [0.0.27]
- Fix incsearch and allow to use `<C-t>`/`<C-g>` with it
- Reworked/Refactored command line. Now with wildmenu completion support. Also keys like `<C-w>` or `<C-u>` are working fine now in cmdline now
## [0.0.26]
- Partially revert [#41](https://github.com/asvetliakov/vscode-neovim/issues/41)
## [0.0.25]
- Tab management commands & keys, like `gt` or `tabo[nly]`
- Window management commands & keys like `sp[lit]`/`vs[plit]` and `<C-w> j/k/l/h` keys
- Bind scroll commands in neovim instead of vscode extension ([#41](https://github.com/asvetliakov/vscode-neovim/issues/41))
## [0.0.24]
- File management commands, like `:w` or `:q` (bound to vscode actions)
- Fix [#40](https://github.com/asvetliakov/vscode-neovim/issues/40)
## [0.0.1-0.0.23]
- A bunch of development versions. 0.0.23 has the following features
- Correct editing and the cursor management
- Control keys in the insert & normal/visual modes
- Visual mode produces vscode selections
- Working VIM highlighting (most of a default VIM HL groups are ignored since they don't make sense in VSCode, but non standard groups are processed, so things like vim-easymotion or vim-highlight are working fine)
- Scrolling commands (scrolling is done by vscode so things are slighly different here)
- Special vim-easymotion fork to use vscode text decorators instead of replacing text (as original vim-easymotion does)
- Analogue of vim-commentary (original vim-commentary works fine too)
- Working external vim buffers, like `:help` or `:PlugStatus`
- Multiple cursors for visual line/visual block modes
## [0.0.1]
- Initial release

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Alexey Svetliakov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,593 @@
<h2 align="center"><img src="https://github.com/asvetliakov/vscode-neovim/raw/HEAD/./images/icon.png" height="128"><br>VSCode Neovim</h2>
<p align="center"><strong>VSCode Neovim Integration</strong></p>
<p align=center>
<a href="https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim"><img src="https://vsmarketplacebadge.apphb.com/version/asvetliakov.vscode-neovim.svg"></a>
<a href="https://github.com/asvetliakov/vscode-neovim/actions/workflows/build_test.yml"><img src="https://github.com/asvetliakov/vscode-neovim/workflows/Code%20Check%20&%20Test/badge.svg"></a>
<a href="https://gitter.im/vscode-neovim/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/vscode-neovim/community.svg"></a>
</p>
[Neovim](https://neovim.io/) is a fork of VIM to allow greater extensibility and integration. This extension uses a full
embedded Neovim instance, no more half-complete VIM emulation! VSCode's native functionality is used for insert mode and
editor commands, making the best use of both editors.
- 🎉 Almost fully feature-complete VIM integration by utilizing neovim as a backend.
- 🔧 Supports custom `init.vim` and many vim plugins.
- 🥇 First-class and lag-free insert mode, letting VSCode do what it does best.
- 🤝 Complete integration with VSCode features (lsp/autocompletion/snippets/multi-cursor/etc).
<details>
<summary><strong>Table of Contents</strong> (click to expand)</summary>
- [🧰 Installation](#-installation)
- [💡 Tips and Features](#-tips-and-features)
- [Important](#important)
- [VSCode specific differences](#vscode-specific-differences)
- [Performance problems](#performance-problems)
- [Conditional init.vim](#conditional-initvim)
- [Custom escape keys](#custom-escape-keys)
- [Jumplist](#jumplist)
- [Wildmenu completion](#wildmenu-completion)
- [Multiple cursors](#multiple-cursors)
- [Keyboard Quickfix](#keyboard-quickfix)
- [Invoking VSCode actions from neovim](#invoking-vscode-actions-from-neovim)
- [Examples](#examples)
- [⌨️ Bindings](#-bindings)
- [File management](#file-management)
- [Tab management](#tab-management)
- [Buffer/window management](#bufferwindow-management)
- [Insert mode special keys](#insert-mode-special-keys)
- [Normal mode control keys](#normal-mode-control-keys)
- [Cmdline special keys](#cmdline-special-keys)
- [VSCode specific bindings](#vscode-specific-bindings)
- [Editor command](#editor-command)
- [Explorer/list navigation](#explorerlist-navigation)
- [Explorer file manipulation](#explorer-file-manipulation)
- [Custom keybindings](#custom-keybindings)
- [🤝 Vim Plugins](#-vim-plugins)
- [vim-easymotion](#vim-easymotion)
- [vim-commentary](#vim-commentary)
- [quick-scope](#quick-scope)
- [📑 How it works](#-how-it-works)
- [❤️ Credits & External Resources](#-credits--external-resources)
</details>
## 🧰 Installation
- Install the [vscode-neovim](https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim)
extension.
- Install [Neovim](https://github.com/neovim/neovim/wiki/Installing-Neovim) **0.5.0 nightly** or greater.
- Set the neovim path in the extension settings. You must specify full path to neovim, like
"`C:\Neovim\bin\nvim.exe"` or "`/usr/local/bin/nvim`".
- The setting id is "`vscode-neovim.neovimExecutablePaths.win32/linux/darwin`", respective to your system.
- If you want to use neovim from WSL, set the `useWSL` configuration toggle and specify linux path to nvim binary.
`wsl.exe` windows binary and `wslpath` linux binary are required for this. `wslpath` must be available through
`$PATH` linux env setting. Use `wsl --list` to check for the correct default linux distribution.
> ❗ **Neovim 0.5.0 nightly** or greater is **required**. Any version lower than that won't work. Many linux
> distributions have an **old** version of neovim in their package repo - always check what version are you installing.
> You can install neovim separately, outside your system's package manager installation, for example using the appimage
> from the neovim releases page.
> 🐛 See the [issues section](https://github.com/asvetliakov/vscode-neovim/issues) for known issues.
## 💡 Tips and Features
### Important
- If you get "Unable to init vscode-neovim: command 'type' already exists" message, uninstall other VSCode extensions
that register the `type` command (like
[VSCodeVim](https://marketplace.visualstudio.com/items?itemName=vscodevim.vim) or
[Overtype](https://marketplace.visualstudio.com/items?itemName=adammaras.overtype)).
- If you already have a big `init.vim` it is recommended to wrap existing settings & plugins with
[`if !exists('g:vscode')`](#conditional-initvim) to prevent potential conflicts. If you have any problems, try with
empty `init.vim` first.
- On a Mac, the <kbd>h</kbd>, <kbd>j</kbd>, <kbd>k</kbd> and <kbd>l</kbd> movement keys may not repeat when held, to
fix this open Terminal and execute the following command:
`defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false`.
- The extension works best if `editor.scrollBeyondLastLine` is disabled.
### VSCode specific differences
- File and editor management commands such as `:e`/`:w`/`:q`/`:vsplit`/`:tabnext`/etc are mapped to corresponding
vscode commands and behavior may be different ([see below](#-bindings)). **Do not** use vim commands like `:w` in
scripts/keybindings, they won't work. If you're using them in some custom commands/mappings, you might need to
rebind them to call vscode commands from neovim with `VSCodeCall/VSCodeNotify`
([see below](#invoking-vscode-actions-from-neovim)).
- Visual modes don't produce vscode selections, so any vscode commands expecting selection won't work. To round the
corners, invoking the VSCode command picker from visual mode through the default hotkeys
(<kbd>f1</kbd>/<kbd>ctrl/cmd+shift+p</kbd>) converts vim selection to real vscode selection. This conversion is also
done automatically for some commands like commenting and formatting. If you're using some custom mapping for calling
vscode commands that depends on real vscode selection, you can use `VSCodeNotifyRange`/`VSCodeNotifyRangePos` (the
first one linewise, the latter characterwise) which will convert vim visual mode selection to vscode selection
before calling the command ([see below](#invoking-vscode-actions-from-neovim)).
- When you type some commands they may be substituted for the another, like `:write` will be replaced by `:Write`.
This is normal.
- Scrolling is done by VSCode. <kbd>C-d</kbd>/<kbd>C-u</kbd>/etc are slightly different.
- Editor customization (relative line number, scrolloff, etc) is handled by VSCode.
- Dot-repeat (<kbd>.</kbd>) is slightly different - moving the cursor within a change range won't break the repeat
sequence. In neovim, if you type `abc<cursor>` in insert mode, then move cursor to `a<cursor>bc` and type `1` here
the repeat sequence would be `1`. However in vscode it would be `a1bc`. Another difference is that when you delete
some text in insert mode, dot repeat only works from right-to-left, meaning it will treat <kbd>Del</kbd> key as
<kbd>BS</kbd> keys when running dot repeat.
### Performance problems
If you have any performance problems (cursor jitter usually) make sure you're not using these kinds of extensions:
- Anything that renders decorators very often:
- Line number extensions (VSCode has built-in support for normal/relative line numbers)
- Indent guide extensions (VSCode has built-in indent guides)
- Brackets highlighter extensions (VSCode has built-in feature)
- VSCode extensions that delay the extension host like "Bracket Pair Colorizer"
- VIM plugins that increase latency and cause performance problems.
- Make sure to disable unneeded plugins, as many of them don't make sense with vscode and may cause problems.
- You don't need any code, highlighting, completion, lsp plugins as well any plugins that spawn windows/buffers
(nerdtree and similar), fuzzy-finders, etc.
- Many navigation/textobject/editing plugins should be fine.
If you're not sure, disable all other extensions, **reload vscode window**, and see if the problem persists before
reporting.
### Conditional init.vim
To determine if neovim is running in vscode, add to your init.vim:
```vim
if exists('g:vscode')
" VSCode extension
else
" ordinary neovim
endif
```
To conditionally activate plugins, `vim-plug` has a
[few solutions](https://github.com/junegunn/vim-plug/wiki/tips#conditional-activation). For example, using the `Cond`
helper, you can conditionally activate installed plugins
([source](https://github.com/asvetliakov/vscode-neovim/issues/415#issuecomment-715533865)):
```vim
" inside plug#begin:
" use normal easymotion when in vim mode
Plug 'easymotion/vim-easymotion', Cond(!exists('g:vscode'))
" use vscode easymotion when in vscode mode
Plug 'asvetliakov/vim-easymotion', Cond(exists('g:vscode'), { 'as': 'vsc-easymotion' })
```
### Custom escape keys
Since VSCode is responsible for insert mode, custom insert-mode vim mappings don't work. To map composite escape keys,
put into your keybindings.json:
for <kbd>jj</kbd>
```json
{
"command": "vscode-neovim.compositeEscape1",
"key": "j",
"when": "neovim.mode == insert && editorTextFocus",
"args": "j"
}
```
to enable <kbd>jk</kbd> add also:
```json
{
"command": "vscode-neovim.compositeEscape2",
"key": "k",
"when": "neovim.mode == insert && editorTextFocus",
"args": "k"
}
```
Currently, there is no way to map both `jk` and `kj`, or to map `jk` without also mapping `jj`.
### Jumplist
VSCode's jumplist is used instead of Neovim's. This is to make VSCode native navigation (mouse click, jump to
definition, ect) navigable through the jumplist.
Make sure to bind to `workbench.action.navigateBack` / `workbench.action.navigateForward` if you're using custom
mappings. Marks (both upper & lowercased) should work fine.
### Wildmenu completion
Command menu has the wildmenu completion on type. The completion options appear after 1.5s (to not bother you when you
write `:w` or `:noh`). <kbd>Up</kbd>/<kbd>Down</kbd> selects the option and <kbd>Tab</kbd> accepts it. See the gif:
![wildmenu](https://github.com/asvetliakov/vscode-neovim/raw/HEAD/images/wildmenu.gif)
### Multiple cursors
Multiple cursors work in:
1. Insert mode
2. Visual line mode
3. Visual block mode
To spawn multiple cursors from visual line/block modes type <kbd>ma</kbd>/<kbd>mA</kbd> or <kbd>mi</kbd>/<kbd>mI</kbd>
(by default). The effect differs:
- For visual line mode, <kbd>mi</kbd> will start insert mode on each selected line on the first non whitespace
character and <kbd>ma</kbd> will on the end of line.
- For visual block mode, <kbd>mi</kbd> will start insert on each selected line before the cursor block and
<kbd>ma</kbd> after.
- <kbd>mA</kbd>/<kbd>mI</kbd> versions accounts for empty lines (only for visual line mode, for visual block mode
they're same as <kbd>ma</kbd>/<kbd>mi</kbd>).
See gif in action:
![multicursors](https://github.com/asvetliakov/vscode-neovim/raw/HEAD/images/multicursor.gif)
### Keyboard Quickfix
By default, the quickfix menu can be opened using <kbd>z=</kbd> or <kbd>C-.</kbd>. However, it is currently
[not possible](https://github.com/microsoft/vscode/issues/55111) to add mappings to the quickfix menu, so it can only be
navigated with arrow keys. A
[workaround vscode extension](https://marketplace.visualstudio.com/items?itemName=pascalsenn.keyboard-quickfix) has been
made to use the quick open menu, which can be navigated with custom bindings.
To use, install the
[keyboard-quickfix](https://marketplace.visualstudio.com/items?itemName=pascalsenn.keyboard-quickfix) extension, and add
to your keybindings.json:
```jsonc
{
"key": "ctrl+.",
"command": "keyboard-quickfix.openQuickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
```
and add to your init.vim:
```vim
nnoremap z= <Cmd>call VSCodeNotify('keyboard-quickfix.openQuickFix')<CR>
```
### Invoking VSCode actions from neovim
There are a
[few helper functions](https://github.com/asvetliakov/vscode-neovim/blob/master/vim/vscode-neovim.vim#L17-L39) that
could be used to invoke any vscode commands:
| Command | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `VSCodeNotify(command, ...)` <br/> `VSCodeCall(command, ...)` | Invoke vscode command with optional arguments. |
| `VSCodeNotifyRange(command, line1, line2, leaveSelection ,...)` <br/> `VSCodeCallRange(command, line1, line2, leaveSelection, ...)` | Produce real linewise vscode selection from `line1` to `line2` and invoke vscode command. Put 1 for the `leaveSelection` argument to leave vscode selection after invoking the command. |
| `VSCodeNotifyRangePos(command, line1, line2, pos1, pos2, leaveSelection ,...)` <br/> `VSCodeCallRangePos(command, line1, line2, pos1, pos2, leaveSelection, ...)` | Produce real characterwise vscode selection from `line1.pos1` to `line2.pos2` and invoke vscode command. |
> 💡 Functions with `Notify` in their name are non-blocking, the ones with `Call` are blocking. Generally **use Notify**
> unless you really need a blocking call.
#### Examples
Produce linewise/characterwise selection and show vscode commands (default binding):
```vim
function! s:openVSCodeCommandsInVisualMode()
let mode = mode()
if mode ==# 'V'
let startLine = line('v')
let endLine = line('.')
call VSCodeNotifyRange('workbench.action.showCommands', startLine, endLine, 1)
else
let startPos = getpos('v')
let endPos = getpos('.')
call VSCodeNotifyRangePos('workbench.action.showCommands', startPos[1], endPos[1], startPos[2], endPos[2] + 1, 1)
endif
endfunction
xnoremap <C-P> <Cmd>call <SID>openVSCodeCommandsInVisualMode()<CR>
```
Open definition aside (default binding):
```vim
nnoremap <C-w>gd <Cmd>call VSCodeNotify('editor.action.revealDefinitionAside')<CR>
```
Run Find in files for word under cursor in vscode:
```vim
nnoremap ? <Cmd>call VSCodeNotify('workbench.action.findInFiles', { 'query': expand('<cword>')})<CR>
```
## ⌨️ Bindings
**Custom keymaps for scrolling/window/tab/etc management**
- See [vscode-scrolling.vim](https://github.com/asvetliakov/vscode-neovim/blob/HEAD/vim/vscode-scrolling.vim) for scrolling commands reference
- See [vscode-file-commands.vim](https://github.com/asvetliakov/vscode-neovim/blob/HEAD/vim/vscode-file-commands.vim) for file commands reference
- See [vscode-tab-commands.vim](https://github.com/asvetliakov/vscode-neovim/blob/HEAD/vim/vscode-tab-commands.vim) for tab commands reference
- See [vscode-window-commands.vim](https://github.com/asvetliakov/vscode-neovim/blob/HEAD/vim/vscode-window-commands.vim) for window commands reference
> 💡 "With bang" refers to adding a "!" to the end of a command.
### File management
| Command | Description |
| ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `e[dit]` / `ex` | Open quickopen. <br/> With filename, e.g. `:e $MYVIMRC`: open the file in new tab. The file must exist. <br/> With bang: revert file to last saved version. <br/> With filename and bang e.g. `:e! $MYVIMRC`: close current file (discard any changes) and open the file. The file must exist. |
| `ene[w]` | Create new untitled document in vscode. <br/> With bang: close current file (discard any changes) and create new document. |
| `fin[d]` | Open vscode's quick open window. Arguments and count are not supported. |
| `w[rite]` | Save current file. With bang: open 'save as' dialog. |
| `sav[eas]` | Open 'save as' dialog. |
| `wa[ll]` | Save all files. |
| `q[uit]` / <kbd>C-w</kbd> <kbd>q</kbd> / <kbd>C-w</kbd> <kbd>c</kbd> / <kbd>ZQ</kbd> | Close the active editor. With bang: revert changes and close the active editor. |
| `wq` / <kbd>ZZ</kbd> | Save and close the active editor. |
| `qa[ll]` | Close all editors, but don't quit vscode. Acts like `qall!`, so beware for nonsaved changes. |
| `wqa[ll]` / `xa[ll]` | Save all editors & close. |
### Tab management
| Command | Description |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `tabe[dit]` | Similar to `e[dit]`. Open quickopen. <br/> With argument: open the file in new tab. |
| `tabnew` | Open new untitled file. |
| `tabf[ind]` | Open quickopen window. |
| `tab`/`tabs` | Not supported. Doesn't make sense with vscode. |
| `tabc[lose]` | Close active editor (tab). |
| `tabo[nly]` | Close other tabs in vscode **group** (pane). This differs from vim where a `tab` is a like a new window, but doesn't make sense in vscode. |
| `tabn[ext]` / <kbd>gt</kbd> | Switch to next (or `count` tabs if argument is given) in the active vscode **group** (pane). |
| `tabp[revious]` / <kbd>gT</kbd> | Switch to previous (or `count` tabs if argument is given) in the active vscode **group** (pane). |
| `tabfir[st]` | Switch to the first tab in the active editor group. |
| `tabl[ast]` | Switch to the last tab in the active editor group. |
| `tabm[ove]` | Not supported yet. |
### Buffer/window management
| Command | Key | Description |
| ---------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sp[lit]` | <kbd>C-w</kbd> <kbd>s</kbd> | Split editor horizontally. <br/> With argument: open the specified file, e.g `:sp $MYVIMRC`. File must exist. |
| `vs[plit]` | <kbd>C-w</kbd> <kbd>v</kbd> | Split editor vertically. <br/> With argument: open the specified file. File must exist. |
| `new` | <kbd>C-w</kbd> <kbd>n</kbd> | Like `sp[lit]` but create new untitled file if no argument given. |
| `vne[w]` | | Like `vs[plit]` but create new untitled file if no argument given. |
| | <kbd>C-w</kbd> <kbd>=</kbd> | Align all editors to have the same width. |
| | <kbd>C-w</kbd> <kbd>\_</kbd> | Toggle maximized editor size. Pressing again will restore the size. |
| | <kbd>[count]</kbd> <kbd>C-w</kbd> <kbd>+</kbd> | Increase editor height by (optional) count. |
| | <kbd>[count]</kbd> <kbd>C-w</kbd> <kbd>-</kbd> | Decrease editor height by (optional) count. |
| | <kbd>[count]</kbd> <kbd>C-w</kbd> <kbd>></kbd> | Increase editor width by (optional) count. |
| | <kbd>[count]</kbd> <kbd>C-w</kbd> <kbd>\<</kbd> | Decrease editor width by (optional) count. |
| `on[ly]` | <kbd>C-w</kbd> <kbd>o</kbd> | Without bang: merge all editor groups into the one. Don't close editors. <br/> With bang: close all editors from all groups except current one. |
| | <kbd>C-w</kbd> <kbd>j/k/h/l</kbd> | Focus group below/above/left/right. |
| | <kbd>C-w</kbd> <kbd>C-j/i/h/l</kbd> | Move editor to group below/above/left/right. <br/> **Note**: <kbd>C-w</kbd> <kbd>C-i</kbd> moves editor up. Ideally it should be <kbd>C-w</kbd> <kbd>C-k</kbd> but vscode has many commands mapped to <kbd>C-k</kbd> <kbd>[key]</kbd> and doesn't allow to use <kbd>C-w</kbd> <kbd>C-k</kbd> without unbinding them first. |
| | <kbd>C-w</kbd> <kbd>J/K/H/L</kbd> | Move whole editor group below/above/left/right. |
| | <kbd>C-w</kbd> <kbd>w</kbd> or <kbd>C-w</kbd> <kbd>C-w</kbd> | Focus next group. The behavior may differ than in vim. |
| | <kbd>C-w</kbd> <kbd>W</kbd> or <kbd>C-w</kbd> <kbd>p</kbd> | Focus previous group. The behavior may differ than in vim. <kbd>C-w</kbd> <kbd>p</kbd> is completely different than in vim. |
| | <kbd>C-w</kbd> <kbd>b</kbd> | Focus last editor group (most bottom-right). |
| | <kbd>C-w</kbd> <kbd>r/R/x</kbd> | Not supported, use <kbd>C-w</kbd> <kbd>C-j</kbd> and similar to move editors. |
> 💡 Split size distribution is controlled by `workbench.editor.splitSizing` setting. By default, it's `distribute`,
> which is equal to vim's `equalalways` and `eadirection = 'both'` (default).
To use VSCode command 'Increase/decrease current view size' instead of separate bindings for width and height:
- `workbench.action.increaseViewSize`
- `workbench.action.decreaseViewSize`
<details>
<summary>Copy this into init.vim</summary>
function! s:manageEditorSize(...)
let count = a:1
let to = a:2
for i in range(1, count ? count : 1)
call VSCodeNotify(to ==# 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
endfor
endfunction
" Sample keybindings. Note these override default keybindings mentioned above.
nnoremap <C-w>> <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
xnoremap <C-w>> <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
nnoremap <C-w>+ <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
xnoremap <C-w>+ <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
nnoremap <C-w>< <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
xnoremap <C-w>< <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
nnoremap <C-w>- <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
xnoremap <C-w>- <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
</details>
### Insert mode special keys
Enabled by `useCtrlKeysForInsertMode` (default true).
| Key | Description | Status |
| ------------------------------------------- | ----------------------------------------------------------------- | --------------------------------- |
| <kbd>C-r</kbd> <kbd>[0-9a-z"%#*+:.-=]</kbd> | Paste from register. | Works |
| <kbd>C-a</kbd> | Paste previous inserted content. | Works |
| <kbd>C-o</kbd> | Switch to normal mode for a single command, then back. | Works |
| <kbd>C-u</kbd> | Delete all text till beginning of line. If empty, delete newline. | Bound to VSCode key |
| <kbd>C-w</kbd> | Delete word left. | Bound to VSCode key |
| <kbd>C-h</kbd> | Delete character left. | Bound to VSCode key |
| <kbd>C-t</kbd> | Indent lines right. | Bound to VSCode indent line |
| <kbd>C-d</kbd> | Indent lines left. | Bound to VSCode outindent line |
| <kbd>C-j</kbd> | Insert line. | Bound to VSCode insert line after |
| <kbd>C-c</kbd> | Escape. | Works |
Other keys are not supported in insert mode.
### Normal mode control keys
Enabled by `useCtrlKeysForNormalMode` (default true).
Refer to vim manual for their use.
- <kbd>C-a</kbd>
- <kbd>C-b</kbd>
- <kbd>C-c</kbd>
- <kbd>C-d</kbd>
- <kbd>C-e</kbd>
- <kbd>C-f</kbd>
- <kbd>C-i</kbd>
- <kbd>C-o</kbd> (to enable, see
[this issue](https://github.com/asvetliakov/vscode-neovim/issues/181#issuecomment-585264621))
- <kbd>C-r</kbd>
- <kbd>C-u</kbd>
- <kbd>C-v</kbd>
- <kbd>C-w</kbd>
- <kbd>C-x</kbd>
- <kbd>C-y</kbd>
- <kbd>C-]</kbd>
- <kbd>C-j</kbd>
- <kbd>C-k</kbd>
- <kbd>C-l</kbd>
- <kbd>C-h</kbd>
- <kbd>C-/</kbd>
### Cmdline special keys
Always enabled.
| Key | Desription |
| ------------------------------- | --------------------------------------------------------- |
| <kbd>C-h</kbd> | Delete one character left. |
| <kbd>C-w</kbd> | Delete word left. |
| <kbd>C-u</kbd> | Clear line. |
| <kbd>C-g</kbd> / <kbd>C-t</kbd> | In incsearch mode moves to next/previous result. |
| <kbd>C-l</kbd> | Add next character under the cursor to incsearch. |
| <kbd>C-n</kbd> / <kbd>C-p</kbd> | Go down/up history. |
| <kbd>Up</kbd> / <kbd>Down</kbd> | Select next/prev suggestion (cannot be used for history). |
| <kbd>Tab</kbd> | Select suggestion. |
### VSCode specific bindings
#### Editor command
| Key | VSCode Command |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| <kbd>=</kbd> / <kbd>==</kbd> | `editor.action.formatSelection` |
| <kbd>gh</kbd> / <kbd>K</kbd> | `editor.action.showHover` |
| <kbd>gd</kbd> / <kbd>C-]</kbd> | `editor.action.revealDefinition` <br/> Also works in vim help. |
| <kbd>gf</kbd> | `editor.action.revealDeclaration` |
| <kbd>gH</kbd> | `editor.action.referenceSearch.trigger` |
| <kbd>gO</kbd> | `workbench.action.gotoSymbol` |
| <kbd>C-w</kbd> <kbd>gd</kbd> / <kbd>C-w</kbd> <kbd>gf</kbd> | `editor.action.revealDefinitionAside` |
| <kbd>gD</kbd> | `editor.action.peekDefinition` |
| <kbd>gF</kbd> | `editor.action.peekDeclaration` |
| <kbd>Tab</kbd> | `togglePeekWidgetFocus` <br/> Switch between peek editor and reference list. |
| <kbd>C-n</kbd> / <kbd>C-p</kbd> | Navigate lists, parameter hints, suggestions, quick-open, cmdline history, peek reference list |
> 💡 To specify the default peek mode, modify `editor.peekWidgetDefaultFocus` in your settings.
#### Explorer/list navigation
| Key | VSCode Command |
| ---------------------------------- | ------------------------------- |
| <kbd>j</kbd> / <kbd>k</kbd> | `list.focusDown/Up` |
| <kbd>h</kbd> / <kbd>l</kbd> | `list.collapse/select` |
| <kbd>Enter</kbd> | `list.select` |
| <kbd>gg</kbd> | `list.focusFirst` |
| <kbd>G</kbd> | `list.focusLast` |
| <kbd>o</kbd> | `list.toggleExpand` |
| <kbd>C-u</kbd> / <kbd>C-d</kbd> | `list.focusPageUp/Down` |
| <kbd> / </kbd> / <kbd>Escape</kbd> | `list.toggleKeyboardNavigation` |
> 💡 To enable explorer list navigation, add `"workbench.list.automaticKeyboardNavigation": false` to your
> `settings.json`.
#### Explorer file manipulation
| Key | VSCode Command |
| ------------ | --------------------- |
| <kbd>r</kbd> | `renameFile` |
| <kbd>d</kbd> | `deleteFile` |
| <kbd>y</kbd> | `filesExplorer.copy` |
| <kbd>x</kbd> | `filesExplorer.cut` |
| <kbd>p</kbd> | `filesExplorer.paste` |
| <kbd>v</kbd> | `explorer.openToSide` |
| <kbd>a</kbd> | `explorer.newFile` |
| <kbd>A</kbd> | `explorer.newFolder` |
### Custom keybindings
Control keys which are not in the above tables are not sent to neovim by default. To pass additional ctrl keys to
neovim, for example <kbd>C-Tab</kbd>, add to your keybindings.json:
```jsonc
{
"command": "vscode-neovim.send",
// the key sequence to activate the binding
"key": "ctrl+tab",
// don't activate during insert mode
"when": "editorTextFocus && neovim.mode != insert",
// the input to send to neovim
"args": "<C-Tab>"
}
```
To disable existing an ctrl key sequence, for example <kbd>C-A</kbd> add to your keybindings.json:
```json
{
"command": "-vscode-neovim.send",
"key": "ctrl+a"
}
```
## 🤝 Vim Plugins
Most vim plugins will work out of the box, but certain plugins may require some fixes to work properly.
### vim-easymotion
While the original [vim-easymotion](https://github.com/easymotion/vim-easymotion) functions as expected, it works by
replacing your text with markers then restoring back, which leads to broken text and many errors reported in VSCode.
For this reason I created the special [vim-easymotion fork](https://github.com/asvetliakov/vim-easymotion) which doesn't
touch your text and instead use vscode text decorations. Just add my fork to your `vim-plug` block or by using your
favorite vim plugin installer and delete original vim-easymotion. Also overwin motions won't work (obviously) so don't
use them.
By default, text decorations will appear behind of the associated text as shown in the screenshot. To show the
decorations on top of the text, set `vscode-neovim.textDecorationsAtTop` to true.
Happy jumping!
![easymotion](https://github.com/asvetliakov/vscode-neovim/raw/HEAD/images/easy-motion-vscode.png)
### vim-commentary
You can use [vim-commentary](https://github.com/tpope/vim-commentary) if you like it. But vscode already has such
functionality so why don't use it? Add to your init.vim/init.nvim:
```vim
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
```
Similar to vim-commentary, gcc is comment line (accept count), use gc with motion/in visual mode. `VSCodeCommentary` is
just a simple function which calls `editor.action.commentLine`.
### quick-scope
[quick-scope](https://github.com/unblevable/quick-scope) plugin uses default vim HL groups by default but they are
normally ignored. To fix, add
```vim
highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
```
to your init.vim. The underline color can be changed by the `guisp` tag.
## 📑 How it works
- VScode connects to neovim instance
- When opening a some file, a scratch buffer is created in nvim and being init with text content from vscode
- Normal/visual mode commands are being sent directly to neovim. The extension listens for buffer events and applies
edits from neovim
- When entering the insert mode, the extensions stops listen for keystroke events and delegates typing mode to vscode
(no neovim communication is being performed here)
- After pressing escape key from the insert mode, extension sends changes obtained from the insert mode to neovim
## ❤️ Credits & External Resources
- [vim-altercmd](https://github.com/kana/vim-altercmd) - Used for rebinding default commands to call vscode command
- [neovim nodejs client](https://github.com/neovim/node-client) - NodeJS library for communicating with Neovim
- [VSCodeVim](https://github.com/VSCodeVim/Vim) - Used for various inspiration

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,200 @@
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line

View file

@ -0,0 +1,200 @@
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line

View file

@ -0,0 +1,200 @@
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is lineThis is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line
This is line

View file

@ -0,0 +1,3 @@
.vim-flavor
Gemfile.lock
VimFlavor.lock

View file

@ -0,0 +1,4 @@
language: ruby
rvm:
- 2.1.5
script: rake ci

View file

@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem 'vim-flavor', '~> 2.0'

View file

@ -0,0 +1,11 @@
#!/usr/bin/env rake
task :ci => [:dump, :test]
task :dump do
sh 'vim --version'
end
task :test do
sh 'bundle exec vim-flavor test'
end

View file

@ -0,0 +1 @@
# No dependencies.

View file

@ -0,0 +1,62 @@
" altercmd - Alter built-in Ex commands by your own ones
" Version: 0.0.1
" Copyright (C) 2009-2015 Kana Natsuno <http://whileimautomaton.net/>
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
" Interface "{{{1
function! altercmd#define(...) "{{{2
let [buffer, original_name, alternate_name]
\ = (a:000[0] ==? '<buffer>' ? [] : ['']) + a:000
if original_name =~ '\['
let [original_name_head, original_name_tail] = split(original_name, '[')
let original_name_tail = substitute(original_name_tail, '\]', '', '')
else
let original_name_head = original_name
let original_name_tail = ''
endif
let original_name_tail = ' ' . original_name_tail
for i in range(len(original_name_tail))
let lhs = original_name_head . original_name_tail[1:i]
execute 'cnoreabbrev <expr>' buffer lhs
\ '(getcmdtype() == ":" && getcmdline() ==# "' . lhs . '")'
\ '?' ('"' . alternate_name . '"')
\ ':' ('"' . lhs . '"')
endfor
endfunction
function! altercmd#load() "{{{2
runtime plugin/altercmd.vim
endfunction
" __END__ "{{{1
" vim: foldmethod=marker

View file

@ -0,0 +1,134 @@
*altercmd.txt* Alter built-in Ex commands by your own ones
Version 0.0.1
Script ID: 2675
Copyright (C) 2009-2015 Kana Natsuno <http://whileimautomaton.net/>
License: MIT license {{{
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}}
CONTENTS *altercmd-contents*
Introduction |altercmd-introduction|
Interface |altercmd-interface|
Commands |altercmd-commands|
Functions |altercmd-functions|
Bugs |altercmd-bugs|
Changelog |altercmd-changelog|
==============================================================================
INTRODUCTION *altercmd-introduction*
*altercmd* is a Vim plugin to provide an easy way to alternate built-in Ex
commands by user-defined Ex commands. This plugin provides |:AlterCommand|
for this purpose. For example, if you define :CD, a custom version of |:cd|,
add the following in your vimrc.
>
AlterCommand cd CD
<
With the above setting, you can use :cd as if it is :CD. It means that :CD
will be automatically inserted if you type :cd as an Ex command, so you don't
have to type :CD to use :cd and you'll never encounter mistyping :cd and :CD.
:AlterCommand also supports partial command names. For example, |:help| can
be invoked with :h, :he, :hel or :help.
>
AlterCommand h[elp] HELP
<
With the above setting, you can use :h, :he, :hel and :help as if they are
:HELP, your own version of :help.
Requirements:
- Vim 7.2 or later
Latest version:
https://github.com/kana/vim-altercmd
==============================================================================
INTERFACE *altercmd-interface*
------------------------------------------------------------------------------
COMMANDS *altercmd-commands*
*:AlterCommand*
:AlterCommand [<buffer>] {original} {alternative}
Declare to use {alternative} Ex command instead of
{original} Ex command.
If <buffer> is given, this declaration is only
available for the current buffer. Otherwise, this
declaration is available globally.
See also |altercmd-introduction| for examples.
Technically, this Ex command does just define some
|abbreviations| in Command-line mode.
------------------------------------------------------------------------------
FUNCTIONS *altercmd-functions*
altercmd#define({original}, {alternative}) *altercmd#define()*
altercmd#define('<buffer>', {original}, {alternative})
Function version of |:AlterCommand|.
altercmd#load() *altercmd#load()*
Load this plugin. You have to call this in your vimrc
if you want to use |:AlterCommand| in your vimrc.
==============================================================================
BUGS *altercmd-bugs*
- Not all cases are supported. For example:
- [range] is not supported yet. If [range] is given, altercmd doesn't work.
- If any argument is not given to an Ex command which has an alternative Ex
command, altercmd doesn't work.
- And there may be more cases where altercmd doesn't work well.
==============================================================================
CHANGELOG *altercmd-changelog*
0.0.1 2015-01-31T23:52:24+09:00
- Fix a bug that buffer-local |:AlterCommand| could not be defined.
0.0.0 2009-06-14T03:47:25+09:00
- Initial version.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker:

View file

@ -0,0 +1,41 @@
" altercmd - Alter built-in Ex commands by your own ones
" Version: 0.0.1
" Copyright (C) 2009-2015 Kana Natsuno <http://whileimautomaton.net/>
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to
" permit persons to whom the Software is furnished to do so, subject to
" the following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
if exists('g:loaded_altercmd')
finish
endif
command! -bar -complete=command -nargs=* AlterCommand
\ call altercmd#define(<f-args>)
let g:loaded_altercmd = 1
" __END__
" vim: foldmethod=marker

View file

@ -0,0 +1,45 @@
call altercmd#define('full', 'F-U-L-L')
call altercmd#define('ab[br]', 'A-B-B-R')
function! RecordTheCurrentCommandLine()
let g:cmdline = getcmdline()
return ''
endfunction
cnoremap <expr> {X} RecordTheCurrentCommandLine()
function! Test(lhs, rhs)
let g:cmdline = ''
silent execute 'normal' ":".a:lhs."\<C-]>{X}\<C-c>"
Expect g:cmdline ==# a:rhs
endfunction
describe 'altercmd#define'
it 'replaces a built-in command'
call Test('full', 'F-U-L-L')
end
it 'replaces all abbreviated names of a built-in command'
call Test('ab', 'A-B-B-R')
call Test('abb', 'A-B-B-R')
call Test('abbr', 'A-B-B-R')
end
it 'supports <buffer>'
silent edit 'test-A'
call altercmd#define('<buffer>', 'ctx', 'Axe')
silent edit 'test-B'
call altercmd#define('<buffer>', 'ctx', 'Bow')
silent edit 'test-C'
call altercmd#define('<buffer>', 'ctx', 'Club')
silent edit 'test-A'
call Test('full', 'F-U-L-L')
call Test('ctx', 'Axe')
silent edit 'test-B'
call Test('full', 'F-U-L-L')
call Test('ctx', 'Bow')
silent edit 'test-C'
call Test('full', 'F-U-L-L')
call Test('ctx', 'Club')
end
end

View file

@ -0,0 +1,96 @@
function! s:vscodeFormat(...) abort
if !a:0
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
return 'g@'
elseif a:0 > 1
let [line1, line2] = [a:1, a:2]
else
let [line1, line2] = [line("'["), line("']")]
endif
call VSCodeCallRange('editor.action.formatSelection', line1, line2, 0)
endfunction
function! s:vscodeCommentary(...) abort
if !a:0
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
return 'g@'
elseif a:0 > 1
let [line1, line2] = [a:1, a:2]
else
let [line1, line2] = [line("'["), line("']")]
endif
call VSCodeCallRange('editor.action.commentLine', line1, line2, 0)
endfunction
function! s:vscodeGoToDefinition(str)
if exists('b:vscode_controlled') && b:vscode_controlled
call VSCodeNotify('editor.action.reveal' . a:str)
else
" Allow to funcionar in help files
exe "normal! \<C-]>"
endif
endfunction
function! s:openVSCodeCommandsInVisualMode()
let mode = mode()
if mode ==# 'V'
let startLine = line('v')
let endLine = line('.')
call VSCodeNotifyRange('workbench.action.showCommands', startLine, endLine, 1)
else
let startPos = getpos('v')
let endPos = getpos('.')
call VSCodeNotifyRangePos('workbench.action.showCommands', startPos[1], endPos[1], startPos[2], endPos[2] + 1, 1)
endif
endfunction
command! -range -bar VSCodeCommentary call s:vscodeCommentary(<line1>, <line2>)
xnoremap <expr> <Plug>VSCodeCommentary <SID>vscodeCommentary()
nnoremap <expr> <Plug>VSCodeCommentary <SID>vscodeCommentary()
nnoremap <expr> <Plug>VSCodeCommentaryLine <SID>vscodeCommentary() . '_'
" Bind format to vscode format selection
xnoremap <expr> = <SID>vscodeFormat()
nnoremap <expr> = <SID>vscodeFormat()
nnoremap <expr> == <SID>vscodeFormat() . '_'
" gf/gF . Map to go to definition for now
nnoremap K <Cmd>call VSCodeNotify('editor.action.showHover')<CR>
nnoremap gh <Cmd>call VSCodeNotify('editor.action.showHover')<CR>
nnoremap gf <Cmd>call <SID>vscodeGoToDefinition("Declaration")<CR>
nnoremap gd <Cmd>call <SID>vscodeGoToDefinition("Definition")<CR>
nnoremap <C-]> <Cmd>call <SID>vscodeGoToDefinition("Definition")<CR>
nnoremap gO <Cmd>call VSCodeNotify('workbench.action.gotoSymbol')<CR>
nnoremap gF <Cmd>call VSCodeNotify('editor.action.peekDeclaration')<CR>
nnoremap gD <Cmd>call VSCodeNotify('editor.action.peekDefinition')<CR>
nnoremap gH <Cmd>call VSCodeNotify('editor.action.referenceSearch.trigger')<CR>
xnoremap K <Cmd>call VSCodeNotify('editor.action.showHover')<CR>
xnoremap gh <Cmd>call VSCodeNotify('editor.action.showHover')<CR>
xnoremap gf <Cmd>call <SID>vscodeGoToDefinition("Declaration")<CR>
xnoremap gd <Cmd>call <SID>vscodeGoToDefinition("Definition")<CR>
xnoremap <C-]> <Cmd>call <SID>vscodeGoToDefinition("Definition")<CR>
xnoremap gO <Cmd>call VSCodeNotify('workbench.action.gotoSymbol')<CR>
xnoremap gF <Cmd>call VSCodeNotify('editor.action.peekDeclaration')<CR>
xnoremap gD <Cmd>call VSCodeNotify('editor.action.peekDefinition')<CR>
xnoremap gH <Cmd>call VSCodeNotify('editor.action.referenceSearch.trigger')<CR>
" <C-w> gf opens definition on the side
nnoremap <C-w>gf <Cmd>call VSCodeNotify('editor.action.revealDefinitionAside')<CR>
nnoremap <C-w>gd <Cmd>call VSCodeNotify('editor.action.revealDefinitionAside')<CR>
xnoremap <C-w>gf <Cmd>call VSCodeNotify('editor.action.revealDefinitionAside')<CR>
xnoremap <C-w>gd <Cmd>call VSCodeNotify('editor.action.revealDefinitionAside')<CR>
" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors
xnoremap <expr> <C-/> <SID>vscodeCommentary()
nnoremap <expr> <C-/> <SID>vscodeCommentary() . '_'
" open quickfix menu for spelling corrections and refactoring
" only keyboard arrows can be used to navigate, for a solution, see https://github.com/asvetliakov/vscode-neovim#keyboard-quickfix
nnoremap z= <Cmd>call VSCodeNotify('editor.action.quickFix')<CR>
" workaround for calling command picker in visual mode
xnoremap <C-P> <Cmd>call <SID>openVSCodeCommandsInVisualMode()<CR>

View file

@ -0,0 +1,63 @@
function! s:editOrNew(...)
let file = a:1
let bang = a:2
if empty(file)
if bang ==# '!'
call VSCodeNotify('workbench.action.files.revert')
else
call VSCodeNotify('workbench.action.quickOpen')
endif
else
" Last arg is to close previous file, e.g. e! ~/blah.txt will open blah.txt instead the current file
call VSCodeExtensionNotify('open-file', expand(file), bang ==# '!' ? 1 : 0)
endif
endfunction
function! s:saveAndClose() abort
call VSCodeCall('workbench.action.files.save')
call VSCodeNotify('workbench.action.closeActiveEditor')
endfunction
function! s:saveAllAndClose() abort
call VSCodeCall('workbench.action.files.saveAll')
call VSCodeNotify('workbench.action.closeAllEditors')
endfunction
" command! -bang -nargs=? Edit call VSCodeCall('workbench.action.quickOpen')
command! -complete=file -bang -nargs=? Edit call <SID>editOrNew(<q-args>, <q-bang>)
command! -bang -nargs=? Ex call <SID>editOrNew(<q-args>, <q-bang>)
command! -bang Enew call <SID>editOrNew('__vscode_new__', <q-bang>)
command! -bang Find call VSCodeNotify('workbench.action.quickOpen')
command! -complete=file -bang Write if <q-bang> ==# '!' | call VSCodeNotify('workbench.action.files.saveAs') | else | call VSCodeNotify('workbench.action.files.save') | endif
command! -bang Saveas call VSCodeNotify('workbench.action.files.saveAs')
command! -bang Wall call VSCodeNotify('workbench.action.files.saveAll')
command! -bang Quit if <q-bang> ==# '!' | call VSCodeNotify('workbench.action.revertAndCloseActiveEditor') | else | call VSCodeNotify('workbench.action.closeActiveEditor') | endif
command! -bang Wq call <SID>saveAndClose()
command! -bang Xit call <SID>saveAndClose()
command! -bang Qall call VSCodeNotify('workbench.action.closeAllEditors')
command! -bang Wqall call <SID>saveAllAndClose()
command! -bang Xall call <SID>saveAllAndClose()
AlterCommand e[dit] Edit
AlterCommand ex Ex
AlterCommand ene[w] Enew
AlterCommand fin[d] Find
AlterCommand w[rite] Write
AlterCommand sav[eas] Saveas
AlterCommand wa[ll] Wall
AlterCommand q[uit] Quit
AlterCommand wq Wq
AlterCommand x[it] Xit
AlterCommand qa[ll] Qall
AlterCommand wqa[ll] Wqall
AlterCommand xa[ll] Xall
nnoremap ZZ <Cmd>Wq<CR>
nnoremap ZQ <Cmd>Quit!<CR>

View file

@ -0,0 +1,31 @@
function! s:vscodePrepareMultipleCursors(append, skipEmpty)
let m = mode()
if m ==# 'V' || m ==# "\<C-v>"
let b:notifyMultipleCursors = 1
let b:multipleCursorsVisualMode = m
let b:multipleCursorsAppend = a:append
let b:multipleCursorsSkipEmpty = a:skipEmpty
" We need to start insert, then spawn cursors otherwise they'll be destroyed
" using feedkeys() here because :startinsert is being delayed
call feedkeys("\<Esc>i", 'n')
endif
endfunction
function! s:vscodeNotifyMultipleCursors()
if exists('b:notifyMultipleCursors') && b:notifyMultipleCursors
let b:notifyMultipleCursors = 0
call VSCodeExtensionNotify('visual-edit', b:multipleCursorsAppend, b:multipleCursorsVisualMode, line("'<"), line("'>"), col("'>"), b:multipleCursorsSkipEmpty)
endif
endfunction
augroup MultipleCursors
autocmd!
autocmd InsertEnter * call <SID>vscodeNotifyMultipleCursors()
augroup END
" Multiple cursors support for visual line/block modes
xnoremap ma <Cmd>call <SID>vscodePrepareMultipleCursors(1, 1)<CR>
xnoremap mi <Cmd>call <SID>vscodePrepareMultipleCursors(0, 1)<CR>
xnoremap mA <Cmd>call <SID>vscodePrepareMultipleCursors(1, 0)<CR>
xnoremap mI <Cmd>call <SID>vscodePrepareMultipleCursors(0, 0)<CR>

View file

@ -0,0 +1,4 @@
nnoremap <C-o> <Cmd>call VSCodeNotify("workbench.action.navigateBack")<CR>
nnoremap <C-i> <Cmd>call VSCodeNotify("workbench.action.navigateForward")<CR>
nnoremap <Tab> <Cmd>call VSCodeNotify("workbench.action.navigateForward")<CR>

View file

@ -0,0 +1,16 @@
function! s:toFirstCharOfScreenLine()
call VSCodeNotify('cursorMove', { 'to': 'wrappedLineFirstNonWhitespaceCharacter' })
endfunction
function! s:toLastCharOfScreenLine()
call VSCodeNotify('cursorMove', { 'to': 'wrappedLineLastNonWhitespaceCharacter' })
" Offfset cursor moving to the right caused by calling VSCode command in Vim mode
call VSCodeNotify('cursorLeft')
endfunction
nnoremap g0 <Cmd>call <SID>toFirstCharOfScreenLine()<CR>
nnoremap g$ <Cmd>call <SID>toLastCharOfScreenLine()<CR>
" Note: Using these in macro will break it
nnoremap gk <Cmd>call VSCodeNotify('cursorMove', { 'to': 'up', 'by': 'wrappedLine', 'value': v:count ? v:count : 1 })<CR>
nnoremap gj <Cmd>call VSCodeNotify('cursorMove', { 'to': 'down', 'by': 'wrappedLine', 'value': v:count ? v:count : 1 })<CR>

View file

@ -0,0 +1,153 @@
" Set global flag to allow checking in custom user config
let g:vscode = 1
let s:currDir = fnamemodify(resolve(expand('<sfile>:p')), ':h')
" Adjust rtp path
let &runtimepath = &runtimepath . ',' . s:currDir . '/vim-altercmd'
" Used to execute vscode command
let s:vscodeCommandEventName = 'vscode-command'
" Used to execute vscode command with some range (the specified range will be selected and the command will be executed on this range)
let s:vscodeRangeCommandEventName = 'vscode-range-command'
" Used for externsion inter-communications
let s:vscodePluginEventName = 'vscode-neovim'
" RPC and global functions
function! VSCodeCall(cmd, ...) abort
call rpcrequest(g:vscode_channel, s:vscodeCommandEventName, a:cmd, a:000)
endfunction
function! VSCodeCallRange(cmd, line1, line2, leaveSelection, ...) abort
call rpcrequest(g:vscode_channel, s:vscodeRangeCommandEventName, a:cmd, a:line1, a:line2, 0, 0, a:leaveSelection, a:000)
endfunction
function! VSCodeCallRangePos(cmd, line1, line2, pos1, pos2, leaveSelection, ...) abort
call rpcrequest(g:vscode_channel, s:vscodeRangeCommandEventName, a:cmd, a:line1, a:line2, a:pos1, a:pos2, a:leaveSelection, a:000)
endfunction
function! VSCodeNotify(cmd, ...)
call rpcnotify(g:vscode_channel, s:vscodeCommandEventName, a:cmd, a:000)
endfunction
function! VSCodeNotifyRange(cmd, line1, line2, leaveSelection, ...)
call rpcnotify(g:vscode_channel, s:vscodeRangeCommandEventName, a:cmd, a:line1, a:line2, 0, 0, a:leaveSelection, a:000)
endfunction
function! VSCodeNotifyRangePos(cmd, line1, line2, pos1, pos2, leaveSelection, ...)
call rpcnotify(g:vscode_channel, s:vscodeRangeCommandEventName, a:cmd, a:line1, a:line2, a:pos1, a:pos2, a:leaveSelection, a:000)
endfunction
function! VSCodeExtensionCall(cmd, ...) abort
call rpcrequest(g:vscode_channel, s:vscodePluginEventName, a:cmd, a:000)
endfunction
function! VSCodeExtensionNotify(cmd, ...) abort
call rpcnotify(g:vscode_channel, s:vscodePluginEventName, a:cmd, a:000)
endfunction
" Called from extension when opening/creating new file in vscode to reset undo tree
function! VSCodeClearUndo(bufId)
let oldlevels = &undolevels
call nvim_buf_set_option(a:bufId, 'undolevels', -1)
call nvim_buf_set_lines(a:bufId, 0, 0, 0, [])
call nvim_buf_set_option(a:bufId, 'undolevels', oldlevels)
unlet oldlevels
endfunction
" Called from extension to align screen row in neovim after scrolling
" function! VSCodeAlignScreenRow(row)
" let currentRow = winline()
" let diff = abs(currentRow - a:row)
" if diff > 0
" if (a:row - currentRow) < 0
" if diff > 1
" silent! exe "normal! " . diff . "\<C-e>"
" else
" silent! exe "normal! \<C-e>"
" endif
" else
" if diff > 1
" silent! exe "normal! " . diff . "\<C-y>"
" else
" silent! exe "normal! \<C-y>"
" endif
" endif
" endif
" endfunction
" Set text decorations for given ranges. Used in easymotion
function! VSCodeSetTextDecorations(hlName, rowsCols)
call VSCodeExtensionNotify('text-decorations', a:hlName, a:rowsCols)
endfunction
" Used for ctrl-a insert keybinding
function! VSCodeGetLastInsertText()
let [lineStart, colStart] = getpos("'[")[1:2]
let [lineEnd, colEnd] = getpos("']")[1:2]
if (lineStart == 0)
return []
endif
let lines = getline(lineStart, lineEnd)
let lines[0] = lines[0][colStart - 1:]
let lines[-1] = lines[-1][:colEnd - 1]
return lines
endfunction
" Used for ctrl-r [reg] insert keybindings
function! VSCodeGetRegister(reg)
return getreg(a:reg)
endfunction
" This is called by extension when created new buffer
function! s:onBufEnter(name, id)
if exists('b:vscode_temp') && b:vscode_temp
return
endif
set conceallevel=0
let tabstop = &tabstop
let isJumping = 0
if exists('g:isJumping')
let isJumping = g:isJumping
endif
call VSCodeExtensionCall('external-buffer', a:name, a:id, 1, tabstop, isJumping)
endfunction
function! s:runFileTypeDetection()
doautocmd BufRead
if exists('b:vscode_controlled') && b:vscode_controlled
" make sure we disable syntax (global option seems doesn't take effect for 2nd+ windows)
setlocal syntax=off
endif
endfunction
function! s:onInsertEnter()
let reg = reg_recording()
if !empty(reg)
call VSCodeExtensionCall('notify-recording', reg)
endif
endfunction
" Load altercmd first
execute 'source ' . s:currDir . '/vim-altercmd/plugin/altercmd.vim'
execute 'source ' . s:currDir . '/vscode-insert.vim'
execute 'source ' . s:currDir . '/vscode-scrolling.vim'
execute 'source ' . s:currDir . '/vscode-jumplist.vim'
execute 'source ' . s:currDir . '/vscode-code-actions.vim'
execute 'source ' . s:currDir . '/vscode-file-commands.vim'
execute 'source ' . s:currDir . '/vscode-tab-commands.vim'
execute 'source ' . s:currDir . '/vscode-window-commands.vim'
execute 'source ' . s:currDir . '/vscode-motion.vim'
augroup VscodeGeneral
autocmd!
" autocmd BufWinEnter,WinNew,WinEnter * :only
autocmd BufWinEnter * call <SID>onBufEnter(expand('<afile>'), expand('<abuf>'))
" Help and other buffer types may explicitly disable line numbers - reenable them, !important - set nowrap since it may be overriden and this option is crucial for now
" autocmd FileType * :setlocal conceallevel=0 | :setlocal number | :setlocal numberwidth=8 | :setlocal nowrap | :setlocal nofoldenable
autocmd InsertEnter * call <SID>onInsertEnter()
autocmd BufAdd * call <SID>runFileTypeDetection()
" Looks like external windows are coming with "set wrap" set automatically, disable them
" autocmd WinNew,WinEnter * :set nowrap
augroup END

View file

@ -0,0 +1,86 @@
" This file used to force set neovim options which may break the extension. Loaded after user config
scriptencoding utf-8
set shortmess=filnxtToOFI
set nowrap
set mouse=a
set cmdheight=1
set wildmode=list
set wildchar=<C-e>
set nobackup
set nowb
set noswapfile
set noautoread
set scrolloff=100
set conceallevel=0
set nocursorline
" do not hide buffers
" set nohidden
set hidden
set bufhidden=hide
" do not attempt autowrite any buffers
set noautowrite
" Disable shada session storing
" set shada=
" set nonumber
set norelativenumber
" Render line number as "marker" of the visible top/bottom screen row
set nonumber
" up to 10 000 000
" set numberwidth=8
" Need to know tabs for HL
set listchars=tab:❥♥
set list
" Allow to use vim HL for external buffers, vscode buffers explicitly disable it
syntax on
set signcolumn=no
" Disable statusline and ruler since we don't need them anyway
set statusline=
set laststatus=0
set noruler
" Disable modeline processing. It's being used for tab related settings usually and we don't want to override ours
set nomodeline
set modelines=0
" Turn off auto-folding
set nofoldenable
set foldmethod=manual
" Turn on auto-indenting
set autoindent
set smartindent
" split/nosplit doesn't work currently, see https://github.com/asvetliakov/vscode-neovim/issues/329
set inccommand=
" lazyredraw breaks the movement
set nolazyredraw
function s:forceLocalOptions()
setlocal nowrap
setlocal conceallevel=0
setlocal scrolloff=100
setlocal hidden
setlocal bufhidden=hide
setlocal noautowrite
setlocal nonumber
setlocal norelativenumber
setlocal list
setlocal listchars=tab:❥♥
if exists('b:vscode_controlled') && b:vscode_controlled
setlocal syntax=off
endif
setlocal nofoldenable
setlocal foldmethod=manual
setlocal nolazyredraw
endfunction
augroup VscodeForceOptions
autocmd!
autocmd BufEnter,FileType * call <SID>forceLocalOptions()
augroup END

View file

@ -0,0 +1,46 @@
function s:reveal(direction, resetCursor)
call VSCodeExtensionNotify('reveal', a:direction, a:resetCursor)
endfunction
nnoremap z<CR> <Cmd>call <SID>reveal('top', 1)<CR>
xnoremap z<CR> <Cmd>call <SID>reveal('top', 1)<CR>
nnoremap zt <Cmd>call <SID>reveal('top', 0)<CR>
xnoremap zt <Cmd>call <SID>reveal('top', 0)<CR>
nnoremap z. <Cmd>call <SID>reveal('center', 1)<CR>
xnoremap z. <Cmd>call <SID>reveal('center', 1)<CR>
nnoremap zz <Cmd>call <SID>reveal('center', 0)<CR>
xnoremap zz <Cmd>call <SID>reveal('center', 0)<CR>
nnoremap z- <Cmd>call <SID>reveal('bottom', 1)<CR>
xnoremap z- <Cmd>call <SID>reveal('bottom', 1)<CR>
nnoremap zb <Cmd>call <SID>reveal('bottom', 0)<CR>
xnoremap zb <Cmd>call <SID>reveal('bottom', 0)<CR>
function s:moveCursor(to)
" Native VSCode commands don't register jumplist. Fix by registering jumplist in Vim e.g. for subsequent use of <C-o>
normal! m'
call VSCodeExtensionNotify('move-cursor', a:to)
endfunction
nnoremap H <Cmd>call <SID>moveCursor('top')<CR>
xnoremap H <Cmd>call <SID>moveCursor('top')<CR>
nnoremap M <Cmd>call <SID>moveCursor('middle')<CR>
xnoremap M <Cmd>call <SID>moveCursor('middle')<CR>
nnoremap L <Cmd>call <SID>moveCursor('bottom')<CR>
xnoremap L <Cmd>call <SID>moveCursor('bottom')<CR>
" Disabled due to scroll problems (the ext binds them directly)
" nnoremap <silent> <expr> <C-d> VSCodeExtensionCall('scroll', 'halfPage', 'down')
" xnoremap <silent> <expr> <C-d> VSCodeExtensionCall('scroll', 'halfPage', 'down')
" nnoremap <silent> <expr> <C-u> VSCodeExtensionCall('scroll', 'halfPage', 'up')
" xnoremap <silent> <expr> <C-u> VSCodeExtensionCall('scroll', 'halfPage', 'up')
" nnoremap <silent> <expr> <C-f> VSCodeExtensionCall('scroll', 'page', 'down')
" xnoremap <silent> <expr> <C-f> VSCodeExtensionCall('scroll', 'page', 'down')
" nnoremap <silent> <expr> <C-b> VSCodeExtensionCall('scroll', 'page', 'up')
" xnoremap <silent> <expr> <C-b> VSCodeExtensionCall('scroll', 'page', 'up')
" nnoremap <silent> <expr> <C-e> VSCodeExtensionNotify('scroll-line', 'down')
" xnoremap <silent> <expr> <C-e> VSCodeExtensionNotify('scroll-line', 'down')
" nnoremap <silent> <expr> <C-y> VSCodeExtensionNotify('scroll-line', 'up')
" xnoremap <silent> <expr> <C-y> VSCodeExtensionNotify('scroll-line', 'up')

View file

@ -0,0 +1,40 @@
function! s:switchEditor(...) abort
let count = a:1
let direction = a:2
for i in range(1, count ? count : 1)
call VSCodeCall(direction ==# 'next' ? 'workbench.action.nextEditorInGroup' : 'workbench.action.previousEditorInGroup')
endfor
endfunction
command! -complete=file -nargs=? Tabedit if empty(<q-args>) | call VSCodeNotify('workbench.action.quickOpen') | else | call VSCodeExtensionNotify('open-file', expand(<q-args>), 0) | endif
command! -complete=file Tabnew call VSCodeExtensionNotify('open-file', '__vscode_new__', 0)
command! Tabfind call VSCodeNotify('workbench.action.quickOpen')
command! Tab echoerr 'Not supported'
command! Tabs echoerr 'Not supported'
command! -bang Tabclose if <q-bang> ==# '!' | call VSCodeNotify('workbench.action.revertAndCloseActiveEditor') | else | call VSCodeNotify('workbench.action.closeActiveEditor') | endif
command! Tabonly call VSCodeNotify('workbench.action.closeOtherEditors')
command! -nargs=? Tabnext call <SID>switchEditor(<q-args>, 'next')
command! -nargs=? Tabprevious call <SID>switchEditor(<q-args>, 'prev')
command! Tabfirst call VSCodeNotify('workbench.action.firstEditorInGroup')
command! Tablast call VSCodeNotify('workbench.action.lastEditorInGroup')
command! Tabrewind call VSCodeNotify('workbench.action.firstEditorInGroup')
command! -nargs=? Tabmove echoerr 'Not supported yet'
AlterCommand tabe[dit] Tabedit
AlterCommand tabnew Tabnew
AlterCommand tabf[ind] Tabfind
AlterCommand tab Tab
AlterCommand tabs Tabs
AlterCommand tabc[lose] Tabclose
AlterCommand tabo[nly] Tabonly
AlterCommand tabn[ext] Tabnext
AlterCommand tabp[revious] Tabprevious
AlterCommand tabr[ewind] Tabrewind
AlterCommand tabfir[st] Tabfirst
AlterCommand tabl[ast] Tablast
AlterCommand tabm[ove] Tabmove
nnoremap gt <Cmd>call <SID>switchEditor(v:count, 'next')<CR>
xnoremap gt <Cmd>call <SID>switchEditor(v:count, 'next')<CR>
nnoremap gT <Cmd>call <SID>switchEditor(v:count, 'prev')<CR>
xnoremap gT <Cmd>call <SID>switchEditor(v:count, 'prev')<CR>

View file

@ -0,0 +1,158 @@
function! s:split(...) abort
let direction = a:1
let file = exists('a:2') ? a:2 : ''
call VSCodeCall(direction ==# 'h' ? 'workbench.action.splitEditorDown' : 'workbench.action.splitEditorRight')
if !empty(file)
call VSCodeExtensionNotify('open-file', expand(file), 'all')
endif
endfunction
function! s:splitNew(...)
let file = a:2
call s:split(a:1, empty(file) ? '__vscode_new__' : file)
endfunction
function! s:closeOtherEditors()
call VSCodeNotify('workbench.action.closeEditorsInOtherGroups')
call VSCodeNotify('workbench.action.closeOtherEditors')
endfunction
function! s:manageEditorHeight(...)
let count = a:1
let to = a:2
for i in range(1, count ? count : 1)
call VSCodeNotify(to ==# 'increase' ? 'workbench.action.increaseViewHeight' : 'workbench.action.decreaseViewHeight')
endfor
endfunction
function! s:manageEditorWidth(...)
let count = a:1
let to = a:2
for i in range(1, count ? count : 1)
call VSCodeNotify(to ==# 'increase' ? 'workbench.action.increaseViewWidth' : 'workbench.action.decreaseViewWidth')
endfor
endfunction
command! -complete=file -nargs=? Split call <SID>split('h', <q-args>)
command! -complete=file -nargs=? Vsplit call <SID>split('v', <q-args>)
command! -complete=file -nargs=? New call <SID>split('h', '__vscode_new__')
command! -complete=file -nargs=? Vnew call <SID>split('v', '__vscode_new__')
command! -bang Only if <q-bang> ==# '!' | call <SID>closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif
AlterCommand sp[lit] Split
AlterCommand vs[plit] Vsplit
AlterCommand new New
AlterCommand vne[w] Vnew
AlterCommand on[ly] Only
" buffer management
nnoremap <C-w>n <Cmd>call <SID>splitNew('h', '__vscode_new__')<CR>
xnoremap <C-w>n <Cmd>call <SID>splitNew('h', '__vscode_new__')<CR>
nnoremap <C-w>q <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
xnoremap <C-w>q <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
nnoremap <C-w>c <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
xnoremap <C-w>c <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
nnoremap <C-w><C-c> <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
xnoremap <C-w><C-c> <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>
" window/splits management
nnoremap <C-w>s <Cmd>call <SID>split('h')<CR>
xnoremap <C-w>s <Cmd>call <SID>split('h')<CR>
nnoremap <C-w><C-s> <Cmd>call <SID>split('h')<CR>
xnoremap <C-w><C-s> <Cmd>call <SID>split('h')<CR>
nnoremap <C-w>v <Cmd>call <SID>split('v')<CR>
xnoremap <C-w>v <Cmd>call <SID>split('v')<CR>
nnoremap <C-w><C-v> <Cmd>call <SID>split('v')<CR>
xnoremap <C-w><C-v> <Cmd>call <SID>split('v')<CR>
nnoremap <C-w>= <Cmd>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
xnoremap <C-w>= <Cmd>call VSCodeNotify('workbench.action.evenEditorWidths')<CR>
nnoremap <C-w>_ <Cmd>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
xnoremap <C-w>_ <Cmd>call VSCodeNotify('workbench.action.toggleEditorWidths')<CR>
nnoremap <C-w>+ <Cmd>call <SID>manageEditorHeight(v:count, 'increase')<CR>
xnoremap <C-w>+ <Cmd>call <SID>manageEditorHeight(v:count, 'increase')<CR>
nnoremap <C-w>- <Cmd>call <SID>manageEditorHeight(v:count, 'decrease')<CR>
xnoremap <C-w>- <Cmd>call <SID>manageEditorHeight(v:count, 'decrease')<CR>
nnoremap <C-w>> <Cmd>call <SID>manageEditorWidth(v:count, 'increase')<CR>
xnoremap <C-w>> <Cmd>call <SID>manageEditorWidth(v:count, 'increase')<CR>
nnoremap <C-w>< <Cmd>call <SID>manageEditorWidth(v:count, 'decrease')<CR>
xnoremap <C-w>< <Cmd>call <SID>manageEditorWidth(v:count, 'decrease')<CR>
nnoremap <C-w>o <Cmd>call VSCodeNotify('workbench.action.joinAllGroups')<CR>
xnoremap <C-w>o <Cmd>call VSCodeNotify('workbench.action.joinAllGroups')<CR>
nnoremap <C-w><C-o> <Cmd>call VSCodeNotify('workbench.action.joinAllGroups')<CR>
xnoremap <C-w><C-o> <Cmd>call VSCodeNotify('workbench.action.joinAllGroups')<CR>
" window navigation
nnoremap <C-w>j <Cmd>call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
xnoremap <C-w>j <Cmd>call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
nnoremap <C-w>k <Cmd>call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
xnoremap <C-w>k <Cmd>call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
nnoremap <C-w>h <Cmd>call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
xnoremap <C-w>h <Cmd>call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
nnoremap <C-w>l <Cmd>call VSCodeNotify('workbench.action.focusRightGroup')<CR>
xnoremap <C-w>l <Cmd>call VSCodeNotify('workbench.action.focusRightGroup')<CR>
nnoremap <C-w><Down> <Cmd>call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
xnoremap <C-w><Down> <Cmd>call VSCodeNotify('workbench.action.focusBelowGroup')<CR>
nnoremap <C-w><Up> <Cmd>call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
xnoremap <C-w><Up> <Cmd>call VSCodeNotify('workbench.action.focusAboveGroup')<CR>
nnoremap <C-w><Left> <Cmd>call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
xnoremap <C-w><Left> <Cmd>call VSCodeNotify('workbench.action.focusLeftGroup')<CR>
nnoremap <C-w><Right> <Cmd>call VSCodeNotify('workbench.action.focusRightGroup')<CR>
xnoremap <C-w><Right> <Cmd>call VSCodeNotify('workbench.action.focusRightGroup')<CR>
nnoremap <C-w><C-j> <Cmd>call VSCodeNotify('workbench.action.moveEditorToBelowGroup')<CR>
xnoremap <C-w><C-j> <Cmd>call VSCodeNotify('workbench.action.moveEditorToBelowGroup')<CR>
nnoremap <C-w><C-i> <Cmd>call VSCodeNotify('workbench.action.moveEditorToAboveGroup')<CR>
xnoremap <C-w><C-i> <Cmd>call VSCodeNotify('workbench.action.moveEditorToAboveGroup')<CR>
nnoremap <C-w><C-h> <Cmd>call VSCodeNotify('workbench.action.moveEditorToLeftGroup')<CR>
xnoremap <C-w><C-h> <Cmd>call VSCodeNotify('workbench.action.moveEditorToLeftGroup')<CR>
nnoremap <C-w><C-l> <Cmd>call VSCodeNotify('workbench.action.moveEditorToRightGroup')<CR>
xnoremap <C-w><C-l> <Cmd>call VSCodeNotify('workbench.action.moveEditorToRightGroup')<CR>
nnoremap <C-w><C-Down> <Cmd>call VSCodeNotify('workbench.action.moveEditorToBelowGroup')<CR>
xnoremap <C-w><C-Down> <Cmd>call VSCodeNotify('workbench.action.moveEditorToBelowGroup')<CR>
nnoremap <C-w><C-Up> <Cmd>call VSCodeNotify('workbench.action.moveEditorToAboveGroup')<CR>
xnoremap <C-w><C-Up> <Cmd>call VSCodeNotify('workbench.action.moveEditorToAboveGroup')<CR>
nnoremap <C-w><C-Left> <Cmd>call VSCodeNotify('workbench.action.moveEditorToLeftGroup')<CR>
xnoremap <C-w><C-Left> <Cmd>call VSCodeNotify('workbench.action.moveEditorToLeftGroup')<CR>
nnoremap <C-w><C-Right> <Cmd>call VSCodeNotify('workbench.action.moveEditorToRightGroup')<CR>
xnoremap <C-w><C-Right> <Cmd>call VSCodeNotify('workbench.action.moveEditorToRightGroup')<CR>
nnoremap <C-w><S-j> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupDown')<CR>
xnoremap <C-w><S-j> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupDown')<CR>
nnoremap <C-w><S-k> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupUp')<CR>
xnoremap <C-w><S-k> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupUp')<CR>
nnoremap <C-w><S-h> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupLeft')<CR>
xnoremap <C-w><S-h> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupLeft')<CR>
nnoremap <C-w><S-l> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupRight')<CR>
xnoremap <C-w><S-l> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupRight')<CR>
nnoremap <C-w><S-Down> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupDown')<CR>
xnoremap <C-w><S-Down> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupDown')<CR>
nnoremap <C-w><S-Up> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupUp')<CR>
xnoremap <C-w><S-Up> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupUp')<CR>
nnoremap <C-w><S-Left> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupLeft')<CR>
xnoremap <C-w><S-Left> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupLeft')<CR>
nnoremap <C-w><S-Right> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupRight')<CR>
xnoremap <C-w><S-Right> <Cmd>call VSCodeNotify('workbench.action.moveActiveEditorGroupRight')<CR>
nnoremap <C-w>w <Cmd>call VSCodeNotify('workbench.action.focusNextGroup')<CR>
xnoremap <C-w>w <Cmd>call VSCodeNotify('workbench.action.focusNextGroup')<CR>
nnoremap <C-w><C-w> <Cmd>call VSCodeNotify('workbench.action.focusNextGroup')<CR>
xnoremap <C-w><C-w> <Cmd>call VSCodeNotify('workbench.action.focusNextGroup')<CR>
nnoremap <C-w>W <Cmd>call VSCodeNotify('workbench.action.focusPreviousGroup')<CR>
xnoremap <C-w>W <Cmd>call VSCodeNotify('workbench.action.focusPreviousGroup')<CR>
nnoremap <C-w>p <Cmd>call VSCodeNotify('workbench.action.focusPreviousGroup')<CR>
xnoremap <C-w>p <Cmd>call VSCodeNotify('workbench.action.focusPreviousGroup')<CR>
nnoremap <C-w>t <Cmd>call VSCodeNotify('workbench.action.focusFirstEditorGroup')<CR>
xnoremap <C-w>t <Cmd>call VSCodeNotify('workbench.action.focusFirstEditorGroup')<CR>
nnoremap <C-w>b <Cmd>call VSCodeNotify('workbench.action.focusLastEditorGroup')<CR>
xnoremap <C-w>b <Cmd>call VSCodeNotify('workbench.action.focusLastEditorGroup')<CR>