From 31581abcfb33c5c18dc21e11241ed5e5d2f382c6 Mon Sep 17 00:00:00 2001 From: pmeinhardt Date: Mon, 20 Feb 2023 16:16:34 +0100 Subject: [PATCH] Check Vim plugin code with Vint --- .github/workflows/checks.yml | 13 +++++++++++++ plugin/ql.vim | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1d65bd0..07fef82 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,3 +15,16 @@ jobs: run: make - name: Run run: test -x bin/ql && (bin/ql || true) + vint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.11 + - name: Install dependencies + run: | + pip install --upgrade pip + pip install vim-vint + - name: Run vint + run: vint . diff --git a/plugin/ql.vim b/plugin/ql.vim index 046a81b..41f66d5 100644 --- a/plugin/ql.vim +++ b/plugin/ql.vim @@ -8,7 +8,7 @@ let s:cmd = exepath(s:path . '/bin/ql') if exists('g:ql_command') let s:cmd = g:ql_command -elseif s:cmd != '' +elseif !empty(s:cmd) let s:cmd = s:cmd . ' --title "$TITLE"' elseif executable('ql') let s:cmd = exepath('ql') . ' --title "$TITLE"' @@ -37,13 +37,13 @@ endfunction function! s:view(...) abort let argc = a:0 - if argc == 0 + if argc > 0 + let path = a:1 + let name = fnamemodify(path, ':t') + else let name = expand('%:t') let path = tempname() . '.' . name silent execute 'write ' . fnameescape(path) - else - let path = a:1 - let name = fnamemodify(path, ':t') endif if !filereadable(path)