From d0a139abcac1156ea218497db947a16d236ba055 Mon Sep 17 00:00:00 2001 From: Benjamin Rae Date: Mon, 27 Nov 2023 11:06:56 +0100 Subject: [PATCH] feat: setup eslint autoformat with eslint_ls --- lua/kickstart/plugins/autoformat.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/kickstart/plugins/autoformat.lua index bc56b15b..eb837c5a 100644 --- a/lua/kickstart/plugins/autoformat.lua +++ b/lua/kickstart/plugins/autoformat.lua @@ -39,14 +39,18 @@ return { local client = vim.lsp.get_client_by_id(client_id) local bufnr = args.buf - -- Only attach to clients that support document formatting - if not client.server_capabilities.documentFormattingProvider then - return - end - -- Tsserver usually works poorly. Sorry you work with bad languages -- You can remove this line if you know what you're doing :) if client.name == 'tsserver' then + client.server_capabilities.documentFormattingProvider = false + end + + if client.name == 'eslint_ls' then + client.server_capabilities.documentFormattingProvider = true + end + + -- Only attach to clients that support document formatting + if not client.server_capabilities.documentFormattingProvider then return end