-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
187 lines (165 loc) · 4.61 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
local vim=vim
-- Stand-alone neovim config file with all my defaults
--TODO:
-- fix "$nv/after/syntax/gcode.vim"
-- fix clipboard
--- yanking text always copies it to system clipboard as well as the local instance clipboard
-- remove highlights after search
-- highlights only in current buffer
-- add better pair matching functionality to replace:
--- [matchit](https://github.com/neovim/neovim/blob/master/runtime/pack/dist/opt/matchit/plugin/matchit.vim) &
--- [vim-surround](https://github.com/tpope/vim-surround)
-- builting support for markdown style lists
-- Language Configs: (in order)
--- Lua, C, Rust, Zig
-- Settings: {{{
-- :help lua-guide-options
vim.cmd('filetype plugin indent on')
vim.cmd('packadd! matchit')
vim.opt.syntax='on'
vim.opt.shortmess='a'
vim.opt.errorbells=true
vim.opt.timeoutlen=800
vim.opt.splitbelow=true
vim.opt.splitright=true
vim.opt.mouse='nv'
vim.opt.virtualedit:append('block')
vim.opt.scrolloff=8
vim.opt.sidescrolloff=6
vim.opt.relativenumber=true
vim.opt.number=true
vim.opt.wrap=false
vim.opt.signcolumn='yes'
vim.opt.foldcolumn='auto'
vim.opt.foldmethod='marker'
vim.opt.colorcolumn='100'
vim.opt.cmdheight=2
vim.opt.magic=true
vim.opt.smartcase=true
vim.opt.ignorecase=true
vim.opt.hlsearch=true
vim.opt.incsearch=true
vim.opt.showmatch=true
vim.opt.tabstop=4
vim.opt.softtabstop=4
vim.opt.shiftwidth=4
vim.opt.expandtab=true
vim.opt.smarttab=true
vim.opt.autoindent=true
vim.opt.shiftround=true
vim.opt.autochdir=true
vim.opt.exrc=true
vim.opt.hidden=true
vim.opt.autoread=true
vim.opt.swapfile=false
vim.opt.backup=false
vim.opt.writebackup=false
vim.opt.undodir=vim.fn.stdpath('data') .. '/undo'
vim.opt.undofile=true
-- }}}
-- Keymaps: {{{
-- set the leader key
vim.g.leader=' '
-- ESC terminal mode
vim.keymap.set('t', '<C-[>', '<C-\\><C-n>')
-- Scroll Buffer
vim.keymap.set('n', 'J', '<C-e>')
vim.keymap.set('n', 'K', '<C-y>')
-- (Readline) Insert Mode Bindings
--- movement
vim.keymap.set('i', '<C-j>', '<Cr>')-- newline
vim.keymap.set('i', '<C-a>', '<Esc>^i')-- goto start of text
vim.keymap.set('i', '<C-e>', '<Esc>$a')-- goto end of line
vim.keymap.set('i', '<C-f>', '<C-right>')-- skip to end of word
vim.keymap.set('i', '<C-b>', '<C-left>')-- go back a word
--- deletion
--[[
vim.keymap.set('i', '<C-u>', function()-- delete to start of text or indent level
indent = vim.fn.indent('.')
print('current indent = '..indent)
end)
--]]
vim.keymap.set('i', '<C-k>', '<Esc>lv$hda')-- delete to end of text
--- undo
vim.keymap.set('i', '<C-z>', '<Esc>lv$hda')
--- completion
vim.keymap.set('i', '<C-;>', '')-- request completion
vim.keymap.set('i', '<C-/>', '')-- digraph menu, set to <C-k> by default
-- Navigate Widows
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')
-- Resize Windows
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>')
-- Toggle Window Maximized
vim.keymap.set('n', '<C-w>m', function() ToggleWindowMaximized() end, {silent = true})
-- Append Line
vim.keymap.set('n', ',o', 'o<ESC>')
vim.keymap.set('n', ',O', 'O<ESC>')
-- Use Sys Cliboard
vim.g.clipboard = 'unamedplus'
vim.keymap.set('n', '<leader>Y', '"+yg_')
vim.keymap.set({'n', 'v'}, '<leader>y', '"+y')
vim.keymap.set({'n', 'v'}, '<leader>p', '"+p')
vim.keymap.set({'n', 'v'}, '<leader>P', '"+P')
-- }}}
-- Commands: {{{
vim.cmd([[
com! Q q!
com! Qa qa!
com! W w!
com! Reload source $MYVIMRC
]])
-- Functions & Augroups:
-- augroup saveOnClose
-- augroup trimWhitespace
function PingCursor()
end
local windowMaximized = 0
function ToggleWindowMaximized()
if windowMaximized == 0 then
vim.cmd('vertical resize')
vim.cmd('resize')
windowMaximized = 1
else
vim.cmd('exe "normal \\<C-w>="')
windowMaximized = 0
end
end
-- }}}
-- Detect Filetypes: {{{
-- see: "https://github.com/neovim/neovim/pull/16600#issuecomment-990409210"
vim.filetype.add({
filename = {
['.envrc'] = "sh",
},
extension = {
-- GLSL
vert = "glsl", -- vertex shader
tesc = "glsl", -- tessellation control shader
tese = "glsl", -- tessellation evaluation shader
geom = "glsl", -- geometry shader
frag = "glsl", -- fragment shader
comp = "glsl", -- compute shader
glsl = "glsl",
-- GCode
gcode = "gcode",
ngc = "gcode",
nc = "gcode",
cnc = "gcode",
tap = "gcode",
-- Zig
zon = "zig",
-- Javascript (sucks)
cps = "javascript",-- fusion 360 post processor
-- Misc.
buildconf = "make",
},
pattern = {
},
})
-- }}}