-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adding an option to allow automatic shebang even when current dir is not in $PATH #3
Comments
Hi @shreyas-a-s , thanks you for your nice words. If I understand the issue correctly, you would like to automatically add shebang to ALL new files? |
@Susensio Yes, Exactly. Irrespective of whether the file is in $PATH or not. EDIT: That's because I usually create bash, python, etc. scripts in non-PATH directories. For example in /home/shreyas/test. I would like the shebang to be automatically applied when creating new files in that directory. I know it is possible with autocommands. But an inbuilt option would be much simpler. |
I find it interesting that this feature is being proposed twice already. I would like understand the use case better to get proper implementation. What if you are working in a large python project? By large I mean multiple modules. Everytime you edit a Maybe an interesting solution would be to add custom paths as an option, maybe using glob patterns. BTW: you could always use the |
The 'adding shebang' part only works for new (python) files, right? If so I don't think it would be that problematic. But I really forgot about the 'making it executable' part. Thanks for letting me know. That might bring some issues. Hence I think the custom paths option that takes in a table of globs would be the desired solution. Because for my use case, currently I only need this new feature to work on I don't know much about the programming implications of adding such a feature. I'm still learning. But I would love to help in any manner in making this feature possible. EDIT: About the :Bang command, I was using keymap for invoking it and now using an autocommand for the same. It's just that since I am trying to reduce as much as friction from coding as possible, I thought automating the process of adding a shebang would be pretty cool and an inbuilt option would be even cooler. |
Sorry for the late replay. If you like to, you can implement it and send a PR. I was thinking in an |
It's absolutely fine for the late reply. We all have other things to do right! The fact that you have replied is the important part.
|
That's perfect. If you need any help understanding my code, just ask. |
For sure. |
Hi, @Susensio. I think I have a basic configuration of the feature. All the variable, function names as well as the totality of the code can be considered as an initial draft and any modification can be made. You can checkout this commit to see the changes. Also, I had some doubts regarding the feature:
Thanks for letting me contribute to the project. |
Hey Shreyas, thanks for your work. Regarding your concern about globs, I think globs are more user friendly than lua patterns, and I would rather use them. But the implementation may be simpler! Autocmd patterns [:h autocmd-pattern] are close enough to shell globs. Then, I haven't tested it but I think it should work. |
Now that I think about it, are globs even needed here? extra_paths = {
"~/bin",
"~/coolproject/scripts/"
} That should get translated into vim.api.nvim_create_autocmd(
"BufNewFile",
{
pattern = {
"~/bin/*",
"~/coolproject/scripts/*"
}
...
}
) |
Thanks for the good words, man. It truly motivates me. Regarding globs-or-patterns, I agree that globs are more user-friendly and generally better. And about the autocmd pattern matching, thank you so much for letting me remember. It had totally gone through the top of my head that there is a |
That's totally true. If The reason I brought up the use of globs was so that the application of shebang can be made a bit more granular. What I mean by that is, if we allow only directories to be placed inside But now that I think more, this scenario is a bit too niche to even think about it. So I am also getting to a point where I think we should just roll with 'allowing only directory paths' in the |
What is your personal use case? Would you use globs per filetype? Two scenarios I see here: only directories
This seems doable and easy allow globs
If you don't think you would use globs, I would rather keep it simple and only allow directory paths. The other option is... too magic I think |
To be honest, now I really don't know where the thought of globs came from. I don't think I would need globs. Because my use case is that I have a directory that is So at the moment there is not really a good reason to opt for globs, especially since it requires more work. Hence let's go with allowing only directories in the table. Now when it comes to implementation part
Also, I think it would also be necessary to convert '~' in items to actual HOME path using something like the code below so that users don't need to write the full path to home directory. local home = os.getenv("HOME")
modified_path = path:gsub("^~", home) |
Hi @shreyas-a-s, and sorry again for the delay.
I think that |
Again, it's absolutely no problem, mate :)
From my testing At this point, I feel we've touched all the important points. I think It'd be best if I create a PR and we discuss and modify that. You ok with that? |
something like
I've read in
perfect, give it a go! |
You were right, thanks for pointing that out, I've just solved a bug in my config =)
|
Hi, Nogueras. First of all, great plugin you have created. Works like a charm.
I would like the addition of an option with which even if current directory is not in $PATH, automatic shebang is applied.
Maybe something like modifying already existing variable
automatic
to have an extra valueignore_path
would be possible I think.I see that there is already a PR i.e. #1 by @mgabs but it only adds a new variable and nothing more as far as I can see.
I would love to contribute in adding this feature if you would like that and if the scope of this plugin allows such a feature. If not, then no problem at all.
Thanks for reading through my
essay
. Hoping to hear from you.The text was updated successfully, but these errors were encountered: