Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit 7aedc74

Browse files
committed
refactor: respect luacheck
1 parent 8283680 commit 7aedc74

11 files changed

Lines changed: 20 additions & 31 deletions

File tree

lua/completion.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
local vim = vim
22
local api = vim.api
3-
local util = require 'completion.util'
43
local source = require 'source'
54
local signature = require'completion.signature_help'
65
local hover = require'completion.hover'
@@ -161,6 +160,7 @@ M.completionToggle = function()
161160
end
162161
end
163162

163+
-- Deprecated
164164
M.customize_buf_label = function(label)
165165
api.nvim_buf_set_var(0, "completion_buf_customize_lsp_label", label)
166166
end

lua/completion/chain_completion.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ local function chain_list_to_tree(complete_list)
3737
end
3838
end
3939

40-
function getScopedChain(ft_subtree)
40+
local function getScopedChain(ft_subtree)
4141

4242
local function syntaxGroupAtPoint()
4343
local pos = api.nvim_win_get_cursor(0)
@@ -112,7 +112,6 @@ function M.checkHealth(complete_items_map)
112112
if not error then
113113
health_ok("all completion source are valid")
114114
end
115-
116115
end
117116

118117
return M

lua/completion/health.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ local source = require'source'
55
local health_start = vim.fn["health#report_start"]
66
local health_ok = vim.fn['health#report_ok']
77
local health_info = vim.fn['health#report_info']
8-
local health_warn = vim.fn['health#report_warn']
98
local health_error = vim.fn['health#report_error']
109

1110
local M = {}

