This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
forked from brainfucksec/neovim-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.lua
146 lines (122 loc) · 5.21 KB
/
settings.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
-----------------------------------------------------------
-- General Neovim settings and configuration
-----------------------------------------------------------
-- Default options are not included
--- See: https://neovim.io/doc/user/vim_diff.html
--- [2] Defaults - *nvim-defaults*
-----------------------------------------------------------
-- Neovim API aliases
-----------------------------------------------------------
local cmd = vim.cmd -- Execute Vim commands
local exec = vim.api.nvim_exec -- Execute Vimscript
local g = vim.g -- Global variables
local opt = vim.opt -- Set options (global/buffer/windows-scoped)
--local fn = vim.fn -- Call Vim functions
-----------------------------------------------------------
-- General
-----------------------------------------------------------
opt.mouse = 'niv' -- Enable mouse support
opt.clipboard = 'unnamedplus' -- Copy/paste to system clipboard
opt.swapfile = false -- Don't use swapfile
-----------------------------------------------------------
-- Neovim UI
-----------------------------------------------------------
opt.number = true -- Show line number
opt.relativenumber = true -- Show line number
opt.showmatch = true -- Highlight matching parenthesis
opt.ignorecase = true -- Ignore case letters when search
opt.smartcase = true -- Ignore lowercase for the whole pattern
opt.termguicolors = true -- set cursorcolumn
opt.cursorline = true -- 高亮当前行
opt.ruler = true -- 显示当前行号及列号
opt.cindent = true -- C 缩进
opt.hlsearch = true -- 高亮搜索
opt.incsearch = true -- 键入搜索
opt.foldenable = false -- 取消自动折叠
opt.showmode = false -- 不显示status
-----------------------------------------------------------
-- Neovim theme
-----------------------------------------------------------
g.sonokai_style = 'espresso'
-- g.sonokai_style = 'default'
g.sonokai_enable_italic = false
g.sonokai_disable_italic_comment = true
g.sonokai_transparent_background = false
g.sonokai_diagnostic_text_highlight = false
cmd [[colorscheme sonokai]]
-----------------------------------------------------------
-- Tabs, indent
-----------------------------------------------------------
opt.expandtab = true -- Use spaces instead of tabs
opt.shiftwidth = 2 -- Shift 4 spaces when tab
opt.tabstop = 2 -- 1 tab == 4 spaces
opt.softtabstop = 2 -- 设置按 tab 时缩进的宽度为 4
opt.smartindent = true -- Autoindent new lines
g.nowrap = true -- 不自动换行
g.Autoindent = true
-----------------------------------------------------------
-- Memory, CPU
-----------------------------------------------------------
opt.hidden = true -- Enable background buffers
opt.history = 100 -- Remember N lines in history
opt.lazyredraw = true -- Faster scrolling
opt.synmaxcol = 240 -- Max column for syntax highlight
-----------------------------------------------------------
-- Autocommands
-----------------------------------------------------------
-- Remove whitespace on save
-- cmd [[au BufWritePre * :%s/\s\+$//e]]
-- Don't auto commenting new lines
cmd [[au BufEnter * set fo-=c fo-=r fo-=o]]
-- Remove line lenght marker for selected filetypes
-- cmd [[autocmd FileType text,markdown,html,xhtml,javascript setlocal cc=0]]
-- 2 spaces for selected filetypes
-- cmd [[
-- autocmd FileType xml,html,xhtml,css,scss,javascript,lua,yaml setlocal shiftwidth=2 tabstop=2
-- ]]
-- automatically close the tab/vim when nvim-tree is the last window in the tabs
cmd [[autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif]]
-- specify file type
cmd [[autocmd BufNewFile,BufRead *.defs set filetype=make]]
-----------------------------------------------------------
-- Terminal
-----------------------------------------------------------
-- Open a terminal pane on the right using :Term
cmd [[command Term :botright vsplit term://$SHELL]]
-- Terminal visual tweaks:
--- enter insert mode when switching to terminal
--- close terminal buffer on process exit
cmd [[
autocmd TermOpen * setlocal listchars= nonumber norelativenumber nocursorline
autocmd TermOpen * startinsert
autocmd BufLeave term://* stopinsert
]]
-----------------------------------------------------------
-- Startup
-----------------------------------------------------------
-- Disable nvim intro
opt.shortmess:append "sI"
-- Disable builtins plugins
local disabled_built_ins = {
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"gzip",
"zip",
"zipPlugin",
"tar",
"tarPlugin",
"getscript",
"getscriptPlugin",
"vimball",
"vimballPlugin",
"2html_plugin",
"logipat",
"rrhelper",
"spellfile_plugin",
"matchit"
}
for _, plugin in pairs(disabled_built_ins) do
g["loaded_" .. plugin] = 1
end