Giter VIP home page Giter VIP logo

alternaut.vim's Introduction

alternaut.vim

Build Status

Jump between your test and source files.

Example

Say you've got a project structure like this:

src/
  __tests__/
    logic.test.js
    foo.test.js
  logic.js
  foo.js

and you're editing src/foo.js. You want to open the test file.

That's where alternaut comes in. Hit the keybinding and you're in src/__tests__/foo.test.js. Toggle again and you're right back in the other file.

Configuration

Alternaut doesn't make any assumptions about your project structure. You need to tell it your conventions. What do you name your test directories? What do you name your test files? That kind of thing.

" A typical JavaScript setup.
let alternaut#conventions = {}
let alternaut#conventions['javascript'] = {
\   'directory_naming_conventions': ['__tests__', 'tests'],
\   'file_naming_conventions': ['{name}.test.{ext}', '{name}.spec.{ext}'],
\   'file_extensions': ['js', 'jsx'],
\ }

Once that's registered, create a mapping:

nmap <leader>a <Plug>(alternaut-toggle)

Any time you open a javascript file, press <leader>a and it'll toggle between the corresponding test and source file.

The way of our people is help files.

:help alternaut

alternaut.vim's People

Contributors

psychollama avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

alternaut.vim's Issues

Function calls fail on initial load

If you're using a plugin manager like vim-plug, the first run of your vimrc may throw errors because alternaut hasn't been installed yet. Any alternaut#RegisterLanguage(...) statements will throw. It's a poor design. I should replace it with a config. Maybe something like this...

let alternaut#conventions = {
\   'javascript': {
\     'file_naming_conventions': ['{name}.test.{ext}'],
\     'directory_naming_conventions': ['__tests__'],
\     'file_extensions': ['js'],
\   },
\ }

Alternauting from test to source when they share the same directory hangs.

I started a new job. Every "component" has a directory and everything related to that component is in that directory, including tests. Here is an example.

src/components/header/
├── styles.js
├── header.js
├── header.test.js
└── package.json

I added '.' to my directory_naming_conventions and continued on with my life. I alternauted from source to test and exclaimed, "NICE! This psycho llama thought of everything!" I toggled from the test to the source and neovim hung indefinitely, until I Ctrl+C-ed.

I might fix it, you might it; we just have to decide first. I consider this a severity-0 bug since it really messes up my flow, man...

Improve mappings DX

I've seen some smart vim people use the <Plug> namespace for plugin mappings. I should use that rather than encouraging people to use internal alternaut functions.

-nnoremap <silent><leader>a <esc>:call alternaut#Toggle()<cr>
+nmap <silent><leader>a <Plug>(alternaut-toggle)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.