change lazyvim

This commit is contained in:
veypi
2024-10-14 23:51:28 +08:00
parent e53c7aa336
commit 5ae3bc2041
38 changed files with 567 additions and 1143 deletions
+3
View File
@@ -0,0 +1,3 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
+3
View File
@@ -0,0 +1,3 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
+53
View File
@@ -0,0 +1,53 @@
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)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
+4
View File
@@ -0,0 +1,4 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
--
-113
View File
@@ -1,113 +0,0 @@
-- r rename
-- d delete
-- s open item in system tool
-- a add file/dir
require 'nvim-tree'.setup {
sort_by = "case_sensitive",
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
custom = {},
exclude = {},
},
git = {
enable = true,
ignore = true,
timeout = 400,
},
view = {
width = 24,
}
}
vim.opt.background = "dark" -- or "light" for light mode
vim.cmd([[colorscheme gruvbox]])
vim.opt.termguicolors = true
require("bufferline").setup {
options = {
sort_by = 'id',
numbers = 'ordinal',
-- 左侧让出 nvim-tree 的位置
diagnostics = "nvim_lsp";
offsets = { {
filetype = "NvimTree",
text = "veypi.com",
highlight = "Directory",
text_align = "center"
} }
}
}
vim.g.gitblame_display_virtual_text = 0 -- Disable virtual text
vim.g.gitblame_date_format = "%r"
local git_blame = require('gitblame')
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {},
always_divide_middle = true,
globalstatus = false,
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {
{ git_blame.get_current_blame_text, cond = git_blame.is_blame_text_available },
'filename'
},
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = {}
}
require 'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all"
ensure_installed = { "c", "lua", "rust", "go", "javascript", "html", "json", "python", "typescript", "vue", "css" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- List of parsers to ignore installing (for "all")
ignore_install = { "" },
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 = {},
-- 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,
},
}
-2
View File
@@ -1,2 +0,0 @@
return {
}
-30
View File
@@ -1,30 +0,0 @@
-- 部分补全代码不支持autoformat 需使用efm自动补全
-- https://github.com/mattn/efm-langserver
return {
init_options = { documentFormatting = true },
filetypes = { 'python', 'json', 'css', 'yaml' },
settings = {
rootMarkers = { ".git/" },
languages = {
python = {
-- pip install yapf
{ formatCommand = "yapf --quiet", formatStdin = true }
},
json = {
-- yarn global add fixjson
{ formatCommand = "fixjson", formatStdin = true }
},
-- yarn global add yaml-lint
yaml = {
{ formatCommand = "yamllint -f parsable -", formatStdin = true }
},
css = {
-- yarn global add prettier
{ formatCommand = "prettier --tab-width=4 ${--single-quote:singleQuote} --parser css", formatStdin = true }
-- { formatCommand = "prettier ${--tab-width:tabWidth} ${--single-quote:singleQuote} --parser css", formatStdin = true }
}
}
}
}
-14
View File
@@ -1,14 +0,0 @@
local eslint_config = require("lspconfig.server_configurations.eslint")
return {
on_attach = function(client, bufnr)
-- neovim's LSP client does not currently support dynamic capabilities registration, so we need to set
-- the resolved capabilities of the eslint server ourselves!
client.resolved_capabilities.document_formatting = true
end,
settings = {
format = { enable = true },
},
print(unpack(eslint_config.default_config.cmd)),
cmd = { "yarn", "exec", unpack(eslint_config.default_config.cmd) }
}
View File
-27
View File
@@ -1,27 +0,0 @@
local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
return {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Setup your lua path
path = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { 'vim' },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false
},
},
},
}
View File
-145
View File
@@ -1,145 +0,0 @@
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", "sqlls", "efm", "html" },
}
local lspconfig = require('lspconfig')
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- 需特别配置的lsp插件
-- { key: 语言 value: 配置文件 }
-- pyright 不支持autoformat
local servers = {
sumneko_lua = require "lsp.lua", -- /lua/lsp/lua.lua
tailwindcss = require "lsp.tailwind",
sqlls = require "lsp.sqlls",
efm = require "lsp.efm",
volar = require "lsp.volar"
}
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.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local keyOpts = { noremap = true, silent = true }
-- vim.api.nvim_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
vim.api.nvim_set_keymap('n', '<C-]>', '<cmd>lua vim.lsp.buf.definition()<CR>', keyOpts)
vim.api.nvim_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', keyOpts)
vim.api.nvim_set_keymap('n', 'e[', '<cmd>lua vim.diagnostic.goto_prev()<CR>', keyOpts)
vim.api.nvim_set_keymap('n', 'e]', '<cmd>lua vim.diagnostic.goto_next()<CR>', keyOpts)
-- vim.cmd [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
-- luasnip setup
local luasnip = require 'luasnip'
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
require('nvim-ts-autotag').setup()
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ 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
-- }
}
}
-29
View File
@@ -1,29 +0,0 @@
#! /usr/bin/env lua
--
-- sql.lua
-- Copyright (C) 2022 veypi <i@veypi.com>
--
-- Distributed under terms of the Apache license.
--
return {
settings = {
sqlls = {
connections = {
{
driver = 'mysql',
dataSourceName = 'root:123456@tcp(127.0.0.1:3306)/test',
},
},
},
},
on_attach = function(client)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
-- print(vim.inspect(client))
end,
}
-3
View File
@@ -1,3 +0,0 @@
return {
filetypes = { "html", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte" }
}
-3
View File
@@ -1,3 +0,0 @@
return {
filetypes = { 'vue', 'typescript', 'javascript', 'css' }
}
-102
View File
@@ -1,102 +0,0 @@
-- 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]]
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 代码补全插件
use 'neovim/nvim-lspconfig'
use 'windwp/nvim-autopairs'
use 'windwp/nvim-ts-autotag'
use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-omni'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-nvim-lsp'
use 'saadparwaiz1/cmp_luasnip'
use 'L3MON4D3/LuaSnip'
-- 格式化
use 'mhartington/formatter.nvim'
-- 界面插件
use { "ellisonleao/gruvbox.nvim" }
-- need to install nerd font
use 'kyazdani42/nvim-web-devicons'
use 'kyazdani42/nvim-tree.lua'
use 'akinsho/bufferline.nvim'
use 'nvim-lualine/lualine.nvim'
use 'f-person/git-blame.nvim'
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
-- 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)
+193
View File
@@ -0,0 +1,193 @@
-- since this is just an example spec, don't actually load anything here and return an empty spec
-- stylua: ignore
if true then return {} end
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
--
-- In your plugin files, you can:
-- * add extra plugins
-- * disable/enabled LazyVim plugins
-- * override the configuration of LazyVim plugins
return {
-- add gruvbox
{ "ellisonleao/gruvbox.nvim" },
-- Configure LazyVim to load gruvbox
{
"LazyVim/LazyVim",
opts = {
colorscheme = "gruvbox",
},
},
-- change trouble config
{
"folke/trouble.nvim",
-- opts will be merged with the parent spec
opts = { use_diagnostic_signs = true },
},
-- disable trouble
{ "folke/trouble.nvim", enabled = false },
-- override nvim-cmp and add cmp-emoji
{
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, { name = "emoji" })
end,
},
-- change some telescope options and a keymap to browse plugin files
{
"nvim-telescope/telescope.nvim",
keys = {
-- add a keymap to browse plugin files
-- stylua: ignore
{
"<leader>fp",
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
desc = "Find Plugin File",
},
},
-- change some options
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = { prompt_position = "top" },
sorting_strategy = "ascending",
winblend = 0,
},
},
},
-- add pyright to lspconfig
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- pyright will be automatically installed with mason and loaded with lspconfig
pyright = {},
},
},
},
-- add tsserver and setup with typescript.nvim instead of lspconfig
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/typescript.nvim",
init = function()
require("lazyvim.util").lsp.on_attach(function(_, buffer)
-- stylua: ignore
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
end)
end,
},
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- tsserver will be automatically installed with mason and loaded with lspconfig
tsserver = {},
},
-- you can do any additional lsp server setup here
-- return true if you don't want this server to be setup with lspconfig
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
setup = {
-- example to setup with typescript.nvim
tsserver = function(_, opts)
require("typescript").setup({ server = opts })
return true
end,
-- Specify * to use this function as a fallback for any server
-- ["*"] = function(server, opts) end,
},
},
},
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
{ import = "lazyvim.plugins.extras.lang.typescript" },
-- add more treesitter parsers
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"bash",
"html",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"tsx",
"typescript",
"vim",
"yaml",
},
},
},
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
-- would overwrite `ensure_installed` with the new value.
-- If you'd rather extend the default config, use the code below instead:
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- add tsx and treesitter
vim.list_extend(opts.ensure_installed, {
"tsx",
"typescript",
})
end,
},
-- the opts function can also be used to change the default opts:
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function(_, opts)
table.insert(opts.sections.lualine_x, "😄")
end,
},
-- or you can return new options to override all the defaults
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function()
return {
--[[add your custom lualine config here]]
}
end,
},
-- use mini.starter instead of alpha
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
{ import = "lazyvim.plugins.extras.lang.json" },
-- add any tools you want to have installed below
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
},
},
}
+30
View File
@@ -0,0 +1,30 @@
return {
{
"folke/noice.nvim",
opts = function(_, opts)
opts.presets = {
command_palette = {
views = {
cmdline_popup = {
position = {
row = 18,
col = "50%",
},
size = {
min_width = 60,
width = "auto",
height = "auto",
},
},
cmdline_popupmenu = {
position = {
row = 20,
col = "50%",
},
},
},
},
}
end,
},
}
-40
View File
@@ -1,40 +0,0 @@
require('Comment').setup()
require('nvim-autopairs').setup()
require("toggleterm").setup {
open_mapping = [[<C-\>]],
hide_numbers = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
terminal_mappings = true,
shell = vim.o.shell,
}
-- require("autosave").setup {
-- enabled = true,
-- execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"),
-- events = { "BufLeave", "FocusLost" },
-- conditions = {
-- exists = true,
-- filename_is_not = {},
-- filetype_is_not = {},
-- modifiable = true
-- },
-- write_all_buffers = true,
-- on_off_commands = true,
-- clean_command_line_interval = 0,
-- debounce_delay = 135
-- }
require('gitsigns').setup {
}
require("indent_blankline").setup {
-- for example, context is off by default, use this to turn it on
show_current_context = true,
show_current_context_start = true,
}
require 'colorizer'.setup()