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

[BUG]: The comment_string of some filetypes will contain trailing space #26

Closed
MasouShizuka opened this issue Nov 23, 2023 · 5 comments
Closed

Comments

@MasouShizuka
Copy link

Take the CBllbox command as an example.

In the python file,
before:

# test

after:

#  ╭──────────────────────────────────────────────────────────╮
#  │ fuck                                                     │
#  ╰──────────────────────────────────────────────────────────╯

The comment_string is # .

In the lua file,
before:

-- test

after:

--  ╭──────────────────────────────────────────────────────────╮
--  │ test                                                     │
--  ╰──────────────────────────────────────────────────────────╯

The comment_string is -- .

In the rust file,
before:

// test

after:

// ╭──────────────────────────────────────────────────────────╮
//test// ╰──────────────────────────────────────────────────────────╯

The comment_string is //, and does not contain space.

It can be seen that some filetypes are separated by 2 spaces, and some are separated by 1 space.
In the former, I found that it contains space by printing comment_string, such as # in Python.

Is there something wrong with my configuration?

Also, I think this can be used as a configuration item, that is, the number of spaces between comment and box.
0 means no spaces, etc.

@LudoPinelli
Copy link
Owner

LudoPinelli commented Dec 22, 2023

I obtain the same results as yours. I use the built-in vim.bo.commentstring to determine the comment_string and it seems that this command doesn't give a consistent/accurate result or I'm missing something, in the former I'm afraid I can't do much about it. A better and definitive solution would be to use a table of the possible comment types as Comment.nvim does but I looked into it and it's beyond what I'm capable to accomplish with my poor understanding of lua, regex and the nvim api right now ^^

For your suggestion to configure the number of spaces between the start of the box and the comment (am I understanding correctly?) I will look into it.

Thanks for your feedback!

LudoPinelli added a commit that referenced this issue Dec 22, 2023
@LudoPinelli
Copy link
Owner

Just found a workaround while working on another issue (I just had to trim the comment_string after retrieving it). It should work consistently with all filetypes now.

I close this issue but I keep in mind your suggestion. Thanks again for your feedback!

@MasouShizuka
Copy link
Author

Lines still have redundant spaces.

In the python file:

#  ────────────────────────────────────────────────────────────
# ╭──────────────────────────────────────────────────────────╮
# │ test                                                     │
# ╰──────────────────────────────────────────────────────────╯
#  ────────────────────────────────────────────────────────────

@MasouShizuka
Copy link
Author

By the way, there seems to be a small error in the readme?

image

@LudoPinelli
Copy link
Owner

You're right in both cases! Should be fixed now. Thank you!

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

No branches or pull requests

2 participants