From 0b64cf2329bfcbfbe336a27c1e16d423125d64b6 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Salinas Date: Wed, 2 Aug 2023 14:41:24 -0400 Subject: [PATCH] lsp: configure lua to ignore unused locals starting with '_' --- init.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 5383d4a..d40d389 100644 --- a/init.lua +++ b/init.lua @@ -201,7 +201,7 @@ local lsp = require("lspconfig") -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer -local on_lsp_attach = function(client, bufnr) +local on_lsp_attach = function(_client, _bufnr) vim.keymap.set("n", "gD", vim.lsp.buf.declaration) vim.keymap.set("n", "gd", vim.lsp.buf.definition) vim.keymap.set("n", "K", vim.lsp.buf.hover) @@ -232,7 +232,10 @@ local servers = { settings = { Lua = { runtime = { version = "LuaJIT" }, - diagnostics = { globals = { "vim" } }, + diagnostics = { + globals = { "vim" }, + unusedLocalExclude = { "_*" }, + }, workspace = { library = vim.api.nvim_get_runtime_file("", true), }, @@ -338,7 +341,6 @@ for ft, ft_linters in pairs(linters) do lint.try_lint(nil, { ignore_errors = true }) end, }) - lint.try_lint(nil, { ignore_errors = true }) end, }) end @@ -425,7 +427,7 @@ end g.gitblame_enabled = 0 ---- gitsigns.nvim require("gitsigns").setup({ - on_attach = function(bufnr) + on_attach = function(_bufnr) local gs = package.loaded.gitsigns -- Navigation