diff options
author | Yigit Sever | 2023-09-03 20:26:08 +0300 |
---|---|---|
committer | Yigit Sever | 2023-09-03 20:26:08 +0300 |
commit | f69e8f3c3259460fe6842a951c8c4d2728a67f57 (patch) | |
tree | d48092ed21016b93e0d9c44e39cd0cfae10c72b8 | |
parent | 0fca0070797db185316e91668741bc3eab401cd4 (diff) | |
download | dotfiles-f69e8f3c3259460fe6842a951c8c4d2728a67f57.tar.gz dotfiles-f69e8f3c3259460fe6842a951c8c4d2728a67f57.tar.bz2 dotfiles-f69e8f3c3259460fe6842a951c8c4d2728a67f57.zip |
nvim: cmp cleanup, actually use luasnip
-rw-r--r-- | .config/nvim/lazy-lock.json | 47 | ||||
-rw-r--r-- | .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 @@ | |||
1 | { | 1 | { |
2 | "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, | 2 | "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, |
3 | "LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" }, | 3 | "LuaSnip": { "branch": "master", "commit": "ea7d7ea510c641c4f15042becd27f35b3e5b3c2b" }, |
4 | "barbar.nvim": { "branch": "master", "commit": "352c09f3e59065299a6e66386f0fe11bb8d5c601" }, | 4 | "barbar.nvim": { "branch": "master", "commit": "dd852401ee902745b67fc09a83d113b3fe82a96f" }, |
5 | "catppuccin": { "branch": "main", "commit": "2e3e5ebcdc24ef0d5b14a0a999dbbe7936512c46" }, | 5 | "catppuccin": { "branch": "main", "commit": "81096cabe67f360acb06d64c0f7db8dd840afeba" }, |
6 | "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, | 6 | "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, |
7 | "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, | 7 | "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, |
8 | "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, | ||
8 | "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, | 9 | "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, |
9 | "cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" }, | 10 | "cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" }, |
10 | "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, | 11 | "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, |
11 | "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, | 12 | "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, |
12 | "dashboard-nvim": { "branch": "master", "commit": "9134d7befd50ff920ede5b0f7d6c3dbb9f7c0ecb" }, | 13 | "dashboard-nvim": { "branch": "master", "commit": "2caf39ffe2b51bdcf28528473b51042760e888f3" }, |
13 | "dial.nvim": { "branch": "master", "commit": "c6657df5453a6cbe4e8356e1675e9652cadc332f" }, | 14 | "dial.nvim": { "branch": "master", "commit": "5b9763eaa483250650eb4f60c96db62abbb250aa" }, |
14 | "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, | 15 | "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, |
15 | "friendly-snippets": { "branch": "main", "commit": "377d45475b49e37460a902d6d569d2093d4037d0" }, | 16 | "gitsigns.nvim": { "branch": "main", "commit": "d927caa075df63bf301d92f874efb72fd22fd3b4" }, |
16 | "gitsigns.nvim": { "branch": "main", "commit": "79127db3b127f5d125f35e0d44ba60715edf2842" }, | ||
17 | "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, | 17 | "indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" }, |
18 | "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, | 18 | "lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" }, |
19 | "leap.nvim": { "branch": "main", "commit": "5efe985cf68fac3b6a6dfe7a75fbfaca8db2af9c" }, | 19 | "leap.nvim": { "branch": "main", "commit": "5efe985cf68fac3b6a6dfe7a75fbfaca8db2af9c" }, |
20 | "ltex-extra.nvim": { "branch": "master", "commit": "9bed99b2b8488cc2daf66c76d2e0cf051ee80d13" }, | 20 | "ltex-extra.nvim": { "branch": "master", "commit": "9bed99b2b8488cc2daf66c76d2e0cf051ee80d13" }, |
21 | "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, | 21 | "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, |
22 | "mason-lspconfig.nvim": { "branch": "main", "commit": "2997f467881ac4faa6f8c5e7065e3a672297c8ad" }, | 22 | "mason-lspconfig.nvim": { "branch": "main", "commit": "dfdd771b792fbb4bad8e057d72558255695aa1a7" }, |
23 | "mason.nvim": { "branch": "main", "commit": "4a8deb615a477029a549cea5cef69d90e4d1f850" }, | 23 | "mason.nvim": { "branch": "main", "commit": "0942198fb9a998b6ccee36fb8dd7495eb8ba659c" }, |
24 | "neodev.nvim": { "branch": "main", "commit": "0d210aa340ec9840ac963938bf1b5d06cfdf67dc" }, | 24 | "neodev.nvim": { "branch": "main", "commit": "183f5a7357397260b631d6cccceccc3621b50f78" }, |
25 | "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, | 25 | "nvim-autopairs": { "branch": "master", "commit": "a52fc6eeec116746110b703381777c46d89d9e27" }, |
26 | "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, | 26 | "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, |
27 | "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, | 27 | "nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" }, |
28 | "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" }, | 28 | "nvim-surround": { "branch": "main", "commit": "0d6882635817a2677749a330127d12ac30a4f3c8" }, |
29 | "nvim-tree.lua": { "branch": "master", "commit": "00741206c2df9c4b538055def19b99790f0c95c8" }, | 29 | "nvim-tree.lua": { "branch": "master", "commit": "5897b3622f033b1f3ea6adf8eb1c165e9f20554f" }, |
30 | "nvim-treesitter": { "branch": "master", "commit": "cb74c1c5aefd8b903f1b547d08d4df42be07aa2a" }, | 30 | "nvim-treesitter": { "branch": "master", "commit": "17b943e7c5cc2b2db3ac7b5720fbd42e75a00d8d" }, |
31 | "nvim-treesitter-textobjects": { "branch": "master", "commit": "e3e2b6de4ccf781fb653a3a1d397aeb4a0095609" }, | 31 | "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" }, |
32 | "nvim-ufo": { "branch": "main", "commit": "8b01594c29bd01e7b49b647a663c819ed909714f" }, | 32 | "nvim-ufo": { "branch": "main", "commit": "890b94870f052773d77175d07a51f2e083210632" }, |
33 | "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, | 33 | "nvim-web-devicons": { "branch": "master", "commit": "bc11ee2498de2310de5776477dd9dce65d03b464" }, |
34 | "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, | 34 | "plenary.nvim": { "branch": "master", "commit": "0dbe561ae023f02c2fb772b879e905055b939ce3" }, |
35 | "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, | 35 | "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, |
36 | "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, | 36 | "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, |
@@ -38,18 +38,19 @@ | |||
38 | "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, | 38 | "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, |
39 | "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, | 39 | "targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" }, |
40 | "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, | 40 | "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, |
41 | "telescope.nvim": { "branch": "master", "commit": "207285ccec21b69996a4d3bcfa59df35d48610e8" }, | 41 | "telescope.nvim": { "branch": "master", "commit": "3fae9c1e14910e6669bb8ecbb473aba6a9e13b33" }, |
42 | "trouble.nvim": { "branch": "main", "commit": "40aad004f53ae1d1ba91bcc5c29d59f07c5f01d3" }, | 42 | "trouble.nvim": { "branch": "main", "commit": "3f85d8ed30e97ceeddbbcf80224245d347053711" }, |
43 | "turkish-deasciifier.vim": { "branch": "master", "commit": "5b3a0bfef7424d218df7ab3dac8ee9dab42a105e" }, | 43 | "turkish-deasciifier.vim": { "branch": "master", "commit": "5b3a0bfef7424d218df7ab3dac8ee9dab42a105e" }, |
44 | "vim-characterize": { "branch": "master", "commit": "1ba0fcf208464647e2df2e9f693247a2207f22a4" }, | 44 | "vim-characterize": { "branch": "master", "commit": "1ba0fcf208464647e2df2e9f693247a2207f22a4" }, |
45 | "vim-cutlass": { "branch": "master", "commit": "7afd649415541634c8ce317fafbc31cd19d57589" }, | 45 | "vim-cutlass": { "branch": "master", "commit": "7afd649415541634c8ce317fafbc31cd19d57589" }, |
46 | "vim-fugitive": { "branch": "master", "commit": "b3b838d690f315a503ec4af8c634bdff3b200aaf" }, | 46 | "vim-fugitive": { "branch": "master", "commit": "572c8510123cbde02e8a1dafcd376c98e1e13f43" }, |
47 | "vim-illuminate": { "branch": "master", "commit": "76f28e858f1caae87bfa45fb4fd09e4b053fc45b" }, | 47 | "vim-illuminate": { "branch": "master", "commit": "76f28e858f1caae87bfa45fb4fd09e4b053fc45b" }, |
48 | "vim-move": { "branch": "master", "commit": "244a2908ffbca3d09529b3ec24c2c090f489f401" }, | 48 | "vim-move": { "branch": "master", "commit": "244a2908ffbca3d09529b3ec24c2c090f489f401" }, |
49 | "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, | 49 | "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, |
50 | "vim-snippets": { "branch": "master", "commit": "d37486881a0a771b844a235bc3e025046088690d" }, | ||
50 | "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, | 51 | "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }, |
51 | "vimtex": { "branch": "master", "commit": "534fd725f2475a9083b032e402c7e73b8a3fc6bb" }, | 52 | "vimtex": { "branch": "master", "commit": "ad17583ce399b6830b4c2888ef2a12d52c5eb607" }, |
52 | "vimwiki": { "branch": "dev", "commit": "5f0a6c7523df3a15cc0331dc050a680ee4ddff04" }, | 53 | "vimwiki": { "branch": "dev", "commit": "5f0a6c7523df3a15cc0331dc050a680ee4ddff04" }, |
53 | "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, | 54 | "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, |
54 | "yanky.nvim": { "branch": "main", "commit": "95c2f006ea6eaed2b2d8b8b4943b8fcf13faf03f" } | 55 | "yanky.nvim": { "branch": "main", "commit": "ef70e4e44095a17ab8611cb6630b727ccee0a271" } |
55 | } \ No newline at end of file | 56 | } \ 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 @@ | |||
1 | return { | 1 | return { |
2 | { | 2 | { |
3 | "hrsh7th/nvim-cmp", | 3 | "hrsh7th/nvim-cmp", |
4 | event = "InsertEnter", | ||
5 | dependencies = { | 4 | dependencies = { |
6 | "hrsh7th/cmp-nvim-lsp", | 5 | "hrsh7th/cmp-nvim-lsp", |
7 | "hrsh7th/cmp-nvim-lua", | 6 | "hrsh7th/cmp-nvim-lua", |
8 | "hrsh7th/cmp-buffer", | 7 | "hrsh7th/cmp-buffer", |
9 | "hrsh7th/cmp-path", | 8 | "hrsh7th/cmp-path", |
10 | "hrsh7th/cmp-omni", | 9 | "hrsh7th/cmp-omni", |
10 | "hrsh7th/cmp-nvim-lsp-signature-help", | ||
11 | "L3MON4D3/LuaSnip", | 11 | "L3MON4D3/LuaSnip", |
12 | "saadparwaiz1/cmp_luasnip", | 12 | "saadparwaiz1/cmp_luasnip", |
13 | "rafamadriz/friendly-snippets", | 13 | "honza/vim-snippets", |
14 | }, | 14 | }, |
15 | config = function() | 15 | config = function() |
16 | local cmp = require("cmp") | 16 | local cmp = require("cmp") |
@@ -49,13 +49,10 @@ return { | |||
49 | ---@diagnostic disable-next-line: missing-fields | 49 | ---@diagnostic disable-next-line: missing-fields |
50 | cmp.setup({ | 50 | cmp.setup({ |
51 | enabled = function() | 51 | enabled = function() |
52 | -- disable autocompletion in prompt | 52 | -- disable autocompletion in telescope prompt |
53 | local buftype = vim.api.nvim_buf_get_option(0, "buftype") | 53 | local buftype = vim.api.nvim_buf_get_option(0, "buftype") |
54 | if buftype == "prompt" then return false end | ||
55 | 54 | ||
56 | local context = require 'cmp.config.context' | 55 | return buftype ~= "prompt" |
57 | -- disable autocompletion in comments | ||
58 | return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") | ||
59 | end, | 56 | end, |
60 | ---@diagnostic disable-next-line: missing-fields | 57 | ---@diagnostic disable-next-line: missing-fields |
61 | completion = { | 58 | completion = { |
@@ -73,8 +70,6 @@ return { | |||
73 | mapping = cmp.mapping.preset.insert({ | 70 | mapping = cmp.mapping.preset.insert({ |
74 | ["<C-f>"] = cmp.mapping.scroll_docs(-4), | 71 | ["<C-f>"] = cmp.mapping.scroll_docs(-4), |
75 | ["<C-d>"] = cmp.mapping.scroll_docs(4), | 72 | ["<C-d>"] = cmp.mapping.scroll_docs(4), |
76 | ["<C-k>"] = cmp.mapping.select_prev_item(), | ||
77 | ["<C-j>"] = cmp.mapping.select_next_item(), | ||
78 | ["<CR>"] = cmp.mapping.confirm({ | 73 | ["<CR>"] = cmp.mapping.confirm({ |
79 | behavior = cmp.ConfirmBehavior.Replace, | 74 | behavior = cmp.ConfirmBehavior.Replace, |
80 | select = false, | 75 | select = false, |
@@ -105,16 +100,19 @@ return { | |||
105 | -- kind icons | 100 | -- kind icons |
106 | vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) | 101 | vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) |
107 | vim_item.menu = ({ | 102 | vim_item.menu = ({ |
108 | nvim_lsp = "[lsp]", | 103 | nvim_lsp = "[ ]", |
109 | luasnip = "[snippet]", | 104 | nvim_lsp_signature_help = "[ ]", |
110 | buffer = "[buffer]", | 105 | omni = "[ ]", |
111 | path = "[path]", | 106 | luasnip = "[ ]", |
107 | buffer = "[ ]", | ||
108 | path = "[ ]", | ||
112 | })[entry.source.name] | 109 | })[entry.source.name] |
113 | return vim_item | 110 | return vim_item |
114 | end, | 111 | end, |
115 | }, | 112 | }, |
116 | sources = { | 113 | sources = { |
117 | { name = "nvim_lsp" }, | 114 | { name = "nvim_lsp" }, |
115 | { name = "nvim_lsp_signature_help" }, | ||
118 | { name = "luasnip" }, | 116 | { name = "luasnip" }, |
119 | { name = "buffer" }, | 117 | { name = "buffer" }, |
120 | { name = "path" }, | 118 | { name = "path" }, |
@@ -128,40 +126,14 @@ return { | |||
128 | cmp_autopairs.on_confirm_done() | 126 | cmp_autopairs.on_confirm_done() |
129 | ) | 127 | ) |
130 | 128 | ||
131 | ---@diagnostic disable-next-line: missing-fields | ||
132 | cmp.setup.filetype('gitcommit', { | ||
133 | sources = cmp.config.sources({ | ||
134 | { name = 'git' }, | ||
135 | }, { | ||
136 | { name = 'buffer' }, | ||
137 | }) | ||
138 | }) | ||
139 | |||
140 | -- use buffer source for `/` . | ||
141 | ---@diagnostic disable-next-line: missing-fields | ||
142 | cmp.setup.cmdline('/', { | ||
143 | mapping = cmp.mapping.preset.cmdline(), | ||
144 | sources = { | ||
145 | { name = 'buffer' } | ||
146 | } | ||
147 | }) | ||
148 | |||
149 | -- use cmdline & path source for ':' . | ||
150 | ---@diagnostic disable-next-line: missing-fields | ||
151 | cmp.setup.cmdline(':', { | ||
152 | mapping = cmp.mapping.preset.cmdline(), | ||
153 | sources = cmp.config.sources({ | ||
154 | { name = 'path' } | ||
155 | }, { | ||
156 | { name = 'cmdline' } | ||
157 | }) | ||
158 | }) | ||
159 | |||
160 | -- use omnifunc in vimwiki to complete paths and tags | 129 | -- use omnifunc in vimwiki to complete paths and tags |
161 | ---@diagnostic disable-next-line: missing-fields | 130 | ---@diagnostic disable-next-line: missing-fields |
162 | cmp.setup.filetype('vimwiki', { | 131 | cmp.setup.filetype('vimwiki', { |
163 | sources = cmp.config.sources({ | 132 | sources = cmp.config.sources({ |
164 | { name = 'omni' }, | 133 | { name = "omni" }, |
134 | { name = "luasnip" }, | ||
135 | { name = "buffer" }, | ||
136 | { name = "path" }, | ||
165 | option = { | 137 | option = { |
166 | disable_omnifuncs = {}, | 138 | disable_omnifuncs = {}, |
167 | }, | 139 | }, |
@@ -169,4 +141,28 @@ return { | |||
169 | }) | 141 | }) |
170 | end, | 142 | end, |
171 | }, | 143 | }, |
144 | { | ||
145 | "L3MON4D3/LuaSnip", | ||
146 | event = "InsertEnter", | ||
147 | dependencies = { | ||
148 | "honza/vim-snippets", | ||
149 | }, | ||
150 | build = "make install_jsregexp", | ||
151 | keys = { | ||
152 | { | ||
153 | "<C-l>", | ||
154 | function() require("luasnip").expand_or_jump() end, | ||
155 | mode = { "i", "s" }, | ||
156 | }, | ||
157 | }, | ||
158 | opts = { | ||
159 | history = false, | ||
160 | region_check_events = 'InsertEnter', | ||
161 | delete_check_events = 'InsertLeave', | ||
162 | }, | ||
163 | config = function(_, opts) | ||
164 | require("luasnip").setup(opts) | ||
165 | require("luasnip.loaders.from_snipmate").lazy_load() | ||
166 | end, | ||
167 | }, | ||
172 | } | 168 | } |