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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
--[[
NeoVIM Configuration
Copyright (c) Freya Murphy 2025
]]--
--[[ LIB ]]--
local function bind(key, action, opts)
opts = opts or {}
vim.keymap.set('n', key, action, opts)
end
--[[ VIM ]]--
vim.opt.tabstop = config.tabwidth
vim.opt.softtabstop = config.tabwidth
vim.opt.shiftwidth = config.tabwidth
vim.opt.expandtab = config.expandtab
vim.opt.mouse = "a"
vim.opt.clipboard = "unnamedplus"
vim.opt.hlsearch = true
vim.opt.autoindent = true
vim.opt.ttyfast = true
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.rnu = true
vim.opt.swapfile = false
vim.opt.fillchars = { eob = " "}
--[[ BUF ]]--
-- remove trailing whitespace on save
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[%s/\s\+$//e]],
})
--[[ KEYBINDS ]]--
-- leader
vim.g.mapleader = config.keys.leader
vim.g.maplocalleader = config.keys.leader
vim.keymap.set("", '<leader>', '<Nop>', { noremap = true, silent = true })
-- lsp
bind(config.keys.noh, vim.cmd.noh)
vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions',
callback = function(event)
local opts = {buffer = event.buf}
bind(config.keys.lsp.hover, function() vim.lsp.buf.hover() end, opts)
bind(config.keys.lsp.action, function() vim.lsp.buf.code_action() end, opts)
bind(config.keys.lsp.references, function() vim.lsp.buf.references() end, opts)
bind(config.keys.lsp.rename, function() vim.lsp.buf.rename() end, opts)
end
})
--[[ COLORSCHEME ]]--
vim.opt.termguicolors = true
if config.theme.transparent then
vim.g.base16_transparent_background = 1
end
local colorscheme = require('base16-colorscheme')
colorscheme.setup({
base00 = config.theme.colors.base00,
base01 = config.theme.colors.base01,
base02 = config.theme.colors.base02,
base03 = config.theme.colors.base03,
base04 = config.theme.colors.base04,
base05 = config.theme.colors.base05,
base06 = config.theme.colors.base06,
base07 = config.theme.colors.base07,
base08 = config.theme.colors.base08,
base09 = config.theme.colors.base09,
base0A = config.theme.colors.base0A,
base0B = config.theme.colors.base0B,
base0C = config.theme.colors.base0C,
base0D = config.theme.colors.base0D,
base0E = config.theme.colors.base0E,
base0F = config.theme.colors.base0F,
})
-- make transparent background
if config.theme.transparent then
local colors = {
-- Text
"Normal", "NormalNC", "NormalFloat",
-- Line Numbers
"LineNr", "EndOfBuffer", "SignColumn",
-- Floating
"FloatBorder",
-- Mode/Buffer Lines
"TabLine", "TabLineFill", "StatusLine",
}
for _,color in pairs(colors) do
vim.api.nvim_set_hl(0, color, { bg = "none" })
end
end
-- identifiers should not be colored
vim.api.nvim_set_hl(0, "Identifier", { fg = config.theme.colors.base05 })
vim.api.nvim_set_hl(0, "TSVariable", { fg = config.theme.colors.base05 })
-- macro should be colored as a keyword
vim.api.nvim_set_hl(0, "TSFuncMacro", { fg = config.theme.colors.base0E })
-- comments are too dark
vim.api.nvim_set_hl(0, "Comment", { fg = config.theme.colors.base07 })
vim.api.nvim_set_hl(0, "@comment", { link = "Comment" })
--[[ MODE LINE ]]--
local lualine_theme = require('lualine.themes.base16')
if config.theme.transparent then
lualine_theme.normal.c = { fg = config.theme.colors.base05, bg = "none" }
end
require('lualine').setup {
options = {
theme = lualine_theme,
icons_enabled = true,
globalstatus = true,
},
}
--[[ BUFFER LINE ]]--
require('bufferline').setup {}
--[[ FILE BROWSER ]]--
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require('nvim-tree').setup {
sort = {
sorter = "case_sensitive",
},
view = {
centralize_selection = true,
signcolumn = "yes",
float = {
enable = true,
quit_on_focus_loss = true,
open_win_config = {
relative = "editor",
border = "rounded",
width = 80,
height = 30,
row = 1,
col = 1,
},
}
},
renderer = {
group_empty = true,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
restrict_above_cwd = false,
},
expand_all = {
max_folder_discovery = 300,
exclude = {},
},
file_popup = {
open_win_config = {
col = 1,
row = 1,
relative = "cursor",
border = "shadow",
style = "minimal",
},
},
open_file = {
quit_on_open = true,
window_picker = {
enable = false,
picker = "default",
chars = "abcdefghijklmnopqrstuvwxyz1234567890",
exclude = {
filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
remove_file = {
close_window = true,
},
},
filters = {
dotfiles = false,
},
tab = {
sync = {
open = false,
close = false,
ignore = {},
},
},
git = {
enable = false,
},
update_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_cwd = true
},
}
bind(config.keys.menus.browser, vim.cmd.NvimTreeToggle)
--[[ UNDO TREE ]]--
bind(config.keys.menus.undo, vim.cmd.UndotreeToggle)
--[[ ERROR MENU ]]--
bind(config.keys.menus.error, function() require('trouble').toggle() end)
--[[ TELESCOPE ]]--
local telescope = require('telescope.builtin')
bind(config.keys.menus.buffers, telescope.buffers)
bind(config.keys.menus.find, telescope.find_files)
bind(config.keys.menus.grep, telescope.live_grep)
bind(config.keys.menus.help, telescope.help_tags)
if config.theme.transparent then
vim.api.nvim_set_hl(0, 'TelescopeNormal', { bg = "none" })
vim.api.nvim_set_hl(0, 'TelescopeBorder', { bg = "none" })
vim.api.nvim_set_hl(0, 'TelescopeResultsTitle', { bg = "none" })
vim.api.nvim_set_hl(0, 'TelescopePromptTitle', { bg = "none" })
vim.api.nvim_set_hl(0, 'TelescopePreviewTitle', { bg = "none" })
vim.api.nvim_set_hl(0, 'TelescopePromptNormal', { bg = "none" })
vim.api.nvim_set_hl(0, 'TelescopePromptBorder', { bg = "none" })
end
--[[ COMPLETION ]]--
local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.select}
local cmp_mappings = cmp.mapping.preset.insert({
[config.keys.cmp.prev] = cmp.mapping.select_prev_item(cmp_select),
[config.keys.cmp.next] = cmp.mapping.select_next_item(cmp_select),
[config.keys.cmp.confirm] = cmp.mapping.confirm({ select = false }),
[config.keys.cmp.complete] = cmp.mapping.complete(),
})
cmp_mappings['<Tab>'] = nil
cmp_mappings['<S-Tab>'] = nil
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
sources = cmp.config.sources {
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'buffer' },
},
mapping = cmp_mappings,
formatting = {
format = require("nvim-highlight-colors").format
},
}
--[[ Surround Delimiters ]]--
require('nvim-surround').setup {}
--[[ SYNTAX HIGHLIGHTING ]]--
require('nvim-treesitter.configs').setup {
highlight = {
enable = true,
disable = function(lang, buf)
local max_filesize = config.highlight.max_size * 1024
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
additional_vim_regex_highlighting = true,
},
}
require('illuminate').configure {
providers = {
'lsp',
'treesitter',
'regex',
},
}
require("nvim-highlight-colors").setup {
render = "virtual",
virtual_symbol = '■',
enable_var_usage = true,
}
--[[ TODO COMMENTS ]]--
require('todo-comments').setup()
--[[ LSP SERVER ]]--
local lspconfig = require('lspconfig')
local capabilities = require('cmp_nvim_lsp').default_capabilities()
for lsp,settings in pairs(config.lsps) do
lspconfig[lsp].setup {
capabilities = capabilities,
settings = settings,
}
end
vim.diagnostic.config({
virtual_text = true,
})
--[[ NOTIFICATIONS ]]--
require('fidget').setup {
notification = {
window = {
winblend = 0,
},
},
}
--[[ AUTO INDENTATION ]]--
require('indent-o-matic').setup {
max_lines = 2048,
standard_widths = { 2, 4, 8 },
skip_multiline = true,
}
--[[ 80 COLUMN WIDTH ]]--
if config.col.show then
require('virt-column').setup {
enabled = true,
virtcolumn = tostring(config.col.width),
}
end
|