From a22872fb929fa59fa239546cd2dee6a489d1e623 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Wed, 8 May 2024 12:19:57 -0400 Subject: [PATCH] feat(completion): add `cmp-git` (#950) --- .../completion/cmp-git/README.md | 5 +++++ .../completion/cmp-git/init.lua | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lua/astrocommunity/completion/cmp-git/README.md create mode 100644 lua/astrocommunity/completion/cmp-git/init.lua diff --git a/lua/astrocommunity/completion/cmp-git/README.md b/lua/astrocommunity/completion/cmp-git/README.md new file mode 100644 index 000000000..b2bee9ce4 --- /dev/null +++ b/lua/astrocommunity/completion/cmp-git/README.md @@ -0,0 +1,5 @@ +# cmp-git + +Git source for nvim-cmp + +**Repository:** diff --git a/lua/astrocommunity/completion/cmp-git/init.lua b/lua/astrocommunity/completion/cmp-git/init.lua new file mode 100644 index 000000000..00ce4eabb --- /dev/null +++ b/lua/astrocommunity/completion/cmp-git/init.lua @@ -0,0 +1,21 @@ +return { + "petertriho/cmp-git", + ft = { "gitcommit", "octo" }, + dependencies = { "hrsh7th/nvim-cmp" }, + opts = function(_, opts) + opts.filetypes = require("lazy.core.plugin").values(assert(require("astrocore").get_plugin "cmp-git"), "ft") + end, + config = function(_, opts) + if opts.filetypes then + local cmp = require "cmp" + cmp.setup.filetype(opts.filetypes, { + sources = cmp.config.sources({ + { name = "git" }, + }, { + { name = "buffer" }, + }), + }) + end + require("cmp_git").setup(opts) + end, +}