Giter Club home page Giter Club logo

better-comments.nvim's Introduction

πŸ‘‹ Hi, I’m Djan,

I'm full stack developer with 7+ years of experience in web apps & e-commerce.

I'm a team player, I like to work with people and I'm always open to new ideas.

I'm a fast learner and I'm always looking for new challenges.

I'm a problem solver, I like to find solutions to problems.

My tools:

Linux       Twitter             Git       Git

Languages and framewoks:

Languages that I speak:

  • πŸ‡¬πŸ‡§English (fluent)
  • πŸ‡¨πŸ‡ΎTurkish (native)
  • πŸ‡ͺπŸ‡ΈSpanish - Currently learning

better-comments.nvim's People

Contributors

anthony-perficient avatar djancyp avatar elcih17 avatar finleyge avatar raiseflaymeexception avatar yodigi7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

better-comments.nvim's Issues

FIX FOR THE WHOLE PLUGIN (extmarks, highlight and annoying stuff)

EDIT:

See the 2 last comment, they are the most importants one.
Also see my pull request.

END EDIT

I have successfuly fixed the extmarks.

Here is the code from lua\better-comment\init.lua:

-- TODO: don't having to resave to remove extmark
-- TODO: see the others TODO


local M = {}

local api = vim.api
local cmd = vim.api.nvim_create_autocmd
local treesitter = vim.treesitter
local opts = {
    tags = {
        {
            name = "TODO",
            fg = "white",
            bg = "#0a7aca",
            bold = true,
            virtual_text = "",
        },
        {
            name = "FIX",
            fg = "white",
            bg = "#f44747",
            bold = true,
            virtual_text = "",
        },
        {
            name = "WARNING",
            fg = "#FFA500",
            bg = "",
            bold = false,
            virtual_text = "",
        },
        {
            name = "!",
            fg = "#f44747",
            bg = "",
            bold = true,
            virtual_text = "",
        }

    },
}


M.Setup = function(config)
    if config and config.tags then
        opts.tags = vim.tbl_deep_extend("force", opts.tags, config.tags or {})
    end

    local augroup = vim.api.nvim_create_augroup("better-comments", {clear = true})
    cmd({ 'BufWinEnter', 'BufFilePost', 'BufWritePost' }, {
        group = augroup,
        callback = function()
            local current_buffer = api.nvim_get_current_buf()
            local current_buffer_name = api.nvim_buf_get_name(current_buffer)
            if current_buffer_name == '' then
                return
            end
            local fileType = api.nvim_buf_get_option(current_buffer, "filetype")
            local success, parsed_query = pcall(function()
                return treesitter.query.parse(fileType, [[(comment) @all]])
            end)
            if not success then
                return
            end
            local commentsTree = treesitter.query.parse(fileType, [[(comment) @all]])

            -- FIX: Check if file has treesitter
            local root = Get_root(current_buffer, fileType)
            local comments = {}
            for _, node in commentsTree:iter_captures(root, current_buffer, 0, -1) do
                local range = { node:range() }
                table.insert(comments, {
                    line = range[1],
                    col_start = range[2],
                    finish = range[4],
                    text = vim.treesitter.get_node_text(node, current_buffer)
                })
            end

            if comments == {} then
                return
            end
            Create_hl(opts.tags)

            for id, comment in ipairs(comments) do
                for hl_id, hl in ipairs(opts.tags) do
                    if string.find(comment.text, hl.name) then
                        if hl.virtual_text ~= "" then
                            local ns_id = vim.api.nvim_create_namespace(hl.name)
                            local v_opts = {
                                id = id,
                                virt_text = { { hl.virtual_text, "" } },
                                virt_text_pos = 'overlay',
                                virt_text_win_col = comment.finish + 2,
                            }

                            -- FIX comment.line -> 0 in col
                            api.nvim_buf_set_extmark(current_buffer, ns_id, comment.line, 0, v_opts)
                        end

                        vim.api.nvim_buf_add_highlight(current_buffer, 0, tostring(hl_id), comment.line,
                            comment.col_start,
                            comment.finish)
                    else
                        -- FIX added else to delted extmark
                        
                        -- TODO: THIS PART IS CALLED A LOT FIND A WAY TO NOT CHECK EVERY TIME
                        if hl.virtual_text ~= "" then
                            local ns_id = vim.api.nvim_create_namespace(hl.name)

                            api.nvim_buf_del_extmark(current_buffer, ns_id, id)
                            -- print("DELETED")
                        end
                    end
                end
            end

        end
    })
end

Get_root = function(bufnr, filetype)
    local parser = vim.treesitter.get_parser(bufnr, filetype, {})
    local tree = parser:parse()[1]
    return tree:root()
end

function Create_hl(list)
    for id, hl in ipairs(list) do
        vim.api.nvim_set_hl(0, tostring(id), {
            fg = hl.fg,
            bg = hl.bg,
            bold = hl.bold,
        })
    end
end

return M

minor style change: function names should be lowercase and module name should match repo name

Hey :) Thanks for this nice plugin!

I'd like to suggest to rename the module from better-comment.lua to better-comments.lua so that it better matches the repository name.
Also function names should be snake case (ref: https://github.com/luarocks/lua-style-guide). Maybe you could also change this, so that the setup function can be called as setup() like in most of the other plugins.

Thanks for your time and effort!

Error "Invalid 'col': out of range

Saving a python file that contains any # TODO comments (empty or populated) is giving me this same error.

Error detected while processing BufWritePost Autocommands for "*":
Error executing lua callback: ...im/lazy/better-comments.nvim/lua/better-comment/init.lua:93: Invalid 'col': out of range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...im/lazy/better-comments.nvim/lua/better-comment/init.lua:93: in function <...im/lazy/better-comments.nvim/lua/better-comment/init.lua:49>

Any ideas?


nvim 0.10.0
M2 MacBook Pro on iOS Ventura 13.4

On file write flickers todo highlights

On file save it will correctly flicker the todo highlighting but will get overridden with default highlighting. Switching between buffers will correctly keep highlighting. Have a feeling its another plugin conflict but haven't narrowed down which one yet. Happening in my lua config files, have yet to test other file types.

FIX comment uses TODO highlighting

Having this line in my lua file will use the TODO highlighting rather than the FIX highlighting. Using the default setup.

-- FIX: https://github.com/noib3/nvim-cokeline#sparkles-features

[feature request] globs as filter

Hey, thank you for the amazing plugin!! was wondering if it was something achievable making globs usable in the selection

given this image

image

I would like to specify that the ! needs to be at the start of the comment somehow, or have a space before and after it

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.