update
This commit is contained in:
parent
e6d0b2d1f6
commit
e8e3fa6a3d
62
lua/G.lua
62
lua/G.lua
@ -1,55 +1,55 @@
|
||||
local G = {}
|
||||
|
||||
G.g = vim.g
|
||||
G.b = vim.b
|
||||
G.o = vim.o
|
||||
G.fn = vim.fn
|
||||
G.api = vim.api
|
||||
G.opt = vim.opt
|
||||
G.loop = vim.loop
|
||||
G.lb = vim.lsp.buf
|
||||
G.dic = vim.diagnostic
|
||||
G.cgp = vim.nvim_create_augroup
|
||||
G.g = vim.g
|
||||
G.b = vim.b
|
||||
G.o = vim.o
|
||||
G.fn = vim.fn
|
||||
G.api = vim.api
|
||||
G.opt = vim.opt
|
||||
G.loop = vim.loop
|
||||
G.lb = vim.lsp.buf
|
||||
G.dic = vim.diagnostic
|
||||
G.cgp = vim.nvim_create_augroup
|
||||
|
||||
function G.map(maps)
|
||||
for _,map in pairs(maps) do
|
||||
if #map == 3 then
|
||||
vim.keymap.set(map[1], map[2], map[3], {noremap = true})
|
||||
elseif #map == 4 then
|
||||
vim.keymap.set(map[1], map[2], map[3], map[4])
|
||||
else
|
||||
print("太多变量了")
|
||||
end
|
||||
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
|
||||
for _, map in pairs(maps) do
|
||||
if #map == 3 then
|
||||
vim.keymap.set(map[1], map[2], map[3], { noremap = true })
|
||||
elseif #map == 4 then
|
||||
vim.keymap.set(map[1], map[2], map[3], map[4])
|
||||
else
|
||||
print("太多变量了")
|
||||
end
|
||||
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
|
||||
end
|
||||
end
|
||||
|
||||
function G.delmap(maps)
|
||||
for _,map in pairs(maps) do
|
||||
if #map == 2 then
|
||||
vim.keymap.del(map[1], map[2], {})
|
||||
elseif #map == 3 then
|
||||
vim.keymap.del(map[1], map[2], map[3])
|
||||
else
|
||||
print("太多变量了")
|
||||
end
|
||||
for _, map in pairs(maps) do
|
||||
if #map == 2 then
|
||||
vim.keymap.del(map[1], map[2], {})
|
||||
elseif #map == 3 then
|
||||
vim.keymap.del(map[1], map[2], map[3])
|
||||
else
|
||||
print("太多变量了")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function G.cmd(cmd)
|
||||
G.api.nvim_command(cmd)
|
||||
G.api.nvim_command(cmd)
|
||||
end
|
||||
|
||||
function G.exec(c)
|
||||
G.api.nvim_exec(c)
|
||||
G.api.nvim_exec(c)
|
||||
end
|
||||
|
||||
function G.eval(c)
|
||||
return G.api.nvim_eval(c)
|
||||
return G.api.nvim_eval(c)
|
||||
end
|
||||
|
||||
function G.au(even, opts)
|
||||
return G.api.nvim_create_autocmd(even, opts)
|
||||
return G.api.nvim_create_autocmd(even, opts)
|
||||
end
|
||||
|
||||
G.g.mapleader = ' '
|
||||
|
@ -1,45 +1,44 @@
|
||||
local opt = {noremap = true}
|
||||
local opt = { noremap = true }
|
||||
|
||||
-- base
|
||||
G.map({
|
||||
{'n', '<leader>nh', ':nohlsearch<CR>', opt},
|
||||
{'n', '<leader>rp', ':%s/',opt},
|
||||
{ 'n', '<leader>nh', ':nohlsearch<CR>', opt },
|
||||
{ 'n', '<leader>rp', ':%s/', opt },
|
||||
|
||||
{'v', 'L', '$', opt},
|
||||
{'v', 'H', '^', opt},
|
||||
{'n', 'L', '$', opt},
|
||||
{'n', 'H', '^', opt},
|
||||
{'v', '>', '>gv', opt},
|
||||
{'v', '<', '<gv', opt},
|
||||
{ 'v', 'L', '$', opt },
|
||||
{ 'v', 'H', '^', opt },
|
||||
{ 'n', 'L', '$', opt },
|
||||
{ 'n', 'H', '^', opt },
|
||||
{ 'v', '>', '>gv', opt },
|
||||
{ 'v', '<', '<gv', opt },
|
||||
|
||||
{'n', '>', '>>', opt},
|
||||
{'n', '<', '<<', opt},
|
||||
{'n', '?', ':set hlsearch<CR>?', opt},
|
||||
{'n', '/', ':set hlsearch<CR>/', opt},
|
||||
{ 'n', '>', '>>', opt },
|
||||
{ 'n', '<', '<<', opt },
|
||||
{ 'n', '?', ':set hlsearch<CR>?', opt },
|
||||
{ 'n', '/', ':set hlsearch<CR>/', opt },
|
||||
|
||||
{'n', '<A-l>', ':tabn<CR>', opt},
|
||||
{'n', '<A-h>', ':tabp<CR>', opt},
|
||||
{ 'n', '<A-l>', ':tabn<CR>', opt },
|
||||
{ 'n', '<A-h>', ':tabp<CR>', opt },
|
||||
|
||||
|
||||
{'n', '<c-j>', '<c-w>j', opt},
|
||||
{'n', '<c-h>', '<c-w>h', opt},
|
||||
{'n', '<c-k>', '<c-w>k', opt},
|
||||
{'n', '<c-l>', '<c-w>l', opt},
|
||||
{ 'n', '<c-j>', '<c-w>j', opt },
|
||||
{ 'n', '<c-h>', '<c-w>h', opt },
|
||||
{ 'n', '<c-k>', '<c-w>k', opt },
|
||||
{ 'n', '<c-l>', '<c-w>l', opt },
|
||||
|
||||
|
||||
{'n', '<c-c>', ':q<CR>', opt},
|
||||
{'n', '<c-S>', ':w !sudo tee %<CR>', opt},
|
||||
{'n', '<c-q>', ':q!<CR>', opt},
|
||||
{ 'n', '<c-c>', ':q<CR>', opt },
|
||||
{ 'n', '<c-S>', ':w !sudo tee %<CR>', opt },
|
||||
{ 'n', '<c-q>', ':q!<CR>', opt },
|
||||
|
||||
|
||||
{'n', '<leader>y', 'ggyG', opt},
|
||||
{'n', '<leader>p', 'ggpG', opt},
|
||||
{'n', '<leader>v', 'ggVG', opt},
|
||||
{ 'n', '<leader>y', 'ggyG', opt },
|
||||
{ 'n', '<leader>p', 'ggpG', opt },
|
||||
{ 'n', '<leader>v', 'ggVG', opt },
|
||||
|
||||
{'n', '<up>', ':res -5<CR>', opt},
|
||||
{'n', '<down>', ':res +5<CR>', opt},
|
||||
{'n', '<left>', ':vertical resize -5<CR>', opt},
|
||||
{'n', '<right>', ':vertical resize +5<CR>', opt},
|
||||
{ 'n', '<up>', ':res -5<CR>', opt },
|
||||
{ 'n', '<down>', ':res +5<CR>', opt },
|
||||
{ 'n', '<left>', ':vertical resize -5<CR>', opt },
|
||||
{ 'n', '<right>', ':vertical resize +5<CR>', opt },
|
||||
|
||||
})
|
||||
|
||||
|
@ -1,38 +1,38 @@
|
||||
--
|
||||
G.opt.ttimeout = true
|
||||
G.opt.ttimeoutlen = 100
|
||||
G.opt.ttimeout = true
|
||||
G.opt.ttimeoutlen = 100
|
||||
|
||||
-- 行号
|
||||
G.opt.nu = true
|
||||
G.opt.rnu = true
|
||||
G.opt.scrolloff = 999
|
||||
G.opt.nu = true
|
||||
G.opt.rnu = true
|
||||
G.opt.scrolloff = 999
|
||||
|
||||
-- 自动保存
|
||||
G.opt.autowrite = true
|
||||
G.opt.autowriteall = true
|
||||
G.opt.autowrite = true
|
||||
G.opt.autowriteall = true
|
||||
|
||||
-- tab键
|
||||
G.opt.sw = 2
|
||||
G.opt.ts = 2
|
||||
G.opt.softtabstop = 2
|
||||
G.opt.smarttab = true
|
||||
G.opt.expandtab = true
|
||||
G.opt.autoindent = true
|
||||
G.opt.sw = 2
|
||||
G.opt.ts = 2
|
||||
G.opt.softtabstop = 2
|
||||
G.opt.smarttab = true
|
||||
G.opt.expandtab = true
|
||||
G.opt.autoindent = true
|
||||
|
||||
-- 光标
|
||||
G.opt.cursorline = true
|
||||
G.opt.cursorline = true
|
||||
|
||||
-- 分屏
|
||||
G.opt.splitright = true
|
||||
G.opt.splitbelow = true
|
||||
G.opt.splitright = true
|
||||
G.opt.splitbelow = true
|
||||
|
||||
-- 搜索
|
||||
G.opt.ignorecase = true
|
||||
G.opt.incsearch = true
|
||||
G.opt.ignorecase = true
|
||||
G.opt.incsearch = true
|
||||
|
||||
-- 不换行
|
||||
G.opt.textwidth = 999
|
||||
G.opt.wrap = false
|
||||
G.opt.textwidth = 999
|
||||
G.opt.wrap = false
|
||||
|
||||
|
||||
-- 文件判断
|
||||
@ -40,27 +40,27 @@ G.cmd("filetype plugin indent on")
|
||||
|
||||
-- 取消换行注释
|
||||
G.au({ "BufEnter" }, {
|
||||
pattern = { "*" },
|
||||
callback = function()
|
||||
-- vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" }
|
||||
G.opt.formatoptions = G.opt.formatoptions
|
||||
- "o" -- O and o, don't continue comments
|
||||
+ "r" -- But do continue when pressing enter.
|
||||
end,
|
||||
pattern = { "*" },
|
||||
callback = function()
|
||||
-- vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" }
|
||||
G.opt.formatoptions = G.opt.formatoptions
|
||||
- "o" -- O and o, don't continue comments
|
||||
+ "r" -- But do continue when pressing enter.
|
||||
end,
|
||||
})
|
||||
|
||||
G.au({ "InsertEnter" }, {
|
||||
pattern = { "*" },
|
||||
callback = function()
|
||||
pattern = { "*" },
|
||||
callback = function()
|
||||
G.opt.hlsearch = false
|
||||
end,
|
||||
end,
|
||||
})
|
||||
|
||||
G.au({ "VimEnter" }, {
|
||||
pattern = { "*.code-snippets" },
|
||||
callback = function()
|
||||
pattern = { "*.code-snippets" },
|
||||
callback = function()
|
||||
G.cmd("setfiletype json")
|
||||
end,
|
||||
end,
|
||||
})
|
||||
|
||||
-- G.au({
|
||||
@ -69,6 +69,3 @@ G.au({ "VimEnter" }, {
|
||||
-- if index
|
||||
-- }
|
||||
-- })
|
||||
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ return {
|
||||
build = ":TSUpdate html",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"nvim-lua/plenary.nvim", -- telescope 所需
|
||||
"nvim-lua/plenary.nvim", -- telescope 所需
|
||||
"MunifTanjim/nui.nvim",
|
||||
|
||||
-- 可选
|
||||
|
@ -2,49 +2,49 @@ return {
|
||||
"phaazon/hop.nvim",
|
||||
branch = "v2",
|
||||
keys = {
|
||||
"f","F","t","T",
|
||||
"f", "F", "t", "T",
|
||||
"<c-f>"
|
||||
},
|
||||
lazy = true,
|
||||
config = function ()
|
||||
require("hop").setup{keys = 'asdfghjkl;'}
|
||||
config = function()
|
||||
require("hop").setup { keys = 'asdfghjkl;' }
|
||||
local hop = require('hop')
|
||||
local directions = require('hop.hint').HintDirection
|
||||
G.map({
|
||||
{"n", "<c-f>", ":HopChar2MW<CR>", {noremap = true}},
|
||||
{"n", "f",
|
||||
function ()
|
||||
{ "n", "<c-f>", ":HopChar2MW<CR>", { noremap = true } },
|
||||
{ "n", "f",
|
||||
function()
|
||||
hop.hint_char1({
|
||||
direction = directions.AFTER_CURSOR,
|
||||
current_line_only = true
|
||||
})
|
||||
end, {noremap = true}
|
||||
end, { noremap = true }
|
||||
},
|
||||
{"n", "F",
|
||||
function ()
|
||||
{ "n", "F",
|
||||
function()
|
||||
hop.hint_char1({
|
||||
direction = directions.BEFORE_CURSOR,
|
||||
current_line_only = true
|
||||
})
|
||||
end, {noremap = true}
|
||||
end, { noremap = true }
|
||||
},
|
||||
{"n", "t",
|
||||
function ()
|
||||
{ "n", "t",
|
||||
function()
|
||||
hop.hint_char1({
|
||||
direction = directions.AFTER_CURSOR,
|
||||
current_line_only = true,
|
||||
hint_offset = -1
|
||||
})
|
||||
end, {noremap = true}
|
||||
end, { noremap = true }
|
||||
},
|
||||
{"n", "T",
|
||||
function ()
|
||||
{ "n", "T",
|
||||
function()
|
||||
hop.hint_char1({
|
||||
direction = directions.BEFORE_CURSOR,
|
||||
current_line_only = true,
|
||||
hint_offset = -1
|
||||
})
|
||||
end, {noremap = true}
|
||||
end, { noremap = true }
|
||||
},
|
||||
})
|
||||
end
|
||||
|
@ -7,8 +7,7 @@ return {
|
||||
"<c-e>"
|
||||
},
|
||||
config = function()
|
||||
|
||||
require 'nvim-web-devicons'.setup{}
|
||||
require 'nvim-web-devicons'.setup {}
|
||||
|
||||
require 'nvim-tree'.setup {
|
||||
sort_by = "case_sensitive",
|
||||
|
@ -1,83 +1,82 @@
|
||||
return {
|
||||
{
|
||||
'folke/tokyonight.nvim',
|
||||
config = function ()
|
||||
config = function()
|
||||
G.cmd("colorscheme tokyonight") -- 主题
|
||||
G.opt.background = 'dark' -- 背景
|
||||
G.opt.background = 'dark' -- 背景
|
||||
end
|
||||
},
|
||||
{
|
||||
-- line插件
|
||||
'kdheepak/tabline.nvim',
|
||||
'nvim-lualine/lualine.nvim',
|
||||
config = function()
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = { left = '', right = ''},
|
||||
section_separators = { left = '', right = ''},
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
config = function()
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = '' },
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {{
|
||||
'filename',
|
||||
file_status = false,
|
||||
path = 1
|
||||
}},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress'},
|
||||
lualine_z = {}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
}
|
||||
require('tabline').setup {
|
||||
-- Defaults configuration options
|
||||
enable = true,
|
||||
options = {
|
||||
-- If lualine is installed tabline will use separators configured in lualine by default.
|
||||
-- These options can be used to override those settings.
|
||||
section_separators = {' ', ' '},
|
||||
component_separators = {'', ''},
|
||||
max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3
|
||||
show_tabs_always = false, -- this shows tabs only when there are more than one tab or if the first tab is named
|
||||
show_devicons = true, -- this shows devicons in buffer section
|
||||
show_bufnr = false, -- this appends [bufnr] to buffer section,
|
||||
show_filename_only = true, -- shows base filename only instead of relative path in filename
|
||||
modified_icon = "+ ", -- change the default modified icon
|
||||
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified
|
||||
show_tabs_only = false, -- this shows only tabs instead of tabs + buffers
|
||||
},
|
||||
G.cmd[[
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = { {
|
||||
'filename',
|
||||
file_status = false,
|
||||
path = 1
|
||||
} },
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_y = { 'progress' },
|
||||
lualine_z = {}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {}
|
||||
}
|
||||
require('tabline').setup {
|
||||
-- Defaults configuration options
|
||||
enable = true,
|
||||
options = {
|
||||
-- If lualine is installed tabline will use separators configured in lualine by default.
|
||||
-- These options can be used to override those settings.
|
||||
section_separators = { ' ', ' ' },
|
||||
component_separators = { '', '' },
|
||||
max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3
|
||||
show_tabs_always = false, -- this shows tabs only when there are more than one tab or if the first tab is named
|
||||
show_devicons = true, -- this shows devicons in buffer section
|
||||
show_bufnr = false, -- this appends [bufnr] to buffer section,
|
||||
show_filename_only = true, -- shows base filename only instead of relative path in filename
|
||||
modified_icon = "+ ", -- change the default modified icon
|
||||
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified
|
||||
show_tabs_only = false, -- this shows only tabs instead of tabs + buffers
|
||||
},
|
||||
G.cmd [[
|
||||
set guioptions-=e " Use showtabline in gui vim
|
||||
set sessionoptions+=tabpages,globals " store tabpages and globals in session
|
||||
]]
|
||||
}
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
return {
|
||||
-- amongst your other plugins
|
||||
{ 'akinsho/toggleterm.nvim',
|
||||
{
|
||||
'akinsho/toggleterm.nvim',
|
||||
version = "*",
|
||||
config = function ()
|
||||
require("toggleterm").setup{
|
||||
config = function()
|
||||
require("toggleterm").setup {
|
||||
-- size can be a number or function which is passed the current terminal
|
||||
size = 10,
|
||||
open_mapping = [[<c-t>]],
|
||||
hide_numbers = true, -- hide the number column in toggleterm buffers
|
||||
shade_filetypes = {},
|
||||
shade_terminals = true,
|
||||
shading_factor = 1, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
|
||||
shading_factor = 1, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
|
||||
start_in_insert = true,
|
||||
insert_mappings = true, -- whether or not the open mapping applies in insert mode
|
||||
persist_size = true,
|
||||
direction = 'horizontal',
|
||||
}
|
||||
|
||||
end
|
||||
},
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require'lazy'.setup({
|
||||
require 'lazy'.setup({
|
||||
|
||||
require("plugs.hop"),
|
||||
require('plugs.edit-plugs'),
|
||||
|
26
snippets/c.json
Normal file
26
snippets/c.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"for": {
|
||||
"prefix": "for",
|
||||
"body": [
|
||||
" for(int $1 = $2; $1 < $3; $1+=$4) {",
|
||||
" $5",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
"for1": {
|
||||
"prefix": "for1",
|
||||
"body": [
|
||||
" for(int $1 = $2; $1 < $3; $1++) {",
|
||||
" $4",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
"fori": {
|
||||
"prefix": "fori",
|
||||
"body": [
|
||||
" for(int i = $1; i < $2; i++) {",
|
||||
" $3",
|
||||
" }"
|
||||
]
|
||||
}
|
||||
}
|
13
snippets/json.json
Normal file
13
snippets/json.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"mod": {
|
||||
"prefix": "mod",
|
||||
"body": [
|
||||
" \"$1\": {",
|
||||
" \"prefix\": \"$1\",",
|
||||
" \"body\": [",
|
||||
" $2",
|
||||
" ]",
|
||||
" }"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,32 +1,3 @@
|
||||
{
|
||||
"Class_Array_tree": {
|
||||
"prefix": "Class_Array_tree",
|
||||
"body": [
|
||||
"",
|
||||
"template <class T>",
|
||||
"class Array_tree {",
|
||||
" public:",
|
||||
" Array_tree() {}",
|
||||
" Array_tree(int n) { this->n = n, tree = vector<T>(n + 1); }",
|
||||
" void add(int id, T key) {",
|
||||
" for (int i = id; i <= n; i += lowbit(i)) tree[i] += key;",
|
||||
" }",
|
||||
"",
|
||||
" T get_sum(int id) {",
|
||||
" T sum = 0;",
|
||||
" for (int i = id; i; i -= lowbit(i)) sum += tree[i];",
|
||||
" return sum;",
|
||||
" }",
|
||||
"",
|
||||
" T get_sum(int l, int r) { return get_sum(r) - get_sum(l - 1); }",
|
||||
"",
|
||||
" private:",
|
||||
" int n;",
|
||||
" vector<T> tree;",
|
||||
" int lowbit(int x) { return x & -x; }",
|
||||
"};",
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user