lua/completion/hover.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-- define some hover related function modified from neovim source code
12
local vim = vim
23
local validate = vim.validate
34
local api = vim.api
@@ -320,7 +321,6 @@ M.autoOpenHoverInPopup = function(manager)
320321
if user_data['hover'] ~= nil and type(user_data['hover']) == 'string' and #user_data['hover'] ~= 0 then
321322
local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(user_data['hover'])
322323
markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines)
323-
local bufnr, winnr
324324
local position = vim.fn.pum_getpos()
325325
-- Set max width option to avoid overlapping with popup menu
326326
local total_column = api.nvim_get_option('columns')
@@ -330,7 +330,7 @@ M.autoOpenHoverInPopup = function(manager)
330330
else
331331
align = 'left'
332332
end
333-
bufnr, winnr = fancy_floating_markdown(markdown_lines, {
333+
local _, winnr = fancy_floating_markdown(markdown_lines, {
334334
pad_left = 1; pad_right = 1;
335335
col = position['col']; width = position['width']; row = position['row']-1;
336336
align = align
@@ -349,7 +349,6 @@ M.autoOpenHoverInPopup = function(manager)
349349
textDocument = vim.lsp.util.make_text_document_params();
350350
position = { line = row; character = col-1; }
351351
}
352-
local winnr
353352
vim.lsp.buf_request(bufnr, 'textDocument/hover', params)
354353
end
355354
manager.textHover = false

lua/completion/signature_help.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ function M.open_floating_preview(contents, filetype, opts)
8181
end
8282
api.nvim_buf_set_lines(floating_bufnr, 0, -1, true, contents)
8383
api.nvim_buf_set_option(floating_bufnr, 'modifiable', false)
84-
api.nvim_command("autocmd CursorMovedI,BufHidden,TextChangedI,InsertLeave <buffer> ++once lua pcall(vim.api.nvim_win_close, "
85-
..floating_winnr..", true)")
84+
api.nvim_command("autocmd CursorMovedI,BufHidden,TextChangedI,InsertLeave <buffer> ++once \
85+
lua pcall(vim.api.nvim_win_close, "..floating_winnr..", true)")
8686
return floating_bufnr, floating_winnr
8787
end
8888

@@ -124,7 +124,7 @@ local signature_help_to_preview_contents = function(input)
124124
return contents
125125
end
126126

127-
M.autoOpenSignatureHelp = function(bufnr, line_to_cursor)
127+
M.autoOpenSignatureHelp = function()
128128
local bufnr = api.nvim_get_current_buf()
129129
local pos = api.nvim_win_get_cursor(0)
130130
local line = api.nvim_get_current_line()

lua/completion/util.lua

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
------------------------------------------------------------------------
2+
-- utility function that are modified from neovim's source --
3+
------------------------------------------------------------------------
4+
15
local protocol = require 'vim.lsp.protocol'
26
local vim = vim
37
local api = vim.api
@@ -7,9 +11,6 @@ function M.is_list(thing)
711
return vim.fn.type(thing) == api.nvim_get_vvar("t_list")
812
end
913

10-
------------------------------------------------------------------------
11-
-- utility function that are modified from neovim's source --
12-
------------------------------------------------------------------------
1314

1415
------------------------
1516
-- completion items --
@@ -51,9 +52,6 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
5152
end
5253

5354
local customize_label = vim.g.completion_customize_lsp_label
54-
local buf_customize_label = api.nvim_call_function(
55-
'completion#get_buffer_variable', {'completion_buf_customize_lsp_label'})
56-
if buf_customize_label == nil then buf_customize_label = {} end
5755
items = remove_unmatch_completion_items(items, prefix)
5856
-- sort_completion_items(items)
5957

@@ -86,12 +84,12 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
8684
table.insert(matches, {
8785
word = word,
8886
abbr = completion_item.label,
89-
kind = buf_customize_label[kind] or customize_label[kind] or kind or '',
87+
kind = customize_label[kind] or kind or '',
9088
menu = completion_item.detail or '',
9189
info = info,
9290
priority = priority,
9391
icase = 1,
94-
user_data = vim.fn.json_encode(user_data),
92+
user_data = user_data,
9593
dup = 1,
9694
empty = 1,
9795
})

lua/source.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ M.stop_complete = false
3535
-- local function --
3636
------------------------------------------------------------------------
3737

38-
local getTriggerCharacter = function(complete_source)
38+
local getTriggerCharacter = function()
3939
local triggerCharacter = {}
4040
local complete_source = M.chain_complete_list[M.chain_complete_index]
4141
if complete_source ~= nil and vim.fn.has_key(complete_source, "complete_items") > 0 then

lua/source/ins_complete.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ M.triggerCompletion = function(manager, mode)
5050
checkEmptyCompletion(manager)
5151
end
5252
else
53-
insertChar = false
53+
manager.insertChar = false
5454
end
5555
end
5656

lua/source/lsp.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ M.getCallback = function()
1313
return M.callback
1414
end
1515

16-
M.triggerFunction = function(prefix, _, bufnr, manager)
16+
M.triggerFunction = function(prefix, _, bufnr, _)
1717
local params = vim.lsp.util.make_position_params()
1818
M.callback = false
1919
M.items = {}

lua/source/path.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ M.items = {}
77
M.callback = false
88

99
-- onDirScanned handler for vim.loop
10-
local function onDirScanned(err, data)
11-
if err then
12-
-- print('ERROR: ', err)
13-
-- TODO handle err
14-
end
10+
local function onDirScanned(_, data)
1511
if data then
1612
local function iter()
1713
return vim.loop.fs_scandir_next(data)
@@ -31,7 +27,7 @@ local fileTypesMap = setmetatable({
3127
['block'] = "(block)",
3228
['fifo'] = "(pipe)",
3329
['socket'] = "(socket)"
34-
}, {__index = function()
30+
}, {__index = function()
3531
return '(unknown)'
3632
end
3733
})
@@ -58,7 +54,7 @@ M.getCallback = function()
5854
return M.callback
5955
end
6056

61-
M.triggerFunction = function(_, _, _, manager)
57+
M.triggerFunction = function()
6258
local pos = api.nvim_win_get_cursor(0)
6359
local line = api.nvim_get_current_line()
6460
local line_to_cursor = line:sub(1, pos[2])
@@ -83,9 +79,8 @@ M.triggerFunction = function(_, _, _, manager)
8379
end
8480
end
8581

86-
::continue::
8782
M.items = {}
88-
vim.loop.fs_scandir(path, onDirScanned)
83+
loop.fs_scandir(path, onDirScanned)
8984
end
9085

9186
return M

0 commit comments

Comments
 (0)