Skip to content

Commit

Permalink
feat(ci): automatic format with stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Jan 3, 2024
1 parent b491f02 commit 2bbcfe4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Format using stylua

on:
push:
branches:
- main
pull_request_target:

jobs:
postprocessing:
runs-on: ubuntu-latest
steps:
- name: "Format with Stylua"
uses: JohnnyMorganz/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.15.1
args: .
- name: Auto Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(core): formatted with stylua"
26 changes: 0 additions & 26 deletions lua/core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,6 @@ M.lazy = function(lazy_path)
vim.opt.rtp:prepend(lazy_path)
end

M.lazy_load = function(plugin)
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
callback = function()
local file = vim.fn.expand "%"
local condition = file ~= "[lazy]" and file ~= ""

if condition then
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin)

if plugin ~= "treesitter" then
vim.schedule(function()
require("lazy").load { plugins = plugin }

if plugin == "lspconfig" then
vim.cmd "silent! do FileType"
end
end, 0)
else
require("lazy").load { plugins = plugin }
end
end
end,
})
end

--- Toggle line numbers
local cmds = { "nu!", "rnu!", "nonu!" }
local current_index = 1
Expand Down
20 changes: 8 additions & 12 deletions lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ local plugins = {
"neovim/nvim-lspconfig",
name = "lspconfig",
cmd = { "LspInfo", "LspInstall", "LspUninstall" },
event = {
"LspAttach",
},
init = function()
require("core.mappings").lsp()
require("core.utils").lazy_load "lspconfig"
end,
event = { "BufReadPost", "BufNewFile" },
config = function()
require "plugins.configs.lsp"
end,
Expand Down Expand Up @@ -202,11 +196,13 @@ local plugins = {
event = "VeryLazy",
dir = conf_path,
config = function()
require("core.opts").final()
require("core.mappings").general()
require("core.mappings").misc()
require("core.utils").mousepad()
require("core.utils").autocmds()
vim.schedule(function()
require("core.opts").final()
require("core.mappings").general()
require("core.mappings").misc()
require("core.utils").mousepad()
require("core.utils").autocmds()
end)
end,
},
}
Expand Down

0 comments on commit 2bbcfe4

Please sign in to comment.