refactor: fix bugs, dedup :R, cleanup dead code, enable ufo+go.nvim, unify capabilities

This commit is contained in:
QQ 2026-06-10 21:59:29 +08:00
parent a296f56268
commit 94274b126a
16 changed files with 77 additions and 147 deletions

View File

@ -1,9 +1,8 @@
G = require('G')
-- Clone lazy.nvim (only needed for native Neovim, not VSCode)
if not G.g.vscode then
local lazypath = G.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not G.loop.fs_stat(lazypath) then
G.fn.system({
"git",
@ -13,34 +12,23 @@ if not G.g.vscode then
"--branch=stable",
lazypath,
})
G.fn.system({
"git",
"config",
"--global",
"credential.helper",
"store",
})
end
G.opt.rtp:prepend(lazypath)
require("keymap")
if G.g.vscode then
require('vscode')
else
require("options")
local clone_prefix = G.use_ssh and "git@github.com:%s.git" or "https://github.com/%s.git"
require("lazy").setup(
require('plugs'), {
lockfile = G.fn.stdpath("data") .. "/lazy/lazy-lock.json",
git = {
url_format = clone_prefix,
}
}
)
end
end
require("keymap")
if G.g.vscode then
require('vscode')
else
require("options")
local clone_prefix = G.use_ssh and "git@github.com:%s.git" or "https://github.com/%s.git"
require("lazy").setup(
require('plugs'), {
lockfile = G.fn.stdpath("data") .. "/lazy/lazy-lock.json",
git = {
url_format = clone_prefix,
}
}
)
end

View File

@ -54,6 +54,14 @@ function G.au(even, opts)
return G.api.nvim_create_autocmd(even, opts)
end
function G.run_cmd(cmd)
return function()
G.cmd [[set splitbelow | sp]]
G.cmd("term " .. cmd)
G.cmd [[resize 10 | startinsert]]
end
end
G.g.mapleader = ' '
return G

View File

