From 5d0d3159425dd1fc0ba2935bfd61b3eac0105882 Mon Sep 17 00:00:00 2001 From: "Andy K. Massimino" Date: Sun, 18 Apr 2021 09:50:31 -0400 Subject: [PATCH] Lint lua --- .github/workflows/lint.yml | 20 ++++++++++++++++++++ .github/workflows/scripts/style-check.sh | 3 +++ lua/treesitter-matchup/internal.lua | 11 +++++------ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/scripts/style-check.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5be5422 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Linting and style checking + +on: [push, pull_request] + +jobs: + luacheck: + name: Luacheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Prepare + run: | + sudo apt-get update + sudo add-apt-repository universe + sudo apt install luarocks -y + sudo luarocks install luacheck + + - name: Run Luacheck + run: sudo ./.github/workflows/scripts/style-check.sh diff --git a/.github/workflows/scripts/style-check.sh b/.github/workflows/scripts/style-check.sh new file mode 100644 index 0000000..181ab45 --- /dev/null +++ b/.github/workflows/scripts/style-check.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +luacheck `find -name "*.lua"` --codes diff --git a/lua/treesitter-matchup/internal.lua b/lua/treesitter-matchup/internal.lua index 1b9dddd..8584101 100644 --- a/lua/treesitter-matchup/internal.lua +++ b/lua/treesitter-matchup/internal.lua @@ -5,7 +5,6 @@ end local vim = vim local api = vim.api local configs = require'nvim-treesitter.configs' -local locals = require'nvim-treesitter.locals' local parsers = require'nvim-treesitter.parsers' local queries = require'nvim-treesitter.query' local ts_utils = require'nvim-treesitter.ts_utils' @@ -14,7 +13,7 @@ local util = require'treesitter-matchup.util' local M = {} -local cache = lru.new(100) +local cache = lru.new(150) function M.is_enabled(bufnr) local buf = bufnr or api.nvim_get_current_buf() @@ -136,7 +135,7 @@ end --- Fill in a match result based on a seed node function M.do_node_result(initial_node, bufnr, opts) - local node, side, key = M.active_node(initial_node, bufnr) + local _, side, key = M.active_node(initial_node, bufnr) if not side then return nil end @@ -146,7 +145,7 @@ function M.do_node_result(initial_node, bufnr, opts) return nil end - row, col, _ = initial_node:start() + local row, col, _ = initial_node:start() local result = { type = 'delim_py', @@ -213,7 +212,7 @@ function M.get_delim(bufnr, opts) if opts.direction == 'next' and pos >= cur_pos or opts.direction == 'prev' and pos <= cur_pos then - dist = math.abs(pos - cur_pos) + local dist = math.abs(pos - cur_pos) if dist < closest_dist then closest_dist = dist closest_node = node @@ -274,7 +273,7 @@ function M.get_matching(delim, down, bufnr) -- no stop marker is found, use enclosing scope if down and not got_close then - row, col, _ = info.scope:end_() + local row, col, _ = info.scope:end_() table.insert(matches, {'', row + 1, col + 1}) end