From c87b3f76ecec5719d9eccd54559e7c1bc57f7127 Mon Sep 17 00:00:00 2001 From: Jose Veiga Date: Fri, 10 Feb 2023 20:06:41 -0500 Subject: docs(eslint): fix on save example creates a buflocal autocmd (#2450) * docs(eslint): fix on save example creates a buflocal autocmd * docs(eslint): fix example spacing --- lua/lspconfig/server_configurations/eslint.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/eslint.lua b/lua/lspconfig/server_configurations/eslint.lua index 92a44ac4..dc71e94f 100644 --- a/lua/lspconfig/server_configurations/eslint.lua +++ b/lua/lspconfig/server_configurations/eslint.lua @@ -181,8 +181,16 @@ npm i -g vscode-langservers-extracted ``` `vscode-eslint-language-server` provides an `EslintFixAll` command that can be used to format a document on save: -```vim -autocmd BufWritePre *.tsx,*.ts,*.jsx,*.js EslintFixAll +```lua +lspconfig.eslint.setup({ + --- ... + on_attach = function(client, bufnr) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + command = "EslintFixAll", + }) + end, +}) ``` See [vscode-eslint](https://github.com/microsoft/vscode-eslint/blob/55871979d7af184bf09af491b6ea35ebd56822cf/server/src/eslintServer.ts#L216-L229) for configuration options. -- cgit v1.2.3-70-g09d2