Skip to content

Dynamically setting up vim-project #13

Description

@rengolin

This is a bit of an odd one, but I'm at odds with vim-script (which I'm not very good at).

So, we use Git worktrees, and we automated in a way that we can create multiple directories as worktrees of the main repo, and we can edit, build and test each one of them on separate terminals, depending on which environment variables we've set.

A simplified view of my current setup:

" Vim Project
set rtp+=~/.vim/ext/vim-project/
let llvm = $LLVM_SRC
call project#rc("")
  Project llvm, 'LLVM'
call project#rc()`

For some reason, using "$LLVM_SRC" in there doesn't work, I needed a vim variable. Anyway...

That works when I start my Vim from the command line, where I have all the variables set, but not from my window manager's key binding (i3wm). So, I wanted to list all the directories in my worktree base and list them as projects, and not need any setup ($LLVM_ROOT is set in .bashrc).

Here's my feeble attempt:

" Vim Project
set rtp+=~/.vim/ext/vim-project/
let g:project_use_nerdtree = 1
let project_config = "call project#rc(\"\")\n"
for workdir in split(globpath($LLVM_ROOT, '*'), '\n')
  let dir = fnamemodify(workdir, ':t')
  if dir != "repos"
    let project_config .= "  Project '".dir."', 'LLVM ".dir."'\n"
  endif
endfor
let project_config .= "call project#rc()"
echo project_config
execute project_config

Which produces:

call project#rc("")
  Project 'default', 'LLVM default'
  Project 'other', 'LLVM other'
call project#rc()

but vim-project says:

E116: Invalid arguments for function project#config#project

I'm guessing that the execute is serialising everything and project#config#project thinks that the base dir is everything after the call?

Is there another way of doing this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions