From a0e42d5506739009c4755830b380a122eefab400 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sun, 4 Aug 2024 01:02:30 +0300 Subject: feat(nvim): migrated from none-ls to conform (formatter) + nvim-lint --- .config/nvim/lua/custom/plugins/conform.lua | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .config/nvim/lua/custom/plugins/conform.lua (limited to '.config/nvim/lua/custom/plugins/conform.lua') diff --git a/.config/nvim/lua/custom/plugins/conform.lua b/.config/nvim/lua/custom/plugins/conform.lua new file mode 100644 index 0000000..759f5ba --- /dev/null +++ b/.config/nvim/lua/custom/plugins/conform.lua @@ -0,0 +1,38 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { 'ft', 'FormatToggle', desc = '[F]ormat [T]oggle Globally' }, + { 'fT', 'FormatToggle!', desc = '[F]ormat [T]oggle Locally' }, + { 'ff', 'Format', desc = '[F]ormat [F]ile' }, + { 'f', 'Format', desc = '[F]ormat', mode = 'v' }, + }, + ---@module "conform" + ---@type conform.setupOpts + opts = { + formatters_by_ft = { + ['lua'] = { 'stylua' }, + ['c'] = { 'clang-format' }, + ['python'] = { 'isort', 'black' }, + ['rust'] = { 'rustfmt' }, + ['go'] = { 'gofumpt' }, + ['markdown'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['yaml'] = { 'prettierd' }, + ['json'] = { 'jq' }, + ['html'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['css'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['javascript'] = { 'prettierd', 'prettier', stop_after_first = true }, + ['typescript'] = { 'prettierd', 'prettier', stop_after_first = true }, + }, + format_on_save = function(bufnr) + -- Disable with a global or buffer local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, + notify_on_error = true, + lsp_fallback = true, + }, +} -- cgit v1.3.1