dotfiles/dot-config/nvim/init.lua

182 lines
5 KiB
Lua

-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Leader key
vim.g.mapleader = " "
-- Settings
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.expandtab = true
-- Keybindings
local k = vim.keymap.set
k({ "n", "v" }, ";", ":")
k({ "n", "v" }, "q;", "q:")
k({ "n", "v" }, "<leader>y", '"+y')
k({ "n", "v" }, "<leader>Y", '"+Y')
k({ "n", "v" }, "<leader>p", '"+p')
k({ "n", "v" }, "<leader>P", '"+P')
k("n", "<leader>w", "<cmd>w<cr>")
k("n", "<leader>q", "<cmd>q<cr>")
k("n", "<esc>", "<cmd>nohlsearch<cr>")
k("n", '<leader>"', "<cmd>split<cr>")
k("n", "<leader>%", "<cmd>vsplit<cr>")
k("n", "<C-h>", "<C-w>h")
k("n", "<C-j>", "<C-w>j")
k("n", "<C-k>", "<C-w>k")
k("n", "<C-l>", "<C-w>l")
-- Plugins
require("lazy").setup({
{ "catppuccin/nvim", version = "^v1.11.0", name = "catppuccin", priority = 1000 },
{ "tpope/vim-abolish", version = "^v1.2" },
{ "tpope/vim-commentary", version = "^v1.3" },
{ "tpope/vim-repeat", version = "^v1.2" },
{
"windwp/nvim-autopairs",
commit = "c2a0dd0",
event = "InsertEnter",
config = true,
},
{
"kylechui/nvim-surround",
version = "^3.0.0",
event = "VeryLazy",
opts = {},
},
{
"nvim-telescope/telescope.nvim",
version = "^v0.2.1",
dependencies = { "nvim-lua/plenary.nvim" },
keys = {
{ "<leader><space>", "<cmd>Telescope find_files<cr>" },
{ "<leader>/", "<cmd>Telescope live_grep<cr>" },
},
},
{
"nvim-tree/nvim-tree.lua",
version = "^1.14.0",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
keys = {
{ "<leader><tab>", "<cmd>NvimTreeToggle<cr>" },
{ "<leader>fl", "<cmd>NvimTreeFindFile<cr>" },
},
},
{
"mason-org/mason-lspconfig.nvim",
version = "^v2.1.0",
dependencies = {
{ "mason-org/mason.nvim", version = "^v2.2.1", opts = {} },
{ "neovim/nvim-lspconfig", version = "^v2.5.0"}
},
config = function()
require("mason-lspconfig").setup({})
local lspconfig = require("lspconfig")
for _, server in ipairs(require("mason-lspconfig").get_installed_servers()) do
lspconfig[server].setup({})
end
end,
},
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
{
"L3MON4D3/LuaSnip",
version = "^v2.4.1",
build = "make install_jsregexp",
},
},
config = function()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end
},
sources = {
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
},
mapping = {
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'}),
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'}),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
local luasnip = require('luasnip')
if cmp.visible() then
cmp.confirm({ select = true })
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, {'i', 's'}),
["<S-Tab>"] = cmp.mapping(function(fallback)
local luasnip = require('luasnip')
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {'i', 's'}),
}
})
end,
},
{
"nvim-treesitter/nvim-treesitter",
branch = 'master',
lazy = false,
build = ":TSUpdate",
config = function()
require('nvim-treesitter.configs').setup({
sync_install = false,
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
})
end
},
{
"swaits/zellij-nav.nvim",
lazy = true,
event = "VeryLazy",
keys = {
{ "<c-h>", "<cmd>ZellijNavigateLeftTab<cr>", { silent = true, desc = "navigate left or tab" } },
{ "<c-j>", "<cmd>ZellijNavigateDown<cr>", { silent = true, desc = "navigate down" } },
{ "<c-k>", "<cmd>ZellijNavigateUp<cr>", { silent = true, desc = "navigate up" } },
{ "<c-l>", "<cmd>ZellijNavigateRightTab<cr>", { silent = true, desc = "navigate right or tab" } },
},
opts = {},
},
})
vim.cmd.colorscheme "catppuccin"