Initial Neovim configuration
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- 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
|
||||
-- with `vim.api.nvim_create_autocmd`
|
||||
--
|
||||
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
|
||||
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
|
||||
@@ -0,0 +1,66 @@
|
||||
-- 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
|
||||
-- -- F6:选择当前标签页中可见的窗格
|
||||
local function choose_window()
|
||||
local api = vim.api
|
||||
local current = api.nvim_get_current_win()
|
||||
local items = {}
|
||||
|
||||
for _, win in ipairs(api.nvim_tabpage_list_wins(0)) do
|
||||
local config = api.nvim_win_get_config(win)
|
||||
|
||||
if config.focusable ~= false and not config.hide then
|
||||
local buf = api.nvim_win_get_buf(win)
|
||||
local ft = vim.bo[buf].filetype
|
||||
local name = api.nvim_buf_get_name(buf)
|
||||
local label
|
||||
|
||||
if vim.bo[buf].buftype == "terminal" then
|
||||
label = "终端"
|
||||
elseif ft == "neo-tree" or ft == "NvimTree" then
|
||||
label = "文件树"
|
||||
elseif name ~= "" then
|
||||
label = vim.fn.fnamemodify(name, ":~:.")
|
||||
else
|
||||
label = ft ~= "" and ft or "未命名文件"
|
||||
end
|
||||
|
||||
items[#items + 1] = {
|
||||
win = win,
|
||||
label = string.format("%s [%d] %s", win == current and "●" or " ", api.nvim_win_get_number(win), label),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
vim.ui.select(items, {
|
||||
prompt = "切换到窗格",
|
||||
format_item = function(item)
|
||||
return item.label
|
||||
end,
|
||||
}, function(item)
|
||||
if not item then
|
||||
return
|
||||
end
|
||||
|
||||
-- 等选择窗口关闭、恢复焦点后,再进入目标窗格
|
||||
vim.schedule(function()
|
||||
if api.nvim_win_is_valid(item.win) then
|
||||
api.nvim_set_current_win(item.win)
|
||||
|
||||
local buf = api.nvim_win_get_buf(item.win)
|
||||
if vim.bo[buf].buftype == "terminal" then
|
||||
vim.cmd.startinsert()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("ChooseWindow", choose_window, { force = true })
|
||||
|
||||
local opts = { desc = "选择窗格", silent = true }
|
||||
|
||||
vim.keymap.set("n", "<F6>", "<Cmd>ChooseWindow<CR>", opts)
|
||||
vim.keymap.set("i", "<F6>", "<Esc><Cmd>ChooseWindow<CR>", opts)
|
||||
vim.keymap.set("t", "<F6>", "<C-\\><C-n><Cmd>ChooseWindow<CR>", opts)
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
-- 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
|
||||
Reference in New Issue
Block a user