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

View File

@ -1,45 +1,44 @@
local opt = {noremap = true} local opt = { noremap = true }
-- base -- base
G.map({ G.map({
{'n', '<leader>nh', ':nohlsearch<CR>', opt}, { 'n', '<leader>nh', ':nohlsearch<CR>', opt },
{'n', '<leader>rp', ':%s/',opt}, { 'n', '<leader>rp', ':%s/', opt },
{'v', 'L', '$', opt}, { 'v', 'L', '$', opt },
{'v', 'H', '^', opt}, { 'v', 'H', '^', opt },
{'n', 'L', '$', opt}, { 'n', 'L', '$', opt },
{'n', 'H', '^', opt}, { 'n', 'H', '^', opt },
{'v', '>', '>gv', opt}, { 'v', '>', '>gv', opt },
{'v', '<', '<gv', opt}, { 'v', '<', '<gv', opt },
{'n', '>', '>>', opt}, { 'n', '>', '>>', opt },
{'n', '<', '<<', opt}, { 'n', '<', '<<', opt },
{'n', '?', ':set hlsearch<CR>?', opt}, { 'n', '?', ':set hlsearch<CR>?', opt },
{'n', '/', ':set hlsearch<CR>/', opt}, { 'n', '/', ':set hlsearch<CR>/', opt },
{'n', '<A-l>', ':tabn<CR>', opt}, { 'n', '<A-l>', ':tabn<CR>', opt },
{'n', '<A-h>', ':tabp<CR>', opt}, { 'n', '<A-h>', ':tabp<CR>', opt },
{'n', '<c-j>', '<c-w>j', opt}, { 'n', '<c-j>', '<c-w>j', opt },
{'n', '<c-h>', '<c-w>h', opt}, { 'n', '<c-h>', '<c-w>h', opt },
{'n', '<c-k>', '<c-w>k', opt}, { 'n', '<c-k>', '<c-w>k', opt },
{'n', '<c-l>', '<c-w>l', opt}, { 'n', '<c-l>', '<c-w>l', opt },
{'n', '<c-c>', ':q<CR>', opt}, { 'n', '<c-c>', ':q<CR>', opt },
{'n', '<c-S>', ':w !sudo tee %<CR>', opt}, { 'n', '<c-S>', ':w !sudo tee %<CR>', opt },
{'n', '<c-q>', ':q!<CR>', opt}, { 'n', '<c-q>', ':q!<CR>', opt },
{'n', '<leader>y', 'ggyG', opt}, { 'n', '<leader>y', 'ggyG', opt },
{'n', '<leader>p', 'ggpG', opt}, { 'n', '<leader>p', 'ggpG', opt },
{'n', '<leader>v', 'ggVG', opt}, { 'n', '<leader>v', 'ggVG', opt },
{'n', '<up>', ':res -5<CR>', opt}, { 'n', '<up>', ':res -5<CR>', opt },
{'n', '<down>', ':res +5<CR>', opt}, { 'n', '<down>', ':res +5<CR>', opt },
{'n', '<left>', ':vertical resize -5<CR>', opt}, { 'n', '<left>', ':vertical resize -5<CR>', opt },
{'n', '<right>', ':vertical resize +5<CR>', opt}, { 'n', '<right>', ':vertical resize +5<CR>', opt },
}) })

View File

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

View File

