-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
178 lines (138 loc) · 4.93 KB
/
init.lua
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
169
170
171
172
173
174
175
176
177
178
-- OPTIONS >>>>>>>>
--
-- disable netrw because of possible problems with nvim-tree
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true
-- set leader key to <Space>
vim.g.mapleader = " "
-- line numbers
vim.opt.nu = true
-- relative line numbers
vim.opt.relativenumber = true
--
-- set tabs to 4 spaces instead of 8
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
-- convert tabs to spaces
vim.opt.expandtab = true
-- highlight cursor position
vim.opt.cursorline = true
-- does smart autoindenting when starting a new line
vim.opt.autoindent = true
vim.opt.smartindent = true
-- prevents wrapping of long lines
vim.opt.wrap = false
-- don't create a swapfile
vim.opt.swapfile = false
-- better undos (the plugin `undotree` is also used)
vim.opt.undodir = os.getenv("HOME") .. "/.config/.nvim/undo"
vim.opt.undofile = true
-- start searching while typing and
-- highlight results
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.ignorecase = true
-- case-sensitive search when using uppercase letters,
-- case-insensitive otherwise
vim.opt.smartcase = true
-- minimum number of screen lines to keep above and below the cursor
vim.opt.scrolloff = 8
-- number of columns the screen is moved when the cursor would leave it
vim.opt.sidescroll = 1
-- minimum number of columns to keep visible when scrolling horizontally
vim.opt.sidescrolloff = 16
-- adds a column next to the line numbers holding symbols
-- for diagnostics or information like if a breakpoint is
-- on that line
vim.opt.signcolumn = "yes"
-- colored column indicating preferred max line length
vim.opt.colorcolumn = "88"
-- disables displaying of mode (this is done by lualine)
vim.opt.showmode = false
-- hide commandline when it's not used
vim.opt.cmdheight = 0
-- checks if buffer is already loaded and if so
-- opens it in that window
vim.opt.swb = "useopen"
-- limit elements in pop-up windows to 8 (e.g. nvim-cmp)
vim.opt.pumheight = 8
-- open vertical split windows to the right
vim.opt.splitright = true
-- open horizontal split down
vim.opt.splitbelow = true
-- use system clipboard as default
vim.opt.clipboard = "unnamedplus"
-- see :h shortmess for options
vim.opt.shortmess = "filmxstToOF"
-- treeview in netrw
vim.g.netrw_liststyle = 3
-- KEY MAPPINGS >>>>>>>>
-- netrw file explorer
-- vim.api.nvim_set_keymap("n", "<leader>e", ":Lexplore<CR> :vertical resize 30<CR>", { noremap = true })
-- moves selected lines up or down
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- keeps cursor in the middle of the screen
-- when jumping half pages up and down
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- search results stay in the middle of the screen
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- easier indent in visualmode
vim.keymap.set("v", ">", ">gv")
vim.keymap.set("v", "<", "<gv")
-- move cursor between buffers
vim.keymap.set("n", "<C-h>", "<C-w>h")
vim.keymap.set("n", "<C-j>", "<C-w>j")
vim.keymap.set("n", "<C-k>", "<C-w>k")
vim.keymap.set("n", "<C-l>", "<C-w>l")
-- easier buffer resizing
vim.keymap.set("n", "<C-Up>", ":resize -2<CR>")
vim.keymap.set("n", "<C-Down>", ":resize +2<CR>")
vim.keymap.set("n", "<C-Left>", ":vertical resize -2<CR>")
vim.keymap.set("n", "<C-Right>", ":vertical resize +2<CR>")
-- AUTOCOMMANDS >>>>>>>>
-- open :help in vertical split
vim.api.nvim_create_autocmd("BufWinEnter", {
group = vim.api.nvim_create_augroup("help_window_right", {}),
pattern = { "*.txt" },
callback = function()
if vim.o.filetype == "help" then
vim.cmd.wincmd("L")
end
end,
})
-- PLUGINS >>>>>>>>
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not 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)
require("lazy").setup("plugins", { defaults = { lazy = false } })
-- COLORSCHEME >>>>>>>
-- set colorscheme AFTER loading plugins
vim.cmd.colorscheme("catppuccin")
-- highlights the current line number
vim.api.nvim_set_hl(0, "CursorLineNr", { fg = "#f9e2af", bg = "#33313a", bold = true })
-- color of line the debugger is on
vim.api.nvim_set_hl(0, "debugPC", { fg = "#f9e2af", bg = "#33313a", bold = true })
-- highlights for indent-blankline plugin
vim.opt.termguicolors = true
vim.opt.list = true
vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#E06C75", nocombine = true })
vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#E5C07B", nocombine = true })
vim.api.nvim_set_hl(0, "IndentBlanklineIndent3", { fg = "#98C379", nocombine = true })
vim.api.nvim_set_hl(0, "IndentBlanklineIndent4", { fg = "#56B6C2", nocombine = true })
vim.api.nvim_set_hl(0, "IndentBlanklineIndent5", { fg = "#61AFEF", nocombine = true })
vim.api.nvim_set_hl(0, "IndentBlanklineIndent6", { fg = "#C678DD", nocombine = true })