-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
276 lines (236 loc) · 6.97 KB
/
init.lua
File metadata and controls
276 lines (236 loc) · 6.97 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
--
-- defaults
--
local opt = vim.opt
local keymap = vim.keymap
local cmd = vim.cmd
local g = vim.g
-- apperance
opt.termguicolors = true
opt.signcolumn = "yes"
opt.number = true
opt.cursorline = true
opt.textwidth = 120
-- display
opt.relativenumber = true
opt.wrap = false
opt.hidden = true
opt.showcmd = false
opt.inccommand = "nosplit"
opt.laststatus = 2
-- mouse
-- opt.mouse:append("a")
opt.mouse = "nv"
-- split window
opt.splitright = true
opt.splitbelow = true
-- scroll
opt.scrolloff = 4
opt.sidescrolloff = 10
opt.ttyfast = true
opt.lazyredraw = false -- avoid issue in noice
-- search
opt.ignorecase = true
opt.smartcase = true
opt.incsearch = true
opt.hlsearch = true
-- opt.wildignorecase = true;
-- temp files, backup, swap, etc
opt.backup = false
opt.writebackup = false
opt.swapfile = false
opt.undofile = false
-- editing
opt.autoread = true -- auto read if file is modified in other place
opt.title = true
opt.wildmenu = true
opt.errorbells = false
opt.spell = false
opt.history = 1000
-- match bracket
opt.showmatch = true
opt.matchtime = 2
-- fold
opt.foldenable = true
opt.foldmethod = "indent"
opt.foldlevel = 99
opt.foldlevelstart = 99
-- indentation
opt.autoindent = true
opt.smartindent = true
opt.expandtab = true
opt.tabstop = 4
opt.shiftwidth = 4
opt.softtabstop = 4
-- filetype spec
cmd([[autocmd FileType lua,json,yaml setlocal ts=2 sts=2 sw=2]])
cmd([[autocmd FileType json set formatprg=jq]])
cmd([[autocmd BufNewFile,BufRead *.typst set filetype=typst]])
cmd([[autocmd BufNewFile,BufRead *.typ set filetype=typst]])
--
-- keymaps
--
g.mapleader = "," -- Make sure to set `mapleader` before lazy so your mappings are correct
g.localmapleader = ","
keymap.set("n", "<esc>", "<cmd>nohl<CR>")
keymap.set("n", "Q", "<nop>")
keymap.set("n", "<c-q>", "<nop>")
-- buffer
keymap.set("n", "[b", "<cmd>bprevious<CR>")
keymap.set("n", "]b", "<cmd>bnext<CR>")
-- clipboard
keymap.set("v", "Y", '"+y')
-- filetype
-- keymap.set("n", "<leader>ft", "<cmd>set ft=")
-- command mode and insert mode emacs-style {
keymap.set("c", "<c-b>", "<left>")
keymap.set("c", "<c-f>", "<right>")
keymap.set("c", "<c-n>", "<down>")
keymap.set("c", "<c-p>", "<up>")
keymap.set("c", "<c-a>", "<home>")
keymap.set("c", "<c-e>", "<end>")
keymap.set("c", "<c-d>", "<del>")
keymap.set("c", "<m-b>", "<s-left>")
keymap.set("c", "<m-f>", "<s-right>")
keymap.set("i", "<c-b>", "<left>")
keymap.set("i", "<c-f>", "<right>")
keymap.set("i", "<c-a>", "<home>")
keymap.set("i", "<c-e>", "<end>")
keymap.set("i", "<c-d>", "<del>")
keymap.set("i", "<c-k>", "<esc>lC")
keymap.set("i", "jk", "<esc>")
-- faster scroll
keymap.set("n", "<c-e>", "2<c-e>")
keymap.set("n", "<c-y>", "2<c-y>")
keymap.set("n", "<leader>wr", "<cmd>set wrap<cr>")
-- " customize placeholder _TODO_
-- " nnoremap <leader><c-t> a_TODO_<esc>
-- nnoremap <leader><c-t> b/_TODO_<cr><cmd>nohl<cr>"_c6l
-- nnoremap <leader>tt b/_TODO_<cr><cmd>nohl<cr>"_c6l
-- inoremap <c-t> <esc>/_TODO_<cr><cmd>nohl<cr>"_c6l
-- tab
keymap.set("n", "tu", "<cmd>tabe<cr>")
keymap.set("n", "tn", "<cmd>tabnew<cr>")
keymap.set("n", "t=", "<cmd>tabmove +<cr>")
keymap.set("n", "t-", "<cmd>tabmove -<cr>")
-- run vim run
keymap.set("n", "<leader>rr", "<cmd>call RunVimRun()<cr>")
keymap.set("n", "<leader>rt", "<cmd>call RunVimTest()<cr>")
keymap.set("n", "<leader>py", "<cmd>call RunPython()<cr>")
--
-- lazy plugins
--
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "--branch=stable",
lazypath,
})
end
opt.rtp:prepend(lazypath)
require("lazy").setup({
require("pl-mini"),
require("pl-completion"),
require("pl-telescope"),
require("pl-lsp"),
require("pl-explorer"),
require("pl-language"),
require("pl-format"),
require("pl-tpope"),
require("pl-navigation"),
require("pl-ornament"),
-- wilder
{
"folke/noice.nvim",
event = "VeryLazy",
dependencies = {
"MunifTanjim/nui.nvim",
{
"rcarriga/nvim-notify",
opts = {
background_colour = "#000000",
on_open = function(win)
vim.api.nvim_win_set_config(win, { focusable = false })
end,
}
},
},
opts = {
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true, -- requires nvim-cmp
},
},
presets = {
bottom_search = false, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
},
},
-- editing
{
-- narrow region
{
"andrewradev/inline_edit.vim",
keys = { { "<leader>nr", mode = "v", "<cmd>InlineEdit<cr>" } },
config = function()
vim.g.inline_edit_autowrite = 1
end,
},
{ "vim-scripts/swapcol.vim", cmd = { "Swapcols" } },
{ "tani/dmacro.vim", keys = { { "<c-y>", mode = { "n", "i" }, "<Plug>(dmacro-play-macro)" } } },
-- increment
{
"monaqa/dial.nvim",
events = "VeryLazy",
keys = {
{ "<c-a>", mode = { "n", "v" }, "<Plug>(dial-increment)" },
{ "<c-x>", mode = { "n", "v" }, "<Plug>(dial-decrement)" },
},
config = function()
local augend = require("dial.augend")
local weekdays = augend.constant.new({
elements = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" },
word = true,
cyclic = true,
})
require("dial.config").augends:register_group({
default = {
augend.integer.alias.decimal,
augend.constant.alias.bool,
augend.date.alias["%Y/%m/%d"],
weekdays,
},
})
end,
},
-- { "windwp/nvim-autopairs", event = "InsertEnter", opts = { disable_filetype = { "TelescopePrompt", "vim" } } },
-- information
{ "kevinhwang91/nvim-bqf", ft = "qf" },
},
-- diagnostics, references, etc
{
"folke/trouble.nvim",
cmd = "Trouble",
keys = {
{ "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)", },
{ "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)", },
{ "<leader>cs", "<cmd>Trouble symbols toggle focus=false<cr>", desc = "Symbols (Trouble)" },
{ "<leader>cl", "<cmd>Trouble lsp toggle focus=false win.position=right<cr>", desc = "LSP Definitions / references / ... (Trouble)", },
{ "<leader>xL", "<cmd>Trouble loclist toggle<cr>", desc = "Location List (Trouble)", },
{ "<leader>xQ", "<cmd>Trouble qflist toggle<cr>", desc = "Quickfix List (Trouble)", },
},
},
-- others
{ "sindrets/diffview.nvim", cmd = { "DiffviewOpen", "DiffviewFileHistory" } },
})
-- end of lazy plugins
require("builtin")
require("custom-fn")
require("neovide")