Files
dotfiles/nvim/dot-config/nvim/init.lua
T
2026-07-02 07:12:22 +01:00

314 lines
6.4 KiB
Lua

local vim = vim or {}
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
local repo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system({ "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(lazypath)
-- Options
local o = vim.opt
vim.g.mapleader = " "
vim.g.loaded_perl_provider = 0
vim.g.loaded_ruby_provider = 0
vim.g.clipboard = 'osc52'
o.number = true
o.expandtab = true
o.shiftwidth = 2
o.tabstop = 4
o.softtabstop = 4
o.completeopt = { "menuone", "noselect", "noinsert" }
o.updatetime = 100
o.timeoutlen = 300
o.clipboard = "unnamedplus"
o.shell = "/usr/bin/fish"
o.foldenable = false
o.list = true
o.listchars = {
tab = "→ ",
eol = " ",
space = " ",
nbsp = "␣",
trail = "·",
lead = "·",
}
o.scroll = 5
o.smoothscroll = true
o.termguicolors = true
o.laststatus = 3
o.mousescroll = "ver:0,hor:0"
vim.lsp.semantic_tokens.enable = false
vim.lsp.handlers.hover = function(_, result, ctx, config)
config = config or {}
config.border = "rounded"
return vim.lsp.handlers.hover(_, result, ctx, config)
end
vim.lsp.handlers.signature_help = function(_, result, ctx, config)
config = config or {}
config.border = "rounded"
return vim.lsp.handlers.signature_help(_, result, ctx, config)
end
vim.g.rainbow_delimiters = {
highlight = {
"RainbowDelimiterYellow",
"RainbowDelimiterBlue",
"RainbowDelimiterOrange",
"RainbowDelimiterGreen",
"RainbowDelimiterViolet",
"RainbowDelimiterCyan",
"RainbowDelimiterRed",
},
}
vim.diagnostic.config({
virtual_text = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚 ",
[vim.diagnostic.severity.WARN] = "󰀪 ",
[vim.diagnostic.severity.INFO] = "󰋽 ",
[vim.diagnostic.severity.HINT] = "󰌶 ",
},
},
underline = true,
update_in_insert = true,
severity_sort = true,
})
-- Plugin List
require("lazy").setup({
{ "rcarriga/nvim-notify", lazy = false },
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
{ "neovim/nvim-lspconfig", lazy = false },
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons",
},
lazy = false,
opts = {
filesystem = {
filtered_items = { visible = true },
},
},
},
{
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
},
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
},
{ "HiPhish/rainbow-delimiters.nvim" },
{ "ya2s/nvim-cursorline" },
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
"neovim/nvim-lspconfig",
},
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"clangd",
},
})
end,
},
{
"stevearc/conform.nvim",
config = function()
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
})
end,
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
},
},
{ "karb94/neoscroll.nvim" },
{
"SyedM-dev/PicVim",
lazy = false,
config = function()
require("picvim").setup()
end,
},
{
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup()
end,
},
{
"echasnovski/mini.pairs",
config = function()
require("mini.pairs").setup({})
end,
},
})
-- Plugin's setup
require("lualine").setup({
options = { theme = "auto" },
sections = {
lualine_b = {
{ "branch" },
{
"diff",
symbols = {
added = " ",
modified = " ",
removed = " ",
},
diff_color = {
added = { fg = "#a6e3a1" },
modified = { fg = "#f9e2af" },
removed = { fg = "#f38ba8" },
},
},
},
},
})
require("nvim-cursorline").setup({
cursorline = {
enable = true,
timeout = 0,
number = false,
},
cursorword = {
enable = true,
min_length = 1,
hl = { underline = true },
},
})
local neoscroll = require("neoscroll")
neoscroll.setup({
mappings = {
"<C-u>",
"<C-d>",
"<C-b>",
"<C-f>",
"<C-y>",
"<C-e>",
"zt",
"zz",
"zb",
},
})
local cmp = require("cmp")
cmp.setup({
window = {
completion = cmp.config.window.bordered({
border = "rounded",
}),
documentation = cmp.config.window.bordered({
border = "rounded",
}),
},
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping.select_next_item(),
["<S-Tab>"] = cmp.mapping.select_prev_item(),
}),
sources = {
{ name = "nvim_lsp" },
{ name = "clangd" },
},
})
-- Keymaps
local map = vim.keymap.set
map({ "n", "i", "v" }, "<C-s>", "<cmd>w<CR>")
map("n", ";", ":")
map("n", "<A-Up>", ":move-2<CR>")
map("n", "<A-Down>", ":move+1<CR>")
map("x", "<A-Up>", ":move '<-2<CR>gv")
map("x", "<A-Down>", ":move '>+1<CR>gv")
map("i", "<A-Up>", "<C-o>:move-2<CR>")
map("i", "<A-Down>", "<C-o>:move+1<CR>")
map("n", ">", ">>")
map("v", ">", ">gv")
map("n", "<", "<<")
map("v", "<", "<gv")
map("n", ".", ">>")
map("v", ".", ">gv")
map("n", ",", "<<")
map("v", ",", "<gv")
map("n", "<Esc>", "<cmd>nohlsearch<CR><Esc>")
map("n", "u", "ggVG")
map("n", "z", "<cmd>u<CR>")
map("n", "d", "<cmd>red<CR>")
map("n", "q", "<cmd>Neotree<CR>")
map("n", "<A-a>", "<cmd>Minuet virtualtext toggle<CR>")
map("x", "p", '"_dP')
map("x", "P", '"_dP')
map("n", "\\", function()
vim.cmd([[
Neotree close
mksession! p.vim
echo "saved session"
]])
end)
map("n", "<ScrollWheelUp>", function()
neoscroll.scroll(-0.05, { move_cursor = false, duration = 20 })
end)
map("n", "<ScrollWheelDown>", function()
neoscroll.scroll(0.05, { move_cursor = false, duration = 20 })
end)
-- Vimscript stuff
vim.cmd([[
aunmenu PopUp
colorscheme tokyonight-night
]])
-- AutoCMD's
local autocmd = vim.api.nvim_create_autocmd
autocmd("CursorHold", {
callback = function()
vim.diagnostic.open_float(nil, {
focusable = false,
border = "rounded",
source = "if_many",
})
end,
})