From 243ec9d9f37205e724a9276299a735182d7ac2f7 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Sun, 16 Jan 2022 15:08:55 -0800 Subject: [PATCH] chore: remove all LSP warnings --- lua/fzf-lua/init.lua | 1 + lua/fzf-lua/libuv.lua | 6 +++--- lua/fzf-lua/make_entry.lua | 1 + lua/fzf-lua/previewer/builtin.lua | 4 ++-- lua/fzf-lua/previewer/fzf.lua | 2 +- lua/fzf-lua/providers/buffers.lua | 7 +++---- lua/fzf-lua/providers/files.lua | 1 - lua/fzf-lua/providers/grep.lua | 22 +++++++++++----------- lua/fzf-lua/shell.lua | 9 +++++---- lua/fzf-lua/shell_helper.lua | 2 +- 10 files changed, 28 insertions(+), 27 deletions(-) diff --git a/lua/fzf-lua/init.lua b/lua/fzf-lua/init.lua index 1a8851d..df5c4c8 100644 --- a/lua/fzf-lua/init.lua +++ b/lua/fzf-lua/init.lua @@ -90,6 +90,7 @@ M.live_grep_old = require'fzf-lua.providers.grep'.live_grep_st M.live_grep_native = require'fzf-lua.providers.grep'.live_grep_native M.live_grep_resume = require'fzf-lua.providers.grep'.live_grep_resume M.live_grep_glob = require'fzf-lua.providers.grep'.live_grep_glob_mt +M.live_grep_glob_old = require'fzf-lua.providers.grep'.live_grep_glob M.grep_last = require'fzf-lua.providers.grep'.grep_last M.grep_cword = require'fzf-lua.providers.grep'.grep_cword M.grep_cWORD = require'fzf-lua.providers.grep'.grep_cWORD diff --git a/lua/fzf-lua/libuv.lua b/lua/fzf-lua/libuv.lua index 92204d3..c33ade5 100644 --- a/lua/fzf-lua/libuv.lua +++ b/lua/fzf-lua/libuv.lua @@ -31,13 +31,13 @@ local function find_last_newline(str) end end -local function find_next_newline(str, start_idx) +--[[ local function find_next_newline(str, start_idx) for i=start_idx or 1,#str do if string_byte(str, i) == 10 then return i end end -end +end ]] local function process_kill(pid, signal) if not pid or not tonumber(pid) then return false end @@ -82,7 +82,7 @@ M.spawn = function(opts, fn_transform, fn_done) local error_pipe = uv.new_pipe(false) local write_cb_count = 0 local prev_line_content = nil - local num_lines = 0 + -- local num_lines = 0 if opts.fn_transform then fn_transform = opts.fn_transform end diff --git a/lua/fzf-lua/make_entry.lua b/lua/fzf-lua/make_entry.lua index 89c7604..cb56825 100644 --- a/lua/fzf-lua/make_entry.lua +++ b/lua/fzf-lua/make_entry.lua @@ -16,6 +16,7 @@ end M._fzf_lua_server = _G._fzf_lua_server ---@diagnostic disable-next-line: undefined-field M._devicons_path = _G._devicons_path +---@diagnostic disable-next-line: undefined-field M._devicons_setup = _G._devicons_setup local function load_config_section(s, datatype) diff --git a/lua/fzf-lua/previewer/builtin.lua b/lua/fzf-lua/previewer/builtin.lua index ff8f4b6..fd976be 100644 --- a/lua/fzf-lua/previewer/builtin.lua +++ b/lua/fzf-lua/previewer/builtin.lua @@ -118,11 +118,11 @@ function Previewer.base:display_entry(entry_str) self.preview_bufnr = self:clear_preview_buf() end - local populate_preview_buf = function(entry_str) + local populate_preview_buf = function(entry_str_) if not self.win or not self.win:validate_preview() then return end -- specialized previewer populate function - self:populate_preview_buf(entry_str) + self:populate_preview_buf(entry_str_) -- set preview window options if not self.preview_isterm then diff --git a/lua/fzf-lua/previewer/fzf.lua b/lua/fzf-lua/previewer/fzf.lua index d40b5e5..1aa9df9 100644 --- a/lua/fzf-lua/previewer/fzf.lua +++ b/lua/fzf-lua/previewer/fzf.lua @@ -43,7 +43,7 @@ function Previewer.cmd:action(o) if self.opts._line_placeholder then filespec = "{1}" end - local act = shell.raw_action(function (items, fzf_lines, _) + local act = shell.raw_action(function (items, _, _) -- only preview first item local file = path.entry_to_file(items[1], not self.relative and self.opts.cwd) return file.path diff --git a/lua/fzf-lua/providers/buffers.lua b/lua/fzf-lua/providers/buffers.lua index 59c7441..be7f0c1 100644 --- a/lua/fzf-lua/providers/buffers.lua +++ b/lua/fzf-lua/providers/buffers.lua @@ -3,7 +3,6 @@ local path = require "fzf-lua.path" local utils = require "fzf-lua.utils" local config = require "fzf-lua.config" local actions = require "fzf-lua.actions" -local fn, api = vim.fn, vim.api local M = {} @@ -204,9 +203,9 @@ M.buffer_lines = function(opts) for _, bufnr in ipairs(buffers) do local data = {} - local filepath = api.nvim_buf_get_name(bufnr) - if api.nvim_buf_is_loaded(bufnr) then - data = api.nvim_buf_get_lines(bufnr, 0, -1, false) + local filepath = vim.api.nvim_buf_get_name(bufnr) + if vim.api.nvim_buf_is_loaded(bufnr) then + data = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) elseif vim.fn.filereadable(filepath) ~= 0 then data = vim.fn.readfile(filepath, "") end diff --git a/lua/fzf-lua/providers/files.lua b/lua/fzf-lua/providers/files.lua index be0f601..d09d582 100644 --- a/lua/fzf-lua/providers/files.lua +++ b/lua/fzf-lua/providers/files.lua @@ -1,6 +1,5 @@ local core = require "fzf-lua.core" local utils = require "fzf-lua.utils" -local shell = require "fzf-lua.shell" local config = require "fzf-lua.config" local M = {} diff --git a/lua/fzf-lua/providers/grep.lua b/lua/fzf-lua/providers/grep.lua index 4136e5f..d8cc91f 100644 --- a/lua/fzf-lua/providers/grep.lua +++ b/lua/fzf-lua/providers/grep.lua @@ -298,37 +298,37 @@ M.live_grep_glob = function(opts) utils.warn("'--glob|iglob' flags requires 'rg' (https://github.com/BurntSushi/ripgrep)") return end - opts.cmd_fn = function(opts, query, no_esc) + opts.cmd_fn = function(o, query, no_esc) local glob_arg, glob_str = "", "" local search_query = query or "" - if query:find(opts.glob_separator) then - search_query, glob_str = query:match("(.*)"..opts.glob_separator.."(.*)") + if query:find(o.glob_separator) then + search_query, glob_str = query:match("(.*)"..o.glob_separator.."(.*)") for _, s in ipairs(utils.strsplit(glob_str, "%s")) do glob_arg = glob_arg .. (" %s %s") - :format(opts.glob_flag, vim.fn.shellescape(s)) + :format(o.glob_flag, vim.fn.shellescape(s)) end end -- copied over from get_grep_cmd local search_path = '' - if opts.filespec and #opts.filespec>0 then - search_path = opts.filespec - elseif opts.filename and #opts.filename>0 then - search_path = vim.fn.shellescape(opts.filename) + if o.filespec and #o.filespec>0 then + search_path = o.filespec + elseif o.filename and #o.filename>0 then + search_path = vim.fn.shellescape(o.filename) end - if not (no_esc or opts.no_esc) then + if not (no_esc or o.no_esc) then search_query = utils.rg_escape(search_query) end -- do not escape at all - if not (no_esc == 2 or opts.no_esc == 2) then + if not (no_esc == 2 or o.no_esc == 2) then search_query = vim.fn.shellescape(search_query) end local cmd = ("rg %s %s -- %s %s") - :format(opts.rg_opts, glob_arg, search_query, search_path) + :format(o.rg_opts, glob_arg, search_query, search_path) return cmd end opts.__FNCREF__ = utils.__FNCREF__() diff --git a/lua/fzf-lua/shell.lua b/lua/fzf-lua/shell.lua index 13b0c8c..dd46ff9 100644 --- a/lua/fzf-lua/shell.lua +++ b/lua/fzf-lua/shell.lua @@ -24,7 +24,8 @@ end -- instances will then use the same path as the address and it causes a mess, -- i.e. actions stop working on the old instance. So we create our own (random -- path) RPC server for this instance if it hasn't been started already. -local action_server_address = nil +-- NOT USED ANYMORE, we use `vim.g.fzf_lua_server` instead +-- local action_server_address = nil function M.raw_async_action(fn, fzf_field_expression) @@ -67,9 +68,9 @@ function M.raw_action(fn, fzf_field_expression) local receiving_function = function(pipe, ...) local ret = fn(...) - local on_complete = function(err) - -- We are NOT asserting, in case fzf closes the pipe before we can send - -- the preview. + local on_complete = function(_) + -- We are NOT asserting, in case fzf closes + -- the pipe before we can send the preview -- assert(not err) uv.close(pipe) end diff --git a/lua/fzf-lua/shell_helper.lua b/lua/fzf-lua/shell_helper.lua index 74f610e..a633097 100644 --- a/lua/fzf-lua/shell_helper.lua +++ b/lua/fzf-lua/shell_helper.lua @@ -11,7 +11,7 @@ end local preview_socket, preview_socket_path = get_preview_socket() -uv.listen(preview_socket, 100, function(err) +uv.listen(preview_socket, 100, function(_) local preview_receive_socket = uv.new_pipe(false) -- start listening uv.accept(preview_socket, preview_receive_socket)