summaryrefslogtreecommitdiff
path: root/config/nvim-root/init.lua
blob: 1d60c8144313c5f7f6e1ce323dec4809dfce656a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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 },
}