diff --git a/init.lua b/init.lua index 27ec17f..1498982 100644 --- a/init.lua +++ b/init.lua @@ -11,6 +11,7 @@ require('lazy').setup(vim.tbl_extend('keep', config.user_lazy_opts(), { { import = 'plex.plugins.extras.coding' }, { import = 'plex.plugins.extras.ui' }, { import = 'plex.plugins.extras.treesitter' }, + { import = 'plex.plugins.extras.formatting' }, { import = 'plex.plugins.extras.editor' }, { import = 'plex.plugins.extras.org' }, { import = 'plex.plugins.extras.lang.go' }, diff --git a/lua/plex/plugins/extras/formatting/prettier.lua b/lua/plex/plugins/extras/formatting/prettier.lua index dbbeba8..8f85e74 100644 --- a/lua/plex/plugins/extras/formatting/prettier.lua +++ b/lua/plex/plugins/extras/formatting/prettier.lua @@ -4,32 +4,49 @@ return { { - 'williamboman/mason.nvim', + "williamboman/mason.nvim", opts = function(_, opts) - if type(opts.ensure_installed) == 'table' then - table.insert(opts.ensure_installed, 'prettierd') + if type(opts.ensure_installed) == "table" then + table.insert(opts.ensure_installed, "prettierd") end end, }, { - 'mhartington/formatter.nvim', + "mhartington/formatter.nvim", optional = true, + keys = { + { "ff", "Format", desc = "Use Formatter" }, + }, opts = function(_, opts) opts = opts or {} local filetypes = { -- FIXME:add more filetypes - json = { require('formatter.defaults.prettierd') }, + json = { require("formatter.defaults.prettierd") }, + rust = { + rustfmt = function() + return { + exe = "rustfmt", + args = { "--emit=std ut" }, + stdin = true, + } + end, + }, + ["*"] = { + -- "formatter.filetypes.any" defines default configurations for any + -- filetype + require("formatter.filetypes.any").remove_trailing_whitespace, + }, } - opts.filetype = vim.tbl_extend('keep', opts.filetype or {}, filetypes) + opts.filetype = vim.tbl_extend("keep", opts.filetype or {}, filetypes) end, }, { - 'jose-elias-alvarez/null-ls.nvim', + "jose-elias-alvarez/null-ls.nvim", optional = true, opts = function(_, opts) - local nls = require('null-ls') + local nls = require("null-ls") table.insert(opts.sources, nls.builtins.formatting.prettierd) end, },