diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..d511a07 --- /dev/null +++ b/.github/workflows/format.yml @@ -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/stylua-action@v1.1.2 + 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" diff --git a/lua/core/utils.lua b/lua/core/utils.lua index f4271e9..ad66ddf 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -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 diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 65ecb34..653449c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -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, @@ -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, }, }