This commit is contained in:
sam 2024-10-22 20:49:20 +13:00
parent 07eb55c2ce
commit 3a078077cb

View file

@ -10,10 +10,21 @@ vim.opt.mouse = "a"
vim.cmd("colorscheme habamax")
local plugins = {
{
source = "neovim/nvim-lspconfig",
},
{
source = "hrsh7th/nvim-cmp",
depends = { "hrsh7th/cmp-nvim-lsp" }
}
}
local servers = {
clangd = {}
}
-- Install plugin manager
local mini_path = vim.fn.stdpath("data") .. "/site/pack/deps/start/mini.nvim"
if not vim.loop.fs_stat(mini_path) then
vim.fn.system({
@ -23,21 +34,14 @@ if not vim.loop.fs_stat(mini_path) then
vim.cmd("packadd mini.nvim | helptags ALL")
end
require("mini.deps").setup({ path = { package = path_package } })
local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later
now(function()
add({
source = "neovim/nvim-lspconfig",
})
add({
source = "hrsh7th/nvim-cmp",
depends = { "hrsh7th/cmp-nvim-lsp" }
})
end)
-- Install plugins
for plugin in pairs(plugins) do
MiniDeps.add(plugins[plugin])
end
-- Setup completion
local cmp = require("cmp")
cmp.setup({
snippet = {
@ -56,8 +60,9 @@ cmp.setup({
{ name = "buffer" },
});
local lspconfig = require("lspconfig")
-- Setup servers and their configs
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require("lspconfig")
for server in pairs(servers) do
local config = servers[server]
config.capabilities = config.capabilities or capabilities
@ -65,18 +70,19 @@ for server in pairs(servers) do
lspconfig[server].setup(config)
end
vim.keymap.set({ 'i', 's' }, '<Tab>', function()
-- Binds to jump between snippets
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.snippet.active({ direction = 1 }) then
return '<Cmd>lua vim.snippet.jump(1)<CR>'
return "<Cmd>lua vim.snippet.jump(1)<CR>"
else
return '<Tab>'
return "<Tab>"
end
end, { expr = true })
vim.keymap.set({ 'i', 's' }, '<S-Tab>', function()
if vim.snippet.active({ direction = 1 }) then
return '<Cmd>lua vim.snippet.jump(-1)<CR>'
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if vim.snippet.active({ direction = -1 }) then
return "<Cmd>lua vim.snippet.jump(-1)<CR>"
else
return '<Tab>'
return "<S-Tab>"
end
end, { expr = true })