Skip to content
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

Fixed indentation including issues with "=" normal mode command. #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bak-t
Copy link
Contributor

@bak-t bak-t commented Jan 8, 2024

These changes should fix issue #27. I replaced smartindent with fine tuned cindent.

Copy link
Collaborator

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! I'm doing some manual testing, and found automatic one-space indentation in the following scenario:

image

Without your changes, everything stays on the previous line's column. Reading about these cindent-related options - which I admit in 30 some years I haven't really played with much - it seems may be related to the cinkeys options.

Thoughts? I tried to think and test a bunch of indent-related tasks and, for the most part, this does seem to work better, like auto-indenting parameters in a param() block.

@bak-t
Copy link
Contributor Author

bak-t commented Jan 10, 2024

I was able to slightly improve indentation of comments with > normal mode command (for comment started from 1st column only 1 space is used instead of shiftwidth).
But the bug you've found in insert mode still persists. I'll try to experiment with cinkeys.

 - Improved indentation of comments.
 - Simplified option for unclosed parentheses.
@heaths
Copy link
Collaborator

heaths commented Jan 10, 2024

Thanks. I look forward to it. I think this is a big step in the right direction, but worry if I found an arguably minor regression, what other possibly larger regressions have I missed? Hopefully whatever could resolve this issue would mitigate at least some risk of regression elsewhere.

@bak-t
Copy link
Contributor Author

bak-t commented Jan 22, 2024

It seems that cinkeys doesn't help with the issue found or at least I'm unable to find proper values for it.
Also I found that with current fix = normal mode command changes indentation of comments back & forth at root scope at each run. For example:

# comment
# another comment
  # mistakenly indented comment

after gg=G looks like:

  # comment
  # another comment
# mistakenly indented comment

after .:

# comment
# another comment
  # mistakenly indented comment

and so on.

I'll experiment with indentexpr. Looks like it's possible to combine it with C-indent by using cindent function. So, solution may be perform handcrafted indentation for edge cases & call cindent function otherwise. This also could make possible to skip indentation in here-strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants