From f69e8f3c3259460fe6842a951c8c4d2728a67f57 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 3 Sep 2023 20:26:08 +0300 Subject: nvim: cmp cleanup, actually use luasnip --- .config/nvim/lazy-lock.json | 47 ++++++++++++----------- .config/nvim/lua/plugins/cmp.lua | 82 +++++++++++++++++++--------------------- 2 files changed, 63 insertions(+), 66 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 796a984..e93f3fe 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,36 +1,36 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, - "barbar.nvim": { "branch": "master", "commit": "352c09f3e59065299a6e66386f0fe11bb8d5c601" }, - "catppuccin": { "branch": "main", "commit": "2e3e5ebcdc24ef0d5b14a0a999dbbe7936512c46" }, + "LuaSnip": { "branch": "master", "commit": "ea7d7ea510c641c4f15042becd27f35b3e5b3c2b" }, + "barbar.nvim": { "branch": "master", "commit": "dd852401ee902745b67fc09a83d113b3fe82a96f" }, + "catppuccin": { "branch": "main", "commit": "81096cabe67f360acb06d64c0f7db8dd840afeba" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, - "dashboard-nvim": { "branch": "master", "commit": "9134d7befd50ff920ede5b0f7d6c3dbb9f7c0ecb" }, - "dial.nvim": { "branch": "master", "commit": "c6657df5453a6cbe4e8356e1675e9652cadc332f" }, + "dashboard-nvim": { "branch": "master", "commit": "2caf39ffe2b51bdcf28528473b51042760e888f3" }, + "dial.nvim": { "branch": "master", "commit": "5b9763eaa483250650eb4f60c96db62abbb250aa" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, - "friendly-snippets": { "branch": "main", "commit": "377d45475b49e37460a902d6d569d2093d4037d0" }, - "gitsigns.nvim": { "branch": "main", "commit": "79127db3b127f5d125f35e0d44ba60715edf2842" }, + "gitsigns.nvim": { "branch": "main", "commit": "d927caa075df63bf301d92f874efb72fd22fd3b4" }, "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, - "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, + "lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" }, "leap.nvim": { "branch": "main", "commit": "5efe985cf68fac3b6a6dfe7a75fbfaca8db2af9c" }, "ltex-extra.nvim": { "branch": "master", "commit": "9bed99b2b8488cc2daf66c76d2e0cf051ee80d13" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, - "mason.nvim": { "branch": "main", "commit": "4a8deb615a477029a549cea5cef69d90e4d1f850" }, - "neodev.nvim": { "branch": "main", "commit": "0d210aa340ec9840ac963938bf1b5d06cfdf67dc" }, - "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, - "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "dfdd771b792fbb4bad8e057d72558255695aa1a7" }, + "mason.nvim": { "branch": "main", "commit": "0942198fb9a998b6ccee36fb8dd7495eb8ba659c" }, + "neodev.nvim": { "branch": "main", "commit": "183f5a7357397260b631d6cccceccc3621b50f78" }, + "nvim-autopairs": { "branch": "master", "commit": "a52fc6eeec116746110b703381777c46d89d9e27" }, + "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" }, - "nvim-tree.lua": { "branch": "master", "commit": "00741206c2df9c4b538055def19b99790f0c95c8" }, - "nvim-treesitter": { "branch": "master", "commit": "cb74c1c5aefd8b903f1b547d08d4df42be07aa2a" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "e3e2b6de4ccf781fb653a3a1d397aeb4a0095609" }, - "nvim-ufo": { "branch": "main", "commit": "8b01594c29bd01e7b49b647a663c819ed909714f" }, - "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, + "nvim-tree.lua": { "branch": "master", "commit": "5897b3622f033b1f3ea6adf8eb1c165e9f20554f" }, + "nvim-treesitter": { "branch": "master", "commit": "17b943e7c5cc2b2db3ac7b5720fbd42e75a00d8d" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" }, + "nvim-ufo": { "branch": "main", "commit": "890b94870f052773d77175d07a51f2e083210632" }, + "nvim-web-devicons": { "branch": "master", "commit": "bc11ee2498de2310de5776477dd9dce65d03b464" }, "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, @@ -38,18 +38,19 @@ "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, - "telescope.nvim": { "branch": "master", "commit": "207285ccec21b69996a4d3bcfa59df35d48610e8" }, - "trouble.nvim": { "branch": "main", "commit": "40aad004f53ae1d1ba91bcc5c29d59f07c5f01d3" }, + "telescope.nvim": { "branch": "master", "commit": "3fae9c1e14910e6669bb8ecbb473aba6a9e13b33" }, + "trouble.nvim": { "branch": "main", "commit": "3f85d8ed30e97ceeddbbcf80224245d347053711" }, "turkish-deasciifier.vim": { "branch": "master", "commit": "5b3a0bfef7424d218df7ab3dac8ee9dab42a105e" }, "vim-characterize": { "branch": "master", "commit": "1ba0fcf208464647e2df2e9f693247a2207f22a4" }, "vim-cutlass": { "branch": "master", "commit": "7afd649415541634c8ce317fafbc31cd19d57589" }, - "vim-fugitive": { "branch": "master", "commit": "b3b838d690f315a503ec4af8c634bdff3b200aaf" }, + "vim-fugitive": { "branch": "master", "commit": "572c8510123cbde02e8a1dafcd376c98e1e13f43" }, "vim-illuminate": { "branch": "master", "commit": "76f28e858f1caae87bfa45fb4fd09e4b053fc45b" }, "vim-move": { "branch": "master", "commit": "244a2908ffbca3d09529b3ec24c2c090f489f401" }, "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-snippets": { "branch": "master", "commit": "d37486881a0a771b844a235bc3e025046088690d" }, "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, - "vimtex": { "branch": "master", "commit": "534fd725f2475a9083b032e402c7e73b8a3fc6bb" }, + "vimtex": { "branch": "master", "commit": "ad17583ce399b6830b4c2888ef2a12d52c5eb607" }, "vimwiki": { "branch": "dev", "commit": "5f0a6c7523df3a15cc0331dc050a680ee4ddff04" }, "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, - "yanky.nvim": { "branch": "main", "commit": "95c2f006ea6eaed2b2d8b8b4943b8fcf13faf03f" } + "yanky.nvim": { "branch": "main", "commit": "ef70e4e44095a17ab8611cb6630b727ccee0a271" } } \ No newline at end of file diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index 7f3163f..1bc209f 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -1,16 +1,16 @@ return { { "hrsh7th/nvim-cmp", - event = "InsertEnter", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-omni", + "hrsh7th/cmp-nvim-lsp-signature-help", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", - "rafamadriz/friendly-snippets", + "honza/vim-snippets", }, config = function() local cmp = require("cmp") @@ -49,13 +49,10 @@ return { ---@diagnostic disable-next-line: missing-fields cmp.setup({ enabled = function() - -- disable autocompletion in prompt + -- disable autocompletion in telescope prompt local buftype = vim.api.nvim_buf_get_option(0, "buftype") - if buftype == "prompt" then return false end - local context = require 'cmp.config.context' - -- disable autocompletion in comments - return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") + return buftype ~= "prompt" end, ---@diagnostic disable-next-line: missing-fields completion = { @@ -73,8 +70,6 @@ return { mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false, @@ -105,16 +100,19 @@ return { -- kind icons vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) vim_item.menu = ({ - nvim_lsp = "[lsp]", - luasnip = "[snippet]", - buffer = "[buffer]", - path = "[path]", + nvim_lsp = "[ ]", + nvim_lsp_signature_help = "[󰞋 ]", + omni = "[ ]", + luasnip = "[ ]", + buffer = "[󰮳 ]", + path = "[ ]", })[entry.source.name] return vim_item end, }, sources = { { name = "nvim_lsp" }, + { name = "nvim_lsp_signature_help" }, { name = "luasnip" }, { name = "buffer" }, { name = "path" }, @@ -128,40 +126,14 @@ return { cmp_autopairs.on_confirm_done() ) - ---@diagnostic disable-next-line: missing-fields - cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'git' }, - }, { - { name = 'buffer' }, - }) - }) - - -- use buffer source for `/` . - ---@diagnostic disable-next-line: missing-fields - cmp.setup.cmdline('/', { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } - }) - - -- use cmdline & path source for ':' . - ---@diagnostic disable-next-line: missing-fields - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }) - -- use omnifunc in vimwiki to complete paths and tags ---@diagnostic disable-next-line: missing-fields cmp.setup.filetype('vimwiki', { sources = cmp.config.sources({ - { name = 'omni' }, + { name = "omni" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, option = { disable_omnifuncs = {}, }, @@ -169,4 +141,28 @@ return { }) end, }, + { + "L3MON4D3/LuaSnip", + event = "InsertEnter", + dependencies = { + "honza/vim-snippets", + }, + build = "make install_jsregexp", + keys = { + { + "", + function() require("luasnip").expand_or_jump() end, + mode = { "i", "s" }, + }, + }, + opts = { + history = false, + region_check_events = 'InsertEnter', + delete_check_events = 'InsertLeave', + }, + config = function(_, opts) + require("luasnip").setup(opts) + require("luasnip.loaders.from_snipmate").lazy_load() + end, + }, } -- cgit v1.2.3-70-g09d2