From 836286798e959fbaa43bd4502561cf85aea537c9 Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Sat, 17 Jul 2021 00:30:38 +0200 Subject: [Feature] add linter support (#982) --- lua/core/linter.lua | 33 +++++++++++++++++++++++++++++++++ lua/core/which-key.lua | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lua/core/linter.lua (limited to 'lua/core') diff --git a/lua/core/linter.lua b/lua/core/linter.lua new file mode 100644 index 00000000..9c6649a8 --- /dev/null +++ b/lua/core/linter.lua @@ -0,0 +1,33 @@ +local M = {} + +M.setup = function() + if O.lint_on_save then + require("lv-utils").define_augroups { + autolint = { + { + "BufWritePost", + "", + ":silent lua require('lint').try_lint()", + }, + { + "BufEnter", + "", + ":silent lua require('lint').try_lint()", + }, + }, + } + end +end + +local status_ok, linter = pcall(require, "lint") +if not status_ok then + return +end + +if not O.lint_on_save then + vim.cmd [[if exists('#autolint#BufWritePost') + :autocmd! autolint + endif]] +end + +return M diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 6f034e3e..ec64074b 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -127,9 +127,10 @@ M.config = function() "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})", "Prev Diagnostic", }, + l = { "silent lua require('lint').try_lint()", "Lint" }, q = { "Telescope quickfix", "Quickfix" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, - s = { " Telescope lsp_document_symbols", "Document Symbols" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { "Telescope lsp_dynamic_workspace_symbols", "Workspace Symbols", -- cgit v1.2.3