-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add support for project-level configuration #116
Conversation
63eec0e
to
7311e41
Compare
From your description, everything seems good to me, but perhaps the first three options could be only two:
|
I agree the interface could (should?) be simplified. After a bit more thought, I think my preference would be:
|
I agree with the |
I see - thanks for explaining. How would you feel about using another sentinel to indicate no mapping, e.g. I think my aversion to combining |
What about the options for |
To be honest it still doesn't feel like the optimum solution to me 🤔 E.g. it then wouldn't be possible to then have magrittr as default, possibly overridden by I think I still find more options to clearer en balance. Maybe it'd be more palatable to lean into subtables:
Side note: I used 'keymap' instead of 'mapping' here because I think it could be considered a little clearer given the naming scheme used elsewhere, e.g. |
You are right! I like the |
feat: use actual errors in read_dcf fix: allow empty field values fix: correctly strip trailing whitespace from field values chore: add annotations for read_dcf() refactor: make read_dcf() helpers more uniform chore: improve read.dcf() docs chore: improve read.dcf() docs
chore: run stylua feat: Improve annotations in rproj.lua chore: run stylua fix: typo in warning message
feat: make pipe operator respect config.use_native_pipe fix: include spaces before and after inserted pipe feat: make pipe type respect .Rproj settings chore: run stylua feat: use <localleader>m as default pipe mapping feat: run rproj_setup() in each ftplugin script refactor: rename config.rproj_config to .rproj_prioritise
chore: run stylua fix: use oxford comma in utils.msg_join() feat: rework utils.table_structure() into .table_flatten() refactor: remove utils.table_flatten() fix: utils.msg_join() chore: document utils.msg_join() fix: utils.msg_join() annotations fix: utils.msg_join() formatting chore: run stylua
This necessitated a fairly significant refactor of the code that checks + applies user-supplied options to handle sub-tables in a robust way. The end result is powerful enough to handle arbitrary levels of nesting, and doesn't require a user to specify every option in a subtable if they don't like the default. To make this as simple as possible, all options (including hook elements) must now be non-nil. fix: correctly apply rproj settings for pipe version
chore: run stylua
@jalvesaq I think this is ready for review now 😃 Still only adds support for the pipe operator, but as it's already a fairly big PR I thought best to add any extra |
One observation before trying the code: you call Note: I never worked with |
Nice refactor of |
Did you try in your vim.o.autochdir = true
vim.o.autochdir = false And what about different values for the As I said, I never worked with |
Looking at the changes that you have made to |
In two or three hours from now, I'll try to push some commits into your pull request... |
Thanks! Sorry for the late response - been a bit busy since Sunday but done a little work since then in light of your comments. Let me try and push those in the next hour or two, I'll let you know once done so you can go ahead with any edits you want to make. |
This is a good point. RStudio will ignore That said, I think searching upwards would likely only make life easier for people, so happy to add that in anyway. |
Hi @jalvesaq, please go ahead with any extra commits you want to make 👍 If you revert Incidentally, could we rename |
Yes, we can. |
- delete `assign` - rename `assign_map` as `assignment_keymap`
Done! Now there is a single option related to the assignment operator: |
@jalvesaq FYI I'm still working on this, just quit busy currently, but would like to get it right before merging. Will keep you posted 😃 |
@PMassicotte noted that Another problem: most frequently, the pipe operator is followed by a line break, but, if using the key binding to insert the pipe operator, we will get a trailing space in the pipe operator's line after pressing the |
I've made a few changes:
Regarding the trailing spaces, I previously wasn't too bothered about this. As far as I'm aware, very few R users care about trailing whitespace - although {lintr} will complain about it. If we want to get rid of it, some options are:
Any thoughts? |
@jalvesaq all look okay now? I found a way to strip trailing whitespace if a new line is inserted directly after a pipe, basically by temporarily remapping |
I updated the keybinding in the README to |
Thank you! 🙏 |
Addresses #108.
This PR is somewhat a work in progress with fairly minimal testing - for now I'm really just looking for a sense check on the approach I've taken.
New features
This adds a mapping for the pipe which may either insert
|>
or%>%
, depending on whether an.Rproj
file is present and contains the fieldUseNativePipeOperator
. The.Rproj
-awareness can be configured usingconfig.rproj_prioritise
; for the pipe operator it is on by default.All changes
The filetype for
.Rproj
has been changed todcf
(wasyaml
)New
utils.read_dcf()
to read.Rproj
filesNew module
r.rproj
for finding/parsing.Rproj
files:apply_settings({config} [, {force}, {file}])
updates theconfig
table using a.Rproj
file if one is present. This respectsconfig.rproj_prioritise
.parse([{file}])
finds a.Rproj
file if one is present in the current working directory, and parses it into a dictionary of name/value pairs. NB, I considered recursively searching upwards through the directory tree to find a.Rproj
file but decided against it.New
config.rproj_setup([{force}, {file}])
for applying.Rproj
configuration to the current session. I was a bit torn about where this function should live, but theconfig
module seemed most appropriate given how existing code is structured.New config options:
config.pipe = true
config.pipe_map = "<localleader>m"
use_native_pipe = true
config.rproj_prioritise = { "use_native_pipe" }