2021-09-01 00:15:10 +02:00
|
|
|
coc = {}
|
|
|
|
|
2021-04-24 19:41:58 +02:00
|
|
|
vim.g.coc_global_extensions = {
|
2021-05-12 00:49:06 +02:00
|
|
|
"coc-clangd",
|
|
|
|
"coc-fish",
|
|
|
|
"coc-go",
|
|
|
|
"coc-haxe",
|
|
|
|
"coc-java",
|
|
|
|
"coc-json",
|
|
|
|
"coc-kotlin",
|
2021-04-24 19:41:58 +02:00
|
|
|
"coc-lua",
|
|
|
|
"coc-rust-analyzer",
|
2021-05-12 00:49:06 +02:00
|
|
|
"coc-snippets",
|
2021-06-24 22:37:32 +02:00
|
|
|
"coc-tabnine",
|
2021-05-12 00:49:06 +02:00
|
|
|
"coc-toml",
|
2021-04-24 19:41:58 +02:00
|
|
|
}
|
2021-08-31 22:24:12 +02:00
|
|
|
|
|
|
|
local function check_back_space()
|
|
|
|
local col = vim.fn.col(".") - 1
|
|
|
|
return col <= 0 or vim.fn.getline("."):sub(col, col):match("%s")
|
|
|
|
end
|
|
|
|
|
2021-09-01 00:15:10 +02:00
|
|
|
function coc.tab_completion()
|
2021-08-31 22:24:12 +02:00
|
|
|
if vim.fn.pumvisible() > 0 then
|
2021-09-01 00:15:10 +02:00
|
|
|
return escape_keycode("<C-n>")
|
2021-08-31 22:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if check_back_space() then
|
2021-09-01 00:15:10 +02:00
|
|
|
return escape_keycode("<TAB>")
|
2021-08-31 22:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return vim.fn["coc#refresh"]()
|
|
|
|
end
|
|
|
|
|
2021-09-01 00:15:10 +02:00
|
|
|
function coc.shift_tab_completion()
|
|
|
|
if vim.fn.pumvisible() > 0 then
|
|
|
|
return escape_keycode("<C-p>")
|
|
|
|
else
|
|
|
|
return escape_keycode("<C-h>")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function coc.cr_completion()
|
|
|
|
if vim.fn.pumvisible() > 0 then
|
|
|
|
return vim.fn["coc#_select_confirm"]()
|
|
|
|
else
|
|
|
|
return escape_keycode([[\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>]])
|
|
|
|
end
|
|
|
|
end
|