Comments (7)
Could you describe what kind of support you'd like? I don't really write C++, so I can't tell what would be useful.
For instance, take a look at the recent pull request that adds C support, #36. Are some of these things useful to you?
If clauses
if (val1 && val2 || val3);
if (val1
&& val2
|| val3);
Function calls
myfunction(arg1, arg2, arg3, arg4);
myfunction(arg1,
arg2,
arg3,
arg4);
from splitjoin.vim.
Hi Andrew,
That would do it in 90% of the cases, I imagine. In fact, I think it would work with a number of other languages as well, such as Java etc. [Related to this: It would be nice to be able to activate SplitJoin for a particular filetype on another filetype (e.g., use "C/C++"-mode SplitJoin in a Java file) for cases like this: maybe I should submit this as a separate issue?]
The only C++-specific thing I could add, if I were to be greedy, is for initializer lists in constructors:
Initializer Lists
From:
SomeType(SomeType&& other) : namespace1::TemplateType<double>(std::move(other)) , attr1(std::move(other.desc_path_lens_)) , attr2(other.num_leaves_) {
}
To:
SomeType(SomeType&& other)
: namespace1::TemplateType<double>(std::move(other))
, attr1(std::move(other.desc_path_lens_))
, attr2(other.num_leaves_) {
}
But, as I said, that is me being greedy. The pull request you reference really would be quite serviceable for most folks for most of the cases.
from splitjoin.vim.
Technically, you can re-use splitters and joiners. If you take a look at the ftplugin
directory, https://github.com/AndrewRadev/splitjoin.vim/tree/master/ftplugin, you'll notice that for each filetype there's a separate folder with a single file, splitjoin.vim
. The contents of these files are quite simple, for instance, this is the C one:
if !exists('b:splitjoin_split_callbacks')
let b:splitjoin_split_callbacks = [
\ 'sj#c#SplitIfClause',
\ 'sj#c#SplitFuncall',
\ ]
endif
if !exists('b:splitjoin_join_callbacks')
let b:splitjoin_join_callbacks = [
\ 'sj#c#JoinFuncall',
\ 'sj#c#JoinIfClause',
\ ]
endif
The two variables just hold a list of functions to attempt for splitting and joining. They can be overridden by users if some callbacks should be excluded or for the sake of adding custom callbacks.
So, if you'd like to get the same things to work for java, you could just create an ftplugin/java.vim
file in your own vimfiles and put the b:splitjoin_split_callbacks
and b:splitjoin_join_callbacks
initialization with a list of all the functions you'd like to use. Or even just runtime! ftplugin/splitjoin/c.vim
, if you just want the whole filetype.
Of course, this does require a little bit Vimscript knowledge. Still, I can't think of a good way to share the definitions and keep the simplicity of the ftplugin setup at the same time.
As for the initializer lists, I'll see what I can do.
from splitjoin.vim.
Hi Andrew, was not aware of this. This does make custom application of logic very flexible. Thank you!
from splitjoin.vim.
its been ~8 years since last message here, wanted to know if anyone is working on it?
from splitjoin.vim.
@ViRu-ThE-ViRuS Do you mean the initializer list? I haven't worked on it, I'm afraid. I don't write C++ myself. I think I gave it a shot at the time, but ran into problems parsing the content. I could try it again, see how far I can take it -- is this the feature you're looking for? Maybe you could share a few more examples so I can have an idea of edge cases I might run into?
from splitjoin.vim.
Hey @AndrewRadev! this is the feature im looking for, but its okay if it doesn't exist yet. I just feel the lack of a plugin which can easily collapse single line if/else blocks, and also split them to make adding additional lines to each block easier.
Other than in this case, I don't really feel the need for C/C++ support.
from splitjoin.vim.
Related Issues (20)
- YAML splitting flow-object with path as value fails to round-trip from joining HOT 3
- Feature request: Add solidity support HOT 1
- Feature request: "black" compatible python line-splitting HOT 3
- Feature request: Add Scala support HOT 3
- Rust: grouped multiline imports do not split correctly HOT 4
- Rust: attributes on grouped imports are not preserved HOT 10
- Adding splitjoins from one langage to another HOT 9
- Unexpected modifications when using `gS` / `gJ` HOT 1
- Python splitting and indentation HOT 2
- Feature request: Splitting LaTeX commands onto newlines HOT 1
- Can't work in visual after changing keymap HOT 2
- Rust: splitting multi-line expression into blocks produces broken code HOT 7
- Go: can't split/join var, const, type declarations inside block (not global scope) HOT 2
- Go: can't split/join var, const declarations with comma-separated one-typed vars, consts HOT 15
- Go: invalid join for var, const, import list HOT 11
- Go: join of struct fields inserts unnecessary spaces HOT 7
- Support for rmardown (rmd) and quarto (qmd) HOT 2
- Go: split of multiline var, const adds brackets in wrong place HOT 2
- vim: gS on dict access dot incorrectly adds space HOT 3
- Add support for R HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splitjoin.vim.