Comments (6)
Done!
I called them "titled lines" and made sure they are as flexible as the boxes. I hope they reach your expectation, but if not please let me know! :)
from comment-box.nvim.
Sorry for the very late answer. It was part of the few ideas I had to add, but as you can see I didn't work on the plugin for quite some time... I'll do my best in the coming few weeks to give some updates.
from comment-box.nvim.
No worries, take your time and thanks for getting back to me!
Cheers!
from comment-box.nvim.
Since there was no implementation on this I poke around a bit with the function....
local function create_line(choice, centered_line, right_aligned_line)
local symbols = set_line(choice)
comment_string = vim.bo.commentstring
local line = {}
local lead_space = " "
local filetype = vim.bo.filetype
-- Sanetize current line text
local line_text = string.gsub(vim.api.nvim_get_current_line(), "^%s*", "")
-- Add whitespaces if there is text on line
if string.len(line_text) > 0 then
line_text = " " .. line_text .. " "
end
if centered_line then
lead_space = string.rep(
" ",
math.floor((settings.doc_width - settings.line_width) / 2 - vim.fn.strdisplaywidth(comment_string))
)
elseif right_aligned_line then
lead_space = string.rep(
" ",
settings.doc_width - settings.line_width - vim.fn.strdisplaywidth(comment_string) + 2
)
end
if lead_space == "" then
lead_space = " "
end
comment_string, comment_string_end = comment_string:match("^(.*)%%s(.*)")
if not comment_string or filetype == "markdown" or filetype == "org" then
comment_string = ""
end
if settings.line_blank_line_above then
table.insert(line, "")
end
table.insert(
line,
string.format(
"%s%s%s%s%s%s%s%s",
comment_string,
lead_space,
symbols.line_start,
string.rep(symbols.line, ( settings.line_width/2 ) - 2),
line_text,
string.rep(symbols.line, ( settings.line_width/2 ) - 2),
symbols.line_end,
comment_string_end
)
)
if settings.line_blank_line_below then
table.insert(line, "")
end
return line
end
The result
It's a bit ugly since it doesn't take into account the string length, but it works for a quick patch.
from comment-box.nvim.
Does that still work with the CBline?
EDIT:
Oh, it's CBl[l,c,r]line . A bit more keys to press but the alignment feature is sweet thanks
from comment-box.nvim.
Yes, the CBline still works but it's for line without text.
from comment-box.nvim.
Related Issues (20)
- Extract text out of the box HOT 3
- Nice plugin, I like it HOT 1
- Are the Keybindings examples about accbox incorrect? HOT 2
- [Feature Request] A box/line picker HOT 1
- [BUG]: The comment_string of some filetypes will contain trailing space HOT 5
- [BUG]: CBcatalog error in windows HOT 1
- [Bug] Misalignment due to unstripped input HOT 2
- :CLxyline[num] commands don't pick style number while lua API calls work HOT 1
- doc: Incorrect commands HOT 1
- [Feature Request]: Make the length of the left aligned adapted box exceed box_width HOT 5
- Incorrect handling of inline comments HOT 3
- Incorrect box removal HOT 2
- Intendation isn't preserved HOT 2
- Line parameters have no effect HOT 4
- Unnecessary space added if line contains comment char only HOT 9
- [BUG]: Titled lines and lines lengths are inconsistent in some file types HOT 4
- Not working for `.zshrc` HOT 5
- Plugin fails to build docs because of duplicate tags HOT 1
- [Feature Request]: Use vim.v.register to set the register when yanking HOT 1
- CBline length independent of Comment length
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 comment-box.nvim.