mirror of
https://github.com/cap153/nvim.git
synced 2025-12-27 03:34:57 +08:00
first commit
This commit is contained in:
commit
6955e90e07
61 changed files with 3641 additions and 0 deletions
203
lua/lazy/plugins/autocomplete.lua
Normal file
203
lua/lazy/plugins/autocomplete.lua
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
local M = {}
|
||||
|
||||
M.config = {
|
||||
-- 使用nvim-cmp
|
||||
'hrsh7th/nvim-cmp',
|
||||
after = "SirVer/ultisnips",
|
||||
dependencies = {
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ 'hrsh7th/cmp-buffer' }, -- 缓冲区字符
|
||||
{ 'hrsh7th/cmp-path' }, -- 补全路径
|
||||
{ 'hrsh7th/cmp-cmdline' },
|
||||
{
|
||||
"onsails/lspkind.nvim", -- 补全的图标
|
||||
lazy = false,
|
||||
config = function()
|
||||
require("lspkind").init()
|
||||
end
|
||||
},
|
||||
-- 代码片段来源
|
||||
{ 'SirVer/ultisnips', dependencies = { "honza/vim-snippets" }, },
|
||||
{ 'quangnguyen30192/cmp-nvim-ultisnips' },
|
||||
},
|
||||
|
||||
-- 使用coq_nvim补全
|
||||
-- 自动启动默认情况下无法运行,索性懒加载,或者见lazy.nvim中的init
|
||||
-- { 'ms-jpq/coq_nvim', build = 'python3 -m coq deps', lazy = true },
|
||||
-- { 'ms-jpq/coq.artifacts' },
|
||||
-- { 'ms-jpq/coq.thirdparty' },
|
||||
|
||||
config = function()
|
||||
-- Set up nvim-cmp.
|
||||
local cmp = require 'cmp'
|
||||
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
-- 目录nvim/snippets/*: snippets using snipMate format
|
||||
-- 目录nvim/UltiSnips/*: snippets using UltiSnips format
|
||||
expand = function(args)
|
||||
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end,
|
||||
},
|
||||
-- 和cw补全同一种风格样式
|
||||
window = {
|
||||
completion = {
|
||||
-- winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
||||
col_offset = -3,
|
||||
side_padding = 0,
|
||||
},
|
||||
},
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||
kind.kind = " " .. (strings[1] or "") .. " "
|
||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||
|
||||
return kind
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- 召唤代码补全
|
||||
['<c-o>'] = cmp.mapping.complete(),
|
||||
['<c-space>'] = cmp.mapping.complete(),
|
||||
-- 代码片段下一处位置
|
||||
["<c-e>"] = cmp.mapping(
|
||||
function()
|
||||
cmp_ultisnips_mappings.compose { "expand", "jump_forwards" } (function() end)
|
||||
end,
|
||||
{ "i", "s", --[[ "c" (to enable the mapping in command mode) ]] }
|
||||
),
|
||||
-- 代码片段上一处位置
|
||||
["<c-n>"] = cmp.mapping(
|
||||
function(fallback)
|
||||
cmp_ultisnips_mappings.jump_backwards(fallback)
|
||||
end,
|
||||
{ "i", "s", --[[ "c" (to enable the mapping in command mode) ]] }
|
||||
),
|
||||
-- 关闭代码补全,和telescope冲突
|
||||
['<c-f>'] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
cmp.close()
|
||||
fallback()
|
||||
end
|
||||
}),
|
||||
['<c-y>'] = cmp.mapping({ i = function(fallback) fallback() end }),
|
||||
-- cw的回车配置不会默认补全第一个,在:输入命令的时候比较合适
|
||||
-- ['<CR>'] = cmp.mapping({
|
||||
-- i = function(fallback)
|
||||
-- if cmp.visible() and cmp.get_active_entry() then
|
||||
-- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end
|
||||
-- }),
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||
c = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
cmp_ultisnips_mappings.compose { "jump_forwards" } (function() end) -- 添加跳转代码片段下一处的功能
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
}),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }, -- 本地路径补全
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'ultisnips' }, -- For ultisnips users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- 实现查找单词时根据上下文的补全,要输入多次回车,不太实用
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
-- cmp.setup.cmdline({ '/', '?' }, {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = {
|
||||
-- { name = 'buffer' }
|
||||
-- }
|
||||
-- })
|
||||
|
||||
-- cmdline模式下的补全,可以自动纠正大小写
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
-- ===
|
||||
-- === 自动补全coq,更改跳转代码片段快捷键,和idea一样,可以使用ctrl+space召唤补全窗口
|
||||
-- ===
|
||||
-- 代码补全自定义片段放在~/.config/nvim/coq-user-snippets目录下面,格式和snipMate一致除了后缀名是snip结尾
|
||||
-- local lspconfig = require('lspconfig')
|
||||
-- vim.g.coq_settings = {
|
||||
-- auto_start = 'shut-up',
|
||||
-- keymap = {
|
||||
-- jump_to_mark = '<c-e>', -- 跳转至代码片段的下一个占位
|
||||
-- pre_select = true -- 当有补全时预先选择第一个
|
||||
-- }
|
||||
-- }
|
||||
-- -- Enable some language servers with the additional completion capabilities offered by coq_nvim
|
||||
-- -- 具体查看https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
-- local servers = {
|
||||
-- -- 'lua_ls',
|
||||
-- -- 'marksman',
|
||||
-- 'dartls',
|
||||
-- 'pyright',
|
||||
-- 'clangd',
|
||||
-- 'gopls',
|
||||
-- }
|
||||
-- for _, lsp in ipairs(servers) do
|
||||
-- lspconfig[lsp].setup(require('coq').lsp_ensure_capabilities({
|
||||
-- -- on_attach = my_custom_on_attach,
|
||||
-- }))
|
||||
-- end
|
||||
end
|
||||
}
|
||||
|
||||
return M
|
||||
25
lua/lazy/plugins/bufferline.lua
Normal file
25
lua/lazy/plugins/bufferline.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-- ===
|
||||
-- === 文件缓冲标签栏
|
||||
-- ===
|
||||
|
||||
local map = require("core.keymap")
|
||||
-- 在标签之间移动
|
||||
map:cmd('tn', 'BufferLineCyclePrev')
|
||||
map:cmd('ti', 'BufferLineCycleNext')
|
||||
|
||||
-- 移动标签的位置
|
||||
map:cmd('tmn', 'BufferLineMovePrev')
|
||||
map:cmd('tmi', 'BufferLineMoveNext')
|
||||
|
||||
-- 关闭标签,貌似是neovim自带的,完整命令bdelete
|
||||
map:cmd('tq', 'bd')
|
||||
|
||||
return {
|
||||
'akinsho/bufferline.nvim',
|
||||
version = "*",-- 安装最新的稳定版
|
||||
dependencies = 'kyazdani42/nvim-web-devicons',
|
||||
config = function()
|
||||
require("bufferline").setup {}
|
||||
end
|
||||
}
|
||||
|
||||
23
lua/lazy/plugins/closebuffer.lua
Normal file
23
lua/lazy/plugins/closebuffer.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- ===
|
||||
-- === 关闭缓冲区的标签
|
||||
-- ===
|
||||
|
||||
local map = require("core.keymap")
|
||||
-- 关闭当前缓冲区标签
|
||||
map:cmd('tq', 'BDelete this')
|
||||
-- 关闭除当前标签外的其他标签
|
||||
map:cmd('to', 'BDelete other')
|
||||
|
||||
return {
|
||||
'kazhala/close-buffers.nvim',
|
||||
config = function()
|
||||
require('close_buffers').setup({
|
||||
filetype_ignore = {}, -- Filetype to ignore when running deletions
|
||||
file_glob_ignore = {}, -- File name glob pattern to ignore when running deletions (e.g. '*.md')
|
||||
file_regex_ignore = {}, -- File name regex pattern to ignore when running deletions (e.g. '.*[.]md')
|
||||
preserve_window_layout = { 'this', 'nameless' }, -- Types of deletion that should preserve the window layout
|
||||
next_buffer_cmd = nil, -- Custom function to retrieve the next buffer when preserving window layout
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
7
lua/lazy/plugins/color.lua
Normal file
7
lua/lazy/plugins/color.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
'norcalli/nvim-colorizer.lua',
|
||||
config = function()
|
||||
require'colorizer'.setup()
|
||||
end
|
||||
}
|
||||
|
||||
21
lua/lazy/plugins/comment.lua
Normal file
21
lua/lazy/plugins/comment.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- ===
|
||||
-- === 注释插件
|
||||
-- ===
|
||||
|
||||
-- 注释快捷键
|
||||
local map = require("core.keymap")
|
||||
map:key("n", "<space>cn", "<Plug>kommentary_line_increase")
|
||||
map:key("x", "<space>cn", "<Plug>kommentary_visual_increase<esc>") -- 选择模式下注释/反注释后退出该模式
|
||||
map:key("n", "<space>cu", "<Plug>kommentary_line_decrease")
|
||||
map:key("x", "<space>cu", "<plug>kommentary_visual_decrease<esc>")
|
||||
|
||||
return {
|
||||
'b3nj5m1n/kommentary',
|
||||
config = function()
|
||||
-- 默认只使用单行注释
|
||||
require('kommentary.config').configure_language("default", {
|
||||
prefer_single_line_comments = true,
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
62
lua/lazy/plugins/filemanager.lua
Normal file
62
lua/lazy/plugins/filemanager.lua
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
-- ===
|
||||
-- === explorer tree 文件列表 fm-nvim启动joshuto ranger Lazygit
|
||||
-- ===
|
||||
|
||||
return {
|
||||
"DreamMaoMao/yazi.nvim", -- 使用yazi替代joshuto和ranger,仍然使用fm-nvim来启动lazygit
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"nvim-lua/plenary.nvim",
|
||||
'is0n/fm-nvim',commit = 'ad7b80dc99cb8b14977f7ea233a9a299dc8879c0', -- 这个提交解决了joshuto无法启动的问题
|
||||
},
|
||||
keys = {
|
||||
{ "tt", "<cmd>Yazi<CR>", desc = "Toggle Yazi" },
|
||||
{ "<c-g>", "<cmd>Lazygit<CR>", desc = "Toggle Lazygit" },
|
||||
},
|
||||
config = function()
|
||||
require('fm-nvim').setup{
|
||||
-- UI Options
|
||||
ui = {
|
||||
float = {
|
||||
-- Floating window border (see ':h nvim_open_win')
|
||||
border = "single",
|
||||
-- Num from 0 - 1 for measurements
|
||||
height = 0.9,
|
||||
width = 0.8,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
-- local map = require("core.keymap")
|
||||
-- -- 打开文件树
|
||||
-- -- map:cmd('tt', "Ranger")
|
||||
-- map:cmd('tt', "Joshuto")
|
||||
-- -- 使用lazygit
|
||||
-- map:cmd('<c-g>', "Lazygit")
|
||||
|
||||
-- return {
|
||||
-- 'is0n/fm-nvim',
|
||||
-- commit = 'ad7b80dc99cb8b14977f7ea233a9a299dc8879c0', -- 这个提交解决了joshuto无法启动的问题
|
||||
-- config = function()
|
||||
-- require('fm-nvim').setup{
|
||||
-- -- UI Options
|
||||
-- ui = {
|
||||
-- float = {
|
||||
-- -- Floating window border (see ':h nvim_open_win')
|
||||
-- border = "single",
|
||||
-- -- Num from 0 - 1 for measurements
|
||||
-- height = 0.9,
|
||||
-- width = 0.8,
|
||||
-- },
|
||||
-- },
|
||||
-- -- Terminal commands used w/ file manager (have to be in your $PATH)
|
||||
-- cmds = {
|
||||
-- joshuto_cmd = "",
|
||||
-- },
|
||||
-- }
|
||||
-- end
|
||||
-- }
|
||||
|
||||
17
lua/lazy/plugins/flutter.lua
Normal file
17
lua/lazy/plugins/flutter.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
-- ===
|
||||
-- === flutter-tools
|
||||
-- ===
|
||||
|
||||
return {
|
||||
'akinsho/flutter-tools.nvim',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'dart-lang/dart-vim-plugin',
|
||||
},
|
||||
ft= {"dart"},
|
||||
lazy = true,
|
||||
config = function()
|
||||
require("flutter-tools").setup {} -- use defaults
|
||||
end
|
||||
}
|
||||
|
||||
28
lua/lazy/plugins/fold.lua
Normal file
28
lua/lazy/plugins/fold.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- ufo关于折叠的设置
|
||||
vim.o.foldcolumn = '0' -- '0' is not bad,其他的会有奇怪的数字
|
||||
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.o.foldenable = true
|
||||
-- 设置可折叠处的样式
|
||||
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
|
||||
|
||||
return {
|
||||
'kevinhwang91/nvim-ufo',
|
||||
dependencies = 'kevinhwang91/promise-async',
|
||||
config = function()
|
||||
-- Option 3: treesitter as a main provider instead
|
||||
-- Only depend on `nvim-treesitter/queries/filetype/folds.scm`,
|
||||
-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`
|
||||
require('ufo').setup({
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
return {'treesitter', 'indent'}
|
||||
end
|
||||
})
|
||||
-- 键盘映射,这里的按键会打开或折叠全部的可折叠位置
|
||||
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
|
||||
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
|
||||
vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds)
|
||||
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)
|
||||
end
|
||||
}
|
||||
|
||||
7
lua/lazy/plugins/fun.lua
Normal file
7
lua/lazy/plugins/fun.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
"Eandrju/cellular-automaton.nvim",
|
||||
keys = "<leader>rr",
|
||||
config = function()
|
||||
vim.keymap.set("n", "<leader>rr", "<cmd>CellularAutomaton make_it_rain<CR>")
|
||||
end,
|
||||
}
|
||||
11
lua/lazy/plugins/gitstatus.lua
Normal file
11
lua/lazy/plugins/gitstatus.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- ===
|
||||
-- === git status/git状态
|
||||
-- ===
|
||||
|
||||
return {
|
||||
'lewis6991/gitsigns.nvim',
|
||||
build = ':TSUpdate',
|
||||
config = function()
|
||||
require('gitsigns').setup()
|
||||
end
|
||||
}
|
||||
43
lua/lazy/plugins/image.lua
Normal file
43
lua/lazy/plugins/image.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
return {
|
||||
"3rd/image.nvim",
|
||||
dependencies = {
|
||||
"vhyrro/luarocks.nvim",
|
||||
priority = 1001, -- this plugin needs to run before anything else
|
||||
opts = {
|
||||
rocks = { "magick" },
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
-- default config
|
||||
require("image").setup({
|
||||
backend = "kitty",
|
||||
-- backend = "ueberzug",
|
||||
integrations = {
|
||||
markdown = {
|
||||
enabled = true,
|
||||
clear_in_insert_mode = false, -- 插入模式的时候隐藏
|
||||
download_remote_images = true,
|
||||
only_render_image_at_cursor = false,
|
||||
filetypes = { "markdown", "vimwiki" }, -- markdown extensions (ie. quarto) can go here
|
||||
},
|
||||
neorg = {
|
||||
enabled = true,
|
||||
clear_in_insert_mode = true,
|
||||
download_remote_images = true,
|
||||
only_render_image_at_cursor = false,
|
||||
filetypes = { "norg" },
|
||||
},
|
||||
},
|
||||
max_width = nil,
|
||||
max_height = nil,
|
||||
max_width_window_percentage = nil,
|
||||
max_height_window_percentage = 50,
|
||||
window_overlap_clear_enabled = true, -- 当打开重叠的浮动窗口时隐藏图片
|
||||
window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" },
|
||||
editor_only_render_when_focused = false, -- auto show/hide images when the editor gains/looses focus
|
||||
tmux_show_only_in_active_window = false, -- auto show/hide images in the correct Tmux window (needs visual-activity off)
|
||||
hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp", "*.avif" }, -- render image files as images when opened
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
30
lua/lazy/plugins/imgclip.lua
Normal file
30
lua/lazy/plugins/imgclip.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
-- 导入键盘映射的函数
|
||||
local map = require("core.keymap")
|
||||
-- 获取当前文件名
|
||||
local filename = vim.fn.expand("%:t")
|
||||
-- 删除扩展,并添加连加符号`.`
|
||||
filename = string.gsub(filename, "%..*", "") .. "."
|
||||
-- 使用空格+p来粘贴间剪切板的图片,然后输入想保存的图片名称,
|
||||
-- 图片会自动保存在当前文件的同一目录下并调整为markdown格式
|
||||
map:cmd('<space>p','PasteImage')
|
||||
|
||||
return {
|
||||
"HakonHarnes/img-clip.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require'img-clip'.setup {
|
||||
default = {
|
||||
dir_path = filename .. "assets", -- 图片保存路径:./文件名.assets
|
||||
insert_mode_after_paste = false, -- 粘贴图片后不进入插入模式
|
||||
},
|
||||
filetypes = {
|
||||
markdown = {
|
||||
url_encode_path = true, ---@type boolean
|
||||
template = "", -- 图片模板,中括号提示包含文件名
|
||||
download_images = false, ---@type boolean
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
29
lua/lazy/plugins/indent.lua
Normal file
29
lua/lazy/plugins/indent.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
return {
|
||||
"shellRaining/hlchunk.nvim",
|
||||
-- 确保这个插件在lsp之后加载,不然会显示为蓝色的线
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { pattern = "*", command = "EnableHL", })
|
||||
require('hlchunk').setup({
|
||||
chunk = {
|
||||
enable = true,
|
||||
use_treesitter = true,
|
||||
style = {
|
||||
{ fg = "#806d9c" },
|
||||
},
|
||||
},
|
||||
indent = {
|
||||
chars = { "│", "¦", "┆", "┊", },
|
||||
use_treesitter = false,
|
||||
},
|
||||
-- 不显示缩进空白处的点点
|
||||
blank = {
|
||||
enable = false,
|
||||
},
|
||||
-- 让左侧数字高亮
|
||||
line_num = {
|
||||
use_treesitter = true,
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
43
lua/lazy/plugins/indentrainbow.lua
Normal file
43
lua/lazy/plugins/indentrainbow.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
return {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
dependencies = {
|
||||
"TheGLander/indent-rainbowline.nvim",
|
||||
},
|
||||
config = function()
|
||||
opts = {}
|
||||
-- Other blankline configuration here
|
||||
require("ibl").setup(require("indent-rainbowline").make_opts(opts,{
|
||||
-- How transparent should the rainbow colors be. 1 is completely opaque, 0 is invisible. 0.07 by default
|
||||
color_transparency = 0.15,
|
||||
-- The 24-bit colors to mix with the background. Specified in hex.
|
||||
-- { 0xffff40, 0x79ff79, 0xff79ff, 0x4fecec, } by default
|
||||
colors = { 0xff0000, 0x00ff00, 0x0000ff, 0xffff40, 0x79ff79, 0xff79ff, 0x4fecec},
|
||||
}))
|
||||
|
||||
-- local highlight = {
|
||||
-- "RainbowRed",
|
||||
-- "RainbowYellow",
|
||||
-- "RainbowBlue",
|
||||
-- "RainbowOrange",
|
||||
-- "RainbowGreen",
|
||||
-- "RainbowViolet",
|
||||
-- "RainbowCyan",
|
||||
-- }
|
||||
|
||||
-- local hooks = require "ibl.hooks"
|
||||
-- -- create the highlight groups in the highlight setup hook, so they are reset
|
||||
-- -- every time the colorscheme changes
|
||||
-- hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
|
||||
-- vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
|
||||
-- vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
|
||||
-- vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
|
||||
-- vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
|
||||
-- vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
|
||||
-- vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
|
||||
-- vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
|
||||
-- end)
|
||||
|
||||
-- require("ibl").setup { indent = { highlight = highlight } }
|
||||
end
|
||||
}
|
||||
|
||||
19
lua/lazy/plugins/jump.lua
Normal file
19
lua/lazy/plugins/jump.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
"folke/flash.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require('flash').setup {
|
||||
labels = "arstdhneioqwfpgjluyzxcvbkm",
|
||||
modes = {
|
||||
-- options used when flash is activated through
|
||||
-- a regular search with `/` or `?`
|
||||
search = {
|
||||
-- when `true`, flash will be activated during regular search by default.
|
||||
-- You can always toggle when searching with `require("flash").toggle()`
|
||||
enabled = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
89
lua/lazy/plugins/lspconfig.lua
Normal file
89
lua/lazy/plugins/lspconfig.lua
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
return {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v3.x',
|
||||
dependencies = {
|
||||
{ 'neovim/nvim-lspconfig' },
|
||||
{'williamboman/mason.nvim'},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
{
|
||||
"MysticalDevil/inlay-hints.nvim",
|
||||
event = "LspAttach",
|
||||
config = function()
|
||||
require("inlay-hints").setup()
|
||||
end
|
||||
}
|
||||
},
|
||||
config = function()
|
||||
-- 打算启用的语言服务列表
|
||||
local servers = {
|
||||
'marksman', -- 任意标题<space>aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题<space>h可以预览
|
||||
'lua_ls',
|
||||
'pyright',
|
||||
'gopls',
|
||||
'rust_analyzer',
|
||||
}
|
||||
-- lsp_zero的相关配置
|
||||
local lsp_zero = require('lsp-zero')
|
||||
lsp_zero.on_attach(function(client, bufnr)
|
||||
lsp_zero.default_keymaps({ buffer = bufnr })
|
||||
local opts = { buffer = bufnr }
|
||||
vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, opts) -- <space>h显示提示文档
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) -- gd跳转到定义的位置
|
||||
vim.keymap.set('n', 'go', vim.lsp.buf.type_definition, opts) -- go跳转到变量类型定义的位置
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) -- gr跳转到引用了对应变量或函数的位置
|
||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts) -- <space>rn变量重命名
|
||||
vim.keymap.set({ 'n', 'x' }, '<leader>f', function() vim.lsp.buf.format({ async = true }) end, opts) -- <space>f进行代码格式化
|
||||
vim.keymap.set('n', '<leader>aw', vim.lsp.buf.code_action, opts) -- <space>aw可以在出现警告或错误的地方打开建议的修复方法
|
||||
vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, opts) -- <space>d浮动窗口显示所在行警告或错误信息
|
||||
vim.keymap.set('n', '<leader>-', vim.diagnostic.goto_prev, opts) -- <space>-跳转到上一处警告或错误的地方
|
||||
vim.keymap.set('n', '<leader>=', vim.diagnostic.goto_next, opts) -- <space>+跳转到下一处警告或错误的地方
|
||||
end)
|
||||
-- “符号栏”是行号旁边的装订线中的一个空格。当一行中出现警告或错误时,Neovim 会向您显示一个字母
|
||||
lsp_zero.set_sign_icons({
|
||||
error = '✘',
|
||||
warn = '▲',
|
||||
hint = '⚑',
|
||||
info = '»'
|
||||
})
|
||||
-- 通过mason来自动安装语言服务器,可以在对应的代码运行LspIstall来安装可用的语言服务器
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = servers -- 直接把前面的servers列表传递过来
|
||||
})
|
||||
-- cmp相关配置,通过for读取servers列表循环批量激活语言服务
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
local lspconfig = require('lspconfig')
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
-- on_attach = my_custom_on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
gopls = {
|
||||
hints = { -- gopls开启hints
|
||||
rangeVariableTypes = true,
|
||||
parameterNames = true,
|
||||
constantValues = true,
|
||||
assignVariableTypes = true,
|
||||
compositeLiteralFields = true,
|
||||
compositeLiteralTypes = true,
|
||||
functionTypeParameters = true,
|
||||
}
|
||||
},
|
||||
Lua = {
|
||||
hint = { -- Lua开启hints
|
||||
enable = true, -- necessary
|
||||
},
|
||||
diagnostics = {
|
||||
-- 忽略掉vim配置时一些全局变量语言服务器找不到的警告
|
||||
globals = {
|
||||
'vim',
|
||||
'require',
|
||||
'opts',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
}
|
||||
16
lua/lazy/plugins/markdownpreview.lua
Normal file
16
lua/lazy/plugins/markdownpreview.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- ===
|
||||
-- === markdown preview
|
||||
-- ===
|
||||
|
||||
return {
|
||||
"iamcco/markdown-preview.nvim",
|
||||
build = "cd app && npm install",
|
||||
init = function() vim.g.mkdp_filetypes = { "markdown" } end,
|
||||
ft = { "markdown" },
|
||||
lazy = true,
|
||||
config = function()
|
||||
-- 设置使用谷歌浏览器进行预览
|
||||
vim.g.mkdp_browser = '/usr/bin/google-chrome-stable'
|
||||
end
|
||||
}
|
||||
|
||||
21
lua/lazy/plugins/minifiles.lua
Normal file
21
lua/lazy/plugins/minifiles.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
return {
|
||||
'echasnovski/mini.files',
|
||||
config = function()
|
||||
require('mini.files').setup{
|
||||
mappings = {
|
||||
close = 'q',
|
||||
go_in = 'I',
|
||||
go_in_plus = 'i',
|
||||
go_out = 'N',
|
||||
go_out_plus = 'n',
|
||||
reset = '<BS>',
|
||||
reveal_cwd = '@',
|
||||
show_help = 'g?',
|
||||
synchronize = '=',
|
||||
trim_left = '<',
|
||||
trim_right = '>',
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
30
lua/lazy/plugins/outline.lua
Normal file
30
lua/lazy/plugins/outline.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
-- ===
|
||||
-- === outlines,大纲,函数变量结构
|
||||
-- ===
|
||||
|
||||
local map = require("core.keymap")
|
||||
-- 空格+v打开大纲,N全部收起,n收起当前节点,r重命名,I展开全部节点,i展开当前节点
|
||||
map:cmd('<space>v', 'SymbolsOutline')
|
||||
|
||||
return {
|
||||
'simrat39/symbols-outline.nvim',
|
||||
config = function()
|
||||
require("symbols-outline").setup {
|
||||
width = 20,
|
||||
keymaps = { -- These keymaps can be a string or a table for multiple keys
|
||||
close = {"<Esc>", "q"},
|
||||
goto_location = "<Cr>",
|
||||
focus_location = "o",
|
||||
hover_symbol = "<C-space>",
|
||||
toggle_preview = "K",
|
||||
rename_symbol = "r",
|
||||
code_actions = "a",
|
||||
fold = "n",
|
||||
unfold = "i",
|
||||
fold_all = "N",
|
||||
unfold_all = "I",
|
||||
fold_reset = "R",
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
19
lua/lazy/plugins/pairs.lua
Normal file
19
lua/lazy/plugins/pairs.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
config = function()
|
||||
-- 配合cmp,我也不知道有啥效果
|
||||
-- local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
-- local cmp = require('cmp')
|
||||
-- cmp.event:on(
|
||||
-- 'confirm_done',
|
||||
-- cmp_autopairs.on_confirm_done()
|
||||
-- )
|
||||
|
||||
require('nvim-autopairs').setup({
|
||||
-- 在写markdown时禁用括号补全
|
||||
disable_filetype = {"markdown"},
|
||||
-- can use treesitter to check for a pair.
|
||||
check_ts = true,
|
||||
})
|
||||
end
|
||||
}
|
||||
21
lua/lazy/plugins/rainbow.lua
Normal file
21
lua/lazy/plugins/rainbow.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- ===
|
||||
-- === rainbow,彩虹括号,必须要保证安装了treesitter,我分开是为了方便通过文件查找配置
|
||||
-- ===
|
||||
|
||||
return {
|
||||
'p00f/nvim-ts-rainbow',
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup {
|
||||
rainbow = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
|
||||
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
|
||||
max_file_lines = nil, -- Do not enable for files with more than n lines, int
|
||||
-- colors = {}, -- table of hex strings
|
||||
-- termcolors = {} -- table of colour name strings
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
23
lua/lazy/plugins/stickyScroll.lua
Normal file
23
lua/lazy/plugins/stickyScroll.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
config = function()
|
||||
vim.keymap.set("n", "[c", function()
|
||||
require("treesitter-context").go_to_context(vim.v.count1)
|
||||
end, { silent = true })
|
||||
require'treesitter-context'.setup{
|
||||
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
|
||||
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
|
||||
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
|
||||
line_numbers = true,
|
||||
multiline_threshold = 20, -- Maximum number of lines to show for a single context
|
||||
trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
|
||||
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
|
||||
-- Separator between context and content. Should be a single character string, like '-'.
|
||||
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
|
||||
separator = nil,
|
||||
zindex = 20, -- The Z-index of the context window
|
||||
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
4
lua/lazy/plugins/suda.lua
Normal file
4
lua/lazy/plugins/suda.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
'lambdalisue/suda.vim'
|
||||
}
|
||||
|
||||
21
lua/lazy/plugins/surround.lua
Normal file
21
lua/lazy/plugins/surround.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- ===
|
||||
-- === mini.nvim surround,各种对字符的包裹{} [] ''
|
||||
-- ===
|
||||
|
||||
return {
|
||||
'echasnovski/mini.nvim',
|
||||
branch = 'stable',
|
||||
config = function()
|
||||
require('mini.surround').setup {
|
||||
mappings = {
|
||||
add = 's', -- Add surrounding
|
||||
delete = 'sd', -- Delete surrounding
|
||||
find = 'sf', -- Find surrounding (to the right)
|
||||
find_left = 'sF', -- Find surrounding (to the left)
|
||||
highlight = 'sh', -- Highlight surrounding
|
||||
replace = 'cs', -- Replace surrounding/change sround
|
||||
update_n_lines = 'sn', -- Update `n_lines`
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
5
lua/lazy/plugins/tabular.lua
Normal file
5
lua/lazy/plugins/tabular.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- tabular,使用:Tab /=来格式化等号之类,特使符号要转义如:Tabularize /\/
|
||||
return {
|
||||
'godlygeek/tabular'
|
||||
}
|
||||
|
||||
52
lua/lazy/plugins/telescope.lua
Normal file
52
lua/lazy/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
return {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
branch = '0.1.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
},
|
||||
config = function()
|
||||
local builtin = require('telescope.builtin')
|
||||
-- ctrl+t打开文件查找
|
||||
vim.keymap.set('n', '<c-t>', builtin.find_files, {})
|
||||
-- ctrl+f打开字符串查找
|
||||
vim.keymap.set('n', '<c-f>', '<cmd>lua require("telescope.builtin").grep_string({ search = vim.fn.input("Grep For > "), only_sort_text = true, })<cr>', { noremap = true })
|
||||
-- 下面的配置从cw的配置粘贴过来的,删除一部分看不懂的
|
||||
local ts = require('telescope')
|
||||
ts.setup({
|
||||
defaults = {
|
||||
vimgrep_arguments = {
|
||||
"rg",
|
||||
"--color=never",
|
||||
"--no-heading",
|
||||
"--with-filename",
|
||||
"--line-number",
|
||||
"--column",
|
||||
"--fixed-strings",
|
||||
"--smart-case",
|
||||
"--trim",
|
||||
},
|
||||
layout_config = {
|
||||
width = 0.9,
|
||||
height = 0.9,
|
||||
},
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-h>"] = "which_key",
|
||||
["<C-u>"] = "move_selection_previous",
|
||||
["<C-e>"] = "move_selection_next",
|
||||
["<C-l>"] = "preview_scrolling_up",
|
||||
["<C-y>"] = "preview_scrolling_down",
|
||||
["<esc>"] = "close",
|
||||
}
|
||||
},
|
||||
color_devicons = true,
|
||||
prompt_prefix = "🔍 ",
|
||||
selection_caret = " ",
|
||||
path_display = { "truncate" },
|
||||
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
|
||||
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
253
lua/lazy/plugins/themes.lua
Normal file
253
lua/lazy/plugins/themes.lua
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
-- ===
|
||||
-- === 底部状态栏+onedark主题
|
||||
-- ===
|
||||
|
||||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = {
|
||||
'kyazdani42/nvim-web-devicons', -- 图标
|
||||
'navarasu/onedark.nvim', -- onedark主题
|
||||
},
|
||||
config = function()
|
||||
-- Eviline config for lualine
|
||||
-- Author: shadmansaleh
|
||||
-- Credit: glepnir
|
||||
local lualine = require('lualine')
|
||||
|
||||
-- Color table for highlights
|
||||
-- stylua: ignore
|
||||
local colors = {
|
||||
bg = '#202328',
|
||||
fg = '#bbc2cf',
|
||||
yellow = '#ECBE7B',
|
||||
cyan = '#008080',
|
||||
darkblue = '#081633',
|
||||
green = '#98be65',
|
||||
orange = '#FF8800',
|
||||
violet = '#a9a1e1',
|
||||
magenta = '#c678dd',
|
||||
blue = '#51afef',
|
||||
red = '#ec5f67',
|
||||
}
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
end,
|
||||
check_git_workspace = function()
|
||||
local filepath = vim.fn.expand('%:p:h')
|
||||
local gitdir = vim.fn.finddir('.git', filepath .. ';')
|
||||
return gitdir and #gitdir > 0 and #gitdir < #filepath
|
||||
end,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = '',
|
||||
section_separators = '',
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x ot right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
}
|
||||
|
||||
ins_left {
|
||||
-- mode component
|
||||
function()
|
||||
return ''
|
||||
end,
|
||||
color = function()
|
||||
-- auto change color according to neovims mode
|
||||
local mode_color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.blue,
|
||||
[''] = colors.blue,
|
||||
V = colors.blue,
|
||||
c = colors.magenta,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[''] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
['r?'] = colors.cyan,
|
||||
['!'] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = mode_color[vim.fn.mode()] }
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
-- filesize component
|
||||
'filesize',
|
||||
cond = conditions.buffer_not_empty,
|
||||
}
|
||||
|
||||
ins_left {
|
||||
'filename',
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_left { 'location' }
|
||||
|
||||
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
|
||||
|
||||
ins_left {
|
||||
'diagnostics',
|
||||
sources = { 'nvim_diagnostic' },
|
||||
symbols = { error = ' ', warn = ' ', info = ' ' },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
}
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left {
|
||||
function()
|
||||
return '%='
|
||||
end,
|
||||
}
|
||||
|
||||
ins_left {
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = 'No Active Lsp'
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = ' LSP:',
|
||||
color = { fg = '#ffffff', gui = 'bold' },
|
||||
}
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right {
|
||||
'o:encoding', -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'fileformat',
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.green, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'branch',
|
||||
icon = '',
|
||||
color = { fg = colors.violet, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_right {
|
||||
'diff',
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = ' ', modified = '柳 ', removed = ' ' },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
}
|
||||
|
||||
ins_right {
|
||||
function()
|
||||
return '▊'
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
}
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
|
||||
|
||||
-- ===
|
||||
-- === 主题配置 theme
|
||||
-- ===
|
||||
-- vim.cmd 'colorscheme space-vim-dark'
|
||||
-- 使用灰色注释
|
||||
vim.cmd 'hi Comment guifg=#5C6370 ctermfg=59'
|
||||
-- 使用透明背景
|
||||
-- vim.cmd 'hi Normal ctermbg=NONE guibg=NONE'
|
||||
-- vim.cmd 'hi LineNr ctermbg=NONE guibg=NONE'
|
||||
-- vim.cmd 'hi SignColumn ctermbg=NONE guibg=NONE'
|
||||
|
||||
-- dark,darker,cool,deep,warm,warmer
|
||||
require('onedark').setup {
|
||||
style = 'darker'
|
||||
}
|
||||
require('onedark').load()
|
||||
end
|
||||
}
|
||||
|
||||
13
lua/lazy/plugins/translate.lua
Normal file
13
lua/lazy/plugins/translate.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
-- 可视视图下
|
||||
return {
|
||||
"kraftwerk28/gtranslate.nvim",
|
||||
dependencies = "nvim-lua/plenary.nvim",
|
||||
config = function()
|
||||
vim.api.nvim_set_keymap('n', 'tr', "viw:'<,'>Translate<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('v', 'tr', ":'<,'>Translate<CR>", { noremap = true, silent = true })
|
||||
require("gtranslate").setup {
|
||||
default_to_language = "Chinese_Simplified",
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
40
lua/lazy/plugins/treesitter.lua
Normal file
40
lua/lazy/plugins/treesitter.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
-- ===
|
||||
-- === treesitter,语法高亮
|
||||
-- ===
|
||||
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
config = function()
|
||||
-- 要安装高亮的语言直接加入括号即可,把sync_install设置为true下次进入vim自动安装,语言列表查看treesitter的github
|
||||
-- 或者执行:TSInstall <language_to_install>
|
||||
local language = {
|
||||
"python",
|
||||
"lua",
|
||||
"dart",
|
||||
"markdown",
|
||||
"go",
|
||||
"bash",
|
||||
"java",
|
||||
"sql",
|
||||
}
|
||||
require("nvim-treesitter.configs").setup {
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = language,
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = true,
|
||||
-- List of parsers to ignore installing (for "all")
|
||||
ignore_install = {},
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- list of language that will be disabled
|
||||
disable = {},
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
17
lua/lazy/plugins/whichkey.lua
Normal file
17
lua/lazy/plugins/whichkey.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
return {
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
init = function()
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 300
|
||||
end,
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
},
|
||||
config = function()
|
||||
require("which-key").setup {}
|
||||
end
|
||||
}
|
||||
|
||||
73
lua/lazy/plugins/winbar.lua
Normal file
73
lua/lazy/plugins/winbar.lua
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
return {
|
||||
"Bekaboo/dropbar.nvim",
|
||||
config = function()
|
||||
local api = require("dropbar.api")
|
||||
vim.keymap.set('n', '<Leader>;', api.pick)
|
||||
vim.keymap.set('n', '[c', api.goto_context_start)
|
||||
vim.keymap.set('n', ']c', api.select_next_context)
|
||||
|
||||
local confirm = function()
|
||||
local menu = api.get_current_dropbar_menu()
|
||||
if not menu then
|
||||
return
|
||||
end
|
||||
local cursor = vim.api.nvim_win_get_cursor(menu.win)
|
||||
local component = menu.entries[cursor[1]]:first_clickable(cursor[2])
|
||||
if component then
|
||||
menu:click_on(component)
|
||||
end
|
||||
end
|
||||
|
||||
local quit_curr = function()
|
||||
local menu = api.get_current_dropbar_menu()
|
||||
if menu then
|
||||
menu:close()
|
||||
end
|
||||
end
|
||||
|
||||
require("dropbar").setup({
|
||||
menu = {
|
||||
-- When on, automatically set the cursor to the closest previous/next
|
||||
-- clickable component in the direction of cursor movement on CursorMoved
|
||||
quick_navigation = true,
|
||||
---@type table<string, string|function|table<string, string|function>>
|
||||
keymaps = {
|
||||
['<LeftMouse>'] = function()
|
||||
local menu = api.get_current_dropbar_menu()
|
||||
if not menu then
|
||||
return
|
||||
end
|
||||
local mouse = vim.fn.getmousepos()
|
||||
if mouse.winid ~= menu.win then
|
||||
local parent_menu = api.get_dropbar_menu(mouse.winid)
|
||||
if parent_menu and parent_menu.sub_menu then
|
||||
parent_menu.sub_menu:close()
|
||||
end
|
||||
if vim.api.nvim_win_is_valid(mouse.winid) then
|
||||
vim.api.nvim_set_current_win(mouse.winid)
|
||||
end
|
||||
return
|
||||
end
|
||||
menu:click_at({ mouse.line, mouse.column }, nil, 1, 'l')
|
||||
end,
|
||||
['<CR>'] = confirm,
|
||||
['i'] = confirm,
|
||||
['<esc>'] = quit_curr,
|
||||
['q'] = quit_curr,
|
||||
['n'] = quit_curr,
|
||||
['<MouseMove>'] = function()
|
||||
local menu = api.get_current_dropbar_menu()
|
||||
if not menu then
|
||||
return
|
||||
end
|
||||
local mouse = vim.fn.getmousepos()
|
||||
if mouse.winid ~= menu.win then
|
||||
return
|
||||
end
|
||||
menu:update_hover_hl({ mouse.line, mouse.column - 1 })
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue