aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Veiga <jose86veiga@gmail.com>2023-02-10 20:06:41 -0500
committerGitHub <noreply@github.com>2023-02-11 09:06:41 +0800
commitc87b3f76ecec5719d9eccd54559e7c1bc57f7127 (patch)
treebe5aaf87091712889186678bf76e9ff914de4e74
parentchore(license): move copyright notice to readme (#2448) (diff)
downloadnvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.tar
nvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.tar.gz
nvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.tar.bz2
nvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.tar.lz
nvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.tar.xz
nvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.tar.zst
nvim-lspconfig-c87b3f76ecec5719d9eccd54559e7c1bc57f7127.zip
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
-rw-r--r--lua/lspconfig/server_configurations/eslint.lua12
1 files changed, 10 insertions, 2 deletions
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.