Skip to content

Commit 07a2a29

Browse files
authored
Merge pull request #33 from benfowler/fixCodeCosmeticIssues
Fix code cosmetic issues
2 parents 127dac8 + 06b3c64 commit 07a2a29

File tree

7 files changed

+83
-13
lines changed

7 files changed

+83
-13
lines changed

.github/workflows/lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Linting and style checking
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
luacheck:
7+
name: Luacheck
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Prepare
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install -y luarocks
16+
sudo luarocks install luacheck
17+
18+
- name: Lint
19+
run: sudo make lint
20+
21+
stylua:
22+
name: stylua
23+
runs-on: ubuntu-22.04
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: JohnnyMorganz/stylua-action@v4
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
version: latest
30+
# CLI arguments
31+
args: --color always --check lua/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
.luacheckcache
3+

.luacheckrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Rerun tests only if their modification time changed.
2+
cache = true
3+
4+
std = luajit
5+
codes = true
6+
7+
self = false
8+
9+
-- Glorious list of warnings: https://luacheck.readthedocs.io/en/stable/warnings.html
10+
ignore = {
11+
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
12+
"122", -- Indirectly setting a readonly global
13+
}
14+
15+
globals = {
16+
-- ?? "_",
17+
}
18+
19+
-- Global objects defined by the C code
20+
read_globals = {
21+
"vim",
22+
}

.stylua.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

2-
column_width = 100
2+
column_width = 120
33
line_endings = "Unix"
44
indent_type = "Spaces"
55
indent_width = 2
66
quote_style = "AutoPreferSingle"
7-
call_parentheses = "Always"
7+
call_parentheses = "None"
8+
9+
[sort_requires]
10+
enabled = true

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.PHONY: lint stylua
2+
3+
4+
lint:
5+
luacheck lua/telescope
6+
7+
stylua:
8+
stylua --color always lua/
9+
10+

lua/telescope/_extensions/luasnip.lua

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
local has_telescope, telescope = pcall(require, 'telescope')
22
if not has_telescope then
3-
error('This plugins requires nvim-telescope/telescope.nvim')
3+
error 'This plugins requires nvim-telescope/telescope.nvim'
44
end
55

66
-- stylua: ignore start
7-
local actions = require("telescope.actions")
87
local action_state = require("telescope.actions.state")
8+
local actions = require("telescope.actions")
9+
local entry_display = require("telescope.pickers.entry_display")
910
local finders = require("telescope.finders")
1011
local pickers = require("telescope.pickers")
1112
local previewers = require("telescope.previewers")
12-
local entry_display = require("telescope.pickers.entry_display")
1313
local conf = require("telescope.config").values
1414
local ext_conf = require("telescope._extensions")
1515
-- stylua: ignore end
@@ -73,7 +73,7 @@ local _opts = {
7373
M.opts = _opts
7474

7575
M.luasnip_fn = function(opts)
76-
local opts = vim.tbl_extend('keep', opts or {}, M.opts or _opts)
76+
opts = vim.tbl_extend('keep', opts or {}, M.opts or _opts)
7777

7878
-- print(("debug: %s: opts.test"):format(debug.getinfo(1).source))
7979
-- print(vim.inspect(opts.test))
@@ -89,7 +89,7 @@ M.luasnip_fn = function(opts)
8989
end
9090
end
9191
else
92-
print('LuaSnips is not available')
92+
print 'LuaSnip is not available'
9393
end
9494

9595
table.sort(objs, function(a, b)
@@ -102,18 +102,18 @@ M.luasnip_fn = function(opts)
102102
end
103103
end)
104104

105-
local displayer = entry_display.create({
105+
local displayer = entry_display.create {
106106
separator = ' ',
107107
items = { { width = 12 }, { width = 24 }, { width = 16 }, { remaining = true } },
108-
})
108+
}
109109

110110
local make_display = function(entry)
111-
return displayer({
111+
return displayer {
112112
entry.value.ft,
113113
entry.value.context.name,
114114
{ entry.value.context.trigger, 'TelescopeResultsNumber' },
115115
filter_description(entry.value.context.name, entry.value.context.description),
116-
})
116+
}
117117
end
118118

119119
-- stylua: ignore
@@ -122,14 +122,15 @@ M.luasnip_fn = function(opts)
122122
finder = finders.new_table({
123123
results = objs,
124124
entry_maker = function(entry)
125-
search_fn = ext_conf._config.luasnip
125+
local search_fn = ext_conf._config.luasnip
126126
and ext_conf._config.luasnip.search
127127
or default_search_text
128128
return {
129129
value = entry,
130130
filename = entry.context.trigger,
131131
display = make_display,
132-
text = string.format(" %s | %s | %s", entry.ft, entry.context.name, entry.context.description[1] or ''),
132+
text = string.format(" %s | %s | %s", entry.ft, entry.context.name,
133+
entry.context.description[1] or ''),
133134
ordinal = search_fn(entry),
134135
preview_command = function(_, bufnr)
135136
local snippet = get_docstring(luasnip, entry.ft, entry.context)

screenshot.png

177 KB
Loading

0 commit comments

Comments
 (0)