mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
transition from nvim-compe to nvim-cmp
This commit is contained in:
parent
a603ce3e4d
commit
e2bcb7d8f4
@ -1,38 +0,0 @@
|
|||||||
-- nvim-compe settings
|
|
||||||
require("compe").setup({
|
|
||||||
enabled = true,
|
|
||||||
autocomplete = true,
|
|
||||||
debug = false,
|
|
||||||
min_length = 1,
|
|
||||||
preselect = "enable",
|
|
||||||
throttle_time = 80,
|
|
||||||
source_timeout = 200,
|
|
||||||
incomplete_delay = 400,
|
|
||||||
max_abbr_width = 100,
|
|
||||||
max_kind_width = 100,
|
|
||||||
max_menu_width = 100,
|
|
||||||
documentation = true,
|
|
||||||
|
|
||||||
source = {
|
|
||||||
omni = { filetypes = { "tex" } },
|
|
||||||
path = true,
|
|
||||||
buffer = false,
|
|
||||||
spell = { filetypes = { "markdown", "tex" } },
|
|
||||||
emoji = true,
|
|
||||||
nvim_lsp = true,
|
|
||||||
nvim_lua = true,
|
|
||||||
ultisnips = true,
|
|
||||||
calc = false,
|
|
||||||
vsnip = false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.o.completeopt = "menuone,noselect"
|
|
||||||
|
|
||||||
-- nvim-compe mappings
|
|
||||||
local compe_map_opts = { expr = true, noremap = true, silent = true }
|
|
||||||
vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", compe_map_opts)
|
|
||||||
vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", compe_map_opts)
|
|
||||||
vim.api.nvim_set_keymap("i", "<ESC>", "compe#close('<ESC>')", compe_map_opts)
|
|
||||||
vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({'delta': +4})", compe_map_opts)
|
|
||||||
vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({'delta': -4})", compe_map_opts)
|
|
||||||
@ -66,7 +66,7 @@ local custom_attach = function(client, bufnr)
|
|||||||
-- vim.notify(msg, 'info', {title = 'Nvim-config', timeout = 2500})
|
-- vim.notify(msg, 'info', {title = 'Nvim-config', timeout = 2500})
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
@ -88,10 +88,12 @@ lspconfig.pylsp.setup({
|
|||||||
flags = {
|
flags = {
|
||||||
debounce_text_changes = 200,
|
debounce_text_changes = 200,
|
||||||
},
|
},
|
||||||
|
capabilities = capabilities,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- lspconfig.pyright.setup{
|
-- lspconfig.pyright.setup{
|
||||||
-- on_attach = custom_attach,
|
-- on_attach = custom_attach,
|
||||||
|
-- capabilities = capabilities
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
lspconfig.clangd.setup({
|
lspconfig.clangd.setup({
|
||||||
@ -109,6 +111,7 @@ lspconfig.vimls.setup({
|
|||||||
flags = {
|
flags = {
|
||||||
debounce_text_changes = 500,
|
debounce_text_changes = 500,
|
||||||
},
|
},
|
||||||
|
capabilities = capabilities,
|
||||||
})
|
})
|
||||||
|
|
||||||
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
|
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
|
||||||
@ -144,6 +147,7 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
capabilities = capabilities,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
41
lua/config/nvim-cmp.lua
Normal file
41
lua/config/nvim-cmp.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
-- Setup nvim-cmp.
|
||||||
|
local cmp = require'cmp'
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
-- For `ultisnips` user.
|
||||||
|
vim.fn["UltiSnips#Anon"](args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<S-Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<Esc>'] = cmp.mapping.close(),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||||
|
{ name = 'ultisnips' }, -- For ultisnips user.
|
||||||
|
{ name = 'path' }, -- for path completion
|
||||||
|
{ name = 'emoji', insert = true, } -- emoji completion
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
keyword_length = 1,
|
||||||
|
completeopt = "menu,menuone,noinsert"
|
||||||
|
},
|
||||||
|
experimental = {
|
||||||
|
ghost_text = false
|
||||||
|
}
|
||||||
|
})
|
||||||
@ -27,10 +27,16 @@ require("packer").startup({
|
|||||||
use({"wbthomason/packer.nvim", opt = true})
|
use({"wbthomason/packer.nvim", opt = true})
|
||||||
|
|
||||||
-- nvim-lsp configuration
|
-- nvim-lsp configuration
|
||||||
use({ "neovim/nvim-lspconfig", event = 'VimEnter', config = [[require('config.lsp')]] })
|
use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] })
|
||||||
|
|
||||||
-- auto-completion engine
|
-- auto-completion engine
|
||||||
use({ "hrsh7th/nvim-compe", event = "InsertEnter *", config = [[require('config.compe')]] })
|
use {"hrsh7th/nvim-cmp", event = "InsertEnter", config = [[require('config.nvim-cmp')]]}
|
||||||
|
|
||||||
|
-- nvim-cmp completion sources
|
||||||
|
use {"hrsh7th/cmp-nvim-lsp", event = "VimEnter"}
|
||||||
|
use {"hrsh7th/cmp-path", after = "nvim-cmp"}
|
||||||
|
use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}}
|
||||||
|
use {"hrsh7th/cmp-emoji", after = 'nvim-cmp'}
|
||||||
|
|
||||||
if vim.g.is_mac then
|
if vim.g.is_mac then
|
||||||
use({ "nvim-treesitter/nvim-treesitter", event = 'BufEnter', run = ":TSUpdate", config = [[require('config.treesitter')]] })
|
use({ "nvim-treesitter/nvim-treesitter", event = 'BufEnter', run = ":TSUpdate", config = [[require('config.treesitter')]] })
|
||||||
@ -57,7 +63,7 @@ require("packer").startup({
|
|||||||
|
|
||||||
-- Super fast movement with vim-sneak
|
-- Super fast movement with vim-sneak
|
||||||
use({"justinmk/vim-sneak", event = "VimEnter"})
|
use({"justinmk/vim-sneak", event = "VimEnter"})
|
||||||
use { 'phaazon/hop.nvim', as = 'hop', config = [[require('hop').setup()]] }
|
use { 'phaazon/hop.nvim', event = "VimEnter", config = [[require('hop').setup()]] }
|
||||||
|
|
||||||
-- Clear highlight search automatically for you
|
-- Clear highlight search automatically for you
|
||||||
use({"romainl/vim-cool", event = "VimEnter"})
|
use({"romainl/vim-cool", event = "VimEnter"})
|
||||||
@ -306,7 +312,7 @@ require("packer").startup({
|
|||||||
use("gelguy/wilder.nvim")
|
use("gelguy/wilder.nvim")
|
||||||
|
|
||||||
-- showing keybindings
|
-- showing keybindings
|
||||||
use {"folke/which-key.nvim", config = [[require('config.which-key')]]}
|
use {"folke/which-key.nvim", event = "VimEnter", config = [[require('config.which-key')]]}
|
||||||
end,
|
end,
|
||||||
config = {
|
config = {
|
||||||
max_jobs = 16,
|
max_jobs = 16,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user