This commit is contained in:
newbie 2024-01-16 20:16:19 +08:00
parent e6d0b2d1f6
commit e8e3fa6a3d
13 changed files with 223 additions and 219 deletions

View File

@ -12,9 +12,9 @@ G.dic = vim.diagnostic
G.cgp = vim.nvim_create_augroup
function G.map(maps)
for _,map in pairs(maps) do
for _, map in pairs(maps) do
if #map == 3 then
vim.keymap.set(map[1], map[2], map[3], {noremap = true})
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
@ -25,7 +25,7 @@ function G.map(maps)
end
function G.delmap(maps)
for _,map in pairs(maps) do
for _, map in pairs(maps) do
if #map == 2 then
vim.keymap.del(map[1], map[2], {})
elseif #map == 3 then

View File

@ -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 },
})

View File

@ -69,6 +69,3 @@ G.au({ "VimEnter" }, {
-- if index
-- }
-- })

View File

@ -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

View File

@ -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",

View File

@ -1,7 +1,7 @@
return {
{
'folke/tokyonight.nvim',
config = function ()
config = function()
G.cmd("colorscheme tokyonight") -- 主题
G.opt.background = 'dark' -- 背景
end
@ -15,8 +15,8 @@ return {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
@ -31,22 +31,22 @@ return {
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {{
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_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = {}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
@ -61,8 +61,8 @@ return {
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 = {'', ''},
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
@ -72,7 +72,7 @@ return {
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[[
G.cmd [[
set guioptions-=e " Use showtabline in gui vim
set sessionoptions+=tabpages,globals " store tabpages and globals in session
]]
@ -80,4 +80,3 @@ return {
end,
},
}

View File

@ -1,9 +1,10 @@
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>]],
@ -16,7 +17,6 @@ return {
persist_size = true,
direction = 'horizontal',
}
end
},

View File

@ -1,4 +1,4 @@
require'lazy'.setup({
require 'lazy'.setup({
require("plugs.hop"),
require('plugs.edit-plugs'),

26
snippets/c.json Normal file
View 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
View File

@ -0,0 +1,13 @@
{
"mod": {
"prefix": "mod",
"body": [
" \"$1\": {",
" \"prefix\": \"$1\",",
" \"body\": [",
" $2",
" ]",
" }"
]
}
}

View File

@ -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; }",
"};",
""
]
}
}
}