aboutsummaryrefslogtreecommitdiff
path: root/.vim/after/plugin/cmp.vim
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-06-04 16:53:35 +0800
committerGuangxiong Lin <[email protected]>2022-06-04 18:36:58 +0800
commitca6da1729156f74bb36ba94a864ab5e39e78ae3b (patch)
treea8b5d6310eb51a338f9f8808d45a63ce2e5d9b50 /.vim/after/plugin/cmp.vim
parent07231696a2e090790bda1910ec85a7dec3ecbb69 (diff)
downloaddotfiles-ca6da1729156f74bb36ba94a864ab5e39e78ae3b.tar.gz
dotfiles-ca6da1729156f74bb36ba94a864ab5e39e78ae3b.tar.bz2
dotfiles-ca6da1729156f74bb36ba94a864ab5e39e78ae3b.zip
Try using nvim
Diffstat (limited to '.vim/after/plugin/cmp.vim')
-rw-r--r--.vim/after/plugin/cmp.vim61
1 files changed, 61 insertions, 0 deletions
diff --git a/.vim/after/plugin/cmp.vim b/.vim/after/plugin/cmp.vim
new file mode 100644
index 0000000..226f8c5
--- /dev/null
+++ b/.vim/after/plugin/cmp.vim
@@ -0,0 +1,61 @@
+if !has('nvim')
+ finish
+endif
+
+inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
+inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
+
+packadd nvim-cmp
+packadd cmp-buffer
+packadd cmp-path
+packadd cmp-cmdline
+
+lua <<EOF
+
+local cmp = require 'cmp'
+
+cmp.setup({
+ preselect = cmp.PreselectMode.None,
+
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ }, {
+ { name = 'buffer' },
+ }),
+
+ mapping = cmp.mapping.preset.insert({
+ ['<Tab>'] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ else
+ fallback()
+ end
+ end, { 'i', 's' }),
+
+ ['<S-Tab>'] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ else
+ fallback()
+ end
+ end, { 'i', 's' }),
+ }),
+})
+
+cmp.setup.cmdline('/', {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = cmp.config.sources({
+ { name = 'buffer' },
+ }),
+})
+
+cmp.setup.cmdline(':', {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = cmp.config.sources({
+ { name = 'path' },
+ }, {
+ { name = 'cmdline' },
+ }),
+})
+
+EOF