Closed PMassicotte closed 2 months ago
😮 I like this! Worth considering other features in this area, e.g. {codegrip}-style reshaping?
One comment, should Windows path separators \\
also be used to split paths? Both /
and \\
as file separators are valid if using R on Windows so this is pretty rare, but does happen.
😮 I like this! Worth considering other features in this area, e.g. {codegrip}-style reshaping?
One comment, should Windows path separators
\\
also be used to split paths? Both/
and\\
as file separators are valid if using R on Windows so this is pretty rare, but does happen.
I will check for windows support, I really hate seeing \\
:) But you are right. As for node formatting, I use https://github.com/Wansmer/treesj which works very nicely. Could be an option here, but would introduce 1 dependency.
Good job, @PMassicotte! I see no problem in depending on treejs
, but its README says that it already has a preset for R. Did you improve the preset?
treejs
does not split path, it simply reflows the code over multiple lines (i,e spread parameters vertically). At the moment, this PR do not need treejs
, it will on only split the path. into components.
Looking at the split path:
require('r.path').split_path()
repeats the string "path". So, maybe the function name could be split
instead of split_path
.R.nvim
features. Should we make the availability of a tree-sitter parser for R a required dependency?
- You use treesitter... People who don't have a tree-sitter parser for R will miss interesting
R.nvim
features. Should we make the availability of a tree-sitter parser for R a required dependency?
I think that would be nice. We have few functionalities that now relies on it.
New commit coming for your proposed changes.
Is it ready to be merged now?
Yes all good I think!
Thank you!
This PR adds two new keybindings:
<localleader>sp
: Split a file path and wrap it around thepaste()
function.<localleader>sh
: Split a file path and wrap it around thehere()
function.This allows to breaks long lines to nicely format code.
After, one can use the preferred formatter to wrap lines.