Last active
August 14, 2025 03:42
-
-
Save aofei/27d1425c22c4f570058acd7197a71151 to your computer and use it in GitHub Desktop.
Aofei Sheng flavored nvim/init.lua file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | |
if not vim.uv.fs_stat(lazypath) then | |
vim.fn.system({ | |
"git", | |
"clone", | |
"--filter=blob:none", | |
"https://github.com/folke/lazy.nvim.git", | |
"--branch=stable", | |
lazypath, | |
}) | |
end | |
vim.opt.rtp:prepend(lazypath) | |
local afterloads = {} | |
local original_require = require | |
require = function(modname) | |
local result = original_require(modname) | |
local afterload = afterloads[modname] | |
if afterload then | |
afterload() | |
end | |
return result | |
end | |
afterloads["lazyvim.config.options"] = function() | |
vim.g.mapleader = nil | |
vim.g.maplocalleader = nil | |
vim.g.lazyvim_prettier_needs_config = true -- Require a config file for Prettier | |
vim.g.minipairs_disable = true -- Disable minipairs | |
vim.g.snacks_animate = false -- Disable all animations | |
vim.opt.colorcolumn = "81" -- Highlight column 81 | |
vim.opt.conceallevel = 0 -- Disable conceal | |
vim.opt.expandtab = false -- Use tabs | |
vim.opt.relativenumber = false -- Disable relative line numbers | |
vim.opt.shiftwidth = 8 -- Size of an indent | |
vim.opt.tabstop = 8 -- Number of spaces tabs count for | |
end | |
afterloads["lazyvim.config.autocmds"] = function() | |
-- Special settings for all filetypes | |
vim.api.nvim_create_autocmd("FileType", { | |
pattern = "*", | |
callback = function() | |
vim.opt_local.spell = false | |
end, | |
}) | |
-- Special settings for some verbose filetypes | |
vim.api.nvim_create_autocmd({ "FileType" }, { | |
pattern = { | |
"css", | |
"graphql", | |
"hcl", | |
"html", | |
"javascript", | |
"javascriptreact", | |
"json", | |
"jsonc", | |
"less", | |
"lua", | |
"markdown", | |
"markdown.mdx", | |
"proto", | |
"sass", | |
"sql", | |
"tmux", | |
"toml", | |
"typescript", | |
"typescriptreact", | |
"vim", | |
"vue", | |
"xml", | |
"yaml", | |
}, | |
callback = function() | |
vim.opt_local.colorcolumn = "121" | |
vim.opt_local.shiftwidth = 2 | |
vim.opt_local.tabstop = 2 | |
end, | |
}) | |
-- Use spaces instead of tabs for some filetypes | |
vim.api.nvim_create_autocmd({ "FileType" }, { | |
pattern = { | |
"markdown", | |
"markdown.mdx", | |
}, | |
callback = function() | |
vim.opt_local.expandtab = true | |
end, | |
}) | |
end | |
afterloads["lazyvim.config.keymaps"] = function() | |
-- Toggle mouse | |
local mouse = vim.o.mouse ~= "" and vim.o.mouse or "a" | |
Snacks.toggle | |
.new({ | |
name = "Mouse", | |
get = function() | |
return vim.o.mouse ~= "" | |
end, | |
set = function(state) | |
vim.o.mouse = state and mouse or "" | |
end, | |
}) | |
:map("<leader>um") | |
end | |
require("lazy").setup({ | |
spec = { | |
-- LazyVim | |
{ | |
{ | |
"LazyVim/LazyVim", | |
import = "lazyvim.plugins", | |
opts = { colorscheme = "catppuccin" }, | |
}, | |
{ import = "lazyvim.plugins.extras.ai.copilot" }, | |
{ import = "lazyvim.plugins.extras.coding.mini-surround" }, | |
{ import = "lazyvim.plugins.extras.coding.yanky" }, | |
{ import = "lazyvim.plugins.extras.dap.core" }, | |
{ import = "lazyvim.plugins.extras.dap.nlua" }, | |
{ import = "lazyvim.plugins.extras.editor.overseer" }, | |
{ import = "lazyvim.plugins.extras.editor.refactoring" }, | |
{ import = "lazyvim.plugins.extras.formatting.prettier" }, | |
{ import = "lazyvim.plugins.extras.lang.clangd" }, | |
{ import = "lazyvim.plugins.extras.lang.git" }, | |
{ import = "lazyvim.plugins.extras.lang.go" }, | |
{ import = "lazyvim.plugins.extras.lang.typescript" }, | |
-- { import = "lazyvim.plugins.extras.lang.vue" }, | |
{ import = "lazyvim.plugins.extras.linting.eslint" }, | |
{ import = "lazyvim.plugins.extras.test.core" }, | |
{ import = "lazyvim.plugins.extras.util.mini-hipatterns" }, | |
-- Vue | |
{ | |
-- recommended = function() | |
-- return LazyVim.extras.wants({ | |
-- ft = "vue", | |
-- root = { "vue.config.js" }, | |
-- }) | |
-- end, | |
-- depends on the typescript extra | |
{ import = "lazyvim.plugins.extras.lang.typescript" }, | |
{ | |
"nvim-treesitter/nvim-treesitter", | |
opts = { ensure_installed = { "vue", "css" } }, | |
}, | |
-- Configure vtsls (the TypeScript plugin host) with @vue/typescript-plugin | |
{ | |
"neovim/nvim-lspconfig", | |
opts = function(_, opts) | |
opts.servers.vtsls = opts.servers.vtsls or {} | |
opts.servers.vtsls.filetypes = opts.servers.vtsls.filetypes or {} | |
table.insert(opts.servers.vtsls.filetypes, "vue") | |
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { | |
{ | |
name = "@vue/typescript-plugin", | |
location = LazyVim.get_pkg_path( | |
"vue-language-server", | |
"/node_modules/@vue/language-server" | |
), | |
languages = { "vue" }, | |
configNamespace = "typescript", | |
enableForWorkspaceTypeScriptVersions = true, | |
}, | |
}) | |
end, | |
}, | |
-- Hook vue_ls to forward requests to vtsls | |
{ | |
"neovim/nvim-lspconfig", | |
opts = { | |
servers = { | |
volar = { -- when LazyVim switches to nvim-lspconfig ≥ v2.2.0 rename this to `vue_ls` | |
on_init = function(client) | |
client.handlers["tsserver/request"] = function(_, result, context) | |
-- find the vtsls client | |
local clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = "vtsls" }) | |
if #clients == 0 then | |
vim.notify( | |
"Could not find `vtsls` client, Vue LSP features will be disabled", | |
vim.log.levels.ERROR | |
) | |
return | |
end | |
local ts_client = clients[1] | |
-- unpack the forwarded request | |
local params = unpack(result) | |
local id, command, payload = unpack(params) | |
-- forward it | |
ts_client:exec_cmd({ | |
title = "vue_request_forward", | |
command = "typescript.tsserverRequest", | |
arguments = { command, payload }, | |
}, { bufnr = context.bufnr }, function(_, resp) | |
-- send the tsserver/response back to Vue LSP | |
client.notify("tsserver/response", { { id, resp.body } }) | |
end) | |
end | |
end, | |
}, | |
}, | |
}, | |
}, | |
}, | |
-- Polish it up a bit | |
{ | |
{ | |
"folke/snacks.nvim", | |
opts = { | |
indent = { | |
indent = { hl = "IblIndent" }, | |
scope = { enabled = false }, | |
}, | |
picker = { hidden = true }, | |
scroll = { enabled = false }, | |
terminal = { | |
win = { | |
position = "float", | |
keys = {}, | |
}, | |
}, | |
}, | |
}, | |
{ | |
"nvim-treesitter/nvim-treesitter", | |
opts = { ensure_installed = { "scss" } }, | |
}, | |
{ | |
"stevearc/conform.nvim", | |
opts = function(_, opts) | |
for _, ft in ipairs({ | |
"fish", | |
"go", | |
"sh", | |
}) do | |
opts.formatters_by_ft[ft] = nil | |
end | |
end, | |
}, | |
{ | |
"neovim/nvim-lspconfig", | |
opts = { | |
inlay_hints = { enabled = false }, | |
servers = { | |
gopls = { | |
settings = { | |
gopls = { | |
analyses = { | |
unusedparams = false, | |
ST1000 = false, | |
ST1003 = false, | |
ST1012 = false, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
}, | |
-- Match-up | |
{ | |
"andymass/vim-matchup", | |
event = "BufReadPost", | |
config = function() | |
vim.g.matchup_matchparen_offscreen = { method = "status_manual" } | |
end, | |
}, | |
-- Markdown Preview | |
{ | |
"iamcco/markdown-preview.nvim", | |
cmd = { | |
"MarkdownPreviewToggle", | |
"MarkdownPreview", | |
"MarkdownPreviewStop", | |
}, | |
build = function() | |
require("lazy").load({ plugins = { "markdown-preview.nvim" } }) | |
vim.fn["mkdp#util#install"]() | |
end, | |
keys = { | |
{ | |
"<leader>cp", | |
ft = "markdown", | |
"<cmd>MarkdownPreviewToggle<cr>", | |
desc = "Markdown Preview", | |
}, | |
}, | |
config = function() | |
vim.cmd([[do FileType]]) | |
end, | |
}, | |
}, | |
performance = { | |
rtp = { | |
-- Disable some RTP plugins | |
disabled_plugins = { | |
"gzip", | |
"matchit", | |
"matchparen", | |
"netrwPlugin", | |
"tarPlugin", | |
"tohtml", | |
"tutor", | |
"zipPlugin", | |
}, | |
}, | |
}, | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"LazyVim": { "branch": "main", "commit": "25abbf546d564dc484cf903804661ba12de45507" }, | |
"blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, | |
"blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, | |
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, | |
"catppuccin": { "branch": "main", "commit": "3aaf3ab60221bca8edb1354e41bd514a22c89de2" }, | |
"clangd_extensions.nvim": { "branch": "main", "commit": "b67cc417d9020fb4b83d46662351b4d16894905e" }, | |
"conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, | |
"copilot.lua": { "branch": "master", "commit": "0f2fd3829dd27d682e46c244cf48d9715726f612" }, | |
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, | |
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, | |
"gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, | |
"grug-far.nvim": { "branch": "main", "commit": "385d1949dc21d0c39e7a74b4f4a25da18817bc86" }, | |
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, | |
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, | |
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, | |
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, | |
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, | |
"mason-nvim-dap.nvim": { "branch": "main", "commit": "86389a3dd687cfaa647b6f44731e492970034baa" }, | |
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, | |
"mini.ai": { "branch": "main", "commit": "1cd4f021a05c29acd4ab511c0981da14217daf38" }, | |
"mini.hipatterns": { "branch": "main", "commit": "2b78f3d475d60ea1793a6d595ff65a0db9ac3a67" }, | |
"mini.icons": { "branch": "main", "commit": "b8f6fa6f5a3fd0c56936252edcd691184e5aac0c" }, | |
"mini.pairs": { "branch": "main", "commit": "1e1ca3f60f58d4050bf814902b472eec9963a5dd" }, | |
"mini.surround": { "branch": "main", "commit": "7a8606333affe7ce637a0ba91bbafc46fc42bfa0" }, | |
"neotest": { "branch": "master", "commit": "ce178308ea30f96667f1c11f022880d8c04cafd3" }, | |
"neotest-golang": { "branch": "main", "commit": "3f0617ee9c3e6fd3d0d88645cd2e1751dad60c1f" }, | |
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, | |
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, | |
"nvim-dap": { "branch": "master", "commit": "a479e25ed5b5d331fb46ee4b9e160ff02ac64310" }, | |
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, | |
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, | |
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, | |
"nvim-lint": { "branch": "master", "commit": "7ef127aaede2a4d5ad8df8321e2eb4e567f29594" }, | |
"nvim-lspconfig": { "branch": "master", "commit": "45ff1914044de7dbd4cd85053dc09f47312a2f4d" }, | |
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, | |
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, | |
"nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, | |
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, | |
"one-small-step-for-vimkind": { "branch": "main", "commit": "91b4e0fb0d640def73812aceb22dafb99261dd67" }, | |
"overseer.nvim": { "branch": "master", "commit": "fe7b2f9ba263e150ab36474dfc810217b8cf7400" }, | |
"persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" }, | |
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, | |
"refactoring.nvim": { "branch": "master", "commit": "74b608dfee827c2372250519d433cc21cb083407" }, | |
"snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, | |
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, | |
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, | |
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, | |
"ts-comments.nvim": { "branch": "main", "commit": "1bd9d0ba1d8b336c3db50692ffd0955fe1bb9f0c" }, | |
"vim-matchup": { "branch": "master", "commit": "b4efd6a97380b99bb9f5eb80c9002e061402c288" }, | |
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, | |
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" } | |
} |
Comments are disabled for this gist.