Skip to content

Commit 5850f42

Browse files
author
Vinit Kumar
committed
make cmp bearable
1 parent 3cc85e0 commit 5850f42

File tree

3 files changed

+92
-73
lines changed

3 files changed

+92
-73
lines changed

after/plugin/cmp_gh_source.lua

Lines changed: 0 additions & 72 deletions
This file was deleted.

lua/vinit/pluginconfig.lua

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ cmp.setup({
6565
['<C-Space>'] = cmp.mapping.complete(),
6666
['<C-e>'] = cmp.mapping.close(),
6767
['<CR>'] = cmp.mapping.confirm({ select = true }),
68+
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {'i'}),
69+
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {'i'}),
6870
},
6971
sources = {
7072
{ name = 'nvim_lsp' },
71-
{ name = 'gh_issues'},
7273
{ name = 'vsnip' },
74+
{ name = 'conventionalcommits' },
75+
{ name = 'git' },
7376
{ name = 'buffer', keyword_length = 5},
7477
{ name = 'path' },
7578
}
@@ -188,3 +191,89 @@ require("nvim-tree").setup({
188191
dotfiles = true,
189192
},
190193
})
194+
195+
196+
197+
local format = require("cmp_git.format")
198+
local sort = require("cmp_git.sort")
199+
200+
require("cmp_git").setup({
201+
-- defaults
202+
filetypes = { "gitcommit", "octo" },
203+
remotes = { "upstream", "origin" }, -- in order of most to least prioritized
204+
enableRemoteUrlRewrites = false, -- enable git url rewrites, see https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf
205+
git = {
206+
commits = {
207+
limit = 100,
208+
sort_by = sort.git.commits,
209+
format = format.git.commits,
210+
},
211+
},
212+
github = {
213+
issues = {
214+
fields = { "title", "number", "body", "updatedAt", "state" },
215+
filter = "all", -- assigned, created, mentioned, subscribed, all, repos
216+
limit = 100,
217+
state = "open", -- open, closed, all
218+
sort_by = sort.github.issues,
219+
format = format.github.issues,
220+
},
221+
mentions = {
222+
limit = 100,
223+
sort_by = sort.github.mentions,
224+
format = format.github.mentions,
225+
},
226+
pull_requests = {
227+
fields = { "title", "number", "body", "updatedAt", "state" },
228+
limit = 100,
229+
state = "open", -- open, closed, merged, all
230+
sort_by = sort.github.pull_requests,
231+
format = format.github.pull_requests,
232+
},
233+
},
234+
trigger_actions = {
235+
{
236+
debug_name = "git_commits",
237+
trigger_character = ":",
238+
action = function(sources, trigger_char, callback, params, git_info)
239+
return sources.git:get_commits(callback, params, trigger_char)
240+
end,
241+
},
242+
{
243+
debug_name = "gitlab_issues",
244+
trigger_character = "#",
245+
action = function(sources, trigger_char, callback, params, git_info)
246+
return sources.gitlab:get_issues(callback, git_info, trigger_char)
247+
end,
248+
},
249+
{
250+
debug_name = "gitlab_mentions",
251+
trigger_character = "@",
252+
action = function(sources, trigger_char, callback, params, git_info)
253+
return sources.gitlab:get_mentions(callback, git_info, trigger_char)
254+
end,
255+
},
256+
{
257+
debug_name = "gitlab_mrs",
258+
trigger_character = "!",
259+
action = function(sources, trigger_char, callback, params, git_info)
260+
return sources.gitlab:get_merge_requests(callback, git_info, trigger_char)
261+
end,
262+
},
263+
{
264+
debug_name = "github_issues_and_pr",
265+
trigger_character = "#",
266+
action = function(sources, trigger_char, callback, params, git_info)
267+
return sources.github:get_issues_and_prs(callback, git_info, trigger_char)
268+
end,
269+
},
270+
{
271+
debug_name = "github_mentions",
272+
trigger_character = "@",
273+
action = function(sources, trigger_char, callback, params, git_info)
274+
return sources.github:get_mentions(callback, git_info, trigger_char)
275+
end,
276+
},
277+
},
278+
}
279+
)

lua/vinit/plugins.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ return require('packer').startup(function()
2020
use 'windwp/nvim-autopairs'
2121
use 'hrsh7th/vim-vsnip'
2222
use 'ful1e5/onedark.nvim'
23+
use 'davidsierradz/cmp-conventionalcommits'
24+
use 'petertriho/cmp-git'
2325
use {
2426
'nvim-telescope/telescope.nvim', tag = '0.1.0',
2527
-- or , branch = '0.1.x',

0 commit comments

Comments
 (0)