Skip to content

Commit

Permalink
refactor(structure)!: [BREAKING] Structurize nvim config (#458)
Browse files Browse the repository at this point in the history
* refactor(structure): structurize nvim config

* Merge: #694610a23e229e92af9bbdbba18c7b6ecd0201cd and #7087c121d9c5d609d9ecfc51e130e8b984c4a59c

* style: remove extra empty line

* style: remove extra empty line

* fix!: Reorganize assets

* chore: Format with stylua

* chore: Rearrange files

* feat: Save a few keystrokes

* chore: rtp tweaks

* chore: Sync changes with 'main'

* chore: Reorganize / rename assets

* chore: Minor fixes

* chore: Sync changes with 'main'

* chore: Unify code

* fix(sqlite3): add custom path to fix sqlite3 lib issues on Windows

* chore: Sync changes

* chore(script-win): Add sqlite3 dll issue

* chore(lspsaga): Adapt options from v2.3.6

* refactor: reorganize plugins acording to new standard

* chore: rename `tools` to `tool`

* chore: move fugitive to `tool`

* typo

* chore: Sync changes with 'main'

* doc(wiki): add `plugins.md`

* rename: rename `install/` to `scripts`

* rename: rename `my-snippets` to `snips`

* chore: move `wiki` to root

* fix(snips): fix path in `package.json`

* dic(wiki): change `plugins.lua`'s title

* chore: Fixups

* chore: Update release note

* chore: Add line break

* chore: add `plugins/custom.lua` and `configs/custom/example.lua`

* revert: remove custom.lua and `configs/custom`

---------

Co-authored-by: CharlesChiuGit <[email protected]>
Co-authored-by: 冷酔閑吟 <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2023
1 parent 47b3f72 commit 29f746e
Show file tree
Hide file tree
Showing 89 changed files with 3,045 additions and 3,009 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ Just run the following interactive bootstrap command, and you're good to go 👍
- **Windows** _(Note: This script REQUIRES `pwsh` > `v7.1`)_

```pwsh
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/install/install.ps1'))
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.ps1'))
```

- **\*nix**

```sh
if command -v curl >/dev/null 2>&1; then
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/install/install.sh)"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)"
else
bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/install/install.sh)"
bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)"
fi
```

Expand Down
4 changes: 2 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if not vim.g.vscode then
vim.schedule(function()
vim.notify_once(
[[
We've released version v1.0.0!
It has brought about some major changes that would require a manual cleanup.
We've released version v2.0.0!
This is a backward-incompatible release. See the release notes for instructions on how to migrate your configs.
Visit https://github.com/ayamir/nvimdots/releases to see the release notes.
Expand Down
2 changes: 1 addition & 1 deletion lua/core/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ vim.api.nvim_create_autocmd("BufEnter", {
and vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(layout[2]), "filetype") == "NvimTree"
and layout[3] == nil
then
vim.cmd("confirm quit")
vim.api.nvim_command([[confirm quit]])
end
end,
})
Expand Down
2 changes: 1 addition & 1 deletion lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ local load_core = function()
require("core.mapping")
require("keymap")
require("core.event")
require("core.lazy")
require("core.pack")

local colorscheme = require("core.settings").colorscheme
local background = require("core.settings").background
Expand Down
4 changes: 2 additions & 2 deletions lua/core/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ local def_map = {
["c|<C-h>"] = map_cmd("<BS>"):with_noremap(),
["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]]):with_noremap(),
-- Visual
["v|J"] = map_cmd(":m '>+1<cr>gv=gv"),
["v|K"] = map_cmd(":m '<-2<cr>gv=gv"),
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"),
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"),
["v|<"] = map_cmd("<gv"),
["v|>"] = map_cmd(">gv"),
}
Expand Down
6 changes: 6 additions & 0 deletions lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ local function load_options()
for name, value in pairs(global_local) do
vim.o[name] = value
end

-- Fix sqlite3 missing-lib issue on Windows
if global.is_windows then
-- Download the DLLs form https://www.sqlite.org/download.html
vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400100/sqlite3.dll"
end
end

load_options()
56 changes: 27 additions & 29 deletions lua/core/lazy.lua → lua/core/pack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,46 @@ local settings = require("core.settings")
local use_ssh = settings.use_ssh

local icons = {
kind = require("modules.ui.icons").get("kind"),
documents = require("modules.ui.icons").get("documents"),
ui = require("modules.ui.icons").get("ui"),
ui_sep = require("modules.ui.icons").get("ui", true),
misc = require("modules.ui.icons").get("misc"),
kind = require("modules.utils.icons").get("kind"),
documents = require("modules.utils.icons").get("documents"),
ui = require("modules.utils.icons").get("ui"),
ui_sep = require("modules.utils.icons").get("ui", true),
misc = require("modules.utils.icons").get("misc"),
}

local Lazy = {}
Lazy.__index = Lazy

function Lazy:load_plugins()
self.repos = {}
self.modules = {}

local append_nativertp = function()
package.path = package.path
.. string.format(";%s;%s", modules_dir .. "/configs/?.lua", modules_dir .. "/configs/?/init.lua")
end

local get_plugins_list = function()
local list = {}
local tmp = vim.split(fn.globpath(modules_dir, "*/plugins.lua"), "\n")
local subtmp = vim.split(fn.globpath(modules_dir, "*/user/plugins.lua"), "\n")
if type(subtmp) == "table" then
for _, v in ipairs(subtmp) do
if v ~= "" then
table.insert(tmp, v)
end
end
end
if type(tmp) == "table" then
for _, f in ipairs(tmp) do
-- fill list with `plugins.lua`'s path used for later `require` like this:
-- list[#list + 1] = "modules/completion/plugins.lua"
local plugins_list = vim.split(fn.glob(modules_dir .. "/plugins/*.lua"), "\n")
if type(plugins_list) == "table" then
for _, f in ipairs(plugins_list) do
-- fill list with `plugins/*.lua`'s path used for later `require` like this:
-- list[#list + 1] = "plugins/completion.lua"
list[#list + 1] = f:sub(#modules_dir - 6, -1)
end
end
return list
end

append_nativertp()

local plugins_file = get_plugins_list()
for _, m in ipairs(plugins_file) do
-- require repos which returned in `plugins.lua` like this:
-- local repos = require("modules/completion/plugins")
local repos = require(m:sub(0, #m - 4))
if type(repos) == "table" then
for repo, conf in pairs(repos) do
self.repos[#self.repos + 1] = vim.tbl_extend("force", { repo }, conf)
-- require modules which returned in previous operation like this:
-- local modules = require("modules/plugins/completion.lua")
local modules = require(m:sub(0, #m - 4))
if type(modules) == "table" then
for name, conf in pairs(modules) do
self.modules[#self.modules + 1] = vim.tbl_extend("force", { name }, conf)
end
end
end
Expand Down Expand Up @@ -101,7 +99,7 @@ function Lazy:load_lazy()
icons.ui_sep.BigCircle,
icons.ui_sep.BigUnfilledCircle,
icons.ui_sep.Square,
icons.ui_sep.ArrowClosed,
icons.ui_sep.ChevronRight,
},
},
},
Expand All @@ -118,7 +116,7 @@ function Lazy:load_lazy()
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and the config directory
---@type string[]
paths = {}, -- add any custom paths here that you want to indluce in the rtp
paths = {}, -- add any custom paths here that you want to include in the rtp
},
},
}
Expand All @@ -127,7 +125,7 @@ function Lazy:load_lazy()
end

vim.opt.rtp:prepend(lazy_path)
require("lazy").setup(self.repos, lazy_settings)
require("lazy").setup(self.modules, lazy_settings)
end

Lazy:load_lazy()
Loading

0 comments on commit 29f746e

Please sign in to comment.