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

@ -1,55 +1,55 @@
local G = {} local G = {}
G.g = vim.g G.g = vim.g
G.b = vim.b G.b = vim.b
G.o = vim.o G.o = vim.o
G.fn = vim.fn G.fn = vim.fn
G.api = vim.api G.api = vim.api
G.opt = vim.opt G.opt = vim.opt
G.loop = vim.loop G.loop = vim.loop
G.lb = vim.lsp.buf G.lb = vim.lsp.buf
G.dic = vim.diagnostic 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
print("太多变量了") print("太多变量了")
end
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
end end
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
end
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
vim.keymap.del(map[1], map[2], map[3]) vim.keymap.del(map[1], map[2], map[3])
else else
print("太多变量了") print("太多变量了")
end
end end
end
end end
function G.cmd(cmd) function G.cmd(cmd)
G.api.nvim_command(cmd) G.api.nvim_command(cmd)
end end
function G.exec(c) function G.exec(c)
G.api.nvim_exec(c) G.api.nvim_exec(c)
end end
function G.eval(c) function G.eval(c)
return G.api.nvim_eval(c) return G.api.nvim_eval(c)
end end
function G.au(even, opts) function G.au(even, opts)
return G.api.nvim_create_autocmd(even, opts) return G.api.nvim_create_autocmd(even, opts)
end end
G.g.mapleader = ' ' G.g.mapleader = ' '

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

@ -1,38 +1,38 @@
-- --
G.opt.ttimeout = true G.opt.ttimeout = true
G.opt.ttimeoutlen = 100 G.opt.ttimeoutlen = 100
-- 行号 -- 行号
G.opt.nu = true G.opt.nu = true
G.opt.rnu = true G.opt.rnu = true
G.opt.scrolloff = 999 G.opt.scrolloff = 999
-- 自动保存 -- 自动保存
G.opt.autowrite = true G.opt.autowrite = true
G.opt.autowriteall = true G.opt.autowriteall = true
-- tab键 -- tab键
G.opt.sw = 2 G.opt.sw = 2
G.opt.ts = 2 G.opt.ts = 2
G.opt.softtabstop = 2 G.opt.softtabstop = 2
G.opt.smarttab = true G.opt.smarttab = true
G.opt.expandtab = true G.opt.expandtab = true
G.opt.autoindent = true G.opt.autoindent = true
-- 光标 -- 光标
G.opt.cursorline = true G.opt.cursorline = true
-- 分屏 -- 分屏
G.opt.splitright = true G.opt.splitright = true
G.opt.splitbelow = true G.opt.splitbelow = true
-- 搜索 -- 搜索
G.opt.ignorecase = true G.opt.ignorecase = true
G.opt.incsearch = true G.opt.incsearch = true
-- 不换行 -- 不换行
G.opt.textwidth = 999 G.opt.textwidth = 999
G.opt.wrap = false G.opt.wrap = false
-- 文件判断 -- 文件判断
@ -40,27 +40,27 @@ G.cmd("filetype plugin indent on")
-- 取消换行注释 -- 取消换行注释
G.au({ "BufEnter" }, { G.au({ "BufEnter" }, {
pattern = { "*" }, pattern = { "*" },
callback = function() callback = function()
-- vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" } -- vim.opt.formatoptions = vim.opt.formatoptions - { "c", "r", "o" }
G.opt.formatoptions = G.opt.formatoptions G.opt.formatoptions = G.opt.formatoptions
- "o" -- O and o, don't continue comments - "o" -- O and o, don't continue comments
+ "r" -- But do continue when pressing enter. + "r" -- But do continue when pressing enter.
end, end,
}) })
G.au({ "InsertEnter" }, { G.au({ "InsertEnter" }, {
pattern = { "*" }, pattern = { "*" },
callback = function() callback = function()
G.opt.hlsearch = false G.opt.hlsearch = false
end, end,
}) })
G.au({ "VimEnter" }, { G.au({ "VimEnter" }, {
pattern = { "*.code-snippets" }, pattern = { "*.code-snippets" },
callback = function() callback = function()
G.cmd("setfiletype json") G.cmd("setfiletype json")
end, end,
}) })
-- G.au({ -- G.au({
@ -69,6 +69,3 @@ G.au({ "VimEnter" }, {
-- if index -- if index
-- } -- }
-- }) -- })

View File

@ -7,7 +7,7 @@ return {
build = ":TSUpdate html", build = ":TSUpdate html",
dependencies = { dependencies = {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim", -- telescope 所需 "nvim-lua/plenary.nvim", -- telescope 所需
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
-- 可选 -- 可选

View File

@ -52,7 +52,7 @@ return {
-- end -- end
-- }, -- },
{ {
-- hop -- hop
require("plugs.hop") require("plugs.hop")
} }
} }

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,83 +1,82 @@
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
}, },
{ {
-- line插件 -- line插件
'kdheepak/tabline.nvim', 'kdheepak/tabline.nvim',
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
config = function() config = function()
require('lualine').setup { require('lualine').setup {
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 = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
}, },
sections = { ignore_focus = {},
lualine_a = {'mode'}, always_divide_middle = true,
lualine_b = {'branch', 'diff', 'diagnostics'}, globalstatus = false,
lualine_c = {{ refresh = {
'filename', statusline = 1000,
file_status = false, tabline = 1000,
path = 1 winbar = 1000,
}}, }
lualine_x = {'encoding', 'fileformat', 'filetype'}, },
lualine_y = {'progress'}, sections = {
lualine_z = {} lualine_a = { 'mode' },
}, lualine_b = { 'branch', 'diff', 'diagnostics' },
inactive_sections = { lualine_c = { {
lualine_a = {}, 'filename',
lualine_b = {}, file_status = false,
lualine_c = {'filename'}, path = 1
lualine_x = {'location'}, } },
lualine_y = {}, lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_z = {} lualine_y = { 'progress' },
}, lualine_z = {}
tabline = {}, },
winbar = {}, inactive_sections = {
inactive_winbar = {}, lualine_a = {},
extensions = {} lualine_b = {},
} lualine_c = { 'filename' },
require('tabline').setup { lualine_x = { 'location' },
-- Defaults configuration options lualine_y = {},
enable = true, lualine_z = {}
options = { },
-- If lualine is installed tabline will use separators configured in lualine by default. tabline = {},
-- These options can be used to override those settings. winbar = {},
section_separators = {' ', ' '}, inactive_winbar = {},
component_separators = {'', ''}, extensions = {}
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 require('tabline').setup {
show_devicons = true, -- this shows devicons in buffer section -- Defaults configuration options
show_bufnr = false, -- this appends [bufnr] to buffer section, enable = true,
show_filename_only = true, -- shows base filename only instead of relative path in filename options = {
modified_icon = "+ ", -- change the default modified icon -- If lualine is installed tabline will use separators configured in lualine by default.
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified -- These options can be used to override those settings.
show_tabs_only = false, -- this shows only tabs instead of tabs + buffers section_separators = { ' ', ' ' },
}, component_separators = { '', '' },
G.cmd[[ 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 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
]] ]]
} }
end, end,
}, },
} }

View File

@ -1,22 +1,22 @@
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>]],
hide_numbers = true, -- hide the number column in toggleterm buffers hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {}, shade_filetypes = {},
shade_terminals = true, 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, start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode insert_mappings = true, -- whether or not the open mapping applies in insert mode
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; }",
"};",
""
]
}
}
} }