From 113e44cb04858feed13286384d578dbd9a0f20d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 10 May 2024 18:50:22 +0300 Subject: [PATCH] neovim: attach eslint fix to the buffer --- flake.lock | 8 ++++---- neovim/dev.nix | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index 6773082..ba25cdf 100644 --- a/flake.lock +++ b/flake.lock @@ -281,11 +281,11 @@ ] }, "locked": { - "lastModified": 1715345894, - "narHash": "sha256-zf+D09uEUkbQKSpfdAqjIvCUKhVCe/NcJiyI9pyg1QU=", + "lastModified": 1715356074, + "narHash": "sha256-N1X04uvlAIStx/hzYZcqUhXiJne2sb3hxNDYA8DvJ3Q=", "ref": "refs/heads/main", - "rev": "77963b81974872d4f6693e7e6db1ea8d9eca4a72", - "revCount": 60, + "rev": "8d76150a25ca2bcf2383877518ea19133414f210", + "revCount": 61, "type": "git", "url": "https://git.pleshevski.ru/pleshevskiy/nixeovim" }, diff --git a/neovim/dev.nix b/neovim/dev.nix index bacf785..b503da9 100644 --- a/neovim/dev.nix +++ b/neovim/dev.nix @@ -73,7 +73,7 @@ in telescope.extensions.telescope-live-grep-args-nvim.settings = { auto_quoting = true; mappings.i = { - "" = pipe1 + "${ctrl "k"}" = pipe1 (require "telescope-live-grep-args.actions") (call0 "quote_prompt") ; @@ -81,6 +81,17 @@ in }; }; + fn.lspconfig-eslint-on-attach = { + args = [ "client" "bufnr" ]; + content = { bufnr, ... }: { + vim.augroup.eslint-fix = { + event = "BufWritePre"; + buffer = bufnr; + command = "silent! EslintFixAll"; + }; + }; + }; + plugins.language-server.lspconfig.serverSettings = { nil_ls = { }; rust_analyzer = { @@ -95,16 +106,7 @@ in }; tsserver = { }; eslint = { - # TODO: on attach - /* - vim.cmd([[ - aug eslint_fix - au! - au BufWritePre *.tsx,*.ts,*.jsx,*.js silent! EslintFixAll - aug END - ]]) - */ - + on_attach = config.fn.lspconfig-eslint-on-attach.lambda; }; volar = { init_options = {