ludopinelli / comment-box.nvim Goto Github PK
View Code? Open in Web Editor NEW:sparkles: Clarify and beautify your comments and plain text files using boxes and lines.
License: MIT License
:sparkles: Clarify and beautify your comments and plain text files using boxes and lines.
License: MIT License
Not sure how I haven't noticed this before, but...
...can it take into account current indent level?
It would be nice to have some sort of picker, preferably with a preview, so that it's easier to view all the options available and determine on-the-fly which one looks the slickest.
There's a Vim variable v:register
that returns the default register " if the clipboard
option is empty or */+ if it contains unnamed
or unnamedplus
respectively.
For those users that don't set the clipboard
option to unnamedplus
, it would be better if you used that Vim variable (vim.v.register in Lua) instead of the + (plus) register.
Thanks for the plugin!
Hi @LudoPinelli,
I noticed when I want to comment out in a box the following snippets and in some other cases comment-box.nvim and nvim gets frozen. Probably caused by an infinite loop.
Reproduce
call :CBlbox
on line on this code snippet:
# using imperative code
# ────────────────────────────────────────────────────────────
i = 0
for c in range(3):
j = i + cnt[c]
nums[i:j] = [c] * cnt[c]
i = j
It'd be nice to have a command to extract text out of the box (remove the box and leave only the text) or quickly yank the entire content of box to edit it or change the box style.
Setting this plugin up myself, and so far it's pretty amazing. So a couple of possible discrepancies/omissions in the documentation:
Exceptions:
Adapted boxes: x is a (for adapted) y is the position of the box.
I noticed that you x and y values can be swapped around i.e CBlabox
seems equivalent to CBalbox
CBbaox[num]
is incorrect. It should be CBacbox[num]
.Nice work on the plugin.
Rather than having to manually convert comments or docstring to boxes, it would be nice to have option to automatically display them in boxes as virtual text. That way you don't modify the source code.
The plugin does not insert as comments in .zshrc
files.
Before:
test
After CBccbox
:
╭───────────────────────────────────────────────────────────╮
│ test │
╰───────────────────────────────────────────────────────────╯
Expected:
# ╭───────────────────────────────────────────────────────────╮
# │ test │
# ╰───────────────────────────────────────────────────────────╯
{ -- Something begins here...
<Cmd>CBllline<CR>
while on the line. { -- Something begins here... ──────────────────────────────────────────────
-- ── { -- Something begins here... ──────────────────────────────────────────────
In the doc file there are duplicate tags comment-box-lines
in lines 400 and 587. According to the table of contents, it seems that the tag in line 400 should be comment-box-line
instead.
Hi @LudoPinelli,
I noticed comment-box.nvim fails when I'm commenting out an URL.
Reproduce:
https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/discuss/1054742/Python-O(logn)
:CBlbox
on the lineE5108: Error executing lua ...k/packer/start/comment-box.nvim/lua/comment-box/init.lua:114: attempt to perform arithmetic on local 'f' (a nil value)
stack traceback:
...k/packer/start/comment-box.nvim/lua/comment-box/init.lua:114: in function 'wrap'
...k/packer/start/comment-box.nvim/lua/comment-box/init.lua:137: in function 'get_text'
...k/packer/start/comment-box.nvim/lua/comment-box/init.lua:197: in function 'create_box'
...k/packer/start/comment-box.nvim/lua/comment-box/init.lua:422: in function 'display_box'
...k/packer/start/comment-box.nvim/lua/comment-box/init.lua:453: in function 'lbox'
[string ":lua"]:1: in main chunk
Press ENTER or type command to continue
When I use left aligned adapted box, I don't want it to wrap at box_width
.
Currently to do this I have to setup like:
{
doc_width = 10000,
box_width = 10000,
}
But this will affect other box functions.
Is there a related setting, or can the setting be passed to function, something like:
require("comment-box").albox({ doc_width = 10000, box_width = 10000})
Hey Ludo!
Thanks for this amazing plugin!
I wanted to ask, if you would consider implementing another category: lines with text.
The result would look like this:
--- This is a header ---------------------------
As a basis, I would suggest to use the templates from the "cbline" category.
Thanks for considering!
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.
Configured with:
line = {
line = "-",
line_start = "+",
line_end = "+",
title_left = "[",
title_right = "]",
},
Executing :CBllline
and/or :CBccline
still creates line like this:
-- ── Yes, just like this one ────────────────────────────────────────────────────
Interestingly, borders{}
works as expected and :CBclbox
correctly uses chosen set of characters.
Consider the following, *
indicates cursor position:
--[[
- ╭────────────────────────────────────────────────────────────────────────────╮
- │ * Plugins related to comment functionality │
- ╰────────────────────────────────────────────────────────────────────────────╯
]]
Executing :CBd
makes it:
--[[
- ╭────────────────────────────────────────────────────────────────────────────╮
-- Plugins related to comment functionality
- ╰────────────────────────────────────────────────────────────────────────────╯
]]
Expected result:
-- Plugins related to comment functionality
For example, in the python
file, the lengths of title lines and lines are inconsistent:
# before
# test text
# after
# ── test text ─────────────────────────────────────────────────
# ────────────────────────────────────────────────────────────
In the rust
file, the lengths of the two are the same:
// before
// test text
// after
// ── test text ───────────────────────────────────────────────
// ────────────────────────────────────────────────────────────
Thanks for making this plugin, looks to be very useful.
When I do CBlbox
in Lua I get left hand box and text as expected like this:
-- ╭──────────────────────────────────────────────────────────╮
-- │ gets the initial json loaded for excerpts │
-- ╰──────────────────────────────────────────────────────────╯
However, the same command in a Typescript file gives this (not left aligned text)
// ╭──────────────────────────────────────────────────────────╮
// │ gets the initial json loaded for excerpts │
// ╰──────────────────────────────────────────────────────────╯
Presumably this is because it has some issue with TypeScript as when I use a vanilla js file I get the expected result:
// ╭──────────────────────────────────────────────────────────╮
// │ gets the initial json loaded for excerpts │
// ╰──────────────────────────────────────────────────────────╯
Is there a way to associate typescript with the javascript pattern?
When executing CBcatalog
, the error message is displayed:
Error executing Lua callback: ...a/lazy/comment-box.nvim/lua/comment-box/catalog_view.lua:36: Vim:E492: Not an editor command: $readC:\Users\MasouShizuka\AppData\Local\nvim-data\lazy\comment-box.nvim\catalog\catalog.txt
stack traceback:
[C]: in function 'nvim_command'
...a/lazy/comment-box.nvim/lua/comment-box/catalog_view.lua:36: in function 'view'
...a/lazy/comment-box.nvim/lua/comment-box/catalog_view.lua:54: in function 'view_cat'
...nvim-data/lazy/comment-box.nvim/lua/comment-box/init.lua:805: in function 'catalog'
...l/nvim-data/lazy/comment-box.nvim/plugin/comment-box.lua:205: in function <...l/nvim-data/lazy/comment-box.nvim/plugin/comment-box.lua:204>
Spaces before input don't get stripped, which results in a misaligned box.
If the input is not a comment, spaces after the input get preserved as well.
my thing
-- my thing
:CBalbox
on each line-- ╭──────────────────────╮
-- │ my thing │
-- ╰──────────────────────╯
-- ╭─────────────╮
-- │ my thing │
-- ╰─────────────╯
Pipe the input through vim.trim()
local input = " my thing "
input = vim.trim(input) -- => "my thing"
Feature Request:
Instead of always having the CBline always having line_width+Comment characters, is it possible to set set the CBline char number dynamically?
Would make code structure even prettier.
We could have two options there:
The first would display indent structure, whereas the second would keep a nice edge.
For the second option indentation should be preserved.
:set ft=bash
and add execute :CBllline
on an empty commented line.
Before
#
After
# ── ─────────────────────────────────────────────────────────────────────────────
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.