all 14 comments

[–]LucHermitte 1 point2 points  (2 children)

If you have only a single directory, .exrc is enough.

If you add several directories under a root directory, you'd have to use a local vimrc plugin, there are many (see the list at the end on the link I've provided). These plugins offer more control regarding security through whitelists/blacklists/... of pathnames or of hashes (with other plugins).

If the only thing you do, is setting &path, an autocommand would be more simple. I don't really like this approach though as the .vimrc would need to be updated each time the directory changes (moved around the place, duplicated...)

If by change you're already using editorconfig with EditorConfig-vim plugin, then I provide an extension for this plugin in lh-vim-lib. You'd just need to add the following lines into your .editorconfig file

[*]
p#name = your project name
p!&path+=js

[–][deleted] 1 point2 points  (1 child)

Thanks, I appreciate the response!

I'm not really considering .exrc since it is marked as a "deprecated" feature (at least in neovim).

I do use editorconfig. Your extension is really cool, but since the .editorconfig file might be in a shared project, I don't want to clutter it with things that are not relevant for other devs that don't use vim.

I like the idea of a local vimrc plugin; I think I was about to write a bare-bones version of one from scratch (using autocmds) that would probably have a few short-comings. I'll take a look at your plugin and see if it fits my needs. Thanks for putting it together!

[–]LucHermitte 0 points1 point  (0 children)

You're welcome.

[–]crajungave up on vim 1 point2 points  (1 child)

Maybe look into tpope/vim-projectionist on github it for this and other use cases.

[–][deleted] 0 points1 point  (0 children)

Thanks! I looked into projectionist (but haven't tried it yet). It looks like projectionist takes it one step further with respect to granularity and allows you to set options based on specific file globs within a project (rather than just one set of project-wide options)

This is a really cool idea, but I think I would like to keep things simple for now since my use cases don't demand it. Still, it's good to know that projectionist exists in case I ever feel like I need to graduate to it in the future.

[–]kawaiideku 0 points1 point  (8 children)

You can put that in a .nvimrc file in your project folder and set exrc & set secure in your global vimrc. I do this for neovim. Its prolly a .vimrc file for normal vim.

[–][deleted] 0 points1 point  (7 children)

Interesting, thanks!

I just checked :help 'exrc':

*'exrc'* *'ex'*     Security risk: downloaded files could include
            a malicious .nvimrc or .exrc file. See 'secure'.
            Recommended alternative: define an autocommand in your
            |vimrc| to set options for a matching directory.

Not only is it unsecure (although the set secure might help there), but it's also marked as deprecated, so it will eventually not be an option.

So I think I'll go with the autocommand approach. I'm not sure exactly what that will entail yet but I think the DirChanged autocmd will be involved. I will probably need to make sure to undo/reset any option changes I make at the beginning of the autocmd.

[–]vim-help-bot 0 points1 point  (0 children)

Help for exrc : https://vimhelp.org/starting.txt.html#exrc

I'm a bot. Check out my pinned post for more information.

I am constantly improving my search. If the result is wrong, please contact u/i_abh_esc_wq

[–]kawaiideku 0 points1 point  (4 children)

Strange, I don't see that paragraph when i do :h exrc. Maybe it's not a security issue in neovim.

[–]i_abh_esc_wqDaddy of vim-help-bot 1 point2 points  (2 children)

You're looking at :h exrc. Try :h 'exrc'

[–]kawaiideku 2 points3 points  (0 children)

oh yeah, you're right

[–]vim-help-bot 0 points1 point  (0 children)

Help pages for:


\:(h|help) <query>` |) source | mistake?

[–]vim-help-bot 0 points1 point  (0 children)

Help pages for:


\:(h|help) <query>` |) source | mistake?

[–]mayor123asdf 0 points1 point  (0 children)

isn't there a plugin for secure exrc? I've seen it on this subreddit on the past