-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
265 lines (233 loc) · 7.94 KB
/
Copy pathinit.lua
File metadata and controls
265 lines (233 loc) · 7.94 KB
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
vim.opt.relativenumber = true -- Show relative line numbers for other lines
vim.opt.number = true -- Show line numbers
vim.opt.cursorline = true
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'go' },
callback = function() vim.treesitter.start() end,
})
-- For Java
vim.api.nvim_set_keymap(
"n",
"make",
":botright split | term javac % && java %:r<CR>",
{ noremap = true, silent = true }
)
-- For golang
vim.api.nvim_set_keymap(
"n",
"go",
[[:botright split | term go run %<CR>]],
{ noremap = true, silent = true }
)
-- For c++
vim.api.nvim_set_keymap(
"n",
"cm",
":botright split | term g++ % && ./a.out <CR>",
{ noremap = true, silent = true }
)
-- Automatically switch to insert mode when opening a terminal
vim.api.nvim_create_autocmd("TermOpen", {
pattern = "*", -- Match any terminal
callback = function()
vim.cmd("startinsert") -- Switch to insert mode
end,
})
-- vim.cmd("set number")
vim.cmd("set laststatus=2")
vim.cmd("command! Save w")
vim.cmd("command! Nom %s/\r//g")
vim.cmd("command! Noh nohlsearch")
vim.cmd("set encoding=utf-8")
vim.opt.wrap = false
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.clipboard = "unnamedplus"
vim.opt.guicursor = "a:block"
--Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- require("lazy").setup("plugins")
vim.diagnostic.config({
virtual_text = true, -- inline error/warning text
signs = false, -- signs in the gutter
underline = true,
update_in_insert = false,
severity_sort = true,
})
-- Setup lazy.nvim
require("lazy").setup({
ui = {
border = "rounded",
},
spec = {
-- add your plugins here
{
'MeanderingProgrammer/render-markdown.nvim',
lazy = true,
opts = {},
-- keys = {
-- {
-- "<leader>0",
-- }
-- }
},
-- { "catppuccin/nvim", name = "catppuccin", priority = 1000 },
-- { 'mbbill/undotree' },
-- {import = "plugins.gitsigns"}, --1
-- {import = "plugins.nvimcmp"}, --3
{import = "plugins.lspconfig"}, -- uncomment if vim.lsp does not work out
-- {import = "plugins.gruvBoxColorSh"},
{import = "plugins.catColor"}, -- main catppuccin color with tab colors
-- {import = "plugins.onedark"},
{import = "plugins.lualine"}, --5
{import = "plugins.neotree"}, --6
{import = "plugins.blink"}, --6
{import = "plugins.snacks"}, --6
-- {import = "plugins.telescope"}, --10
{import = "plugins.treesitter"}, --12
{ 'echasnovski/mini.nvim', version = '*' },
--end of lazy here
},
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = false},
})
require('mini.surround').setup() -- better surround handling
require('mini.pairs').setup() -- auto-pairing brackets
require('mini.diff').setup() -- auto-pairing brackets
require('mini.ai').setup() -- auto-pairing brackets
-- vim.api.nvim_set_hl(0, "Visual", { bg = "#275378" }) -- or any color you want
-- vim.api.nvim_set_hl(0, "MiniDiffSignAdd", { fg = "#70e000", bg = "NONE" })
-- vim.api.nvim_set_hl(0, "MiniDiffSignChange", { fg = "#ffc300", bg = "NONE" })
-- vim.api.nvim_set_hl(0, "MiniDiffSignDelete", { fg = "#ff595e", bg = "NONE" })
--
-- vim.api.nvim_set_hl(0, "MiniDiffLineAdd", { fg = "#70e000", bg = "NONE" })
-- vim.api.nvim_set_hl(0, "MiniDiffLineChange", { fg = "#ffc300", bg = "NONE" })
-- vim.api.nvim_set_hl(0, "MiniDiffLineDelete", { fg = "#ff595e", bg = "NONE" })
--
-- vim.api.nvim_set_hl(0, "CursorLineNr", { fg = "#f15bb5", bold = true })
vim.api.nvim_set_keymap("n", "<C-d>", "<C-d>zz", { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<C-u>", "<C-u>zz", { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<leader>l", "$", { noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "<leader>h", "^", { noremap = true, silent = true })
-- vim.api.nvim_set_keymap("n", "<leader>k", "gM", { noremap = true, silent = true })
vim.keymap.set("n", "<leader>w", ":w<CR>") -- save
vim.keymap.set("n", "<leader>t", ":vertical belowright terminal<CR>") -- for quik terminal
vim.keymap.set("n", "<leader>f", ":lua Snacks.picker.files()<CR>") -- file picker
vim.keymap.set("n", "<leader>p", ":lua Snacks.picker.buffers()<CR>") -- picker for open buffers
vim.keymap.set("n", "<leader>m", ":w | bd<CR>") -- closing buffer
vim.keymap.set("n", "<leader>gg", ":lua Snacks.lazygit()<CR>") -- lazygit
vim.api.nvim_set_keymap("n", "<leader>nn", ":lcd %:p:h<CR>", { noremap = true, silent = true }) --NOT USELESS
vim.api.nvim_set_keymap("n", "<leader>0", ":RenderMarkdown toggle <CR>", { noremap = true, silent = true }) --NOT USELESS
vim.keymap.set("n", "dd", '"_dd', { noremap = true, desc = "delete line without yanking to clipboard" })
vim.keymap.set(
"n",
"<leader>ge",
"oif err != nil {<CR>}<Esc>Oreturn err<Esc>"
)
vim.api.nvim_create_user_command(
'NoteMode',
function()
print("Take Notes!")
vim.cmd("set nonumber")
vim.cmd("set norelativenumber")
vim.cmd("Lazy load render-markdown.nvim")
end,
{
desc = 'Load render-markdown and get rid of side numbers for note taking'
}
)
vim.api.nvim_create_user_command(
'ToggleTab',
function()
if vim.opt.shiftwidth:get() == 4 then
print("Tab is now 2")
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
else
print("Tab is now 4")
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
end
end,
{
desc = 'Load render-markdown and get rid of side numbers for note taking'
}
)
-- not show the tabline when starting
vim.o.showtabline = 1
-- use custom tabline function
vim.o.tabline = "%!v:lua.MyTabLine()"
function _G.MyTabLine()
local s = ""
for i = 1, vim.fn.tabpagenr('$') do
local winnr = vim.fn.tabpagewinnr(i)
local bufnr = vim.fn.tabpagebuflist(i)[winnr]
local name = vim.fn.bufname(bufnr)
local label = vim.fn.fnamemodify(name, ":t") -- only filename (no path)
if i == vim.fn.tabpagenr() then
s = s .. "%#TabLineSel# " .. label .. " "
else
s = s .. "%#TabLine# " .. label .. " "
end
end
return s .. "%#TabLineFill#"
end
vim.api.nvim_set_hl(0, "Visual", { bg = "#275378" })
vim.api.nvim_set_hl(0, "TabLine", { fg = "#C0C9EE", bg = "#1e1e2e" }) -- inactive tabs
vim.api.nvim_set_hl(0, "TabLineSel", { fg = "#ffffff", bg = "#275378" }) -- active tab
vim.api.nvim_set_hl(0, "TabLineFill", { bg = "#1e1e1e" }) -- background
vim.api.nvim_set_hl(0, "CursorLineNr", { fg = "#f15bb5", bold = true })
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover({
border = "rounded",
})
end, { silent = true })
-- Highlight groups
vim.api.nvim_set_hl(0, "TodoHighlight", {
bg = "#cba6f7",
fg = "#1e1e2e",
bold = true,
})
vim.api.nvim_set_hl(0, "FixHighlight", {
bg = "#fffba8",
fg = "#1e1e2e",
bold = true,
})
vim.api.nvim_set_hl(0, "WarnHighlight", {
bg = "#f38ba8",
fg = "#1e1e2e",
bold = true,
})
vim.api.nvim_set_hl(0, "NoteHighlight", {
bg = "#94e2d5",
fg = "#1e1e2e",
bold = true,
})
-- Apply matches to every opened buffer/window
vim.api.nvim_create_autocmd({ "BufWinEnter", "WinEnter" }, {
callback = function()
vim.fn.matchadd("TodoHighlight", [[\vTODO:.*]])
vim.fn.matchadd("FixHighlight", [[\vFIX:.*]])
vim.fn.matchadd("WarnHighlight", [[\vWARN:.*]])
vim.fn.matchadd("NoteHighlight", [[\vNOTE:.*]])
end,
})
require("pack.undoTree")