organize cmp

This commit is contained in:
Christian Nieves
2023-11-08 19:32:10 +00:00
parent 73cfb41191
commit 7e695c98f5
4 changed files with 59 additions and 65 deletions

View File

@ -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" },

View File

@ -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 = {
["<S-Up>"] = cmp.mapping.scroll_docs(-4),
["<S-Down>"] = 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,
},

View File

@ -34,7 +34,8 @@ local keys = {
{ "<leader>ts", "<cmd>lua live_grep()<CR>", desc = "Search in CWD" },
{ "<C-P>", "<cmd>lua find_files()<CR>", desc = "Find Files in CWD" },
{ "<leader>tf", "<cmd>lua find_files()<CR>", desc = "Find Files in CWD" },
{ "<leader>tf.", "<cmd>lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>tf.", "<cmd>lua vim.notify.error('use <leader>e')<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>e", "<cmd>lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>tg", ":Telescope git_files<CR>", desc = "Git Files" },
{ "<leader>tl", ":Telescope resume<CR>", desc = "Last Query" },
{ "<leader>tr", ":Telescope oldfiles<CR>", desc = "Recent Files" },

View File

@ -25,13 +25,11 @@ vmap <leader>v c<ESC>"+p<ESC>
imap <leader>v <ESC>"+pa
" --------- WINDOW/PANE MAPPINGS ---------
map <leader>wr <C-W>r
map <leader>H :wincmd H<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>J :wincmd J<cr>
map <leader>T :wincmd T<cr>
map <leader>x :wincmd x<cr>
" resize vertical split to 1/3 or 2/3 size
nnoremap <silent> <Leader>s+ :exe "vertical resize " . (winwidth(0) * 5/4)<CR>
@ -44,16 +42,9 @@ nnoremap <silent> <Leader>x- :exe "resize " . (winheight(0) * 2/3)<CR>
" --------- FORMATTING MAPPINGS ---------
" indent file
map <leader>= gg=G ``
nmap <leader>yf :let @+ = expand("%")<cr>
nmap <leader>e :e %%
" replace currently selected text with default register
" without yanking it
vnoremap <leader>p "_dP
nnoremap <leader>rp :lua vim.notify("use <leader><leader>")
nnoremap <leader><leader> :VimuxOpenRunner<cr> :VimuxRunCommand '!!'<cr> :call VimuxSendKeys("Enter")<cr>
nnoremap <leader>s :SessionSave<CR>