diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 0000000..8e5c4a2 --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,25 @@ +name: format + +on: + push: + branches: + - main + paths: + - '**.lua' + +jobs: + postprocessing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Format with Stylua + uses: JohnnyMorganz/stylua-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: v0.16.1 + args: ./lua + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Format with stylua" diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 4bac4ba..3bf658f 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -16,13 +16,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Setup rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - default: true - override: true - - name: Setup neovim uses: rhysd/action-setup-vim@v1 with: @@ -40,12 +33,9 @@ jobs: - name: Setup tools shell: bash run: | - sudo apt install -y curl unzip --no-install-recommends - bash ./utils/install_stylua.sh luarocks install luacheck luarocks install vusted - name: Run tests shell: bash run: make integration - diff --git a/Makefile b/Makefile index e748135..d108f32 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,3 @@ -.PHONY: install-stylua -install-stylua: - @if [ ! -f "./utils/stylua" ]; then \ - sh ./utils/install_stylua.sh; \ - fi - -.PHONY: fmt -fmt: install-stylua - ./utils/stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua - .PHONY: lint lint: luacheck ./lua @@ -17,14 +7,11 @@ test: vusted --output=gtest ./lua .PHONY: pre-commit -pre-commit: install-stylua - ./utils/stylua --config-path stylua.toml --glob 'lua/**/*.lua' -- lua +pre-commit: luacheck lua vusted lua .PHONY: integration -integration: install-stylua - ./utils/stylua --config-path stylua.toml --check --glob 'lua/**/*.lua' -- lua +integration: luacheck lua vusted lua - diff --git a/lua/cmp/config/compare.lua b/lua/cmp/config/compare.lua index 318e527..3aad334 100644 --- a/lua/cmp/config/compare.lua +++ b/lua/cmp/config/compare.lua @@ -1,6 +1,5 @@ local types = require('cmp.types') local cache = require('cmp.utils.cache') -local misc = require('cmp.utils.misc') local compare = {} diff --git a/lua/cmp/entry.lua b/lua/cmp/entry.lua index c808c14..fbecaf4 100644 --- a/lua/cmp/entry.lua +++ b/lua/cmp/entry.lua @@ -60,7 +60,7 @@ entry.get_offset = function(self) if self:get_completion_item().textEdit then local range = self:get_insert_range() if range then - offset = self.context.cache:ensure('entry:' .. 'get_offset:'.. tostring(range.start.character), function() + offset = self.context.cache:ensure('entry:' .. 'get_offset:' .. tostring(range.start.character), function() for idx = range.start.character + 1, self.source_offset do if not char.is_white(string.byte(self.context.cursor_line, idx)) then return idx @@ -361,14 +361,7 @@ end ---@param matching_config cmp.MatchingConfig ---@return { score: integer, matches: table[] } entry.match = function(self, input, matching_config) - return self.match_cache:ensure( - input .. ':' .. - (self.resolved_completion_item and '1' or '0' .. ':') .. - (matching_config.disallow_fuzzy_matching and '1' or '0') .. ':' .. - (matching_config.disallow_partial_fuzzy_matching and '1' or '0') .. ':' .. - (matching_config.disallow_partial_matching and '1' or '0') .. ':' .. - (matching_config.disallow_prefix_unmatching and '1' or '0') - , function() + return self.match_cache:ensure(input .. ':' .. (self.resolved_completion_item and '1' or '0' .. ':') .. (matching_config.disallow_fuzzy_matching and '1' or '0') .. ':' .. (matching_config.disallow_partial_fuzzy_matching and '1' or '0') .. ':' .. (matching_config.disallow_partial_matching and '1' or '0') .. ':' .. (matching_config.disallow_prefix_unmatching and '1' or '0'), function() local option = { disallow_fuzzy_matching = matching_config.disallow_fuzzy_matching, disallow_partial_fuzzy_matching = matching_config.disallow_partial_fuzzy_matching, diff --git a/utils/install_stylua.sh b/utils/install_stylua.sh deleted file mode 100755 index 7e23bbe..0000000 --- a/utils/install_stylua.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash - -set -eu pipefall - -declare -r INSTALL_DIR="$PWD/utils" -declare -r RELEASE="0.10.0" -declare -r OS=$([ "$(uname -s)" == "Darwin" ] && echo "macos" || echo "linux") -declare -r FILENAME="stylua-$RELEASE-$OS" - -declare -a __deps=("curl" "unzip") - -function check_deps() { - for dep in "${__deps[@]}"; do - if ! command -v "$dep" >/dev/null; then - echo "Missing depdendecy!" - echo "The \"$dep\" command was not found!. Please install and try again." - fi - done -} - -function download_stylua() { - local DOWNLOAD_DIR - local URL="https://github.com/JohnnyMorganz/StyLua/releases/download/v$RELEASE/$FILENAME.zip" - - DOWNLOAD_DIR="$(mktemp -d)" - echo "Initiating download for Stylua v$RELEASE" - if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then - echo "Download failed. Check that the release/filename are correct." - exit 1 - fi - - echo "Installation in progress.." - unzip -q "$DOWNLOAD_DIR/$FILENAME.zip" -d "$DOWNLOAD_DIR" - - if [ -f "$DOWNLOAD_DIR/stylua" ]; then - mv "$DOWNLOAD_DIR/stylua" "$INSTALL_DIR/stylua" - else - mv "$DOWNLOAD_DIR/$FILENAME/stylua" "$INSTALL_DIR/." - fi - - chmod u+x "$INSTALL_DIR/stylua" -} - -function verify_install() { - echo "Verifying installation.." - local DOWNLOADED_VER - DOWNLOADED_VER="$("$INSTALL_DIR/stylua" -V | awk '{ print $2 }')" - if [ "$DOWNLOADED_VER" != "$RELEASE" ]; then - echo "Mismatched version!" - echo "Expected: v$RELEASE but got v$DOWNLOADED_VER" - exit 1 - fi - echo "Verification complete!" -} - -function main() { - check_deps - download_stylua - verify_install -} - -main "$@"