-
Notifications
You must be signed in to change notification settings - Fork 33
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
Dev indent align braces #13
base: master
Are you sure you want to change the base?
Conversation
@blueyed I made my hands dirty on the indent file. This version seems to work, except for when using bracket-comments. Please give it a try and tell me what you think and why not adding more test-cases. |
2661397
to
d501b0e
Compare
README.md
Outdated
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
``` | ||
|
||
By setting `g:cmake_indent_no_command_argument_align` to 1 in your vimrc-file the old behavior is activated: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be a good default - resulting in fewer changes in diffs (when the command/function changes). OTOH that's also not so common in CMake I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to 1 you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
That seems to be the current behavior also, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, though it doesn't work correctly in all cases. Will be defaulted to 1 (or the variable name will change).
@pboettch Some remark (which might not really apply): it is possible to also use syntax highlight / hl groups, so that e.g. comments can be skipped etc (see https://github.com/Vimjas/vim-python-pep8-indent/blob/master/indent/python.vim). |
What do you mean by getting comments skipped? Should comments always be aligned to the zero-column for you? |
I've meant that syntax can be used in expressions with searchpairpos for example. |
Cmake has sectional comments as well ( Parens in comments can be a problem. I'll check whether it works or not. |
It seems to work, unless aligned comments are unwanted: add_custom_command(tout # )
#add_custom_command(
hallo
) |
I added an option for users to select whether they want comment to be aligned a 0. Also I tested parens in line-comments to see whether it breaks. It seems not to. I'll merge this branch to master soon. Thanks for your initial work and thus making me learn vim-indent. |
Thanks for the quick fix! :) |
Thanks for finding. |
It does not handle the following (multiline string): message(STATUS "foo
bar")
set(foo 1)
That's a problem on master though already. |
Hard to solve this one. I basically didn't change the regexes which were already there. But they would need to be fixed in order to have something respecting multiline strings and intra-line-comments. Resulting in a complete parser of the CMake-language. |
Actually it's not that bad. The while-you-type indent fails, but when re-indenting the whole block I get: if(HALLO)
message(STATUS "foo
bar")
set(foo)
set(foo 1)
endif() |
It messes with the initial indent of the existing multiline string however: if(HALLO)
message(STATUS "foo
bar")
set(foo)
set(foo 1)
endif() This sounds like a good case where using the actual syntax would be useful: i.e. the line with the multiline comment has types "cmakeString cmakeArguments" - and lines starting with "cmakeString" could be left as-is. Ref: https://github.com/Vimjas/vim-python-pep8-indent/blob/dac91047444e5c907226b1cae39bb3ce428bc441/indent/python.vim#L112-L133
That is kind of what the syntax provides already luckily.. :) |
Previously it would use indent 11 for lines after: set_property(TARGET foo APPEND PROPERTY INCLUDE_DIRECTORIES ${BAR}) set_property(…) Now it uses: set_property(TARGET foo APPEND PROPERTY INCLUDE_DIRECTORIES ${BAR}) set_property(…)
aed30e1
to
7edeedb
Compare
No description provided.