Skip to content

Commit

Permalink
chore: setup linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Conni2461 committed Nov 24, 2023
1 parent 0fc69eb commit 7ef4bcf
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 25 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: linting

on: [push, pull_request]

jobs:
luacheck:
name: Luacheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Prepare
run: |
sudo apt-get update
sudo apt-get install -y luarocks
sudo luarocks install luacheck
- name: Lint
run: sudo luacheck lua

stylua:
name: stylua
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
# CLI arguments
args: --color always --check lua/
23 changes: 23 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Rerun tests only if their modification time changed.
cache = true

std = luajit
codes = true

self = false

-- Glorious list of warnings: https://luacheck.readthedocs.io/en/stable/warnings.html
ignore = {
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
"122", -- Indirectly setting a readonly global
}

globals = {
"_",
"__TelescopeUISelectSpecificOpts",
}

-- Global objects defined by the C code
read_globals = {
"vim",
}
52 changes: 27 additions & 25 deletions lua/telescope/_extensions/ui-select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,34 @@ return require("telescope").register_extension {
local make_ordinal = vim.F.if_nil(sopts.make_ordinal, function(e)
return opts.format_item(e.text)
end)
pickers.new(topts, {
prompt_title = string.gsub(prompt, "\n", " "),
finder = finders.new_table {
results = indexed_items,
entry_maker = function(e)
return {
value = e,
display = make_display,
ordinal = make_ordinal(e),
}
pickers
.new(topts, {
prompt_title = string.gsub(prompt, "\n", " "),
finder = finders.new_table {
results = indexed_items,
entry_maker = function(e)
return {
value = e,
display = make_display,
ordinal = make_ordinal(e),
}
end,
},
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local selection = action_state.get_selected_entry()
if selection == nil then
utils.__warn_no_selection "ui-select"
return
end
actions.close(prompt_bufnr)
on_choice(selection.value.text, selection.value.idx)
end)
return true
end,
},
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local selection = action_state.get_selected_entry()
if selection == nil then
utils.__warn_no_selection "ui-select"
return
end
actions.close(prompt_bufnr)
on_choice(selection.value.text, selection.value.idx)
end)
return true
end,
sorter = conf.generic_sorter(topts),
}):find()
sorter = conf.generic_sorter(topts),
})
:find()
end
end,
}

0 comments on commit 7ef4bcf

Please sign in to comment.