@ -2,49 +2,49 @@ return {
"phaazon/hop.nvim", "phaazon/hop.nvim",
branch = "v2", branch = "v2",
keys = { keys = {
"f","F","t","T", "f", "F", "t", "T",
"<c-f>" "<c-f>"
}, },
lazy = true, lazy = true,
config = function () config = function()
require("hop").setup{keys = 'asdfghjkl;'} require("hop").setup { keys = 'asdfghjkl;' }
local hop = require('hop') local hop = require('hop')
local directions = require('hop.hint').HintDirection local directions = require('hop.hint').HintDirection
G.map({ G.map({
{"n", "<c-f>", ":HopChar2MW<CR>", {noremap = true}}, { "n", "<c-f>", ":HopChar2MW<CR>", { noremap = true } },
{"n", "f", { "n", "f",
function () function()
hop.hint_char1({ hop.hint_char1({
direction = directions.AFTER_CURSOR, direction = directions.AFTER_CURSOR,
current_line_only = true current_line_only = true
}) })
end, {noremap = true} end, { noremap = true }
}, },
{"n", "F", { "n", "F",
function () function()
hop.hint_char1({ hop.hint_char1({
direction = directions.BEFORE_CURSOR, direction = directions.BEFORE_CURSOR,
current_line_only = true current_line_only = true
}) })
end, {noremap = true} end, { noremap = true }
}, },
{"n", "t", { "n", "t",
function () function()
hop.hint_char1({ hop.hint_char1({
direction = directions.AFTER_CURSOR, direction = directions.AFTER_CURSOR,
current_line_only = true, current_line_only = true,
hint_offset = -1 hint_offset = -1
}) })
end, {noremap = true} end, { noremap = true }
}, },
{"n", "T", { "n", "T",
function () function()
hop.hint_char1({ hop.hint_char1({
direction = directions.BEFORE_CURSOR, direction = directions.BEFORE_CURSOR,
current_line_only = true, current_line_only = true,
hint_offset = -1 hint_offset = -1
}) })
end, {noremap = true} end, { noremap = true }
}, },
}) })
end end

View File

@ -7,8 +7,7 @@ return {
"<c-e>" "<c-e>"
}, },
config = function() config = function()
require 'nvim-web-devicons'.setup {}
require 'nvim-web-devicons'.setup{}
require 'nvim-tree'.setup { require 'nvim-tree'.setup {
sort_by = "case_sensitive", sort_by = "case_sensitive",

View File

@ -1,7 +1,7 @@
return { return {
{ {
'folke/tokyonight.nvim', 'folke/tokyonight.nvim',
config = function () config = function()
G.cmd("colorscheme tokyonight") -- 主题 G.cmd("colorscheme tokyonight") -- 主题
G.opt.background = 'dark' -- 背景 G.opt.background = 'dark' -- 背景
end end
@ -15,8 +15,8 @@ return {
options = { options = {
icons_enabled = true, icons_enabled = true,
theme = 'auto', theme = 'auto',
component_separators = { left = '', right = ''}, component_separators = { left = '', right = '' },
section_separators = { left = '', right = ''}, section_separators = { left = '', right = '' },
disabled_filetypes = { disabled_filetypes = {
statusline = {}, statusline = {},
winbar = {}, winbar = {},
@ -31,22 +31,22 @@ return {
} }
}, },
sections = { sections = {
lualine_a = {'mode'}, lualine_a = { 'mode' },
lualine_b = {'branch', 'diff', 'diagnostics'}, lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {{ lualine_c = { {
'filename', 'filename',
file_status = false, file_status = false,
path = 1 path = 1
}}, } },
lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = {'progress'}, lualine_y = { 'progress' },
lualine_z = {} lualine_z = {}
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = {}, lualine_b = {},
lualine_c = {'filename'}, lualine_c = { 'filename' },
lualine_x = {'location'}, lualine_x = { 'location' },
lualine_y = {}, lualine_y = {},
lualine_z = {} lualine_z = {}
}, },
@ -61,8 +61,8 @@ return {
options = { options = {
-- If lualine is installed tabline will use separators configured in lualine by default. -- If lualine is installed tabline will use separators configured in lualine by default.
-- These options can be used to override those settings. -- These options can be used to override those settings.
section_separators = {' ', ' '}, section_separators = { ' ', ' ' },
component_separators = {'', ''}, component_separators = { '', '' },
max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3 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_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_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 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 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 guioptions-=e " Use showtabline in gui vim
set sessionoptions+=tabpages,globals " store tabpages and globals in session set sessionoptions+=tabpages,globals " store tabpages and globals in session
]] ]]
@ -80,4 +80,3 @@ return {
end, end,
}, },
} }

View File

@ -1,9 +1,10 @@
return { return {
-- amongst your other plugins -- amongst your other plugins
{ 'akinsho/toggleterm.nvim', {
'akinsho/toggleterm.nvim',
version = "*", version = "*",
config = function () config = function()
require("toggleterm").setup{ require("toggleterm").setup {
-- size can be a number or function which is passed the current terminal -- size can be a number or function which is passed the current terminal
size = 10, size = 10,
open_mapping = [[<c-t>]], open_mapping = [[<c-t>]],
@ -16,7 +17,6 @@ return {
persist_size = true, persist_size = true,
direction = 'horizontal', direction = 'horizontal',
} }
end end
}, },

View File

@ -1,4 +1,4 @@
require'lazy'.setup({ require 'lazy'.setup({
require("plugs.hop"), require("plugs.hop"),
require('plugs.edit-plugs'), 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; }",
"};",
""
]
}
}
} }