Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic projectionist support #451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mluts
Copy link

@mluts mluts commented Nov 2, 2018

Hello, few days ago i bothered to add support for https://github.com/tpope/vim-projectionist to my config files. Basically i use A shortcut to navigate between tests/source-code, i think it could be useful for other people.

Feel free to modify, thank you for this repo.

@jparise
Copy link
Contributor

jparise commented Dec 28, 2018

You could also set make to mix (for source files).

let root = simplify(fnamemodify('.', ':p:s?[\/]$??'))

let projections = {}
let projections['lib/*.ex'] = { 'type': 'main', 'alternate': ['test/{}_test.exs'] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer type: source to type: main, which follows the convention used by the Projectionist documentation. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use type: lib


let projections = {}
let projections['lib/*.ex'] = { 'type': 'main', 'alternate': ['test/{}_test.exs'] }
let projections['lib/**/*.ex'] = { 'type': 'main', 'alternate': ['test/{}_test.exs'] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these additional lib/**/ and test/**/ entries necessary? The lib/*.ex / test/*.ex entries work well for me, even with file hierarchies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, these aren't needed, quoting docs:

From a globbing perspective, "*" is actually a stand in for "**/*". For advanced cases, you can include both globs explicitly: "test/**/test_*.rb". When expanding with {}, the ** and * portions are joined with a slash. If necessary, the dirname and basename expansions can be used to split the value back apart.

@hauleth
Copy link
Contributor

hauleth commented Aug 21, 2019

My configuration for projectionist looks like this:

let g:projectionist_heuristics['mix.exs'] = {
            \ 'apps/*/mix.exs': { 'type': 'app' },
            \ 'lib/*.ex': {
            \   'type': 'lib',
            \   'alternate': 'test/{}_test.exs',
            \   'template': ['defmodule {camelcase|capitalize|dot} do', 'end'],
            \ },
            \ 'test/*_test.exs': {
            \   'type': 'test',
            \   'alternate': 'lib/{}.ex',
            \   'template': ['defmodule {camelcase|capitalize|dot}Test do', '  use ExUnit.Case', '', '  @subject {camelcase|capitalize|dot}', '', '  doctest @subject', 'end'],
            \ },
            \ 'mix.exs': { 'type': 'mix' },
            \ 'config/*.exs': { 'type': 'config' },
            \ '*.ex': {
            \   'makery': {
            \     'lint': { 'compiler': 'credo' },
            \     'test': { 'compiler': 'exunit' },
            \     'build': { 'compiler': 'mix' }
            \   }
            \ },
            \ '*.exs': {
            \   'makery': {
            \     'lint': { 'compiler': 'credo' },
            \     'test': { 'compiler': 'exunit' },
            \     'build': { 'compiler': 'mix' }
            \   }
            \ }
            \ }

@kelvinst
Copy link
Contributor

@hauleth I like your configuration, 👍 on configuring it that way... I would just add the dispatch config to it, since it's a well known package too

@hauleth
Copy link
Contributor

hauleth commented Aug 21, 2019

@kelvinst no problem, however I use a little bit more powerful makery. That is why there is no Dispatch configuration.

@kelvinst
Copy link
Contributor

Yep, realized that, will check that one someday, but for now I'm sticking with dispatch.

@kelvinst
Copy link
Contributor

I opened a PR for @mluts branch there: mluts#1. The changes should fall here once he accepts (I hope, never did that before).

@sodapopcan
Copy link
Collaborator

This is quite old and doesn't look like there are any signs of it getting merged but just wanted to weigh in here:

I don't think it's a good idea for this to be included in this repo for the very reason outlined by the above convo and comments on the PR: projections.json files are very personal. I feel that anyone who has installed projectionist already has their own system for including their projections.

I think this type of thing would be best included under a "Tips" category or the like in the wiki or README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants