Code Monkey home page Code Monkey logo

comment-box.nvim's Issues

Intendation isn't preserved

Not sure how I haven't noticed this before, but...

recording.mp4

...can it take into account current indent level?

[Feature Request] A box/line picker

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.

[Feature Request]: Use vim.v.register to set the register when yanking

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!

Infinite loop when calling :CBlbox

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

Extract text out of the box

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.

doc: Incorrect commands

Setting this plugin up myself, and so far it's pretty amazing. So a couple of possible discrepancies/omissions in the documentation:

  1. In the section explaining the command structure:

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

  1. In the Commands->Boxes section, the second to last entry in the table CBbaox[num] is incorrect. It should be CBacbox[num].

Nice work on the plugin.

Not working for `.zshrc`

The plugin does not insert as comments in .zshrc files.

Before:

test

After CBccbox:

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

Expected:

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

Incorrect handling of inline comments

Steps to reproduce

  1. Create a Lua file:
    { -- Something begins here...
  1. Execute <Cmd>CBllline<CR> while on the line.

Desired result

    { -- Something begins here... ──────────────────────────────────────────────

Actual result

-- ── { -- Something begins here... ──────────────────────────────────────────────

the indentation disappear

before

after

idea

  • spaces are also info. provided by the user, should be recorded too.
  • as the pic. shown, if would be great to visually include two more lines (since top&bottom borders are added) in the result selection.

The other things are all great. Thanks for the cool plugin :)

Comment boxing URL fails

Hi @LudoPinelli,
I noticed comment-box.nvim fails when I'm commenting out an URL.

Reproduce:

  1. move cursor to line containing https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/discuss/1054742/Python-O(logn)
  2. call :CBlbox on the line
  3. You should get the following error message:
E5108: 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

[Feature Request]: Make the length of the left aligned adapted box exceed box_width

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})

FR: Line comments that incorporate text

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!

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

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.

Line parameters have no effect

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.

Incorrect box removal

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

[BUG]: Titled lines and lines lengths are inconsistent in some file types

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 ───────────────────────────────────────────────
// ────────────────────────────────────────────────────────────

CBlbox not producing left aligned text in TypeScript

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?

[BUG]: CBcatalog error in windows

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>

[Bug] Misalignment due to unstripped input

Bug

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.

Reproduction

  1. Have some input (note the spaces after the input)
    my thing       
--    my thing       
  1. Run :CBalbox on each line
--  ╭──────────────────────╮
--  │      my thing        │
--  ╰──────────────────────╯
--  ╭─────────────╮
--  │    my thing │
--  ╰─────────────╯

Potential solution

Pipe the input through vim.trim()

local input = "    my thing       "
input = vim.trim(input) -- => "my thing"

CBline length independent of Comment length

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:

  1. Set CBline length = line_width - comment_char
  2. Set CBline length = line_width - comment_char - indent

The first would display indent structure, whereas the second would keep a nice edge.
For the second option indentation should be preserved.

Unnecessary space added if line contains comment char only

:set ft=bash and add execute :CBllline on an empty commented line.

Before

  #

After

# ──  ─────────────────────────────────────────────────────────────────────────────

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.