danymat / neogen

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

Could not get neogen to work with LazyVim #172

Open AlbertNg02 opened 4 months ago

AlbertNg02 commented 4 months ago
image Screenshot 2024-04-24 at 11 59 39 AM

My configs are:


{
    "danymat/neogen",
    config = true,
    -- Uncomment next line if you want to follow only stable versions
    version = "*"
  }
rabinadk1 commented 3 months ago

I came up with this. I am currently wondering how to integrate it with native snippets support of neovim>=0.10. Please reply if someone figures it out.

return {
  "danymat/neogen",
  dependencies = "nvim-treesitter/nvim-treesitter",
  cmd = "Neogen",
  keys = {
    {
      "<leader>ga",
      function()
        require("neogen").generate({})
      end,
      desc = "Generate Annotations",
    },
  },
  ---@param _ LazyPlugin
  ---@param opts table
  opts = function(_, opts)
    local util = require("lazyvim.util")
    if util.has("luasnip") then
      opts.snippet_engine = "luasnip"
    elseif util.has("snippy") then
      opts.snippet_engine = "snippy"
    end
  end,
}
ArslanTu commented 3 months ago

@rabinadk1 native snippet support has been added according to this issue. Just set snippet_engine to nvim.

rabinadk1 commented 3 months ago

@rabinadk1 native snippet support has been added according to this issue. Just set snippet_engine to nvim.

Thank you very much. I have updated my config to the following.

return {
  "danymat/neogen",
  dependencies = "nvim-treesitter/nvim-treesitter",
  cmd = "Neogen",
  keys = {
    {
      "<leader>ga",
      function()
        require("neogen").generate({})
      end,
      desc = "Generate Annotations",
    },
  },
  ---@param _ LazyPlugin
  ---@param opts table
  opts = function(_, opts)
    local snippet_engine = nil

    if vim.snippet ~= nil then
      snippet_engine = "nvim"
    else
      local util = require("lazyvim.util")
      if util.has("luasnip") then
        snippet_engine = "luasnip"
      elseif util.has("snippy") then
        snippet_engine = "snippy"
      elseif vim.g.loaded_vsnip then
        snippet_engine = "vsnip"
      end
    end

    opts.snippet_engine = snippet_engine
  end,
}
danymat commented 1 month ago

Weird, do you still have the issue loading Neogen ?