drop _full_feature and use custom.lua

* use a global table for custom config
* add config for proxy
This commit is contained in:
leafee98 2023-07-21 16:29:53 +08:00
parent 62de8c72bc
commit e901a69f28
7 changed files with 30 additions and 15 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
/lazy-lock.json
/_full_feature
/custom.lua

View file

@ -12,8 +12,11 @@ git clone <url of this repo> ~/.config/nvim
By default, this config will only include a few plugins, which suit for mataining other than editing frequently.
If you want to use the full feature this config provided, create a file named `_full_feature` under the root of this repo (usually `~/.config/nvim`.
A custom config (`custom.lua`) file placed aside with `init.lua` is optional, it's content like below.
```
touch ~/.config/nvim/_full_feature
return {
full_feature = true, # enable all configured plugins
proxy_url = "http://localhost:8888", # setup proxy for some plugins (like treesitter)
}
```

View file

@ -26,11 +26,19 @@ vim.keymap.set("n", "<F2>", "<cmd>bnext<CR>", { silent = true })
vim.g.mapleader = " "
vim.g.maplocalleader = " "
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
-- Load custom config
custom = {
full_feature = false,
proxy_url = "",
}
local custom_config_path = vim.fn.stdpath("config") .. "/custom.lua"
local ok, t = pcall(dofile, custom_config_path)
if ok then
for k, v in pairs(t) do
custom[k] = v
end
end
full_feature = file_exists(vim.fn.stdpath("config") .. "/_full_feature")
-- Use lazy.nvim as plugin manager, and load plugin's config
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

View file

@ -24,13 +24,13 @@ return {
},
{
"karb94/neoscroll.nvim",
enabled = full_feature,
enabled = custom.full_feature,
main = "neoscroll",
opts = { },
},
{
"akinsho/bufferline.nvim",
enabled = full_feature,
enabled = custom.full_feature,
main = "bufferline",
opts = {
options = {
@ -54,7 +54,7 @@ return {
},
{
"nvim-lualine/lualine.nvim",
enabled = full_feature,
enabled = custom.full_feature,
dependencies = {
"nvim-tree/nvim-web-devicons"
},
@ -66,7 +66,7 @@ return {
},
{
"nvim-tree/nvim-tree.lua",
enabled = full_feature,
enabled = custom.full_feature,
dependencies = {
"nvim-tree/nvim-web-devicons"
},

View file

@ -1,7 +1,7 @@
return {
"lewis6991/gitsigns.nvim",
main = "gitsigns",
enabled = full_feature,
enabled = custom.full_feature,
opts = {
on_attach = function(bufnr)
local gs = package.loaded.gitsigns

View file

@ -44,7 +44,7 @@ local basic_ensure = {
"yaml",
}
if full_feature then
if custom.full_feature then
ensure = full_ensure
else
ensure = basic_ensure
@ -63,6 +63,10 @@ return {
},
config = function (this, opts)
require(this.name .. ".configs").setup(opts);
require(this.name .. ".install").prefer_git = true;
if custom.proxy_url ~= "" then
require(this.name .. ".install").command_extra_args = {
curl = { "--proxy", custom.proxy_url }
}
end
end
}

View file

@ -39,7 +39,7 @@ end
return {
{
"neovim/nvim-lspconfig",
enabled = full_feature,
enabled = custom.full_feature,
dependencies = {
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",