@ -1,5 +1,5 @@
return {
-- capabilities = require("cmp_nvim_lsp").default_capabilities(),
capabilities = require("cmp_nvim_lsp").default_capabilities(),
settings = {
basedpyright = {
analysis = {
@ -11,12 +11,6 @@ return {
},
},
on_attach = function()
G.api.nvim_create_user_command('R', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term python3 %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
G.api.nvim_create_user_command('R', G.run_cmd('python3 %'), {})
end
}

View File

@ -1,11 +1,6 @@
return{
capabilities = require('cmp_nvim_lsp').default_capabilities(),
on_attach = function()
G.api.nvim_create_user_command('R', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term sh %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
G.api.nvim_create_user_command('R', G.run_cmd('sh %'), {})
end
}

View File

@ -1,11 +1,6 @@
return {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
on_attach = function()
G.api.nvim_create_user_command('R', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term g++ "%" -o "%<" && ./"%<" && rm "%<"]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
G.api.nvim_create_user_command('R', G.run_cmd('g++ "%" -o "%<" && ./"%<" && rm "%<"'), {})
end
}

View File

@ -1,18 +1,7 @@
return {
capabilities = require('cmp_nvim_lsp').default_capabilities(),
on_attach = function()
G.api.nvim_create_user_command('R', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term go run %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
G.api.nvim_create_user_command('Rgin', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term go run ./main.go]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
G.api.nvim_create_user_command('R', G.run_cmd('go run %'), {})
G.api.nvim_create_user_command('Rgin', G.run_cmd('go run ./main.go'), {})
end
}

View File

@ -1,4 +1,3 @@
return {
on_attach = function()
end
capabilities = require('cmp_nvim_lsp').default_capabilities(),
}

View File

@ -1,2 +0,0 @@
return {
}

View File

@ -1,11 +0,0 @@
return {
on_attach = function()
G.api.nvim_create_user_command('R', function()
G.cmd [[set splitbelow]]
G.cmd [[sp]]
G.cmd [[term python3 %]]
G.cmd [[resize 10]]
G.cmd [[startinsert]]
end, {})
end
}

View File

@ -63,13 +63,6 @@ G.au({ "VimEnter", "BufEnter" }, {
end,
})
-- G.au({
-- {"CmdlineEnter"},
-- {
-- if index
-- }
-- })
local function isempty(s)
return s == nil or s == ""

View File

@ -6,27 +6,4 @@ return {
require("plugs.edit-plugs"),
require("plugs.dev"),
-- leetcode刷题
-- {
-- "kawre/leetcode.nvim",
-- build = ":TSUpdate html",
-- dependencies = {
-- "nvim-telescope/telescope.nvim",
-- "nvim-lua/plenary.nvim", -- telescope 所需
-- "MunifTanjim/nui.nvim",
-- -- 可选
-- "nvim-treesitter/nvim-treesitter",
-- "rcarriga/nvim-notify",
-- "nvim-tree/nvim-web-devicons",
-- },
-- opts = {
-- -- 配置放在这里
-- cn = {
-- enabled = true,
-- },
-- },
-- },
}

View File

@ -8,21 +8,20 @@ return {
-- })
-- end
-- },
-- {
-- -- go开发
-- "ray-x/go.nvim",
-- dependencies = { -- optional packages
-- "ray-x/guihua.lua",
-- "neovim/nvim-lspconfig",
-- "nvim-treesitter/nvim-treesitter",
-- },
-- config = function()
-- require("go").setup()
-- end,
-- -- event = { "CmdlineEnter" },
-- ft = { "go", 'gomod' },
-- build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
-- },
{
-- go开发
"ray-x/go.nvim",
dependencies = {
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
},
ft = { "go", 'gomod' },
build = ':lua require("go.install").update_all_sync()',
config = function()
require("go").setup()
end,
},
{
-- conda 环境
"kmontocam/nvim-conda",

View File

@ -44,16 +44,23 @@ return {
})
end
},
-- {
-- 'kevinhwang91/nvim-ufo',
-- dependencies = {
-- 'kevinhwang91/promise-async'
-- },
-- config = function ()
-- require("ufo").setup()
-- end
-- },
{
'kevinhwang91/nvim-ufo',
dependencies = {
'kevinhwang91/promise-async'
},
config = function()
vim.opt.foldcolumn = '0'
vim.opt.foldlevel = 99
vim.opt.foldlevelstart = 99
vim.opt.foldenable = true
require("ufo").setup({
provider_selector = function(bufnr, filetype, buftype)
return { 'treesitter', 'indent' }
end
})
end
},
{
-- hop
"phaazon/hop.nvim",

View File

@ -4,6 +4,7 @@ return {
"neovim/nvim-lspconfig",
dependencies = {
"folke/neodev.nvim",
"hrsh7th/cmp-nvim-lsp",
},
config = function()
require 'neodev'.setup {}
@ -270,8 +271,7 @@ return {
},
indent = { enable = true },
ignore_install = {
"txt",
"go"
"txt"
},
sync_install = false,
auto_install = true,
@ -287,21 +287,21 @@ return {
additional_vim_regex_highlighting = false,
},
parsers = {
html = {
vue = {
install_info = {
url = "https://github.com/ikatyang/tree-sitter-vue",
files = { "src/parser.c" },
branch = "main"
}
}
}
branch = "main",
},
},
},
}
require 'nvim-treesitter'.setup(treesitter_opt)
require 'nvim-treesitter.install'.prefer_git = true
if G.use_ssh then
local parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
for _, p in pairs(parsers) do
p.install_info.url = p.install_info.url:gsub("https://github/com/", "git@github.com:")
p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:")
end
end
end

View File

@ -72,11 +72,11 @@ return {
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified
show_tabs_only = false, -- this shows only tabs instead of tabs + buffers
},
G.cmd [[
}
G.cmd [[
set guioptions-=e " Use showtabline in gui vim
set sessionoptions+=tabpages,globals " store tabpages and globals in session
]]
}
end,
},
}

View File

@ -1,4 +1,3 @@
require 'lazy'.setup({
require('plugs.edit-plugs'),
-- 'vijaymarupudi/nvim-fzf', -- fzf
})