feat(nvim): Major source overhaul

This commit is contained in:
Price Hiller 2022-04-28 05:24:39 -05:00
parent efc11e7c89
commit 7352aaad29
3 changed files with 315903 additions and 398733 deletions

View File

@ -1,4 +1,5 @@
local cmp = require("cmp")
local compare = cmp.config.compare
local luasnip = require("luasnip")
local kind_icons = {
@ -44,12 +45,20 @@ cmp.setup({
vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
-- Source
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
fuzzy_buffer = "[Buffer]",
nvim_lsp = "[Lsp]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
path = "[Path]",
dictionary = "[Dictionary]",
calc = "[Calculator]",
neorg = "[Neorg]",
emoji = "[Emoji]",
zsh = "[Zsh]",
crates = "[Crates]",
cmdline_history = "[Cmd History]",
rg = "[Ripgrep]",
npm = "[Npm],",
})[entry.source.name]
return vim_item
end,
@ -80,9 +89,9 @@ cmp.setup({
}),
["<CR>"] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<C-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable() then
luasnip.jump(1)
elseif luasnip.expand_or_jumpable() then
if luasnip.jumpable() then
luasnip.jump(1)
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
@ -96,9 +105,9 @@ cmp.setup({
end
end, { "i", "s" }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
@ -120,52 +129,81 @@ cmp.setup({
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "buffer" },
{ name = "emoji" },
{ name = "neorg" },
{ name = "luasnip" }, -- For luasnip users.
-- { name = "git" },
{ name = "calc" },
{ name = "zsh" },
{ name = "fuzzy_buffer" },
{ name = "rg" },
{ name = "npm", keyword_length = 2 },
{
name = "dictionary",
keyword_length = 2,
},
}),
sorting = {
priority_weight = 2,
comparators = {
require("cmp_fuzzy_buffer.compare"),
compare.offset,
compare.exact,
compare.score,
compare.recently_used,
compare.kind,
compare.sort_text,
compare.length,
compare.order,
},
},
})
-- Configure Dictionary
require("cmp_dictionary").setup({
dic = {
["*"] = { "~/.dict/primary_dict" },
},
async = true
dic = {
["*"] = { require("os").getenv("HOME") .. "/.dict/primary_dict" },
},
first_case_insensitive = true,
async = true,
})
-- Git Commit Completions
cmp.setup.filetype("gitcommit", {
sources = cmp.config.sources({
{ name = "cmp_git" },
}, {
{ name = "conventionalcommits" },
{ name = "buffer" },
}),
})
cmp.setup.filetype("toml", {
sources = cmp.config.sources({
{ name = "crates" },
}),
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "nvim_lsp_document_symbol" },
}, {
{ name = "buffer" },
-- { name = "buffer" },
{ name = "fuzzy_buffer" },
{ name = "cmdline_history" },
}),
})
cmp.setup.cmdline("?", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "nvim_lsp_document_symbol" },
}, {
{ name = "buffer" },
{ name = "fuzzy_buffer" },
{ name = "cmdline_history" },
}),
})
cmp.setup.cmdline("@", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "fuzzy_buffer" },
{ name = "cmdline_history" },
}),
})
@ -174,7 +212,7 @@ cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
{ name = "cmdline_history" },
}),
})

View File

@ -273,21 +273,38 @@ return packer.startup({
"hrsh7th/nvim-cmp",
requires = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-emoji",
"hrsh7th/vim-vsnip",
"hrsh7th/cmp-nvim-lsp-document-symbol",
"hrsh7th/cmp-calc",
"petertriho/cmp-git",
"uga-rosa/cmp-dictionary",
"hrsh7th/cmp-nvim-lsp-document-symbol",
"hrsh7th/cmp-calc",
"davidsierradz/cmp-conventionalcommits",
"uga-rosa/cmp-dictionary",
"tamago324/cmp-zsh",
"dmitmel/cmp-cmdline-history",
"David-Kunz/cmp-npm",
},
config = function()
require("plugins.configs._cmp")
end,
})
use({ "romgrk/fzy-lua-native", run = "make" })
use({
"tzachar/cmp-fuzzy-buffer",
requires = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" },
})
use({ "tzachar/cmp-fuzzy-path", requires = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" } })
use({
"saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
requires = { { "nvim-lua/plenary.nvim" } },
config = function()
require("crates").setup()
end,
})
-- Show code outline
use({
"simrat39/symbols-outline.nvim",
@ -383,7 +400,7 @@ return packer.startup({
"folke/which-key.nvim",
config = function()
require("which-key").setup({
-- Compatability fix between which-key & modes
-- Compatability fix between which-key & modes
plugins = {
presets = {
operators = false,

File diff suppressed because it is too large Load Diff