mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
feat(nvim): add formatting
This commit is contained in:
45
nvim/lua/plugins/formatting.lua
Normal file
45
nvim/lua/plugins/formatting.lua
Normal file
@@ -0,0 +1,45 @@
|
||||
-- Lightweight yet powerful formatter plugin for Neovim
|
||||
-- https://github.com/stevearc/conform.nvim
|
||||
return {
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre", "BufNewFile" },
|
||||
keys = {
|
||||
{
|
||||
"<leader>mp",
|
||||
mode = { "n", "v" },
|
||||
function()
|
||||
require("conform").format({
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
})
|
||||
end,
|
||||
desc = "Format file or range (in visual mode)",
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
formatters = {
|
||||
eslint_d = {
|
||||
command = "eslint_d",
|
||||
args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" },
|
||||
stdin = true,
|
||||
},
|
||||
},
|
||||
formatters_by_ft = {
|
||||
astro = { "prettier" },
|
||||
css = { "prettier" },
|
||||
graphql = { "prettier" },
|
||||
html = { "prettier" },
|
||||
javascript = { "prettier", "eslint_d" },
|
||||
javascriptreact = { "prettier", "eslint_d" },
|
||||
json = { "prettier" },
|
||||
lua = { "stylua" },
|
||||
markdown = { "prettier" },
|
||||
svelte = { "prettier" },
|
||||
typescript = { "prettier", "eslint_d" },
|
||||
typescriptreact = { "prettier", "eslint_d" },
|
||||
yaml = { "prettier" },
|
||||
python = { "isort", "black" },
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -5,6 +5,7 @@ return {
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"astro-language-server",
|
||||
"black",
|
||||
"cspell",
|
||||
"css-lsp",
|
||||
"cssmodules-language-server",
|
||||
@@ -13,6 +14,7 @@ return {
|
||||
"eslint-lsp",
|
||||
"eslint_d",
|
||||
"html-lsp",
|
||||
"isort",
|
||||
"json-lsp",
|
||||
"lua-language-server",
|
||||
"prettier",
|
||||
|
||||
Reference in New Issue
Block a user