From 4274d31d39e00f9758a3727f74f1a05688cfca41 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Thu, 8 Sep 2022 20:43:59 +0100 Subject: [PATCH] chore(vim): move lint code into the lua lint file This was not working on for some reason in vim script --- site-modules/core/files/vim/init.vim | 6 ------ site-modules/core/files/vim/plugin/lint.lua | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/site-modules/core/files/vim/init.vim b/site-modules/core/files/vim/init.vim index 7dbdf5a..1d430a3 100644 --- a/site-modules/core/files/vim/init.vim +++ b/site-modules/core/files/vim/init.vim @@ -64,12 +64,6 @@ inoremap A; noremap ; gcc "vnoremap ; gc -" Lint code with nvim-lint on save. This will lint all filetypes with cspell -" and then any other filetypes will be linted per the config. -au BufWritePost,BufReadPost lua require('lint').try_lint('cspell') -au BufWritePost,BufReadPost lua require('lint').try_lint() - - inoremap jj :w nnoremap diff --git a/site-modules/core/files/vim/plugin/lint.lua b/site-modules/core/files/vim/plugin/lint.lua index 034af32..6e2f20d 100644 --- a/site-modules/core/files/vim/plugin/lint.lua +++ b/site-modules/core/files/vim/plugin/lint.lua @@ -46,3 +46,17 @@ lint.linters_by_ft = { lua = {'luacheck'}, } + +-- Lint code with nvim-lint on save. This will lint all filetypes with cspell +-- and then any other filetypes will be linted per the config. +local lint_auto_command_group = vim.api.nvim_create_augroup("aa_lint", { clear = true }) +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { + group = lint_auto_command_group, + desc = "Lint the buffer", + pattern = "*", + callback = function() + lint.try_lint('cspell') + lint.try_lint() + end, +}) +