-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
215 lines (177 loc) · 5.76 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
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
_G.MYVIMRC = vim.fn.stdpath('config') .. '/init.lua'
_G.newline = string.char(10)
_G.inspect = vim.inspect
local User = require('user_api') ---@see User User API
require('user_api.types')
local Check = User.check ---@see User.check Checking utilities
local Util = User.util ---@see User.util General utilities
local Opts = User.opts ---@see User.opts Option setting
local Commands = User.commands ---@see User.commands User command generation (WIP)
local Distro = User.distro ---@see User.distro Platform-specific optimizations (WIP)
local Keymaps = require('config.keymaps')
local is_nil = Check.value.is_nil ---@see User.Check.Value.is_nil
local is_tbl = Check.value.is_tbl ---@see User.Check.Value.is_tbl
local empty = Check.value.empty ---@see User.Check.Value.empty
local desc = User.maps.kmap.desc ---@see User.Maps.Keymap.desc
local map_dict = User.maps.map_dict ---@see User.Maps.map_dict
local wk_avail = User.maps.wk.available ---@see User.Maps.WK.available
local displace_letter = Util.displace_letter ---@see User.Util.displace_letter
local capitalize = Util.string.capitalize ---@see User.Util.String.capitalize
local curr_buf = vim.api.nvim_get_current_buf
local curr_win = vim.api.nvim_get_current_win
_G.is_windows = not is_nil((vim.uv or vim.loop).os_uname().version:match('Windows'))
---@see User.Opts.setup
Opts:setup({ ---@see User.Opts.Spec For more info
bg = 'dark', -- `background`
bs = { 'indent', 'eol', 'start' }, -- `backspace`
cmdwinheight = 8,
ci = false, -- `copyindent`
completeopt = { 'menu', 'menuone', 'noinsert', 'noselect', 'preview' },
confirm = true,
equalalways = true,
et = true, -- `expandtab`
fo = { -- `formatoptions`
b = true,
c = false,
j = true,
l = true,
n = true,
o = true,
p = true,
q = true,
w = true,
},
hlg = { 'en' }, -- `helplang`
hls = true, -- `hlsearch`
ignorecase = false,
incsearch = true,
matchtime = 30,
menuitems = 40,
mouse = { a = false },
nu = true, -- `number`
pi = false, -- `preserveindent`
rnu = false, -- `relativenumber`
ru = true, -- `ruler`
so = 3, -- `scrolloff`
sessionoptions = { 'buffers', 'tabpages', 'globals' },
sw = 4, -- `shiftwidth`
showmatch = true,
showmode = false,
stal = 2, -- `showtabline`
signcolumn = 'yes',
sts = 4, -- `softtabstop`
spell = false,
splitbelow = true,
splitright = true,
ts = 4, -- `tabstop`
title = true,
wrap = false,
})
Keymaps:set_leader('<Space>')
vim.g.markdown_minlines = 500
--- Disable `netrw` regardless of whether `nvim_tree/neo_tree` exist or not
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
--- Uncomment to use system clipboard
--- vim.o.clipboard = 'unnamedplus'
--- List of manually-callable plugin
_G.Pkg = require('config.lazy')
--- Setup keymaps
Keymaps:setup({
n = {
['<leader>fii'] = {
function()
local buf = curr_buf()
local win = curr_win()
if not vim.api.nvim_get_option_value('modifiable', { buf = buf }) then
return
end
local saved_pos = vim.api.nvim_win_get_cursor(win)
vim.api.nvim_feedkeys('gg=G', 'n', false)
-- Wait for `feedkeys` to end, then reset to position
vim.schedule(function() vim.api.nvim_win_set_cursor(win, saved_pos) end)
end,
desc('Indent Whole File'),
},
},
})
--- A table containing various possible colorschemes
local Csc = Pkg.colorschemes
---@type KeyMapDict
local CscKeys = {}
--- Reorder to your liking
local selected = {
'tokyonight',
'nightfox',
'kanagawa',
'catppuccin',
'vscode',
'onedark',
'gruvbox',
'spacemacs',
'molokai',
'oak',
'spaceduck',
'dracula',
'space_vim_dark',
}
---@type RegKeysNamed
local NamesCsc = {
['<leader>vc'] = { group = '+Colorschemes' },
}
local csc_group = 'A'
local i = 1
local found_csc = ''
for _, name in next, selected do
---@type CscSubMod|ODSubMod|table
local TColor = Csc[name]
if not is_nil(TColor.setup) then
found_csc = found_csc ~= '' and found_csc or name
NamesCsc['<leader>vc' .. csc_group] = {
group = '+Group ' .. csc_group,
}
if is_tbl(TColor.variants) and not empty(TColor.variants) then
local v = 'a'
for _, variant in next, TColor.variants do
NamesCsc['<leader>vc' .. csc_group .. tostring(i)] = {
group = '+' .. capitalize(name),
}
CscKeys['<leader>vc' .. csc_group .. tostring(i) .. v] = {
function() TColor.setup(variant) end,
desc('Set Colorscheme `' .. capitalize(name) .. '` (' .. variant .. ')'),
}
v = displace_letter(v, 'next', false)
end
else
CscKeys['<leader>vc' .. csc_group .. tostring(i)] = {
TColor.setup,
desc('Set Colorscheme `' .. capitalize(name) .. '`'),
}
end
if i == 9 then
i = 1
csc_group = displace_letter(csc_group, 'next', false)
elseif i < 9 then
i = i + 1
end
end
end
if wk_avail() then
map_dict(NamesCsc, 'wk.register', false, 'n')
end
map_dict(CscKeys, 'wk.register', false, 'n')
if not empty(found_csc) then
Csc[found_csc].setup()
end
--- Call the user file associations and other autocmds
Util.assoc()
vim.g.markdown_minlines = 500
--- Call runtimepath optimizations for Arch Linux (WIP)
Distro.archlinux:setup()
Commands:setup_commands()
User:setup_keys()
vim.cmd([[
filetype plugin indent on
syntax on
]])
--- vim:ts=4:sts=4:sw=4:et:ai:si:sta:noci:nopi: