Skip to content

Commit 9a00937

Browse files
phanenibhagwan
authored andcommitted
chore: luals fixes
1 parent 81a008d commit 9a00937

18 files changed

Lines changed: 90 additions & 40 deletions

File tree

.luarc.jsonc

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
33
"runtime.version": "LuaJIT",
4+
"format": {
5+
"enable": true,
6+
"defaultConfig": {
7+
"indent_style": "space",
8+
"indent_size": "2"
9+
}
10+
},
411
"diagnostics": {
512
"enable": true,
6-
"globals": ["vim", "describe", "it" ],
13+
"globals": ["vim", "describe", "it"],
714
"neededFileStatus": {
815
"codestyle-check": "Any"
916
},
10-
"disable": ["need-check-nil", "missing-parameter", "cast-local-type"]
17+
"groupFileStatus": {
18+
// "strict": "Opened",
19+
// "strong": "Opened",
20+
// "ambiguity": "Opened",
21+
// "duplicate": "Opened",
22+
// "global": "Opened",
23+
// "luadoc": "Opened",
24+
// "redefined": "Opened",
25+
// "type-check": "Opened",
26+
// "unbalanced": "Opened",
27+
// "unused": "Opened"
28+
},
29+
"disable": ["need-check-nil", "missing-parameter", "cast-local-type"],
30+
"unusedLocalExclude": ["_*"]
1131
},
1232
"workspace": {
1333
"library": [
14-
"lua",
15-
"$VIMRUNTIME/lua",
34+
"$VIMRUNTIME",
1635
"${3rd}/luv/library",
17-
"$XDG_DATA_HOME/nvim/lazy/plenary.nvim/lua",
18-
"$LOCALAPPDATA/nvim-data/lazy/plenary.nvim/lua",
1936
// For "cmp_src.lua" type resolving
20-
"$XDG_DATA_HOME/nvim/lazy/nvim-cmp/lua",
21-
"$LOCALAPPDATA/nvim-data/lazy/nvim-cmp/lua"
37+
"deps/mini.nvim",
38+
"deps/nvim-web-devicons",
39+
"deps/nvim-cmp"
2240
],
2341
"checkThirdParty": false,
2442
"maxPreload": 2000,
25-
"preloadFileSize": 1000,
26-
"ignoreDir": ["tests/"]
43+
"preloadFileSize": 1000
2744
},
2845
"type": {
2946
"weakNilCheck": true,
@@ -32,7 +49,7 @@
3249
},
3350
"hint": {
3451
"enable": true,
35-
"setType": true,
52+
"setType": true
3653
},
3754
"telemetry.enable": false
3855
}

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ screenshots:
2626

2727
.PHONY: clean-screenshots
2828
clean-screenshots:
29-
rm -rf tests/screenshots/*
29+
rm -rf tests/screenshots/*
3030
make test
3131

3232
#
@@ -39,8 +39,13 @@ deps:
3939
make clean
4040
@mkdir -p deps
4141
git clone --depth=1 --single-branch https://github.com/echasnovski/mini.nvim deps/mini.nvim
42-
git clone --depth=1 --single-branch https://github.com/nvim-tree/nvim-web-devicons \
43-
deps/nvim-web-devicons
42+
git clone --depth=1 --single-branch https://github.com/nvim-tree/nvim-web-devicons deps/nvim-web-devicons
43+
git clone --depth=1 --single-branch https://github.com/hrsh7th/nvim-cmp deps/nvim-cmp
44+
45+
.PHONY: lint
46+
lint:
47+
VIMRUNTIME="$$(nvim --clean --headless +'echo $$VIMRUNTIME' +q 2>&1)" lua-language-server --configpath=../.luarc.jsonc --check=.
48+
4449

4550
# clean up
4651
.PHONY: clean

lua/fzf-lua/actions.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ M.resume = function(_, _)
140140
loadstring([[require("fzf-lua").resume()]])()
141141
end
142142

143+
---@param _vimcmd string
144+
---@param selected string[]
145+
---@param opts fzf-lua.Config
146+
---@param pcall_vimcmd boolean?
147+
---@return string?
143148
M.vimcmd_entry = function(_vimcmd, selected, opts, pcall_vimcmd)
144149
for i, sel in ipairs(selected) do
145150
(function()
@@ -244,7 +249,7 @@ M.vimcmd_entry = function(_vimcmd, selected, opts, pcall_vimcmd)
244249
-- nvim_exec2(): Vim(normal):Can't re-enter normal mode from terminal mode
245250
pcall(utils.jump_to_location, entry, "utf-16", opts.reuse_win)
246251
else
247-
utils.jump_to_location(entry, "utf-16", opts.reuse_win)
252+
utils.jump_to_location(entry --[[@as lsp.Location]], "utf-16", opts.reuse_win)
248253
end
249254
elseif entry.ctag and entry.line == 0 then
250255
vim.api.nvim_win_set_cursor(0, { 1, 0 })
@@ -333,7 +338,7 @@ local sel_to_qf = function(selected, opts, is_loclist)
333338
else
334339
-- Set the quickfix title to last query and
335340
-- append a new list to end of the stack (#635)
336-
vim.fn.setqflist({}, " ", {
341+
vim.fn.setqflist({}, " ", { ---@diagnostic disable-next-line: assign-type-mismatch
337342
nr = "$",
338343
items = qf_list,
339344
title = title,

lua/fzf-lua/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ M.fzf_exec = function(contents, opts)
160160
return M.fzf_wrap(contents, opts, true)
161161
end
162162

163-
---@param contents string|fun(query: string): string|string[]|function
163+
---@param contents string|fun(query: string[]): string|string[]|function
164164
---@param opts? table
165165
M.fzf_live = function(contents, opts)
166166
assert(contents)

lua/fzf-lua/libuv.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local base64 = require("fzf-lua.lib.base64")
1111
local serpent = require("fzf-lua.lib.serpent")
1212

1313
---@param pid integer
14-
---@param signal integer?
14+
---@param signal integer|string?
1515
---@returns boolean
1616
local function process_kill(pid, signal)
1717
if not pid or not tonumber(pid) then return false end

lua/fzf-lua/path.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ function M.entry_to_ctag(entry, noesc)
387387
return ctag
388388
end
389389

390+
---@return fzf-lua.path.Entry
390391
function M.entry_to_location(entry, opts)
391392
local uri, line, col = entry:match("^(.*://.*):(%d+):(%d+):")
392393
line = line and tonumber(line) > 0 and tonumber(line) or 1
@@ -410,7 +411,7 @@ end
410411

411412
---@param entry string
412413
---@param opts fzf-lua.Config
413-
---@param force_uri boolean
414+
---@param force_uri boolean?
414415
---@return fzf-lua.path.Entry
415416
function M.entry_to_file(entry, opts, force_uri)
416417
opts = opts or {}

lua/fzf-lua/previewer/builtin.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,7 @@ function Previewer.nvim_options:new(o, opts, fzf_win)
17661766
Previewer.nvim_options.super.new(self, o, opts, fzf_win)
17671767
local paths = vim.fn.globpath(vim.o.rtp, "doc/options.txt", false, true)
17681768
self.lines = vim.fn.readfile(paths[1])
1769+
return self
17691770
end
17701771

17711772
function Previewer.nvim_options:gen_winopts()

lua/fzf-lua/previewer/codeaction.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ local function diff_text_edits(text_edits, bufnr, offset_encoding, diff_opts)
3333
vim.lsp.util.apply_text_edits(text_edits, tmpbuf, offset_encoding)
3434
local new_lines = get_lines(tmpbuf)
3535
vim.api.nvim_buf_delete(tmpbuf, { force = true })
36-
local diff = vim.diff(
36+
---@diagnostic disable-next-line: deprecated
37+
local diff = (vim.diff or vim.text.diff)(
3738
table.concat(orig_lines, eol) .. eol,
3839
table.concat(new_lines, eol) .. eol,
3940
diff_opts)

lua/fzf-lua/previewer/fzf.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function Previewer.cmd_async:cmdline(o)
214214
local cmd = errcmd or ("%s %s %s"):format(
215215
self.cmd, self.args, libuv.shellescape(filepath))
216216
return cmd
217-
end, self.opts, "{} {q}", false)
217+
end, self.opts, "{} {q}")
218218
return act
219219
end
220220

@@ -278,7 +278,7 @@ function Previewer.bat_async:cmdline(o)
278278
line_range,
279279
libuv.shellescape(filepath))
280280
return cmd
281-
end, self.opts, "{} {q}", false)
281+
end, self.opts, "{} {q}")
282282
return act
283283
end
284284

@@ -379,7 +379,7 @@ function Previewer.git_diff:cmdline(o)
379379
-- cmd = string.format("%s %s %s", table.concat(setenv, " "), cmd, pager)
380380
cmd = string.format("%s %s", cmd, pager)
381381
return { cmd = cmd, env = env }
382-
end, self.opts, "{}", false)
382+
end, self.opts, "{}")
383383
return act
384384
end
385385

@@ -398,7 +398,7 @@ function Previewer.man_pages:cmdline(o)
398398
local manpage = require("fzf-lua.providers.manpages").manpage_sh_arg(items[1])
399399
local cmd = self.cmd:format(manpage)
400400
return cmd
401-
end, self.opts, "{}", false)
401+
end, self.opts, "{}")
402402
return act
403403
end
404404

@@ -435,7 +435,7 @@ function Previewer.help_tags:cmdline(o)
435435
end
436436
end
437437
return cmd
438-
end, self.opts, "{}", false)
438+
end, self.opts, "{}")
439439
return act
440440
end
441441

lua/fzf-lua/providers/dap.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
---@diagnostic disable: undefined-field, param-type-mismatch
12
local uv = vim.uv or vim.loop
23
local core = require "fzf-lua.core"
34
local utils = require "fzf-lua.utils"
4-
local shell = require "fzf-lua.shell"
55
local config = require "fzf-lua.config"
66
local make_entry = require "fzf-lua.make_entry"
77

@@ -205,7 +205,7 @@ M.frames = function(opts)
205205
end)
206206
return {
207207
path = f.source.path,
208-
content = vim.split(result.content or "", "\n"),
208+
content = result and vim.split(result.content or "", "\n") or nil,
209209
line = f.line,
210210
}
211211
end

0 commit comments

Comments
 (0)