-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
366 lines (313 loc) · 11.3 KB
/
Copy pathinit.lua
File metadata and controls
366 lines (313 loc) · 11.3 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
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
354
355
356
357
358
359
360
361
362
363
364
365
366
---
--- Because most plugins are hosted on GitHub, you can use the helper
--- function to have less repetition in the following sections.
--- @param repo string
--- @return string
function _G.gh(repo) return "https://github.com/" .. repo end
-- Initial recommended configurations
do
-- Enable faster startup by caching compiled Lua modules
vim.loader.enable()
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
-- Make line numbers default
vim.o.number = true
-- Tab size
vim.o.shiftwidth = 4
vim.o.tabstop = 4
-- enable relative line numbers
vim.o.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = "a"
-- Don't show the mode, since it's already in the status line
vim.o.showmode = false
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.schedule(function() vim.o.clipboard = "unnamedplus" end)
-- Enable break indent
vim.o.breakindent = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.o.signcolumn = "yes"
-- Decrease update time
vim.o.updatetime = 250
-- Decrease mapped sequence wait time
vim.o.timeoutlen = 300
-- Configure how new splits should be opened
vim.o.splitright = true
vim.o.splitbelow = true
-- Enable spell check for camelCase words
vim.o.spelloptions = "camel"
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
--
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
-- See `:help lua-options`
-- and `:help lua-guide-options`
vim.o.list = true
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
-- Preview substitutions live, as you type!
vim.o.inccommand = "split"
-- Show which line your cursor is on
vim.o.cursorline = true
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)
-- See `:help 'confirm'`
vim.o.confirm = true
-- undo/redo history persists until session closes
vim.o.undofile = false
-- 4 lines of context around cursor when scrolling
vim.o.scrolloff = 4
-- move to the last character of the last line
vim.keymap.set({ "n", "o", "x" }, "G", function()
local last_line = vim.api.nvim_buf_line_count(0)
local last_col = #vim.api.nvim_buf_get_lines(0, -2, -1, false)[1] - 1
vim.api.nvim_win_set_cursor(0, { last_line, math.max(0, last_col) })
end, { noremap = true })
-- move to the first character of the first line
vim.keymap.set(
{ "n", "o", "x" },
"gg",
function() vim.api.nvim_win_set_cursor(0, { 1, 0 }) end,
{ noremap = true }
)
-- last non-whitespace character of the current line (inverse of `_`)
vim.keymap.set({ "n", "o", "x" }, "=", "g_", { noremap = true })
if vim.fn.executable("nvr") == 1 then
local editor_cmd = "nvr --remote-silent -o"
local git_editor = "nvr --remote-tab-wait-silent +'set bufhidden=wipe'"
vim.env.GIT_EDITOR = git_editor
vim.env.EDITOR = editor_cmd
end
end
-- Basic keymaps (built in vim actions, without any plugin dependency)
do
local unnamed_buf_wipe_grp =
vim.api.nvim_create_augroup("wipe_unnamed_buf", { clear = true })
-- Remove unnamed buf (such as the empty buffer created when neovim is first opened) when they are hidden if:
-- buffer is not modified
-- buffer id is still valid at the next tick
vim.api.nvim_create_autocmd("BufHidden", {
group = unnamed_buf_wipe_grp,
callback = function(ev)
local buf_id = ev.buf
local buf_name = vim.api.nvim_buf_get_name(buf_id)
-- Skip if has name
if buf_name ~= "" then
return
end
-- Skip non-normal buffers
if vim.bo[buf_id].buftype ~= "" then
return
end
-- Skip if modified
if vim.bo[buf_id].modified then
return
end
-- Delete on next tick after hidden event
vim.schedule(function()
-- Check if buffer ID is still valid at this moment
if vim.api.nvim_buf_is_valid(buf_id) then
-- Delete buffer
vim.api.nvim_buf_delete(buf_id, {})
end
end)
end,
})
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
vim.keymap.set(
{ "i", "c", "v", "x", "s", "o", "t", "l" },
"<C-n>",
"<C-\\><C-n>",
{ desc = "Exit to Normal mode" }
)
-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Key binds to navigate between tabs
-- Use ALT+<h,l> to navigate between adjacent tabs
vim.keymap.set(
{ "n", "i", "t" },
"<A-h>",
vim.cmd.tabprevious,
{ silent = true, desc = "Previous tab" }
)
vim.keymap.set(
{ "n", "i", "t" },
"<A-l>",
vim.cmd.tabnext,
{ silent = true, desc = "Next tab" }
)
vim.keymap.set(
{ "n", "i", "t" },
"<A-t>",
function() vim.cmd.wincmd("T") end,
{ silent = true, desc = "Move window to new tab" }
)
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap.set(
{ "n", "i", "t" },
"<C-h>",
function() vim.cmd.wincmd("h") end
)
vim.keymap.set(
{ "n", "i", "t" },
"<C-j>",
function() vim.cmd.wincmd("j") end
)
vim.keymap.set(
{ "n", "i", "t" },
"<C-k>",
function() vim.cmd.wincmd("k") end
)
vim.keymap.set(
{ "n", "i", "t" },
"<C-l>",
function() vim.cmd.wincmd("l") end
)
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.hl.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup(
"kickstart-highlight-yank",
{ clear = true }
),
callback = function() vim.hl.on_yank() end,
})
-- get rid of keyboard LSP shortcuts I don't like
vim.keymap.del("n", "grn")
vim.keymap.del("n", "grx")
vim.keymap.del({ "n", "x" }, "gra")
vim.keymap.del("n", "grr")
vim.keymap.del("n", "gri")
vim.keymap.del("n", "gO") -- [gs] with Snacks.picker is used instead
vim.keymap.del("n", "grt")
end
-- lazy.nvim to load install all other plugins (except theme below)
vim.pack.add({ gh("folke/lazy.nvim") })
-- Default colorscheme
do
vim.pack.add({ gh("ribru17/bamboo.nvim") })
local c = require("bamboo.palette")["vulgaris"]
local util = require("bamboo.util")
local bg1 = util.darken(c.bg1, 0.03)
local bg2 = util.darken(c.bg2, 0.03)
local bg3 = util.darken(c.bg3, 0.03)
local hl_write = util.blend(bg1, c.blue, 0.2)
local hl_read = util.blend(bg1, c.green, 0.1)
local hl_text = util.blend(bg1, c.green, 0.1)
require("bamboo").setup({
style = "vulgaris",
transparent = false,
term_colors = true,
code_style = {
comments = { italic = true },
keywords = { italic = true },
diagnostics = {
darker = true,
undercurl = true,
background = true,
},
},
dim_inactive = true,
colors = {
bg1 = bg1,
bg2 = bg2,
bg3 = bg3,
},
highlights = {
NormalFloat = { bg = c.bg_d },
FloatBorder = { fg = c.purple },
-- LSP highlights
LspReferenceWrite = { bg = hl_write },
LspReferenceRead = { bg = hl_read },
LspReferenceText = { bg = hl_text },
-- Noice Popup highlights
NoiceConfirm = { link = "NormalFloat" },
NoiceConfirmBorder = { link = "FloatBorder" },
},
})
require("bamboo").load()
end
require("lazy").setup({
spec = {
{ import = "config.plugins" },
{ "j-hui/fidget.nvim", config = true },
{ "windwp/nvim-autopairs", config = true },
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
config = true,
},
{
"NMAC427/guess-indent.nvim",
opts = {
auto_cmd = true,
--- @type vim.bo
on_tab_options = {
expandtab = true,
softtabstop = -1,
},
--- @type vim.bo
on_space_options = {
expandtab = true,
tabstop = "detected",
softtabstop = "detected",
shiftwidth = "detected",
},
},
},
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = true,
},
{
name = "config.utils",
dir = vim.fn.stdpath("config"),
},
{
name = "config.mason",
dir = vim.fn.stdpath("config"),
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
},
},
},
defaults = { lazy = false },
})