Replace coq with nvim-cmp
coq is way more complicated (python-venv and sqlite) and crashes in wsl
This commit is contained in:
parent
584ce52dc6
commit
9fafda8a23
2
init.lua
2
init.lua
@ -29,6 +29,4 @@ vim.api.nvim_set_keymap('n', '<C-p>', ":bp<cr>", {})
|
||||
-- Load plugins
|
||||
require('plugins')
|
||||
|
||||
-- Launch COQ after nvim finished starting
|
||||
vim.api.nvim_create_autocmd({'VimEnter'}, {command = 'COQnow -s'})
|
||||
|
||||
|
||||
132
lua/plugins.lua
132
lua/plugins.lua
@ -1,3 +1,15 @@
|
||||
-- functions for auto-complete
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]
|
||||
:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||
end
|
||||
|
||||
-- plugins definition
|
||||
local function manage_plugins()
|
||||
|
||||
local plugins = {
|
||||
@ -42,32 +54,124 @@ local function manage_plugins()
|
||||
end
|
||||
},
|
||||
|
||||
-- COQ
|
||||
["https://github.com/ms-jpq/coq_nvim.git"] = {},
|
||||
["https://github.com/ms-jpq/coq.artifacts.git"] = {
|
||||
packadd_after = { ["https://github.com/ms-jpq/coq_nvim.git"] = true }
|
||||
-- Auto-completion
|
||||
["https://github.com/hrsh7th/cmp-nvim-lsp.git"] = {},
|
||||
["https://github.com/hrsh7th/cmp-buffer.git"] = {},
|
||||
["https://github.com/hrsh7th/cmp-path.git"] = {},
|
||||
["https://github.com/hrsh7th/cmp-cmdline.git"] = {},
|
||||
["https://github.com/hrsh7th/cmp-vsnip.git"] = {},
|
||||
["https://github.com/hrsh7th/vim-vsnip.git"] = {},
|
||||
["https://github.com/hrsh7th/nvim-cmp.git"] = {
|
||||
packadd_after = {
|
||||
["https://github.com/hrsh7th/cmp-nvim-lsp.git"] = true,
|
||||
["https://github.com/hrsh7th/cmp-buffer.git"] = true,
|
||||
["https://github.com/hrsh7th/cmp-path.git"] = true,
|
||||
["https://github.com/hrsh7th/cmp-cmdline.git"] = true,
|
||||
["https://github.com/hrsh7th/cmp-vsnip.git"] = true,
|
||||
["https://github.com/hrsh7th/vim-vsnip.git"] = true,
|
||||
},
|
||||
packadd_hook = function()
|
||||
vim.o.completeopt = "menu,menuone,noselect"
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- snippet engine is required
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
-- The fallback function sends a already mapped key.
|
||||
-- In this case, it's probably `<Tab>`.
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?`
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':'
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
end
|
||||
},
|
||||
|
||||
-- LSP servers
|
||||
["https://github.com/simrat39/rust-tools.nvim.git"] = {
|
||||
packadd_after = { ["https://github.com/neovim/nvim-lspconfig.git"] = true,
|
||||
["https://github.com/ms-jpq/coq_nvim.git"] = true},
|
||||
packadd_after = {
|
||||
["https://github.com/neovim/nvim-lspconfig.git"] = true,
|
||||
["https://github.com/hrsh7th/nvim-cmp.git"] = true,
|
||||
},
|
||||
packadd_hook = function()
|
||||
local rt = require("rust-tools")
|
||||
local coq = require("coq")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
rt.setup(coq.lsp_ensure_capabilities({
|
||||
rt.setup({
|
||||
server = {
|
||||
capabilities = capabilities,
|
||||
on_attach = function(_, bufnr)
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-space>",
|
||||
rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<Leader>a",
|
||||
rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
--vim.keymap.set("n", "<C-space>",
|
||||
--rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
---- Code action groups
|
||||
--vim.keymap.set("n", "<Leader>a",
|
||||
--rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
}))
|
||||
})
|
||||
end
|
||||
},
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user