This commit is contained in:
veypi 2022-10-17 19:31:37 +08:00
parent 082b8a69e5
commit 2bf106a53c
5 changed files with 178 additions and 94 deletions

View File

@ -1,18 +1,21 @@
let g:username = 'veypi' let g:username = 'veypi'
let g:email = 'i@veypi.com' let g:email = 'i@veypi.com'
" 基本配置
runtime ./vimrc.vim runtime ./vimrc.vim
" 插件管理 " 插件管理
lua require('plugins') lua require('plugins')
" 补全
lua require('lsp/setup') lua require('lsp/setup')
" 界面
lua require('frame/setup') lua require('frame/setup')
" 工具类型
lua require('utils/setup') lua require('utils/setup')
" 部分插件补全配置
runtime ./plug.vim runtime ./plug.vim
" 按键映射 " 按键映射
runtime ./maps.vim runtime ./maps.vim

View File

@ -1,6 +1,51 @@
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = ""
}
}
})
-- https://github.com/williamboman/mason-lspconfig.nvim
require("mason-lspconfig").setup {
ensure_installed = { "rust_analyzer", "gopls", "volar", "cssls", "yamlls", "zk", "tsserver", "pyright",
"tailwindcss", "sqls", "efm", "html", "prettierd" },
}
local lspconfig = require('lspconfig')
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
local lsp_installer = require "nvim-lsp-installer"
-- 需特别配置的lsp插件
-- { key: 语言 value: 配置文件 }
-- pyright 不支持autoformat
local servers = {
sumneko_lua = require "lsp.lua", -- /lua/lsp/lua.lua
tailwindcss = require "lsp.tailwind",
sqls = require "lsp.sql",
efm = require "lsp.efm",
}
require("mason-lspconfig").setup_handlers({
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have
-- a dedicated handler.
function(server_name) -- default handler (optional)
local opts = servers[server_name]
if not opts then
opts = {}
end
opts.capabilities = capabilities
opts.flags = {
debounce_text_changes = 150,
}
require("lspconfig")[server_name].setup(opts)
end,
})
-- local lsp_installer = require "nvim-lsp-installer"
-- Mappings. -- Mappings.
@ -16,53 +61,6 @@ vim.api.nvim_set_keymap('n', 'e]', '<cmd>lua vim.diagnostic.goto_next()<CR>', ke
-- vim.cmd [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]] -- vim.cmd [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
-- 安装列表
-- https://github.com/williamboman/nvim-lsp-installer#available-lsps
-- { key: 语言 value: 配置文件 }
-- pyright 不支持autoformat
local servers = {
sumneko_lua = require "lsp.lua", -- /lua/lsp/lua.lua
gopls = require "lsp.base",
volar = require "lsp.base",
basels = require "lsp.base",
cssls = require "lsp.base",
-- eslint = require "lsp.eslint",
yamlls = require "lsp.base",
zk = require "lsp.base",
tsserver = require "lsp.base",
pyright = require "lsp.base",
rust_analyzer = require "lsp.base",
tailwindcss = require "lsp.tailwind",
sqls = require "lsp.sql",
efm = require "lsp.efm",
html = require "lsp.base"
}
-- 自动安装 LanguageServers
for name, _ in pairs(servers) do
local server_is_found, server = lsp_installer.get_server(name)
if server_is_found then
if not server:is_installed() then
print("Installing " .. name)
server:install()
end
end
end
lsp_installer.on_server_ready(function(server)
local opts = servers[server.name]
if not opts then
return
end
opts.capabilities = capabilities
opts.flags = {
debounce_text_changes = 150,
}
server:setup(opts)
end)
-- luasnip setup -- luasnip setup
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
@ -114,3 +112,34 @@ cmp.setup {
{ name = 'omni', } { name = 'omni', }
}, },
} }
-- Utilities for creating configurations
local util = require "formatter.util"
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup {
-- Enable or disable logging
logging = true,
-- Set the log level
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
-- vue = {
-- function()
-- return {
-- exe = "prettierd",
-- args = {vim.api.nvim_buf_get_name(0)},
-- stdin = true
-- }
-- end
-- },
-- Use the special "*" filetype for defining formatter configurations on
-- any filetype
-- ["*"] = {
-- -- "formatter.filetypes.any" defines default configurations for any
-- -- filetype
-- require("formatter.filetypes.any").remove_trailing_whitespace
-- }
}
}

View File

