configs/nvim/init.lua

113 lines
2.6 KiB
Lua
Raw Normal View History

2024-10-21 23:52:27 +13:00
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.expandtab = true
vim.opt.tabstop = 8
vim.opt.softtabstop = 0
vim.opt.shiftwidth = 4
vim.opt.smarttab = true
vim.opt.autoindent = true
vim.opt.mouse = "a"
vim.cmd("colorscheme habamax")
2024-10-22 20:49:20 +13:00
local plugins = {
{
source = "neovim/nvim-lspconfig",
},
{
source = "hrsh7th/nvim-cmp",
depends = { "hrsh7th/cmp-nvim-lsp" }
2024-10-22 20:54:04 +13:00
},
{
source = "andweeb/presence.nvim"
2024-10-22 20:49:20 +13:00
}
}
local servers = {
clangd = {}
}
2024-10-22 20:49:20 +13:00
-- 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({
"git", "clone", "--filter=blob:none",
"https://github.com/echasnovski/mini.nvim", mini_path
})
vim.cmd("packadd mini.nvim | helptags ALL")
end
require("mini.deps").setup({ path = { package = path_package } })
2024-10-22 21:25:38 +13:00
require("mini.sessions").setup({
autoread = true,
autowrite = true
})
-- <C-_> is Ctrl+/
local comment_keybind = "<C-_>"
require("mini.comment").setup({
mappings = {
comment = comment_keybind,
comment_line = comment_keybind,
comment_visual = comment_keybind,
textobject = comment_keybind,
},
})
2024-10-22 20:49:20 +13:00
-- Install plugins
for plugin in pairs(plugins) do
MiniDeps.add(plugins[plugin])
end
2024-10-21 23:52:27 +13:00
2024-10-22 20:49:20 +13:00
-- Setup completion
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
vim.snippet.expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true })
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
})
}, {
{ name = "buffer" },
});
2024-10-21 23:52:27 +13:00
2024-10-22 20:49:20 +13:00
-- Setup servers and their configs
local capabilities = require("cmp_nvim_lsp").default_capabilities()
2024-10-22 20:49:20 +13:00
local lspconfig = require("lspconfig")
for server in pairs(servers) do
local config = servers[server]
config.capabilities = config.capabilities or capabilities
2024-10-21 23:52:27 +13:00
lspconfig[server].setup(config)
end
2024-10-21 23:52:27 +13:00
2024-10-22 20:54:04 +13:00
-- Setup Discord rich presence
require("presence").setup({
neovim_image_text = "Neovim",
})
2024-10-22 20:49:20 +13:00
-- Binds to jump between snippets
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.snippet.active({ direction = 1 }) then
2024-10-22 20:49:20 +13:00
return "<Cmd>lua vim.snippet.jump(1)<CR>"
else
2024-10-22 20:49:20 +13:00
return "<Tab>"
2024-10-21 23:52:27 +13:00
end
end, { expr = true })
2024-10-21 23:52:27 +13:00
2024-10-22 20:49:20 +13:00
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if vim.snippet.active({ direction = -1 }) then
return "<Cmd>lua vim.snippet.jump(-1)<CR>"
else
2024-10-22 20:49:20 +13:00
return "<S-Tab>"
2024-10-21 23:52:27 +13:00
end
end, { expr = true })