-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
161 lines (126 loc) · 4.89 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
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- 3 ways to refer to command-line commands: '<cmd>commandhere', ':commandhere' vim.cmd.commandhere'
vim.keymap.set("n", "<leader>ep", vim.cmd.Explore)
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
vim.keymap.set({"n", "i"}, "<A-c>", "<cmd>%y<CR>")
-- vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- Sigma yank-substitute remap
vim.keymap.set("x", "<leader>p", "\"_dP")
vim.keymap.set("n", "<Esc>", vim.cmd.nohlsearch)
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<S-CR>", "<nop>")
-- See: `:help quickfix`
vim.keymap.set("n", "<leader>cn", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<leader>cp", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>b", "<cmd>!chmod u+x %<CR>")
vim.keymap.set("n", "<F2>", "<cmd>split term://bash<enter>")
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") -- <Esc><Esc> won"t work on all terminal emulators
vim.keymap.set("n", "<F7>", "<cmd>!gcc % && ./a.out <CR>")
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" }) -- Diagnostic keymap
-- See: `:help wincmd` - list of all window commands
vim.keymap.set("n", "<C-h>", "<C-w><C-h>")
vim.keymap.set("n", "<C-l>", "<C-w><C-l>")
vim.keymap.set("n", "<C-j>", "<C-w><C-j>")
vim.keymap.set("n", "<C-k>", "<C-w><C-k>")
-- Write, quit
vim.keymap.set({"n", "i"},"<A-s>", "<cmd>wall<CR>")
vim.keymap.set({"n", "i"},"<A-q>", "<cmd>qall<CR>")
-- NOTE: ### MEGA KEYBINDING ###
function tprint (tbl, indent)
if not indent then indent = 0 end
local toprint = string.rep(" ", indent) .. "{\r\n"
indent = indent + 2
for k, v in pairs(tbl) do
toprint = toprint .. string.rep(" ", indent)
if (type(k) == "number") then
toprint = toprint .. "[" .. k .. "] = "
elseif (type(k) == "string") then
toprint = toprint .. k .. "= "
end
if (type(v) == "number") then
toprint = toprint .. v .. ",\r\n"
elseif (type(v) == "string") then
toprint = toprint .. "\"" .. v .. "\",\r\n"
elseif (type(v) == "table") then
toprint = toprint .. tprint(v, indent + 2) .. ",\r\n"
else
toprint = toprint .. "\"" .. tostring(v) .. "\",\r\n"
end
end
toprint = toprint .. string.rep(" ", indent-2) .. "}"
return toprint
end
vim.keymap.set("n", "<leader>z", function()
if (vim.opt.nrformats:get()[3] == "alpha") then
vim.opt.nrformats:remove{"alpha"}
vim.notify(tprint(vim.opt.nrformats:get()))
else
vim.opt.nrformats:append{"alpha"}
vim.notify(tprint(vim.opt.nrformats:get()))
end
end) -- Increment character alphabetically
vim.schedule(function() -- Schedule the setting after `UiEnter` because it can increase startup-time.
vim.opt.clipboard = 'unnamedplus'
end)
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.cursorline = true -- Cursor line highlight
vim.opt.colorcolumn = '80'
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
-- vim.opt.autochdir = true
vim.opt.undofile = false
vim.opt.incsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true -- Case sensitive when capital letters
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.scrolloff = 8
vim.opt.showmode = false -- Since mode is already in the statusline
vim.opt.breakindent = true
vim.opt.undofile = true -- Save undo history
vim.opt.updatetime = 150 -- Decrease update time
vim.opt.timeoutlen = 1000 -- Ex: leader key timeout
vim.opt.signcolumn = 'yes' -- For symbols on the left
vim.opt.mouse = 'a' -- Enable mouse mode
vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Sets how neovim will display certain whitespaces.
vim.g.netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
vim.g.netrw_banner = 0
vim.g.netrw_liststyle = 3 -- Tree listing
-- See `:help lua-guide-autocommands`
-- See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank { timeout = 60 }
end,
})
vim.api.nvim_create_autocmd("BufEnter", {
desc = 'Do :set formatoptions-=cro', -- since runtime files would override it otherwise
group = vim.api.nvim_create_augroup('robberfox-commentformat', { clear = true }),
pattern = "*",
callback = function()
vim.opt.formatoptions:remove{ 'c', 'r', 'o' }
end
})
vim.api.nvim_create_autocmd("BufEnter", {
desc = 'Prevent style overrides from /usr/share/nvim/runtime/...',
group = vim.api.nvim_create_augroup('robberfox-tab', { clear = true }),
callback = function()
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = false
end
})