Improved completion
This commit is contained in:
parent
5667752cf5
commit
3c71bd600c
|
@ -26,6 +26,7 @@
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" },
|
"nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" },
|
||||||
"nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" },
|
"nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },
|
"nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },
|
||||||
|
"nvim-cmp-lsp-rs": { "branch": "main", "commit": "cb7681abf20b615a7ec33e3f49df3b5a382711a4" },
|
||||||
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
|
"nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "9266dc26862d8f3556c2ca77602e811472b4c5b8" },
|
"nvim-lspconfig": { "branch": "master", "commit": "9266dc26862d8f3556c2ca77602e811472b4c5b8" },
|
||||||
"nvim-surround": { "branch": "main", "commit": "a4e30d33add8a9743b4f518b3a788b3c8e5def71" },
|
"nvim-surround": { "branch": "main", "commit": "a4e30d33add8a9743b4f518b3a788b3c8e5def71" },
|
||||||
|
|
|
@ -32,7 +32,7 @@ vim.o.timeout = true
|
||||||
vim.o.timeoutlen = 300
|
vim.o.timeoutlen = 300
|
||||||
|
|
||||||
-- Set completeopt to have a better completion experience
|
-- Set completeopt to have a better completion experience
|
||||||
vim.o.completeopt = "menuone,noselect"
|
-- vim.o.completeopt = "menuone,noselect"
|
||||||
|
|
||||||
-- NOTE: You should make sure your terminal supports this
|
-- NOTE: You should make sure your terminal supports this
|
||||||
vim.o.termguicolors = true
|
vim.o.termguicolors = true
|
||||||
|
|
|
@ -1,77 +1,116 @@
|
||||||
-- https://github.com/hrsh7th/nvim-cmp
|
-- https://github.com/hrsh7th/nvim-cmp
|
||||||
-- TODO: Go over this
|
-- TODO: Go over this
|
||||||
return {
|
return {
|
||||||
-- Autocompletion
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
-- Autocompletion
|
||||||
dependencies = {
|
"hrsh7th/nvim-cmp",
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
dependencies = {
|
||||||
"L3MON4D3/LuaSnip",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"hrsh7th/cmp-path",
|
||||||
"hrsh7th/cmp-path",
|
"onsails/lspkind-nvim",
|
||||||
"onsails/lspkind-nvim",
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local cmp = require("cmp")
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
local lspkind = require("lspkind")
|
|
||||||
|
|
||||||
luasnip.config.setup({})
|
-- Improve sorting order for rust
|
||||||
|
"zjp-CN/nvim-cmp-lsp-rs",
|
||||||
|
|
||||||
local border = require("symbols.window").border
|
-- Snippets
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
local lspkind = require("lspkind")
|
||||||
|
local border = require("symbols.window").border
|
||||||
|
|
||||||
cmp.setup({
|
local cmp_rs = require("cmp_lsp_rs")
|
||||||
snippet = {
|
local comparators = cmp_rs.comparators
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
cmp.setup({
|
||||||
end,
|
snippet = {
|
||||||
},
|
expand = function(args)
|
||||||
window = {
|
luasnip.lsp_expand(args.body)
|
||||||
completion = cmp.config.window.bordered({ border = border, winhighlight = "CursorLine:CmpSelection" }),
|
end,
|
||||||
documentation = cmp.config.window.bordered({ border = border }),
|
},
|
||||||
},
|
completion = { completeopt = "menu,menuone,noinsert" },
|
||||||
-- Include the source of the cmp entry
|
window = {
|
||||||
formatting = {
|
completion = cmp.config.window.bordered({
|
||||||
format = lspkind.cmp_format({
|
border = border,
|
||||||
mode = "text",
|
winhighlight = "CursorLine:CmpSelection",
|
||||||
menu = {
|
}),
|
||||||
nvim_lsp = "LSP",
|
documentation = cmp.config.window.bordered({ border = border }),
|
||||||
luasnip = "LuaSnip",
|
},
|
||||||
path = "Path",
|
-- Include the source of the cmp entry
|
||||||
|
formatting = {
|
||||||
|
format = lspkind.cmp_format({
|
||||||
|
mode = "text",
|
||||||
|
menu = {
|
||||||
|
nvim_lsp = "LSP",
|
||||||
|
luasnip = "LuaSnip",
|
||||||
|
path = "Path",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete({}),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({
|
||||||
|
select = true,
|
||||||
|
}),
|
||||||
|
["<Esc>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.abort()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
}),
|
||||||
|
sorting = {
|
||||||
|
comparators = {
|
||||||
|
comparators.inherent_import_inscope,
|
||||||
|
comparators.sort_by_label_but_underscore_last,
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
},
|
sources = {
|
||||||
mapping = cmp.mapping.preset.insert({
|
{ name = "nvim_lsp" },
|
||||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
{ name = "luasnip" },
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
{ name = "path" },
|
||||||
["<C-Space>"] = cmp.mapping.complete({}),
|
},
|
||||||
["<CR>"] = cmp.mapping.confirm({
|
})
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
end,
|
||||||
select = true,
|
},
|
||||||
}),
|
{
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
"L3MON4D3/LuaSnip",
|
||||||
if cmp.visible() then
|
build = function()
|
||||||
cmp.select_next_item()
|
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
|
||||||
elseif luasnip.expand_or_jumpable() then
|
return
|
||||||
luasnip.expand_or_jump()
|
end
|
||||||
else
|
return "make install_jsregexp"
|
||||||
fallback()
|
end,
|
||||||
end
|
config = function()
|
||||||
end, { "i", "s" }),
|
require("luasnip").config.setup()
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
-- require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
if cmp.visible() then
|
end,
|
||||||
cmp.select_prev_item()
|
dependencies = {
|
||||||
elseif luasnip.jumpable(-1) then
|
-- "rafamadriz/friendly-snippets",
|
||||||
luasnip.jump(-1)
|
},
|
||||||
else
|
},
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
}),
|
|
||||||
sources = {
|
|
||||||
{ name = "luasnip" },
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "path" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user