vim

For discussion on all things (neo)vim.
dharrigan 2020-10-08T08:11:50.034200Z

Started to use tpope/projectionist <https://github.com/tpope/vim-projectionist> which allows me to swap between src and test with a simple binding, for example, here is my .projections.json configuration which lives at the root of the project

dharrigan 2020-10-08T08:12:06.034400Z

❯ cat .projections.json                        
{
  "src/*.clj": {
    "alternate": "test/{}_test.clj",
    "type": "source"
  },
  "test/*_test.clj": {
    "alternate": "src/{}.clj",
    "type": "test"
  }
}

1🚀
practicalli-john 2020-10-09T20:21:02.039500Z

Do I understand correctly that I need to add this configuration to every Clojure project I work with (I have lots).

practicalli-john 2020-10-09T20:23:10.039700Z

Reading the vim-projectionist docs, it seems you can set it globally if a directory contains a file, using g:projectionist_heuristics I wonder if that would work if we look for a deps.edn file in the root of a project, this could save putting a json file in every project. If you try this approach, let me know if it works. Its on my very long neovim todo list :)

dharrigan 2020-10-11T07:18:04.044500Z

I can certainly give that a try soon!

dharrigan 2020-10-11T08:05:19.044800Z

This works

dharrigan 2020-10-11T08:06:28.045Z

create a file $HOME/.vim/syntax/clojure.vim

dharrigan 2020-10-11T08:06:37.045300Z

then add in this:

dharrigan 2020-10-11T08:06:53.045500Z

"
" Projections
"
autocmd User ProjectionistDetect
  \ call projectionist#append(getcwd(),
  \ {
  \   'src/*.clj': {
  \     'alternate': 'test/{}_test.clj',
  \     'type': 'source'
  \   },
  \   'test/*_test.clj': {
  \     'alternate': 'src/{}.clj',
  \     'type': 'test'
  \   },
  \ })

dharrigan 2020-10-11T08:07:16.045700Z

bingo. only files of type clojure will have that applied, allowing projectionist to work as appropriate.

dharrigan 2020-10-11T08:07:16.045900Z

.

practicalli-john 2020-10-11T09:52:56.046100Z

Excellent, thank you for sharing and improving my vim life

dharrigan 2020-10-11T10:00:33.046300Z

You're most welcome 🙂

dharrigan 2020-10-08T08:12:53.035300Z

if one follows normal naming conventions, then swapping between your src file and the test file can be bound to a key, for example ,t if , is your leader 🙂

practicalli-john 2020-10-09T20:24:35.039900Z

Spacemacs uses SPC p a for alternating between src and test in a project, so I would probably use that myself.

dharrigan 2020-10-08T08:13:03.035500Z

pretty handy!