This commit is contained in:
newbie 2023-11-23 18:39:37 +08:00
parent 31100c0bb4
commit 3cda0b2696
7 changed files with 176 additions and 339 deletions

View File

@ -1,18 +1,14 @@
return {
'github/copilot.vim', -- github copilot
'vijaymarupudi/nvim-fzf', -- fzf
'lilydjwg/colorizer', -- 颜色识别
-- require('plugs.coc'), -- coc
require('plugs.nvim-lspconfig'), --
require('plugs.lualine'), -- lualine
require('plugs.nvim-lspconfig'),
require('plugs.nvimtree'), -- nvimtree
require('plugs.treesitter'), -- treesitter
require('plugs.theme'), -- theme
require("plugs.copilot"),
require("plugs.edit-plugs"),
require("plugs.hop"),
require("plugs.toggleterm")

View File

@ -1,173 +0,0 @@
return {
{
'neoclide/coc.nvim',
config = function()
G.opt.backup = false
G.opt.writebackup = false
G.opt.updatetime = 300
G.opt.signcolumn = "yes"
G.g.coc_global_extensions = {
'coc-json',
'coc-pyright',
'coc-java',
'coc-sh',
'coc-sumneko-lua',
'coc-clangd',
'coc-word',
'coc-lists',
'coc-pairs',
'coc-marketplace',
}
local opts = {
silent = true,
noremap = true,
expr = true,
replace_keycodes = false
}
G.map({
-- { "i", "<TAB>", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "<TAB>" : coc#refresh()', opts },
-- { "i", "<S-TAB>", [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]], opts },
{ "i", "<cr>", [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"]], opts },
{ "n", "gd", "<Plug>(coc-definition)", {silent = true} },
{ "n", "gy", "<Plug>(coc-type-definition)", {silent = true} },
{ "n", "gi", "<Plug>(coc-implementation)", {silent = true} },
{ "n", "gr", "<Plug>(coc-references)", {silent = true} },
{ "n", "<leader>rn", "<Plug>(coc-rename)", {silent = true} },
{ "v", "<c-I>", "<Plug>(coc-format-selected)", {silent = true} },
-- { "n", "<c-I>", "<Plug>(coc-format-selected)", {silent = true} },
})
-- local keyset = vim.keymap.set
function _G.check_back_space()
local col = G.fn.col('.') - 1
return col == 0 or G.fn.getline('.'):sub(col, col):match('%s') ~= nil
end
-- keyset("n", "[g", "<Plug>(coc-diagnostic-prev)", {silent = true})
-- keyset("n", "]g", "<Plug>(coc-diagnostic-next)", {silent = true})
G.api.nvim_create_augroup("CocGroup", {})
G.au("CursorHold", {
group = "CocGroup",
command = "silent call CocActionAsync('highlight')",
desc = "Highlight symbol under cursor on CursorHold"
})
G.au("FileType", {
group = "CocGroup",
pattern = "typescript,json",
command = "setl formatexpr=CocAction('formatSelected')",
desc = "Setup formatexpr specified filetype(s)."
})
-- Update signature help on jump placeholder
G.au("User", {
group = "CocGroup",
pattern = "CocJumpPlaceholder",
command = "call CocActionAsync('showSignatureHelp')",
desc = "Update signature help on jump placeholder"
})
-- Apply codeAction to the selected region
-- Example: `<leader>aap` for current paragraph
--local opts = {silent = true, nowait = true}
--keyset("x", "<leader>a", "<Plug>(coc-codeaction-selected)", opts)
--keyset("n", "<leader>a", "<Plug>(coc-codeaction-selected)", opts)
---- Remap keys for apply code actions at the cursor position.
--keyset("n", "<leader>ac", "<Plug>(coc-codeaction-cursor)", opts)
---- Remap keys for apply source code actions for current file.
--keyset("n", "<leader>as", "<Plug>(coc-codeaction-source)", opts)
---- Apply the most preferred quickfix action on the current line.
--keyset("n", "<leader>qf", "<Plug>(coc-fix-current)", opts)
---- Remap keys for apply refactor code actions.
--keyset("n", "<leader>re", "<Plug>(coc-codeaction-refactor)", { silent = true })
--keyset("x", "<leader>r", "<Plug>(coc-codeaction-refactor-selected)", { silent = true })
--keyset("n", "<leader>r", "<Plug>(coc-codeaction-refactor-selected)", { silent = true })
---- Run the Code Lens actions on the current line
--keyset("n", "<leader>cl", "<Plug>(coc-codelens-action)", opts)
---- Map function and class text objects
---- NOTE: Requires 'textDocument.documentSymbol' support from the language server
--keyset("x", "if", "<Plug>(coc-funcobj-i)", opts)
--keyset("o", "if", "<Plug>(coc-funcobj-i)", opts)
--keyset("x", "af", "<Plug>(coc-funcobj-a)", opts)
--keyset("o", "af", "<Plug>(coc-funcobj-a)", opts)
--keyset("x", "ic", "<Plug>(coc-classobj-i)", opts)
--keyset("o", "ic", "<Plug>(coc-classobj-i)", opts)
--keyset("x", "ac", "<Plug>(coc-classobj-a)", opts)
--keyset("o", "ac", "<Plug>(coc-classobj-a)", opts)
---- Remap <C-f> and <C-b> to scroll float windows/popups
-----@diagnostic disable-next-line: redefined-local
--local opts = {silent = true, nowait = true, expr = true}
--keyset("n", "<C-f>", 'coc#float#has_scroll() ? coc#float#scroll(1) : "<C-f>"', opts)
--keyset("n", "<C-b>", 'coc#float#has_scroll() ? coc#float#scroll(0) : "<C-b>"', opts)
--keyset("i", "<C-f>",
-- 'coc#float#has_scroll() ? "<c-r>=coc#float#scroll(1)<cr>" : "<Right>"', opts)
--keyset("i", "<C-b>",
-- 'coc#float#has_scroll() ? "<c-r>=coc#float#scroll(0)<cr>" : "<Left>"', opts)
--keyset("v", "<C-f>", 'coc#float#has_scroll() ? coc#float#scroll(1) : "<C-f>"', opts)
--keyset("v", "<C-b>", 'coc#float#has_scroll() ? coc#float#scroll(0) : "<C-b>"', opts)
---- Use CTRL-S for selections ranges
---- Requires 'textDocument/selectionRange' support of language server
--keyset("n", "<C-s>", "<Plug>(coc-range-select)", {silent = true})
--keyset("x", "<C-s>", "<Plug>(coc-range-select)", {silent = true})
---- Add `:Format` command to format current buffer
--vim.api.nvim_create_user_command("Format", "call CocAction('format')", {})
---- " Add `:Fold` command to fold current buffer
--vim.api.nvim_create_user_command("Fold", "call CocAction('fold', <f-args>)", {nargs = '?'})
---- Add `:OR` command for organize imports of the current buffer
--vim.api.nvim_create_user_command("OR", "call CocActionAsync('runCommand', 'editor.action.organizeImport')", {})
---- Add (Neo)Vim's native statusline support
---- NOTE: Please see `:h coc-status` for integrations with external plugins that
---- provide custom statusline: lightline.vim, vim-airline
--vim.opt.statusline:prepend("%{coc#status()}%{get(b:,'coc_current_function','')}")
---- Mappings for CoCList
---- code actions and coc stuff
-----@diagnostic disable-next-line: redefined-local
--local opts = {silent = true, nowait = true}
---- Show all diagnostics
--keyset("n", "<space>a", ":<C-u>CocList diagnostics<cr>", opts)
---- Manage extensions
--keyset("n", "<space>e", ":<C-u>CocList extensions<cr>", opts)
---- Show commands
--keyset("n", "<space>c", ":<C-u>CocList commands<cr>", opts)
---- Find symbol of current document
--keyset("n", "<space>o", ":<C-u>CocList outline<cr>", opts)
---- Search workspace symbols
--keyset("n", "<space>s", ":<C-u>CocList -I symbols<cr>", opts)
---- Do default action for next item
--keyset("n", "<space>j", ":<C-u>CocNext<cr>", opts)
---- Do default action for previous item
--keyset("n", "<space>k", ":<C-u>CocPrev<cr>", opts)
---- Resume latest coc list
--keyset("n", "<space>p", ":<C-u>CocListResume<cr>", opts)
end,
},
}

9
lua/plugs/copilot.lua Normal file
View File

@ -0,0 +1,9 @@
return {
'github/copilot.vim', -- github copilot
config = function ()
G.g.copilot_no_tab_map = true
G.map({
{"i", '<c-e>', "copilot#Accept()", {silent = true}},
})
end
}

View File

@ -1,74 +0,0 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = {
'kdheepak/tabline.nvim',
},
config = function()
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
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_z = {}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
require('tabline').setup {
-- Defaults configuration options
enable = true,
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 = {'', ''},
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 sessionoptions+=tabpages,globals " store tabpages and globals in session
]]
}
end,
}

