This plugin is a clone of other popular Angular QuickSwitch plugins, e.g.:
While there are similar plugins for NeoVim, e.g. nvim-quick-switcher or ngswitcher, I usually only use the shortcut to toggle between the class definition and template of an Angular component.
{ "matthiasweiss/angular-quickswitch.nvim", opts = {} }
:NgQuickSwitchToggle
has the following behavior:
- For components it toggles between the class definition and the template of your Angular component
(assumes that the files are in the same folder and that the filenames are identical,
e.g.
src/example.component.html
andsrc/example.component.ts
) - For any other TypeScript file (e.g. services, pipes, guards, etc.) it toggles between the file and
its associated test file, it assumes the test suffix to be
.spec.ts
, e.g.src/example.service.ts
andsrc/example.service.spec.ts
.
All of the following commands switch to one specific file:
command | file |
---|---|
:NgQuickSwitchClass |
Class, e.g. example.component.ts or example.service.ts |
:NgQuickSwitchTemplate |
Template, e.g. example.component.html |
:NgQuickSwitchTest |
Test, e.g. example.component.spec.ts or example.service.spec.ts |
Since calling the commands manually each time is quite cumbersome, I use the following keymaps:
command | keymap |
---|---|
:NgQuickSwitchToggle |
<leader>qs |
If you want to use the same keymaps, you can pass use_default_keymaps=true
as follows:
{ "matthiasweiss/angular-quickswitch.nvim", opts = { use_default_keymaps = true } }