dotfiles/.config/nvim/lua/pluginconf/coc.lua

49 lines
992 B
Lua
Raw Normal View History

2021-09-01 00:15:10 +02:00
coc = {}
2021-04-24 19:41:58 +02:00
vim.g.coc_global_extensions = {
2021-11-05 17:44:11 +01:00
"coc-clangd",
"coc-fish",
"coc-go",
"coc-haxe",
"coc-java",
"coc-json",
"coc-kotlin",
"coc-rust-analyzer",
"coc-snippets",
"coc-sumneko-lua",
"coc-toml",
2021-04-24 19:41:58 +02:00
}
2021-08-31 22:24:12 +02:00
local function check_back_space()
2021-11-05 17:44:11 +01:00
local col = vim.fn.col "." - 1
return col <= 0 or vim.fn.getline("."):sub(col, col):match "%s"
2021-08-31 22:24:12 +02:00
end
2021-09-01 00:15:10 +02:00
function coc.tab_completion()
2021-11-05 17:44:11 +01:00
if vim.fn.pumvisible() > 0 then
return escape_keycode "<C-n>"
end
2021-08-31 22:24:12 +02:00
2021-11-05 17:44:11 +01:00
if check_back_space() then
return escape_keycode "<TAB>"
end
2021-08-31 22:24:12 +02:00
2021-11-05 17:44:11 +01:00
return vim.fn["coc#refresh"]()
2021-08-31 22:24:12 +02:00
end
2021-09-01 00:15:10 +02:00
function coc.shift_tab_completion()
2021-11-05 17:44:11 +01:00
if vim.fn.pumvisible() > 0 then
return escape_keycode "<C-p>"
else
return escape_keycode "<C-h>"
end
2021-09-01 00:15:10 +02:00
end
function coc.cr_completion()
2021-11-05 17:44:11 +01:00
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
2021-09-01 00:15:10 +02:00
end