mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-01 19:49:25 +00:00
[neovim] Use conform plugin for auto formatting
This commit is contained in:
26
.config/nvim/lua/plugins/lsp/conform.lua
Normal file
26
.config/nvim/lua/plugins/lsp/conform.lua
Normal file
@ -0,0 +1,26 @@
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
go = { "goimports", "gofumpt" },
|
||||
javascript = { "prettier" },
|
||||
json = { "prettier" },
|
||||
lua = { "stylua" },
|
||||
markdown = { "prettier" },
|
||||
python = { "isort", "black" },
|
||||
typescript = { "prettier" },
|
||||
yaml = { "prettier" },
|
||||
},
|
||||
formatters = {
|
||||
{
|
||||
command = "black",
|
||||
args = { "--line-length", "100" },
|
||||
},
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
local filetypes = { "go", "typescript", "lua" }
|
||||
if not vim.tbl_contains(filetypes, vim.bo[bufnr].filetype) then
|
||||
return
|
||||
end
|
||||
|
||||
return { timeout_ms = 500, lsp_fallback = false }
|
||||
end,
|
||||
})
|
@ -1,6 +1,7 @@
|
||||
require("plugins.lsp.mason")
|
||||
require("plugins.lsp.handlers").setup()
|
||||
require("plugins.lsp.none-ls")
|
||||
require("plugins.lsp.conform")
|
||||
require("plugins.lsp.lsp-saga")
|
||||
|
||||
local win = require("lspconfig.ui.windows")
|
||||
|
@ -1,6 +1,4 @@
|
||||
local none_ls = require("null-ls")
|
||||
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting
|
||||
local formatting = none_ls.builtins.formatting
|
||||
-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
|
||||
local diagnostics = none_ls.builtins.diagnostics
|
||||
|
||||
@ -13,11 +11,6 @@ end
|
||||
none_ls.setup({
|
||||
debug = false,
|
||||
sources = {
|
||||
formatting.black.with({
|
||||
extra_args = { "--fast", "--line-length", "100" },
|
||||
}),
|
||||
formatting.stylua,
|
||||
formatting.prettier,
|
||||
diagnostics.hadolint,
|
||||
diagnostics.markdownlint,
|
||||
diagnostics.revive.with({
|
||||
|
Reference in New Issue
Block a user