lazyvim, autocmds, options, keymaps, plugins added

This commit is contained in:
m1ngsama 2024-12-10 00:40:12 +08:00
parent b65992aa82
commit 3dde844782
8 changed files with 257 additions and 72 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.json

View file

@ -1,71 +1,13 @@
-- m1ngsama's neovim config -- if Neovim 0.9+, use vim.loade speedup module loading
if vim.loader then
-- 行号 vim.loader.enable()
local set = vim.o
set.number = true
set.relativenumber = true
-- 剪贴板
set.clipboard = "unnamed"
-- copy后高亮
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
pattern = { "*" },
callback = function()
vim.highlight.on_yank({
timeout = 300,
})
end,
})
-- keybindings
local opt = { noremap = true, silent = true }
vim.g.mapleader = " "
vim.keymap.set("n", "<C-l>", "<C-w>l", opt)
vim.keymap.set("n", "<C-h>", "<C-w>h", opt)
vim.keymap.set("n", "<C-j>", "<C-w>j", opt)
vim.keymap.set("n", "<C-k>", "<C-w>k", opt)
vim.keymap.set("n", "<leader>v", "<C-w>v", opt)
vim.keymap.set("n", "<leader>s", "<C-w>s", opt)
vim.keymap.set("n", "<leader>[", "<C-o>", opt)
vim.keymap.set("n", "<leader>]", "<C-i>", opt)
-- https://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
vim.keymap.set("n", "j", [[v:count ? 'j' : 'gj']], { noremap = true, expr = true })
vim.keymap.set("n", "k", [[v:count ? 'k' : 'gk']], { noremap = true, expr = true })
-- lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", --latest stable release
lazypath,
})
end end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"RRethy/nvim-base16",
lazy = true,
},
{
cmd = "Telescope",
keys = {
{ "<leader>p", ":Telescope find_files<CR>", desc = "find files" },
{ "<leader>P", ":Telescope live_grep<CR>", desc = "grep files" },
{ "<leader>rs", ":Telescope resume<CR>", desc = "resume" },
{ "<leader>q", ":Telescope oldfiles<CR>", desc = "old files" },
},
'nvim-telescope/telescope.nvim',
tag = '0.1.3',
dependencies = { 'nvim-lua/plenary.nvim' },
},
})
vim.cmd.colorscheme("base16-tender") -- all use dump print
_G.dd = function(...)
require("util.debug").dump(...)
end
vim.print = _G.dd
-- use plugin
require("config.lazy")

View file

@ -1,6 +1,57 @@
{ {
"lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, "LazyVim": { "branch": "main", "commit": "3c605f547c594b509d83f8677bb7609c005edea5" },
"nvim-base16": { "branch": "master", "commit": "6ac181b5733518040a33017dde654059cd771b7c" }, "SchemaStore.nvim": { "branch": "main", "commit": "e2444a23307f869d7f8005eb27f5003c41b34ea8" },
"bufferline.nvim": { "branch": "main", "commit": "261a72b90d6db4ed8014f7bda976bcdc9dd7ce76" },
"catppuccin": { "branch": "main", "commit": "faf15ab0201b564b6368ffa47b56feefc92ce3f4" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"conform.nvim": { "branch": "master", "commit": "e76afe8f7976071fae308e31bf426f557a8ef339" },
"crates.nvim": { "branch": "main", "commit": "8bf8358ee326d5d8c11dcd7ac0bcc9ff97dbc785" },
"dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" },
"grug-far.nvim": { "branch": "main", "commit": "3707c4fb6ac982a1ca013c1b3bffa8e396f775cc" },
"indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" },
"lazy.nvim": { "branch": "main", "commit": "014d1d6d78df4e58f962158e6e00261d8632612c" },
"lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.ai": { "branch": "main", "commit": "ebb04799794a7f94628153991e6334c3304961b8" },
"mini.hipatterns": { "branch": "main", "commit": "f34975103a38b3f608219a1324cdfc58ea660b8b" },
"mini.icons": { "branch": "main", "commit": "54686be7d58807906cb2c8c2216e0bf9c044f19a" },
"mini.pairs": { "branch": "main", "commit": "7e834c5937d95364cc1740e20d673afe2d034cdb" },
"neo-tree.nvim": { "branch": "main", "commit": "ca340e0747a85a05c08a5ba5e183c70c0a355a7c" },
"noice.nvim": { "branch": "main", "commit": "7b1960c48078a8b2fb44a89db82f4fa637b2d7c8" },
"nui.nvim": { "branch": "main", "commit": "b1b9b75a2d8041e1c2234f7448c61f8468a4258d" },
"nvim-cmp": { "branch": "main", "commit": "ca4d3330d386e76967e53b85953c170658255ecb" },
"nvim-dap": { "branch": "master", "commit": "580d6e526358afd0e4bba053e68fd59cf581a161" },
"nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" },
"nvim-lint": { "branch": "master", "commit": "6b46370d02cd001509a765591a3ffc481b538794" },
"nvim-lspconfig": { "branch": "master", "commit": "b8b725659fa60d2c5f5bd7459bcfee1d8b34acd5" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" },
"nvim-treesitter": { "branch": "master", "commit": "0c26a5c4bc407fdbca545ab25cf6084fd069444b" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" },
"persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" } "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" },
"render-markdown.nvim": { "branch": "main", "commit": "3d2dc15542e56671dd14dfbfff63434ec21d8fcd" },
"rustaceanvim": { "branch": "master", "commit": "a244210b28f9055c2b4cfa85c92c8a71c13671c9" },
"snacks.nvim": { "branch": "main", "commit": "fc71e36c90f44e0e6180ac6c5f035817709569d8" },
"tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"tokyonight.nvim": { "branch": "main", "commit": "355e2842291dbf51b2c5878e9e37281bbef09783" },
"trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" },
"ts-comments.nvim": { "branch": "main", "commit": "2002692ad1d3f6518d016550c20c2a890f0cbf0e" },
"which-key.nvim": { "branch": "main", "commit": "9b365a6428a9633e3eeb34dbef1b791511c54f70" },
"yanky.nvim": { "branch": "main", "commit": "f9b905994cccf3c55f41af3a0a1f4c76c844e411" }
} }

