danymat / neogen

A better annotation generator. Supports multiple languages and annotation conventions.
GNU General Public License v3.0
1.33k stars 56 forks source link

Error While Generating File Documents #196

Open ancientjpeg opened 2 months ago

ancientjpeg commented 2 months ago

I've been encountering this error when I attempt to generate a file comment:

E5108: Error executing lua ...ialnsa/.local/share/nvim/lazy/neogen/lua/neogen/mark.lua:72: Invalid 'end_co
l': out of range
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...ialnsa/.local/share/nvim/lazy/neogen/lua/neogen/mark.lua:72: in function 'add_range_mark'
        ...a/.local/share/nvim/lazy/neogen/lua/neogen/generator.lua:351: in function 'generate'
        [string ":lua"]:1: in main chunk

I'm not 100% sure but it seems to only happen when the file is empty.

Here's my full setup for the plugin using lazy.nvim (slightly redacted for privacy):

return {
  "danymat/neogen",
  config = function()
    local i             = require("neogen.types.template").item
    local doxygen_setup = {
      { nil,         "/**",                                               { no_results = true, type = { "func", "file", "class" } } },
      { nil,         " * @file $1",                                       { no_results = true, type = { "file" } } },
      { nil,         " * @author AUTHOR_NAME", { no_results = true, type = { "file" } } },
      { nil,         " * @date " .. os.date("%Y-%m-%d"),                  { no_results = true, type = { "file" } } },
      { nil,         " * Copyright © 2024 COMPANY_NAME. All rights reserved.", { no_results = true, type = { "file" } } },
      { nil,         " */",                                               { no_results = true, type = { "func", "file", "class" } } },
      { nil,         "",                                                  { no_results = true, type = { "file" } } },

      { nil,         "/**",                                               { type = { "func", "class", "type" } } },
      { i.ClassName, " * @class %s",                                      { type = { "class" } } },
      { i.Type,      " * @typedef %s",                                    { type = { "type" } } },
      { nil,         " * @brief $1",                                      { type = { "func", "class", "type" } } },
      { nil,         " *",                                                { type = { "func", "class", "type" } } },
      { i.Tparam,    " * @tparam %s $1" },
      { i.Parameter, " * @param %s $1" },
      { i.Return,    " * @return $1" },
      { nil,         " */",                                               { type = { "func", "class", "type" } } },
    }

    require('neogen').setup({
      languages = {
        cpp = {
          template = {
            annotation_convention = "custom_doxygen",
            custom_doxygen = doxygen_setup
          }
        }
      }
    })
  end,
  keys   = {
    { "<leader>nf", "<cmd>Neogen<cr>",      desc = "Neogen Generate" },
    { "<leader>nF", "<cmd>Neogen file<cr>", desc = "Neogen Generate File Docstring" },
  },
}
Xiao001010 commented 3 weeks ago

I solved this by installing lang.clangd