-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbasic.lua
More file actions
226 lines (194 loc) · 4.92 KB
/
basic.lua
File metadata and controls
226 lines (194 loc) · 4.92 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
local config = require("kide.config")
vim.g.mapleader = " "
vim.opt.title = true
vim.opt.exrc = true
vim.opt.secure = false
vim.opt.ttyfast = true
-- 相见恨晚的参数...
vim.opt_global.jumpoptions = "stack"
vim.opt.clipboard = "unnamedplus"
-- 禁用 netrw
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
if vim.fn.has("wsl") == 1 then
vim.g.clipboard = {
name = "win32yank-wsl",
copy = {
["+"] = "win32yank.exe -i --crlf",
["*"] = "win32yank.exe -i --crlf",
},
paste = {
["+"] = "win32yank.exe -o --lf",
["*"] = "win32yank.exe -o --lf",
},
cache_enabled = 0,
}
end
-- 行号
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.numberwidth = 2
vim.opt.ruler = false
-- 高亮所在行
vim.opt.cursorline = true
vim.opt.cursorcolumn = true
-- 右侧参考线,超过表示代码太长了,考虑换行
vim.opt.colorcolumn = "120"
-- 边搜索边高亮
vim.opt.incsearch = true
-- 忽悠大小写
vim.opt.ignorecase = true
-- 智能大小写
vim.opt.smartcase = true
vim.opt_global.encoding = "UTF-8"
vim.opt.fileencoding = "UTF-8"
-- jk移动时光标下上方保留8行
vim.opt.scrolloff = 3
vim.opt.sidescrolloff = 3
vim.opt.pumheight = 20
-- 缩进配置
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
-- > < 时移动长度
vim.opt.shiftwidth = 4
if vim.fn.has("nvim-0.10") == 1 then
vim.opt.smoothscroll = true
end
local autocmd = vim.api.nvim_create_autocmd
autocmd("FileType", {
pattern = {
"lua",
"javascript",
"json",
"css",
"html",
"xml",
"yaml",
"http",
"markdown",
"lisp",
"sh",
"dart",
},
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.expandtab = true
end,
})
autocmd("FileType", {
pattern = {
"gd",
"gdscript",
"gdscript3",
},
callback = function()
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
vim.opt_local.expandtab = false
end,
})
-- 新行对齐当前行,空格替代tab
vim.opt.expandtab = true
vim.opt.autoindent = true
vim.opt.smartindent = true
-- 使用增强状态栏后不再需要 vim 的模式提示
vim.opt.showmode = false
-- 当文件被外部程序修改时,自动加载
vim.opt.autoread = true
-- 禁止创建备份文件
vim.opt.backup = false
vim.opt.writebackup = false
vim.opt.swapfile = false
-- smaller updatetime
vim.opt.updatetime = 300
-- split window 从下边和右边出现
vim.opt.splitbelow = false
vim.opt.splitright = true
-- 样式
vim.opt.background = "dark"
vim.opt.termguicolors = true
-- 补全增强
vim.opt.wildmenu = true
vim.opt.confirm = true
vim.g.python3_host_prog = config.env.py_bin
vim.opt.list = true
vim.opt.cul = true -- cursor line
vim.opt.timeout = true
vim.opt.timeoutlen = 450
vim.opt.mouse = "a"
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
vim.opt.foldcolumn = "0"
vim.opt.foldenable = true
vim.opt.signcolumn = "auto"
-- 默认不要折叠
-- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
vim.opt.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.opt.foldlevelstart = 99
vim.opt_global.completeopt = "menu,menuone,noselect"
-- use ethanholz/nvim-lastplace
-- autocmd("BufReadPost", {
-- pattern = "*",
-- callback = function()
-- local l = vim.fn.line("'\"")
-- if l > 1 and l <= vim.fn.line("$") then
-- vim.fn.execute("normal! g'\"")
-- end
-- end,
-- })
vim.opt_global.grepprg = "rg --vimgrep --no-heading --smart-case"
vim.opt_global.grepformat = "%f:%l:%c:%m,%f:%l:%m"
--- see https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
local function augroup(name)
return vim.api.nvim_create_augroup("kide" .. name, { clear = true })
end
-- Highlight on yank
autocmd({ "TextYankPost" }, {
group = augroup("highlight_yank"),
callback = function()
vim.highlight.on_yank()
end,
})
-- close some filetypes with <q>
autocmd("FileType", {
group = augroup("close_with_q"),
pattern = {
"PlenaryTestPopup",
"help",
"lspinfo",
"man",
"notify",
"qf",
"spectre_panel",
"startuptime",
"tsplayground",
"checkhealth",
"fugitive",
"git",
"dbui",
"dbout",
"httpResult",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
autocmd({ "BufReadCmd" }, {
group = augroup("git_close_with_q"),
pattern = "fugitive://*",
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
autocmd("FileType", {
group = augroup("gitcommit"),
pattern = { "gitcommit" },
command = "setlocal spell spelllang=en_us,cjk",
})
autocmd({ "BufRead", "BufNewFile" }, {
group = augroup("spell"),
pattern = "*.md",
command = "setlocal spell spelllang=en_us,cjk",
})