@ -1,18 +1,38 @@
-- This file can be loaded by calling `lua require('plugins')` from your init.vim -- This file can be loaded by calling `lua require('plugins')` from your init.vim
-- Only required if you have packer configured as `opt` -- Only required if you have packer configured as `opt`
vim.cmd [[packadd packer.nvim]] -- vim.cmd [[packadd packer.nvim]]
local execute = vim.api.nvim_command
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
execute 'packadd packer.nvim'
end
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "plugins.lua",
command = "source <afile> | PackerCompile",
})
return require('packer').startup(function() return require('packer').startup(function()
-- Packer can manage itself -- Packer can manage itself
-- 包管理
use 'wbthomason/packer.nvim' use 'wbthomason/packer.nvim'
use "williamboman/mason.nvim"
use "williamboman/mason-lspconfig.nvim"
-- LSP -- LSP 代码补全插件
use { 'neovim/nvim-lspconfig', 'williamboman/nvim-lsp-installer' } use 'neovim/nvim-lspconfig'
use 'windwp/nvim-autopairs' use 'windwp/nvim-autopairs'
use 'windwp/nvim-ts-autotag' use 'windwp/nvim-ts-autotag'
use 'hrsh7th/nvim-cmp' use 'hrsh7th/nvim-cmp'
@ -23,8 +43,11 @@ return require('packer').startup(function()
use 'saadparwaiz1/cmp_luasnip' use 'saadparwaiz1/cmp_luasnip'
use 'L3MON4D3/LuaSnip' use 'L3MON4D3/LuaSnip'
-- 格式化
use 'mhartington/formatter.nvim'
-- Frame
-- 界面插件
use { "ellisonleao/gruvbox.nvim" } use { "ellisonleao/gruvbox.nvim" }
-- need to install nerd font -- need to install nerd font
@ -41,31 +64,39 @@ return require('packer').startup(function()
-- utils -- utils
-- 注释插件
use 'numToStr/Comment.nvim' use 'numToStr/Comment.nvim'
-- 模糊查找工具 文件跳转
use { use {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
requires = { { 'nvim-lua/plenary.nvim' } } requires = { { 'nvim-lua/plenary.nvim' } }
} }
-- vim 内打开终端工具
use { "akinsho/toggleterm.nvim" } use { "akinsho/toggleterm.nvim" }
-- 自动保存
use "Pocco81/AutoSave.nvim" use "Pocco81/AutoSave.nvim"
-- git状态
use 'lewis6991/gitsigns.nvim' use 'lewis6991/gitsigns.nvim'
-- 新文件模板
use 'aperezdc/vim-template' use 'aperezdc/vim-template'
-- 缩进标记
use "lukas-reineke/indent-blankline.nvim" use "lukas-reineke/indent-blankline.nvim"
-- 显示颜色 如#0f0
use "norcalli/nvim-colorizer.lua" use "norcalli/nvim-colorizer.lua"
-- git 查看merge信息
-- ~/.gitconfig -- ~/.gitconfig
-- [merge] -- [merge]
-- conflictStyle = diff3 -- conflictStyle = diff3
use "samoshkin/vim-mergetool" use "samoshkin/vim-mergetool"
-- latex 工具支持
use 'lervag/vimtex' use 'lervag/vimtex'
end) end)

View File

@ -44,8 +44,8 @@ local function save_profiles(threshold)
end end
time([[Luarocks path setup]], true) time([[Luarocks path setup]], true)
local package_path_str = "/Users/light/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/light/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/light/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/light/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" local package_path_str = "/Users/veypi/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/veypi/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/veypi/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/veypi/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/light/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" local install_cpath_pattern = "/Users/veypi/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str package.path = package.path .. ';' .. package_path_str
end end
@ -71,143 +71,163 @@ time([[Defining packer_plugins]], true)
_G.packer_plugins = { _G.packer_plugins = {
["AutoSave.nvim"] = { ["AutoSave.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/AutoSave.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/AutoSave.nvim",
url = "https://github.com/Pocco81/AutoSave.nvim" url = "https://github.com/Pocco81/AutoSave.nvim"
}, },
["Comment.nvim"] = { ["Comment.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/Comment.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim" url = "https://github.com/numToStr/Comment.nvim"
}, },
LuaSnip = { LuaSnip = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/LuaSnip", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/LuaSnip",
url = "https://github.com/L3MON4D3/LuaSnip" url = "https://github.com/L3MON4D3/LuaSnip"
}, },
["bufferline.nvim"] = { ["bufferline.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/bufferline.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/bufferline.nvim",
url = "https://github.com/akinsho/bufferline.nvim" url = "https://github.com/akinsho/bufferline.nvim"
}, },
["cmp-buffer"] = { ["cmp-buffer"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/cmp-buffer", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer" url = "https://github.com/hrsh7th/cmp-buffer"
}, },
["cmp-nvim-lsp"] = { ["cmp-nvim-lsp"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp" url = "https://github.com/hrsh7th/cmp-nvim-lsp"
}, },
["cmp-omni"] = {
loaded = true,
path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/cmp-omni",
url = "https://github.com/hrsh7th/cmp-omni"
},
["cmp-path"] = { ["cmp-path"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/cmp-path", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path" url = "https://github.com/hrsh7th/cmp-path"
}, },
cmp_luasnip = { cmp_luasnip = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/cmp_luasnip", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/cmp_luasnip",
url = "https://github.com/saadparwaiz1/cmp_luasnip" url = "https://github.com/saadparwaiz1/cmp_luasnip"
}, },
["formatter.nvim"] = {
loaded = true,
path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/formatter.nvim",
url = "https://github.com/mhartington/formatter.nvim"
},
["git-blame.nvim"] = { ["git-blame.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/git-blame.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/git-blame.nvim",
url = "https://github.com/f-person/git-blame.nvim" url = "https://github.com/f-person/git-blame.nvim"
}, },
["gitsigns.nvim"] = { ["gitsigns.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
url = "https://github.com/lewis6991/gitsigns.nvim" url = "https://github.com/lewis6991/gitsigns.nvim"
}, },
["gruvbox.nvim"] = { ["gruvbox.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/gruvbox.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/gruvbox.nvim",
url = "https://github.com/ellisonleao/gruvbox.nvim" url = "https://github.com/ellisonleao/gruvbox.nvim"
}, },
["indent-blankline.nvim"] = { ["indent-blankline.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/indent-blankline.nvim",
url = "https://github.com/lukas-reineke/indent-blankline.nvim" url = "https://github.com/lukas-reineke/indent-blankline.nvim"
}, },
["lualine.nvim"] = { ["lualine.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/lualine.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim" url = "https://github.com/nvim-lualine/lualine.nvim"
}, },
["mason-lspconfig.nvim"] = {
loaded = true,
path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason.nvim"] = {
loaded = true,
path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/mason.nvim",
url = "https://github.com/williamboman/mason.nvim"
},
["nvim-autopairs"] = { ["nvim-autopairs"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-autopairs", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-autopairs",
url = "https://github.com/windwp/nvim-autopairs" url = "https://github.com/windwp/nvim-autopairs"
}, },
["nvim-cmp"] = { ["nvim-cmp"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-cmp", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp" url = "https://github.com/hrsh7th/nvim-cmp"
}, },
["nvim-colorizer.lua"] = { ["nvim-colorizer.lua"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-colorizer.lua",
url = "https://github.com/norcalli/nvim-colorizer.lua" url = "https://github.com/norcalli/nvim-colorizer.lua"
}, },
["nvim-lsp-installer"] = {
loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer",
url = "https://github.com/williamboman/nvim-lsp-installer"
},
["nvim-lspconfig"] = { ["nvim-lspconfig"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig" url = "https://github.com/neovim/nvim-lspconfig"
}, },
["nvim-tree.lua"] = { ["nvim-tree.lua"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
url = "https://github.com/kyazdani42/nvim-tree.lua" url = "https://github.com/kyazdani42/nvim-tree.lua"
}, },
["nvim-treesitter"] = { ["nvim-treesitter"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-treesitter", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter" url = "https://github.com/nvim-treesitter/nvim-treesitter"
}, },
["nvim-ts-autotag"] = { ["nvim-ts-autotag"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-ts-autotag", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-ts-autotag",
url = "https://github.com/windwp/nvim-ts-autotag" url = "https://github.com/windwp/nvim-ts-autotag"
}, },
["nvim-web-devicons"] = { ["nvim-web-devicons"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons" url = "https://github.com/kyazdani42/nvim-web-devicons"
}, },
["packer.nvim"] = { ["packer.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/packer.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim" url = "https://github.com/wbthomason/packer.nvim"
}, },
["plenary.nvim"] = { ["plenary.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/plenary.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim" url = "https://github.com/nvim-lua/plenary.nvim"
}, },
smartim = {
loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/smartim",
url = "https://github.com/ybian/smartim"
},
["telescope.nvim"] = { ["telescope.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/telescope.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim" url = "https://github.com/nvim-telescope/telescope.nvim"
}, },
["toggleterm.nvim"] = { ["toggleterm.nvim"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/toggleterm.nvim", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/toggleterm.nvim",
url = "https://github.com/akinsho/toggleterm.nvim" url = "https://github.com/akinsho/toggleterm.nvim"
}, },
["vim-mergetool"] = {
loaded = true,
path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/vim-mergetool",
url = "https://github.com/samoshkin/vim-mergetool"
},
["vim-template"] = { ["vim-template"] = {
loaded = true, loaded = true,
path = "/Users/light/.local/share/nvim/site/pack/packer/start/vim-template", path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/vim-template",
url = "https://github.com/aperezdc/vim-template" url = "https://github.com/aperezdc/vim-template"
},
vimtex = {
loaded = true,
path = "/Users/veypi/.local/share/nvim/site/pack/packer/start/vimtex",
url = "https://github.com/lervag/vimtex"
} }
} }

View File

@ -10,3 +10,4 @@
yarn global add fixjson yarn global add fixjson
yarn global add prettier yarn global add prettier
pip install yapf pip install yapf
pip install codespell