From 73b45db99c8f0230bec6d1021d0194df1f18063c Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Wed, 8 Nov 2023 11:03:45 +0100 Subject: [PATCH] move to nvim.conform --- lua/custom/plugins/formatter.lua | 24 ++++++++++++ lua/custom/plugins/nullls.lua | 65 -------------------------------- 2 files changed, 24 insertions(+), 65 deletions(-) create mode 100644 lua/custom/plugins/formatter.lua delete mode 100644 lua/custom/plugins/nullls.lua diff --git a/lua/custom/plugins/formatter.lua b/lua/custom/plugins/formatter.lua new file mode 100644 index 0000000..a9da6fb --- /dev/null +++ b/lua/custom/plugins/formatter.lua @@ -0,0 +1,24 @@ +return { + 'stevearc/conform.nvim', + opts = { + log_level = vim.log.levels.DEBUG, + format_on_save = { + lsp_fallback = true, + timeout_ms = 500, + }, + notify_on_error = true, + formatters = {}, + formatters_by_ft = { + lua = { 'stylua' }, + javascript = { { 'eslint_d', 'prettierd', 'prettier' } }, + javascriptreact = { { 'eslint_d', 'prettierd', 'prettier' } }, + typescript = { { 'eslint_d', 'prettierd', 'prettier' } }, + typescriptreact = { { 'eslint_d', 'prettierd', 'prettier' } }, + markdown = { { 'prettierd', 'prettier' } }, + css = { { 'stylelint' } }, + json = { { 'eslint_d', 'prettierd', 'prettier' } }, + ['*'] = { 'codespell' }, + ['_'] = { 'trim_whitespace' }, + }, + }, +} diff --git a/lua/custom/plugins/nullls.lua b/lua/custom/plugins/nullls.lua deleted file mode 100644 index e7de581..0000000 --- a/lua/custom/plugins/nullls.lua +++ /dev/null @@ -1,65 +0,0 @@ -return { - 'jay-babu/mason-null-ls.nvim', - lazy = false, - -- event = { "BufReadPre", "BufNewFile" }, - dependencies = { - 'williamboman/mason.nvim', - 'jose-elias-alvarez/null-ls.nvim', - }, - config = function() - require('mason').setup() - require('mason-null-ls').setup { - ensure_installed = { 'stylua', 'jq', 'eslint_d', 'jsonlint' }, - automatic_setup = false, - automatic_installation = false, - } - local nls = require 'null-ls' - local diagnostics = nls.builtins.diagnostics - local formatting = nls.builtins.formatting - local code_actions = nls.builtins.code_actions - local h = require 'null-ls.helpers' - local u = require 'null-ls.utils' - - local function eslint_d_cwd(params) - return u.root_pattern( - -- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats - '.eslintrc', - '.eslintrc.js', - '.eslintrc.cjs', - '.eslintrc.yaml', - '.eslintrc.yml', - '.eslintrc.json' - -- do not respect package.json - -- "package.json", - )(params.bufname) - end - require('null-ls').setup { - debug = true, - sources = { - -- Anything not supported by mason. - -- lua - formatting.stylua, - --json - diagnostics.jsonlint, - -- eslint - diagnostics.eslint_d.with { - cwd = h.cache.by_bufnr(eslint_d_cwd), - -- not sure how to scope this only to bcr's locales - -- extra_filetypes = { 'json' }, - }, - formatting.eslint_d.with { - cwd = h.cache.by_bufnr(eslint_d_cwd), - -- not sure how to scope this only to bcr's locales - extra_filetypes = { 'json' }, - }, - code_actions.eslint_d.with { - cwd = h.cache.by_bufnr(eslint_d_cwd), - -- not sure how to scope this only to bcr's locales - -- extra_filetypes = { 'json' }, - }, - -- refactoring - code_actions.refactoring, - }, - } - end, -}