From 7e695c98f528cdff9acb0267d163a4981f0a0405 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Wed, 8 Nov 2023 19:32:10 +0000 Subject: [PATCH] organize cmp --- config/.config/nvim/lazy-lock.json | 1 + vim/.vim/lua/plugins/cmp.lua | 111 +++++++++++++++-------------- vim/.vim/lua/plugins/telescope.lua | 3 +- vim/.vim/prefs/leader.vim | 9 --- 4 files changed, 59 insertions(+), 65 deletions(-) diff --git a/config/.config/nvim/lazy-lock.json b/config/.config/nvim/lazy-lock.json index 82b3454..921ffc4 100644 --- a/config/.config/nvim/lazy-lock.json +++ b/config/.config/nvim/lazy-lock.json @@ -41,6 +41,7 @@ "libp.nvim": { "branch": "main", "commit": "636b1748e92f66022c1763f32b2ded6b8606eda5" }, "lsp-lens.nvim": { "branch": "main", "commit": "34b6aa13b0196d6b0d5a87cca6d7104ac5071a59" }, "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, + "lsp-timeout.nvim": { "branch": "main", "commit": "6325906730330105a9adc41d0ceb8499b3072e2b" }, "lsp-zero.nvim": { "branch": "v2.x", "commit": "ffebf6f7b0649f1eb81b37c37b75552f8ff96337" }, "lsp_lines.nvim": { "branch": "main", "commit": "cf2306dd332e34a3e91075b40bdd4f6db824b2ee" }, "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, diff --git a/vim/.vim/lua/plugins/cmp.lua b/vim/.vim/lua/plugins/cmp.lua index fce6209..d562dd5 100644 --- a/vim/.vim/lua/plugins/cmp.lua +++ b/vim/.vim/lua/plugins/cmp.lua @@ -53,16 +53,7 @@ return { local cmp = require("cmp") - local conditionalSources = { - { name = "nvim_lsp", max_item_count = 15, priority = 8 }, - { name = "treesitter", max_item_count = 5, priority = 7 }, - { name = "luasnip", max_item_count = 5, priority = 6 }, - { name = "calc" }, - { name = "async_path" }, - { name = "crates" }, - { name = "spell", max_item_count = 5 }, - { name = "emoji", max_item_count = 10 }, - } + local conditionalSources = {} if use_google() then table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 9 }) @@ -97,6 +88,61 @@ return { }) cmp.setup({ + preselect = cmp.PreselectMode.None, + sources = cmp.config.sources(require("utils").TableConcat({ + { name = "async_path" }, + { name = "calc" }, + { name = "crates" }, + { name = "emoji", max_item_count = 10 }, + { name = "luasnip", max_item_count = 5, priority = 6 }, + { name = "nvim_lsp", priority = 8 }, + { name = "spell", max_item_count = 5 }, + { name = "treesitter", max_item_count = 5, priority = 7 }, + }, conditionalSources)), + + formatting = { + format = lspkind.cmp_format({ + menu = { + async_path = " path", + buffer = " Buf", + codiuem = "󰧑 Codeium", + crates = " rust", + luasnip = " snip", + nvim_ciderlsp = "󰧑 Cider", + nvim_lsp = " LSP", + nvim_lua = " lua", + treesitter = " ts", + }, + }), + }, + + sorting = { + priority_weight = 2, + comparators = { + cmp.config.compare.priority, + cmp.config.compare.score, + compare_by_ciderlsp_score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.exact, + require("cmp-under-comparator").under, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + -- cmp.config.compare.offset, + cmp.config.compare.order, + }, + }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + experimental = { + native_menu = false, + ghost_text = true, + }, mapping = { [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), @@ -135,51 +181,6 @@ return { end end), }, - - preselect = cmp.PreselectMode.None, - sources = cmp.config.sources(conditionalSources), - - sorting = { - priority_weight = 2, - comparators = { - cmp.config.compare.priority, - cmp.config.compare.score, - compare_by_ciderlsp_score, - cmp.config.compare.recently_used, - cmp.config.compare.locality, - cmp.config.compare.exact, - require("cmp-under-comparator").under, - cmp.config.compare.kind, - cmp.config.compare.sort_text, - -- cmp.config.compare.offset, - cmp.config.compare.order, - }, - }, - - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - - formatting = { - format = lspkind.cmp_format({ - menu = { - nvim_ciderlsp = "󰧑 Cider", - codiuem = "󰧑 Codeium", - buffer = " Buf", - crates = "", - nvim_lsp = " LSP", - nvim_lua = "", - luasnip = " snip", - async_path = " path", - }, - }), - }, - experimental = { - native_menu = false, - ghost_text = true, - }, }) end, }, diff --git a/vim/.vim/lua/plugins/telescope.lua b/vim/.vim/lua/plugins/telescope.lua index 9e63e3e..0d4bbcd 100644 --- a/vim/.vim/lua/plugins/telescope.lua +++ b/vim/.vim/lua/plugins/telescope.lua @@ -34,7 +34,8 @@ local keys = { { "ts", "lua live_grep()", desc = "Search in CWD" }, { "", "lua find_files()", desc = "Find Files in CWD" }, { "tf", "lua find_files()", desc = "Find Files in CWD" }, - { "tf.", "lua search_cwd()", desc = "Find Files in Buffer Directory" }, + { "tf.", "lua vim.notify.error('use e')", desc = "Find Files in Buffer Directory" }, + { "e", "lua search_cwd()", desc = "Find Files in Buffer Directory" }, { "tg", ":Telescope git_files", desc = "Git Files" }, { "tl", ":Telescope resume", desc = "Last Query" }, { "tr", ":Telescope oldfiles", desc = "Recent Files" }, diff --git a/vim/.vim/prefs/leader.vim b/vim/.vim/prefs/leader.vim index 32d6a4e..5cd80f1 100644 --- a/vim/.vim/prefs/leader.vim +++ b/vim/.vim/prefs/leader.vim @@ -25,13 +25,11 @@ vmap v c"+p imap v "+pa " --------- WINDOW/PANE MAPPINGS --------- -map wr r map H :wincmd H map K :wincmd K map L :wincmd L map J :wincmd J map T :wincmd T -map x :wincmd x " resize vertical split to 1/3 or 2/3 size nnoremap s+ :exe "vertical resize " . (winwidth(0) * 5/4) @@ -44,16 +42,9 @@ nnoremap x- :exe "resize " . (winheight(0) * 2/3) " --------- FORMATTING MAPPINGS --------- " indent file map = gg=G `` - nmap yf :let @+ = expand("%") -nmap e :e %% - " replace currently selected text with default register " without yanking it vnoremap p "_dP - - -nnoremap rp :lua vim.notify("use ") nnoremap :VimuxOpenRunner :VimuxRunCommand '!!' :call VimuxSendKeys("Enter") - nnoremap s :SessionSave