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

Configure center align with odd numbered content #223

Open
bartlett-ops opened this issue Mar 27, 2023 · 5 comments
Open

Configure center align with odd numbered content #223

bartlett-ops opened this issue Mar 27, 2023 · 5 comments

Comments

@bartlett-ops
Copy link

Is it possible to configure the center align behaviour so that it aligns one character left when the cell content is an odd number? Thanks, I'm loving this plugin!

Default Behaviour

| Encoding |
|:--------:|
|   utf-8  |

Desired Behaviour

| Encoding |
|:--------:|
|  utf-8   |
@dhruvasagar
Copy link
Owner

@bartlett-sre Currently that's not configurable.

@bartlett-ops
Copy link
Author

OK no problem thanks.

@dhruvasagar
Copy link
Owner

@bartlett-sre If you are willing to submit a PR, I can point you in the right direction, it should be pretty easy

@bartlett-ops
Copy link
Author

Yeah that would be awesome thanks! I had a quick look, but vimscript is pretty new to me.

@bartlett-ops bartlett-ops reopened this Mar 29, 2023
@dhruvasagar
Copy link
Owner

@bartlett-sre

function! s:Padding(string, length, where) "{{{3
let gap_length = a:length - tablemode#utils#StrDisplayWidth(a:string)
if a:where =~# 'l'
return a:string . repeat(" ", gap_length)
elseif a:where =~# 'r'
return repeat(" ", gap_length) . a:string
elseif a:where =~# 'c'
let right = gap_length / 2
let left = right + (right * 2 != gap_length)
return repeat(" ", left) . a:string . repeat(" ", right)
endif
endfunction
, this function handles adding the padding, the third case is the one that handles center aligning.

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