-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmp.lua
More file actions
164 lines (162 loc) · 6.27 KB
/
Copy pathcmp.lua
File metadata and controls
164 lines (162 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
local M = {
"saghen/blink.cmp",
version = "1.*",
event = { "InsertEnter", "CmdlineEnter" },
dependencies = {
{ "rafamadriz/friendly-snippets" },
{ "L3MON4D3/LuaSnip", version = "v2.*" },
{ "saghen/blink.compat", version = "2.*", lazy = true, opts = {} },
{ "petertriho/cmp-git", dependencies = "nvim-lua/plenary.nvim" },
},
}
M.config = function()
require("cmp_git").setup({
github = {
issues = { state = "all", limit = 50 },
pull_requests = { state = "all", limit = 50 },
},
filetypes = { "gitcommit", "octo", "markdown", "NeogitCommitMessage" },
-- triggers: : (commits), # (issues/PRs), @ (mentions), ! (GitLab MRs)
})
require("blink.cmp").setup({
keymap = {
preset = "super-tab",
["<CR>"] = {
function(cmp)
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
"fallback",
},
},
sources = {
default = { "lsp", "path", "snippets", "lazydev", "unicode" },
per_filetype = {
gitcommit = { "jira", "confluence", "git", "lsp", "path", "snippets" },
NeogitCommitMessage = { "jira", "confluence", "git", "lsp", "path", "snippets" },
markdown = { "git", "lsp", "path", "snippets" },
octo = { "git", "lsp", "path", "snippets" },
csf = { "slash_commands", "jira", "confluence", "lsp", "path", "snippets" },
atlassian_jira = { "slash_commands", "jira", "confluence", "lsp", "path", "snippets" },
atlassian_confluence = { "slash_commands", "jira", "confluence", "lsp", "path", "snippets" },
},
providers = {
git = {
name = "git",
module = "blink.compat.source",
},
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
jira = {
module = "atlassian-cmp.jira",
min_keyword_length = 2,
},
confluence = {
module = "atlassian-cmp.confluence",
min_keyword_length = 2,
},
slash_commands = {
module = "atlassian-cmp.slash_commands",
min_keyword_length = 1,
score_offset = 100,
should_show_items = function(ctx)
local col = ctx.cursor[2]
if col <= 0 then
return false
end
-- Find the / trigger
local line = ctx.line
for i = col, 1, -1 do
if line:sub(i, i) == "/" then
-- / must be at pos 1 or after whitespace
if i == 1 then
return true
end
return line:sub(i - 1, i - 1):match("%s") ~= nil
end
end
return false
end,
},
unicode = {
module = "cmp_providers.unicode",
min_keyword_length = 1,
should_show_items = function(ctx)
-- Don't trigger on dot
local col = ctx.cursor[2]
if col > 0 then
local char = ctx.line:sub(col, col)
if char == "." then
return false
end
end
return true
end,
},
},
},
snippets = { preset = "luasnip" },
signature = { window = { border = "single" } },
term = { enabled = true },
cmdline = {
enabled = true,
keymap = { preset = "cmdline" },
completion = {
menu = { auto_show = true },
ghost_text = { enabled = true },
list = { selection = { preselect = false, auto_insert = true } },
},
sources = function()
local t = vim.fn.getcmdtype()
if t == "/" or t == "?" then
return { "buffer" }
end
if t == ":" or t == "@" then
return { "cmdline", "path" }
end
return {}
end,
},
completion = {
keyword = { range = "prefix" },
documentation = {
window = { border = "single" },
auto_show = true,
auto_show_delay_ms = 500,
},
menu = {
border = "single",
draw = {
padding = { 1, 1 },
treesitter = { "lsp" },
columns = { { "kind_icon" }, { "label", "label_description", gap = 1 }, { "kind" } },
components = {
kind_icon = {
text = function(ctx)
local kind_icon, _, _ = require("mini.icons").get("lsp", ctx.kind)
return kind_icon
end,
highlight = function(ctx)
local _, hl, _ = require("mini.icons").get("lsp", ctx.kind)
return hl
end,
},
kind = {
highlight = function(ctx)
local _, hl, _ = require("mini.icons").get("lsp", ctx.kind)
return hl
end,
},
},
},
},
},
})
end
return M