Merge pull request 'Code Completions' (#21) from code-completions into main
Reviewed-on: #21
This commit was merged in pull request #21.
This commit is contained in:
52
nvim/dot-config/nvim/lua/plugins/completions.lua
Normal file
52
nvim/dot-config/nvim/lua/plugins/completions.lua
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
dependencies = {
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
-- REQUIRED - you must specify a snippet engine
|
||||||
|
expand = function(args)
|
||||||
|
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
|
require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
|
||||||
|
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||||
|
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||||
|
-- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
|
||||||
|
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 }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
-- { name = 'vsnip' }, -- For vsnip users.
|
||||||
|
{ name = "luasnip" }, -- For luasnip users.
|
||||||
|
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||||
|
-- { name = 'snippy' }, -- For snippy users.
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ return {
|
|||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
@@ -16,24 +16,37 @@ return {
|
|||||||
"pyright",
|
"pyright",
|
||||||
"rust_analyzer",
|
"rust_analyzer",
|
||||||
"taplo",
|
"taplo",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
config = function()
|
config = function()
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
lspconfig.clangd.setup({})
|
lspconfig.clangd.setup({
|
||||||
lspconfig.cmake.setup({})
|
capabilities = capabilities
|
||||||
lspconfig.lua_ls.setup({})
|
})
|
||||||
lspconfig.pyright.setup({})
|
lspconfig.cmake.setup({
|
||||||
lspconfig.rust_analyzer.setup({})
|
capabilities = capabilities
|
||||||
lspconfig.taplo.setup({})
|
})
|
||||||
|
lspconfig.lua_ls.setup({
|
||||||
|
capabilities = capabilities
|
||||||
|
})
|
||||||
|
lspconfig.pyright.setup({
|
||||||
|
capabilities = capabilities
|
||||||
|
})
|
||||||
|
lspconfig.rust_analyzer.setup({
|
||||||
|
capabilities = capabilities
|
||||||
|
})
|
||||||
|
lspconfig.taplo.setup({
|
||||||
|
capabilities = capabilities
|
||||||
|
})
|
||||||
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
|
||||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, {})
|
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
19
nvim/dot-config/nvim/lua/plugins/none-ls.lua
Normal file
19
nvim/dot-config/nvim/lua/plugins/none-ls.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
return {
|
||||||
|
"nvimtools/none-ls.nvim",
|
||||||
|
config = function()
|
||||||
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
|
null_ls.setup({
|
||||||
|
sources = {
|
||||||
|
null_ls.builtins.formatting.black,
|
||||||
|
null_ls.builtins.formatting.clang_format,
|
||||||
|
null_ls.builtins.formatting.gersemi,
|
||||||
|
null_ls.builtins.formatting.stylua,
|
||||||
|
null_ls.builtins.diagnostics.cpplint,
|
||||||
|
null_ls.builtins.diagnostics.pylint,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
|
||||||
|
end,
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ return{
|
|||||||
local configs = require("nvim-treesitter.configs")
|
local configs = require("nvim-treesitter.configs")
|
||||||
configs.setup({
|
configs.setup({
|
||||||
ensure_installed = { "c", "cmake", "cpp", "lua", "python", "rust", "toml" },
|
ensure_installed = { "c", "cmake", "cpp", "lua", "python", "rust", "toml" },
|
||||||
|
auto_install = true,
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user