added nvim-cmp for completions
This commit is contained in:
parent
1ee103951a
commit
1e0e1a05c2
|
@ -1,4 +1,10 @@
|
||||||
{
|
{
|
||||||
|
"LuaSnip": { "branch": "master", "commit": "118263867197a111717b5f13d954cd1ab8124387" },
|
||||||
|
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||||
|
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
||||||
|
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
||||||
|
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||||
|
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||||
"crates.nvim": { "branch": "main", "commit": "8437522d12a8c523da2aee9db2979d070b2ecc33" },
|
"crates.nvim": { "branch": "main", "commit": "8437522d12a8c523da2aee9db2979d070b2ecc33" },
|
||||||
"fd": { "branch": "master", "commit": "00b64f3ccbfb832ef744bb42bbdfabaf929b5ee2" },
|
"fd": { "branch": "master", "commit": "00b64f3ccbfb832ef744bb42bbdfabaf929b5ee2" },
|
||||||
"feline.nvim": { "branch": "main", "commit": "a6bebd903e84d5ce0e97c597e0ca85cd24109002" },
|
"feline.nvim": { "branch": "main", "commit": "a6bebd903e84d5ce0e97c597e0ca85cd24109002" },
|
||||||
|
@ -7,6 +13,7 @@
|
||||||
"neo-tree.nvim": { "branch": "v3.x", "commit": "230ff118613fa07138ba579b89d13ec2201530b9" },
|
"neo-tree.nvim": { "branch": "v3.x", "commit": "230ff118613fa07138ba579b89d13ec2201530b9" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" },
|
"nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" },
|
||||||
"nvim": { "branch": "main", "commit": "079500a625f3ae5aa6efb758f1a17fe4c7a57e52" },
|
"nvim": { "branch": "main", "commit": "079500a625f3ae5aa6efb758f1a17fe4c7a57e52" },
|
||||||
|
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "eb81c7ea08d6f01d5fa4cf09e58c708efadf9b2f" },
|
"nvim-lspconfig": { "branch": "master", "commit": "eb81c7ea08d6f01d5fa4cf09e58c708efadf9b2f" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "25ddfde8d7167d7d81403d6809242439037d2b68" },
|
"nvim-treesitter": { "branch": "master", "commit": "25ddfde8d7167d7d81403d6809242439037d2b68" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "a1425903ab52a0a0460622519e827f224e5b4fee" },
|
"nvim-web-devicons": { "branch": "master", "commit": "a1425903ab52a0a0460622519e827f224e5b4fee" },
|
||||||
|
|
68
lua/plugins/completions.lua
Normal file
68
lua/plugins/completions.lua
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
return {
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
-- base
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-cmdline",
|
||||||
|
-- snippets
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp");
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("BufRead", {
|
||||||
|
group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }),
|
||||||
|
pattern = "Cargo.toml",
|
||||||
|
callback = function()
|
||||||
|
cmp.setup.buffer({ sources = { { name = "crates" } } })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won"t work anymore).
|
||||||
|
cmp.setup.cmdline({ "/", "?" }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer" }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path 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 = "path" }
|
||||||
|
}, {
|
||||||
|
{ name = "cmdline" }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
|
@ -30,14 +30,24 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
|
dependencies = {
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
lspconfig.pyright.setup({})
|
local capabilities = require("cmp_nvim_lsp").default_capabilities();
|
||||||
|
|
||||||
lspconfig.rust_analyzer.setup({})
|
lspconfig.pyright.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig.rust_analyzer.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
lspconfig.lua_ls.setup({
|
lspconfig.lua_ls.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
|
|
4
lua/plugins/snippets.lua
Normal file
4
lua/plugins/snippets.lua
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
return {
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
version = "v2.*",
|
||||||
|
}
|
Loading…
Reference in a new issue