refactor: fix bugs, dedup :R, cleanup dead code, enable ufo+go.nvim, unify capabilities
This commit is contained in:
parent
a296f56268
commit
94274b126a
48
init.lua
48
init.lua
|
|
@ -1,9 +1,8 @@
|
||||||
G = require('G')
|
G = require('G')
|
||||||
|
|
||||||
|
-- Clone lazy.nvim (only needed for native Neovim, not VSCode)
|
||||||
if not G.g.vscode then
|
if not G.g.vscode then
|
||||||
|
|
||||||
local lazypath = G.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = G.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
|
||||||
if not G.loop.fs_stat(lazypath) then
|
if not G.loop.fs_stat(lazypath) then
|
||||||
G.fn.system({
|
G.fn.system({
|
||||||
"git",
|
"git",
|
||||||
|
|
@ -13,34 +12,23 @@ if not G.g.vscode then
|
||||||
"--branch=stable",
|
"--branch=stable",
|
||||||
lazypath,
|
lazypath,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
G.fn.system({
|
|
||||||
"git",
|
|
||||||
"config",
|
|
||||||
"--global",
|
|
||||||
"credential.helper",
|
|
||||||
"store",
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
G.opt.rtp:prepend(lazypath)
|
G.opt.rtp:prepend(lazypath)
|
||||||
|
end
|
||||||
require("keymap")
|
|
||||||
|
require("keymap")
|
||||||
|
|
||||||
if G.g.vscode then
|
if G.g.vscode then
|
||||||
require('vscode')
|
require('vscode')
|
||||||
else
|
else
|
||||||
require("options")
|
require("options")
|
||||||
local clone_prefix = G.use_ssh and "git@github.com:%s.git" or "https://github.com/%s.git"
|
local clone_prefix = G.use_ssh and "git@github.com:%s.git" or "https://github.com/%s.git"
|
||||||
require("lazy").setup(
|
require("lazy").setup(
|
||||||
require('plugs'), {
|
require('plugs'), {
|
||||||
lockfile = G.fn.stdpath("data") .. "/lazy/lazy-lock.json",
|
lockfile = G.fn.stdpath("data") .. "/lazy/lazy-lock.json",
|
||||||
git = {
|
git = {
|
||||||
url_format = clone_prefix,
|
url_format = clone_prefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,14 @@ function G.au(even, opts)
|
||||||
return G.api.nvim_create_autocmd(even, opts)
|
return G.api.nvim_create_autocmd(even, opts)
|
||||||
end
|
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 = ' '
|
G.g.mapleader = ' '
|
||||||
|
|
||||||
return G
|
return G
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
return {
|
return {
|
||||||
-- capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||||
settings = {
|
settings = {
|
||||||
basedpyright = {
|
basedpyright = {
|
||||||
analysis = {
|
analysis = {
|
||||||
|
|
@ -11,12 +11,6 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on_attach = function()
|
on_attach = function()
|
||||||
G.api.nvim_create_user_command('R', function()
|
G.api.nvim_create_user_command('R', G.run_cmd('python3 %'), {})
|
||||||
G.cmd [[set splitbelow]]
|
|
||||||
G.cmd [[sp]]
|
|
||||||
G.cmd [[term python3 %]]
|
|
||||||
G.cmd [[resize 10]]
|
|
||||||
G.cmd [[startinsert]]
|
|
||||||
end, {})
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
return{
|
return{
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
on_attach = function()
|
on_attach = function()
|
||||||
G.api.nvim_create_user_command('R', function()
|
G.api.nvim_create_user_command('R', G.run_cmd('sh %'), {})
|
||||||
G.cmd [[set splitbelow]]
|
|
||||||
G.cmd [[sp]]
|
|
||||||
G.cmd [[term sh %]]
|
|
||||||
G.cmd [[resize 10]]
|
|
||||||
G.cmd [[startinsert]]
|
|
||||||
end, {})
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
return {
|
return {
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
on_attach = function()
|
on_attach = function()
|
||||||
G.api.nvim_create_user_command('R', function()
|
G.api.nvim_create_user_command('R', G.run_cmd('g++ "%" -o "%<" && ./"%<" && rm "%<"'), {})
|
||||||
G.cmd [[set splitbelow]]
|
|
||||||
G.cmd [[sp]]
|
|
||||||
G.cmd [[term g++ "%" -o "%<" && ./"%<" && rm "%<"]]
|
|
||||||
G.cmd [[resize 10]]
|
|
||||||
G.cmd [[startinsert]]
|
|
||||||
end, {})
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,7 @@
|
||||||
return {
|
return {
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
on_attach = function()
|
on_attach = function()
|
||||||
G.api.nvim_create_user_command('R', function()
|
G.api.nvim_create_user_command('R', G.run_cmd('go run %'), {})
|
||||||
G.cmd [[set splitbelow]]
|
G.api.nvim_create_user_command('Rgin', G.run_cmd('go run ./main.go'), {})
|
||||||
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, {})
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
return {
|
return {
|
||||||
on_attach = function()
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
return {
|
|
||||||
}
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
@ -63,13 +63,6 @@ G.au({ "VimEnter", "BufEnter" }, {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- G.au({
|
|
||||||
-- {"CmdlineEnter"},
|
|
||||||
-- {
|
|
||||||
-- if index
|
|
||||||
-- }
|
|
||||||
-- })
|
|
||||||
|
|
||||||
|
|
||||||
local function isempty(s)
|
local function isempty(s)
|
||||||
return s == nil or s == ""
|
return s == nil or s == ""
|
||||||
|
|
|
||||||
|
|
@ -6,27 +6,4 @@ return {
|
||||||
require("plugs.edit-plugs"),
|
require("plugs.edit-plugs"),
|
||||||
require("plugs.dev"),
|
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,
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,20 @@ return {
|
||||||
-- })
|
-- })
|
||||||
-- end
|
-- end
|
||||||
-- },
|
-- },
|
||||||
-- {
|
{
|
||||||
-- -- go开发
|
-- go开发
|
||||||
-- "ray-x/go.nvim",
|
"ray-x/go.nvim",
|
||||||
-- dependencies = { -- optional packages
|
dependencies = {
|
||||||
-- "ray-x/guihua.lua",
|
"ray-x/guihua.lua",
|
||||||
-- "neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
-- "nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
-- },
|
},
|
||||||
-- config = function()
|
ft = { "go", 'gomod' },
|
||||||
-- require("go").setup()
|
build = ':lua require("go.install").update_all_sync()',
|
||||||
-- end,
|
config = function()
|
||||||
-- -- event = { "CmdlineEnter" },
|
require("go").setup()
|
||||||
-- ft = { "go", 'gomod' },
|
end,
|
||||||
-- build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
|
},
|
||||||
-- },
|
|
||||||
{
|
{
|
||||||
-- conda 环境
|
-- conda 环境
|
||||||
"kmontocam/nvim-conda",
|
"kmontocam/nvim-conda",
|
||||||
|
|
|
||||||
|
|
@ -44,16 +44,23 @@ return {
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
-- {
|
{
|
||||||
-- 'kevinhwang91/nvim-ufo',
|
'kevinhwang91/nvim-ufo',
|
||||||
-- dependencies = {
|
dependencies = {
|
||||||
-- 'kevinhwang91/promise-async'
|
'kevinhwang91/promise-async'
|
||||||
-- },
|
},
|
||||||
-- config = function ()
|
config = function()
|
||||||
-- require("ufo").setup()
|
vim.opt.foldcolumn = '0'
|
||||||
-- end
|
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
|
-- hop
|
||||||
"phaazon/hop.nvim",
|
"phaazon/hop.nvim",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"folke/neodev.nvim",
|
"folke/neodev.nvim",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require 'neodev'.setup {}
|
require 'neodev'.setup {}
|
||||||
|
|
@ -270,8 +271,7 @@ return {
|
||||||
},
|
},
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
ignore_install = {
|
ignore_install = {
|
||||||
"txt",
|
"txt"
|
||||||
"go"
|
|
||||||
},
|
},
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
|
|
@ -287,21 +287,21 @@ return {
|
||||||
additional_vim_regex_highlighting = false,
|
additional_vim_regex_highlighting = false,
|
||||||
},
|
},
|
||||||
parsers = {
|
parsers = {
|
||||||
html = {
|
vue = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/ikatyang/tree-sitter-vue",
|
url = "https://github.com/ikatyang/tree-sitter-vue",
|
||||||
files = { "src/parser.c" },
|
files = { "src/parser.c" },
|
||||||
branch = "main"
|
branch = "main",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
require 'nvim-treesitter'.setup(treesitter_opt)
|
require 'nvim-treesitter'.setup(treesitter_opt)
|
||||||
require 'nvim-treesitter.install'.prefer_git = true
|
require 'nvim-treesitter.install'.prefer_git = true
|
||||||
if G.use_ssh then
|
if G.use_ssh then
|
||||||
local parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
|
local parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
|
||||||
for _, p in pairs(parsers) do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,11 @@ return {
|
||||||
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified
|
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
|
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 guioptions-=e " Use showtabline in gui vim
|
||||||
set sessionoptions+=tabpages,globals " store tabpages and globals in session
|
set sessionoptions+=tabpages,globals " store tabpages and globals in session
|
||||||
]]
|
]]
|
||||||
}
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
require 'lazy'.setup({
|
require 'lazy'.setup({
|
||||||
require('plugs.edit-plugs'),
|
require('plugs.edit-plugs'),
|
||||||
-- 'vijaymarupudi/nvim-fzf', -- fzf
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue