A plugin to run your project-level neovim configuration.
If you've used set exrc before, you would be informed that using it might execute malicious code, see
:h 'exrc'. Therefore, you would've been advised to also enable set secure to disable some vim config
options like autocmds, shell executions and write commands, see :h 'secure'.
However, there might some options you may want to conditionally set in a project-level basis but the limitations of
secure restrict you those options.
ProjectCMD tries to tackle this by not using set secure or set exrc but sourcing a .vim/.lua file in
your $PROJECT_DIR/.vim/init.vim/$PROJECT_DIR/.vim/init.lua - if allowed by the user - and execute the code once its
determined safe.
Essentially, the goal of this plugin is to help you safely source your project-specific options. Think of it like an
.vscode/settings.json file but for vim.
For example, let's say you're using ALE on a JavaScript project and you only want to enable tsserver,
eslint and prettier for your code. Within your $PROJECT_DIR/.vim/init.vim you can add:
" $PROJECT_DIR/.vim/init.vim
autocmd! FileType javascript let b:ale_linters = ['tsserver', 'eslint'] | let b:ale_fixers = ['prettier']This will introduce two different flows for loading the local config file - which is by default
$PROJECT_DIR/.vim/init.lua
The first time flow, will be when you open nvim for the first time, after adding the local config file:
- You will be prompted to add the local config file to the allowlist
- By saying (pressing any other key will perform the last action on this list):
y, it will add it to the allowlist and source the filen, it will then be ignored until you manually source it yourself (see: Autoloading)c, it will then be ignored until you re-open nvim, to show the prompt
The change flow, will be when you make changes to the local config file:
- You will be prompted to update the allowlist with the new checksum
- By saying (pressing any other key will perform the last action on this list):
y, it will add the updated checksum to the allowlist and source the filec, it will then be ignored until you re-open nvim, to show the prompt
IMPORTANT: Neovim nightly (v0.5 or build from master branch) is required.
Install via a plugin manager, any one will do, here are some examples using packer, minpac, vim-packager and vim-plug.
use 'creativenull/projectcmd.nvim'call minpac#add('creativenull/projectcmd.nvim')call packager#add('creativenull/projectcmd.nvim')Plug 'creativenull/projectcmd.nvim'" init.vim
lua require 'projectcmd'.setup {}-- init.lua
require 'projectcmd'.setup {}Opens the local config file in your project.
Opens the allowlist, displaying all your project directories that are to source the local config file.
Opens the ignorelist, displaying all your project directories that are NOT allowed to be source, unless specified manually, or explicitly deleted from the ignorelist.
Manually source the local config file if not done on the first prompt.
By default this is enabled, this means the plugin will source the local config file on load. If you want to manually source the
local config file, then set the enable key to false. To manually source use :PCmdEnable, this will add the project
to the allowlist but you will still need to :PCmdEnable every time you open vim in that project directory.
require 'projectcmd'.setup {
enable = false
}Below are the default settings that are set, if not provided.
-- Default Settings
require 'projectcmd'.setup {
enable = true,
show_message = true,
root_dir = '~/.cache/projectcmd',
project_config_filepath = '/.vim/init.lua'
}| Key | Description |
|---|---|
enable |
Let the plugin automatically source the project config file |
show_message |
Shows the message on command line bar, at the bottom of statusline |
root_dir |
Shows the message on command line bar, at the bottom of statusline |
project_config_filepath |
Location of the local config file in the project directory |
- If you have
autochdirenabled, make sure to disable it:set noautochdir. This messes with getting the current working directory.
Guide coming soon, but you are more than welcome to explore the codebase and make an issue on the problem 🙂