dotfiles/config/nvim-root/init.lua

169 lines
5.7 KiB
Lua
Raw Normal View History

2025-07-22 11:21:55 +03:30
vim.cmd [[
set nocompatible
filetype plugin indent on
syntax enable
call plug#begin('~/.local/share/nvim/plugged')
Plug 'tpope/vim-sensible'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-repeat'
Plug 'mattn/emmet-vim'
Plug 'norcalli/nvim-colorizer.lua'
call plug#end()
]]
vim.opt.clipboard = "unnamedplus"
vim.opt.updatetime = 300
vim.opt.timeoutlen = 500
vim.opt.signcolumn = "yes"
vim.opt.completeopt = { "menuone", "noinsert", "noselect" }
vim.opt.encoding = "utf-8"
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.numberwidth = 4
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.incsearch = true
vim.opt.hlsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.wrap = true
vim.opt.mouse = "a"
vim.opt.scrolloff = 5
vim.opt.cursorline = true
vim.opt.showmode = false
vim.opt.shortmess:append("I")
vim.opt.autoindent = true
vim.opt.termguicolors = true
vim.opt.list = true
vim.opt.undodir = vim.fn.stdpath("cache") .. "/undo"
vim.opt.undofile = true
vim.opt.wrapscan = true
vim.opt.shortmess:append("c")
vim.opt.autoread = true
vim.opt.cmdheight = 1
vim.opt.belloff = "all"
vim.opt.laststatus = 2
vim.opt.scrolljump = 3
vim.opt.hidden = true
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.backup = false
vim.opt.writebackup = false
vim.opt.lazyredraw = true
vim.opt.smoothscroll = true
vim.api.nvim_set_hl(0, "Normal", { fg = "#a6536f", bg = "NONE", ctermfg = 132, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "NormalNC", { fg = "#bb6c82", bg = "NONE", ctermfg = 168, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "LineNr", { fg = "#743c5e", bg = "NONE", ctermfg = 132, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "CursorLine", { bg = "#3f1f32", fg = "NONE", blend = 30 })
vim.api.nvim_set_hl(0, "VertSplit", { fg = "#3f1f32", bg = "NONE", ctermfg = 237, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "StatusLine", {
fg = "#a6536f",
bg = "#2a1c2e",
ctermfg = 132,
ctermbg = 235,
})
vim.api.nvim_set_hl(0, "StatusLineMode", {
fg = "#f7d8e5",
bg = "#5e2f4c",
bold = true,
ctermfg = 224,
ctermbg = 131,
})
vim.api.nvim_set_hl(0, "Visual", { bg = "#5a2c3a", fg = "NONE", ctermbg = 52, ctermfg = "NONE" })
vim.api.nvim_set_hl(0, "VisualNOS", { bg = "#5a2c3a", fg = "NONE", ctermbg = 52, ctermfg = "NONE" })
vim.api.nvim_set_hl(0, "VisualSB", { bg = "#5a2c3a", fg = "NONE", ctermbg = 52, ctermfg = "NONE" })
vim.api.nvim_set_hl(0, "Search", { fg = "#b0576f", bg = "#1c1533", ctermfg = 131, ctermbg = 234 })
vim.api.nvim_set_hl(0, "IncSearch", { fg = "#f5a3ba", bg = "#1c1533", ctermfg = 218, ctermbg = 234 })
vim.api.nvim_set_hl(0, "Pmenu", { fg = "#b0576f", bg = "NONE", ctermfg = 131, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "PmenuSel", { fg = "#000000", bg = "#b0576f", ctermfg = 0, ctermbg = 131 })
vim.api.nvim_set_hl(0, "WildMenu", { fg = "#b0576f", bg = "NONE", ctermfg = 131, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "Folded", { fg = "#c18299", bg = "NONE", ctermfg = 174, ctermbg = "NONE" })
vim.api.nvim_set_hl(0, "SignColumn", { fg = "#f0b6c8", bg = "NONE", ctermfg = 224, ctermbg = "NONE" })
local mode_names = {
n = "ROOT NRM",
i = "ROOT INS",
v = "ROOT VSL",
V = "ROOT VLI",
[""] = "ROOT VBL",
R = "ROOT RPL",
c = "ROOT CMD",
}
function _G.ModeName()
return mode_names[vim.fn.mode()] or "UNK"
end
vim.opt.statusline = table.concat {
"%#StatusLineMode# ",
"%{v:lua.ModeName()} ",
"%#StatusLine# ",
"%f %m %r ",
"%=",
"Ln:%l/%L ",
"Col:%c ",
"[%p%%]",
}
vim.g.mapleader = " "
local map = vim.keymap.set
map("n", "<leader>w", ":w<CR>")
map("n", "<leader>q", ":q<CR>")
map("n", "<leader>h", ":nohlsearch<CR>", { silent = true })
map("n", "<leader>n", ":set relativenumber!<CR>")
map("n", "<C-h>", "<C-w>h")
map("n", "<C-j>", "<C-w>j")
map("n", "<C-k>", "<C-w>k")
map("n", "<C-l>", "<C-w>l")
map("n", "<leader>v", ":Ex<CR>")
map("", "j", "gj")
map("", "k", "gk")
vim.keymap.set({ "n", "v" }, "<leader>cd", vim.cmd.Ex)
vim.keymap.set({ "n", "v" }, "<leader>d", '"_d', { desc = "Delete without yanking" })
vim.keymap.set("n", "<leader>bn", ":bnext<CR>", { desc = "Next buffer" })
vim.keymap.set("n", "<leader>bp", ":bprevious<CR>", { desc = "Previous buffer" })
vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Move to left window" })
vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Move to bottom window" })
vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Move to top window" })
vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Move to right window" })
local modes_to_disable = { "n", "v", "x", "s", "c" }
local arrows = { "<Up>", "<Down>", "<Left>", "<Right>" }
for _, mode in ipairs(modes_to_disable) do
for _, key in ipairs(arrows) do
vim.keymap.set(mode, key, "<Nop>", { silent = true })
end
end
vim.keymap.set("n", "<leader>sv", ":vsplit<CR>", { desc = "Split window vertically" })
vim.keymap.set("n", "<leader>sh", ":split<CR>", { desc = "Split window horizontally" })
vim.keymap.set("n", "<C-Up>", ":resize +2<CR>", { desc = "Increase window height" })
vim.keymap.set("n", "<C-Down>", ":resize -2<CR>", { desc = "Decrease window height" })
vim.keymap.set("n", "<C-Right>", ":vertical resize -2<CR>", { desc = "Decrease window width" })
vim.keymap.set("n", "<C-Left>", ":vertical resize +2<CR>", { desc = "Increase window width" })
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down" })
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up" })
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
require('colorizer').setup {
'*',
css = { names = true },
html = { names = true },
}