commit 7296c108bcc8515379f36d3d15f84970704f8b55
parent 173c25750ce0554b23e9d615e63882fa294b8bae
Author: bdmfegys@duck.com <bdmfegys@duck.com>
Date: Tue, 30 Apr 2024 18:04:31 -0400
autostart.lua, plugins.lua: install mason-conform.nvim and configure for lua and c formatting
Diffstat:
2 files changed, 73 insertions(+), 51 deletions(-)
diff --git a/lua/autostart.lua b/lua/autostart.lua
@@ -1,2 +1,3 @@
-- colorscheme
require('pywal').setup()
+require("mason-conform").setup()
diff --git a/lua/plugins.lua b/lua/plugins.lua
@@ -1,59 +1,80 @@
require("lazy").setup({
- { 'stevearc/conform.nvim', opts = {}, },
- { 'luukvbaal/nnn.nvim', config = true },
- { 'nvim-treesitter/nvim-treesitter', build = ":TSUpdate", event = "VeryLazy" },
- { 'folke/which-key.nvim',
- event = "VeryLazy",
- init = function()
- vim.o.timeout = true
- vim.o.timeoutlen = 300
- end,
+ {
+ "stevearc/conform.nvim",
+ event = { "VeryLazy" },
+ cmd = { "ConformInfo" },
+ opts = {
+ formatters_by_ft = {
+ lua = { "stylua" },
+ c = { "clang-format" },
+ },
+ },
+ init = function()
+ vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
+ end,
},
- { 'akinsho/toggleterm.nvim', version = "*", config = true },
- { 'AlphaTechnolog/pywal.nvim' },
- { "echasnovski/mini.pairs", event = "VeryLazy",
- opts = {
+ { "luukvbaal/nnn.nvim", config = true },
+ { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", event = "VeryLazy" },
+ {
+ "folke/which-key.nvim",
+ event = "VeryLazy",
+ init = function()
+ vim.o.timeout = true
+ vim.o.timeoutlen = 300
+ end,
+ },
+ { "akinsho/toggleterm.nvim", version = "*", config = true },
+ { "AlphaTechnolog/pywal.nvim" },
+ {
+ "echasnovski/mini.pairs",
+ event = "VeryLazy",
+ opts = {
mappings = {
["`"] = { action = "closeopen", pair = "``", neigh_pattern = "[^\\`].", register = { cr = false } },
},
},
},
- { "williamboman/mason.nvim", cmd = "Mason", keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } }, build = ":MasonUpdate",
- opts = {
- ensure_installed = {
- "stylua",
- "shfmt",
- },
- },
- ---@param opts MasonSettings | {ensure_installed: string[]}
- config = function(_, opts)
- require("mason").setup(opts)
- local mr = require("mason-registry")
- mr:on("package:install:success", function()
- vim.defer_fn(function()
- -- trigger FileType event to possibly load this newly installed LSP server
- require("lazy.core.handler.event").trigger({
- event = "FileType",
- buf = vim.api.nvim_get_current_buf(),
- })
- end, 100)
- end)
- local function ensure_installed()
- for _, tool in ipairs(opts.ensure_installed) do
- local p = mr.get_package(tool)
- if not p:is_installed() then
- p:install()
- end
- end
- end
- if mr.refresh then
- mr.refresh(ensure_installed)
- else
- ensure_installed()
- end
- end,
-},
-
-
-})
+ {
+ "williamboman/mason.nvim",
+ cmd = "Mason",
+ keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
+ build = ":MasonUpdate",
+ opts = {
+ ensure_installed = {
+ "stylua",
+ "shfmt",
+ "ast-grep",
+ "prettier",
+ },
+ },
+ ---@param opts MasonSettings | {ensure_installed: string[]}
+ config = function(_, opts)
+ require("mason").setup(opts)
+ local mr = require("mason-registry")
+ mr:on("package:install:success", function()
+ vim.defer_fn(function()
+ -- trigger FileType event to possibly load this newly installed LSP server
+ require("lazy.core.handler.event").trigger({
+ event = "FileType",
+ buf = vim.api.nvim_get_current_buf(),
+ })
+ end, 100)
+ end)
+ local function ensure_installed()
+ for _, tool in ipairs(opts.ensure_installed) do
+ local p = mr.get_package(tool)
+ if not p:is_installed() then
+ p:install()
+ end
+ end
+ end
+ if mr.refresh then
+ mr.refresh(ensure_installed)
+ else
+ ensure_installed()
+ end
+ end,
+ },
+ { "zapling/mason-conform.nvim" },
+})