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
+77 -48
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()
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.
@@ -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()]]
-- 安装列表
-- 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
local luasnip = require 'luasnip'
@@ -114,3 +112,34 @@ cmp.setup {
{ 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
-- }
}
}
+37 -6
View File
@@ -1,18 +1,38 @@
-- This file can be loaded by calling `lua require('plugins')` from your init.vim
-- 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()
-- Packer can manage itself
-- 包管理
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-ts-autotag'
use 'hrsh7th/nvim-cmp'
@@ -23,8 +43,11 @@ return require('packer').startup(function()
use 'saadparwaiz1/cmp_luasnip'
use 'L3MON4D3/LuaSnip'
-- 格式化
use 'mhartington/formatter.nvim'
-- Frame
-- 界面插件
use { "ellisonleao/gruvbox.nvim" }
-- need to install nerd font
@@ -41,31 +64,39 @@ return require('packer').startup(function()
-- utils
-- 注释插件
use 'numToStr/Comment.nvim'
-- 模糊查找工具 文件跳转
use {
'nvim-telescope/telescope.nvim',
requires = { { 'nvim-lua/plenary.nvim' } }
}
-- vim 内打开终端工具
use { "akinsho/toggleterm.nvim" }
-- 自动保存
use "Pocco81/AutoSave.nvim"
-- git状态
use 'lewis6991/gitsigns.nvim'
-- 新文件模板
use 'aperezdc/vim-template'
-- 缩进标记
use "lukas-reineke/indent-blankline.nvim"
-- 显示颜色 如#0f0
use "norcalli/nvim-colorizer.lua"
-- git 查看merge信息
-- ~/.gitconfig
-- [merge]
-- conflictStyle = diff3
use "samoshkin/vim-mergetool"
-- latex 工具支持
use 'lervag/vimtex'
end)