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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions ftplugin/elixir.vim
Expand Up @@ -51,3 +51,19 @@ silent! setlocal formatoptions-=t formatoptions+=croqlj

let b:undo_ftplugin = 'setlocal sw< sts< et< isk< com< cms< path< inex< sua< def<'.
\ '| unlet! b:match_ignorecase b:match_words b:block_begin b:block_end'

function s:projectionist_detect_elixir()
if filereadable('mix.exs')
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['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.

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

call projectionist#append(root, projections)
endif
endfunc

autocmd User ProjectionistDetect call s:projectionist_detect_elixir()