-
Notifications
You must be signed in to change notification settings - Fork 0
/
vscode_init.lua
127 lines (113 loc) · 3.69 KB
/
vscode_init.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
vim.g.mapleader = " " -- 设置leader键
vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
local map = vim.keymap.set -- 设置键盘映射
--设置 lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- local lazy_config = require "configs.lazy"
-- 在这里继续添加其他插件和配置
require("lazy").setup({
-- Tree-sitter
{
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", -- 运行 TS 更新
config = function()
require("nvim-treesitter.configs").setup {
ensure_installed = { "c", "lua", "python", "javascript", "html", "css", "cpp" }, -- 你需要的语言
highlight = {
enable = true, -- 开启高亮
additional_vim_regex_highlighting = false, -- 关闭额外的 regex 高亮
},
-- 添加其他 Tree-sitter 配置...
}
end,
},
-- surround
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
},
-- telescope
{
'nvim-telescope/telescope.nvim',
tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' },
},
-- flash
{
"folke/flash.nvim",
-- event = "VeryLazy",
opts = {},
},
-- {
-- "rainzm/flash-zh.nvim",
-- event = "VeryLazy",
-- dependencies = "folke/flash.nvim",
-- keys = {{
-- "s",
-- mode = {"n", "x", "o"},
-- function()
-- require("flash-zh").jump({
-- chinese_only = false
-- })
-- end,
-- desc = "Flash between Chinese"
-- }}
-- },
--
})
--- neovim-ui
-- vim.cmd([[
-- " THEME CHANGER
-- function! SetCursorLineNrColorInsert(mode)
-- " Insert mode: blue
-- if a:mode == "i"
-- call VSCodeNotify('nvim-theme.insert')
--
-- " Replace mode: red
-- elseif a:mode == "r"
-- call VSCodeNotify('nvim-theme.replace')
-- endif
-- endfunction
--
-- augroup CursorLineNrColorSwap
-- autocmd!
-- autocmd ModeChanged *:[vV\x16]* call VSCodeNotify('nvim-theme.visual')
-- autocmd ModeChanged *:[R]* call VSCodeNotify('nvim-theme.replace')
-- autocmd InsertEnter * call SetCursorLineNrColorInsert(v:insertmode)
-- autocmd InsertLeave * call VSCodeNotify('nvim-theme.normal')
-- autocmd CursorHold * call VSCodeNotify('nvim-theme.normal')
-- autocmd ModeChanged [vV\x16]*:* call VSCodeNotify('nvim-theme.normal')
-- augroup END
-- ]], false)
--设置系统剪切板和 neovim 剪切板同步
vim.opt.clipboard = "unnamedplus"
local code = require('vscode')
-- 键盘映射
-- flash
map({ "n", "x", "o" }, "s", "<CMD>lua require('flash').jump() <CR>", { desc = "Flash" })
map({ "n", "x", "o" }, "S", "<CMD>lua require('flash').treesitter() <CR>", { desc = "Flash Treesitter" })
--移动
map({ "n", "v" }, "J", "<C-d>")
map({ "n", "v" }, "K", "<C-u>")
map({ "n" }, "L", "$")
map({ "n" }, "H", "^")