12
lua/config/autocmds.lua Normal file
View file

@ -0,0 +1,12 @@
-- Turn off paste mode when leaving insert
vim.api.nvim_create_autocmd("InsertLeave", {
pattern = "*",
command = "set nopaste",
})
-- Disable the concealing in some file formats
vim.api.nvim_create_autocmd("FileType", {
pattern = { "json", "jsonc", "markdown" },
callback = function()
vim.opt.conceallevel = 0
end,
})

34
lua/config/keymaps.lua Normal file
View file

@ -0,0 +1,34 @@
local discipline = require("m1ngsama.discipline")
discipline.trigger()
-- Neovim api to replace classic vim.api.nvim_set_keymap
local keymap = vim.keymap
local opts = { noremap = true, silent = true }
-- Keymap without affecting the registers
keymap.set("n", "x", '"_x')
keymap.set("n", "<Leader>p", '"0p')
keymap.set("n", "<Leader>P", '"0P')
keymap.set("v", "<Leader>p", '"0p')
keymap.set("n", "<Leader>c", '"_c')
keymap.set("n", "<Leader>C", '"_C')
keymap.set("v", "<Leader>c", '"_c')
keymap.set("v", "<Leader>C", '"_C')
keymap.set("n", "<Leader>d", '"_d')
keymap.set("n", "<Leader>D", '"_D')
keymap.set("v", "<Leader>d", '"_d')
keymap.set("v", "<Leader>D", '"_D')
-- Increment/decrement
keymap.set("n", "+", "<C-a>")
keymap.set("n", "-", "<C-x>")
-- Dlete a word backwards
keymap.set("n", "dw", 'vb"_d')
-- Select all
keymap.set("n", "<C-a>", "gg<S-v>G")
-- Disable continuations

73
lua/config/lazy.lua Normal file
View file

@ -0,0 +1,73 @@
-- lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.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)
require("lazy").setup({
spec = {
-- add LazyVim and import plugins
{
"LazyVim/LazyVim",
import = "lazyvim.plugins",
opts = {
colorscheme = "solarized-osaka",
news = {
lazyvim = true,
neovim = true,
},
},
},
{ import = "lazyvim.plugins.extras.linting.eslint" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.coding.copilot" },
{ import = "lazyvim.plugins.extras.dap.core" },
{ import = "lazyvim.plugins.extras.util.mini-hipatterns" },
{ import = "lazyvim.plugins.extras.coding.yanky" },
{ import = "lazyvim.plugins.extras.editors.mini-files" },
{ import = "lazyvim.plugins.extras.util.project" },
},
defaults = {
lazy = false,
version = false,
},
-- automatically check for plugin updates
checker = { enabled = true },
performance = {
cache = {
enabled = true,
},
rtp = {
disabled_plugins = {
"gzip",
"netrwPlugin",
"rplugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
ui = {
custom_keys = {
["<localleader>d"] = function(plugin)
dd(plugin)
end,
},
},
debug = false,
})

34
lua/config/options.lua Normal file
View file

@ -0,0 +1,34 @@
vim.g.mapleader = " "
-- open and save file as utf-8
vim.opt.encoding = "utf-8"
vim.opt.fileencoding = "utf-8"
vim.opt.number = true
vim.opt.title = true
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.hlsearch = true
-- disabled the file~
vim.opt.backup = false
vim.opt.showcmd = true
vim.opt.cmdheight = 1
vim.opt.laststatus = 3
vim.opt.expandtab = true
vim.opt.scolloff = 10
-- vim.opt.shell = "fish"
vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" }
-- use :substitute preview split windows
vim.opt.inccommand = "split"
vim.opt.ignorecase = true
vim.opt.smarttab = true
vim.opt.breakindent = true
vim.opt.shiftwidth = true
vim.opt.tabstop = true
vim.opt.title = true
vim.opt.title = true

View file

@ -0,0 +1,38 @@
local M = {}
function M.trigger()
---@type table?
local id
local ok = true
for _, key in ipairs({ "h", "j", "k", "l", "+", "-" }) do
local count = 0
local timer = assert(vim.loop,new_timer())
local map = key
vim.keymap.set("n", key, function()
if vim.v.count > 0 then
count = 0
end
if count >= 10 then
ok, id = pcall(vim.notify, "Hold on! XD", vim.log.levels.WARN, {
icon = "🔫",
replace = id,
keep = function()
return count >= 10
end,
})
if not ok then
id = nil
retrun map
end
else
count = count + 1
timer:start(2000, 0, function()
count = 0
end)
return map
end
end, { expr = true, silent = true })
end
end
return M