View File

@ -1,21 +1,26 @@
return {
{
-- lsp的config
"neovim/nvim-lspconfig",
config = function ()
require'lspconfig'.lua_ls.setup(require('lsp.lua'))
end
},
{
-- lsp 下载器
"williamboman/mason.nvim",
config = function()
require("mason").setup({})
end
},
{
-- lsp补全
'hrsh7th/cmp-nvim-lsp', -- { name = 'nvim_lua' }
'hrsh7th/cmp-buffer', -- { name = 'buffer' },
'hrsh7th/cmp-path', -- { name = 'path' }
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
'hrsh7th/vim-vsnip',
'hrsh7th/cmp-vsnip',
{
'onsails/lspkind-nvim',
@ -61,37 +66,45 @@ return {
local line, col = unpack(G.api.nvim_win_get_cursor(0))
return col ~= 0 and G.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local cmp = require('cmp')
local lspkind = require('lspkind')
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
sources = cmp.config.sources({
{ name = 'vnsip'},
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'cmdline' },
{name = 'vnsip'},
}),
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<Tab>'] = function(fallback)
if not cmp.select_next_item() then
if vim.bo.buftype ~= 'prompt' and has_words_before() then
cmp.complete()
else
fallback()
end
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end,
end, { "i", "s" }),
['<S-Tab>'] = function(fallback)
if not cmp.select_prev_item() then
if vim.bo.buftype ~= 'prompt' and has_words_before() then
cmp.complete()
else
fallback()
end
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end,
end, { "i", "s" }),
}),
window = {
@ -103,22 +116,75 @@ return {
},
fomatting = {
format = lspkind.cmp_format({
mode = 'symbol', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
mode = 'symbol',
maxwidth = 50,
ellipsis_char = '...',
before = function (_, vim_item)
return vim_item
end
})
},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
}
end,
}
},
{
-- 语法高亮
'nvim-treesitter/nvim-treesitter',
config = function()
require'nvim-treesitter.configs'.setup{
-- A list of parser names, or "all" (the four listed parsers should always be installed)
ensure_installed = {},
indent = { enable = true },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for "all")
-- ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
-- `false` will disable the whole extension
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
-- disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- 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,
},
parsers = {
html = {
install_info = {
url = "https://github.com/ikatyang/tree-sitter-vue",
files = {"src/parser.c"},
branch = "main"
}
}
}
}
end
},
}
}

View File

@ -1,12 +1,83 @@
return {
'shaunsingh/nord.nvim', -- 主题插件
{
'folke/tokyonight.nvim',
config = function ()
G.cmd("colorscheme tokyonight") -- 主题
-- G.api.colorscheme = "tokyonight"
G.opt.background = 'dark' -- 背景
end
},
{
-- line插件
'kdheepak/tabline.nvim',
'nvim-lualine/lualine.nvim',
config = function()
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
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_z = {}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
require('tabline').setup {
-- Defaults configuration options
enable = true,
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 = {'', ''},
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 sessionoptions+=tabpages,globals " store tabpages and globals in session
]]
}
end,
}
}

View File

@ -1,58 +0,0 @@
return {
-- 语法高亮
'nvim-treesitter/nvim-treesitter',
config = function()
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the four listed parsers should always be installed)
ensure_installed = {},
indent = { enable = true },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for "all")
-- ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
-- `false` will disable the whole extension
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
-- disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- 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,
},
parsers = {
html = {
install_info = {
url = "https://github.com/ikatyang/tree-sitter-vue",
files = {"src/parser.c"},
branch = "main"
}
}
}
}
end
}