Skip to content

Commit

Permalink
fix: update expired type comment
Browse files Browse the repository at this point in the history
format code
  • Loading branch information
jinzhongjia committed Jul 7, 2024
1 parent 8f0232a commit 7e560f4
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lua/LspUI/call_hierarchy/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}

-- get all valid clients for lightbulb
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients = lsp.get_clients({
bufnr = buffer_id,
Expand Down
12 changes: 6 additions & 6 deletions lua/LspUI/code_action/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ local lib_util = require("LspUI.lib.util")
local lib_windows = require("LspUI.lib.windows")
local register = require("LspUI.code_action.register")

--- @alias action_tuple { action: lsp.CodeAction|lsp.Command, client: lsp.Client?, buffer_id: integer, callback: function? }
--- @alias action_tuple { action: lsp.CodeAction|lsp.Command, client: vim.lsp.Client?, buffer_id: integer, callback: function? }

local M = {}

-- get all valid clients for lightbulb
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = code_action_feature })
Expand Down Expand Up @@ -158,7 +158,7 @@ local get_register_actions = function(action_tuples, buffer_id, uri, range)
end

-- get action tuples
--- @param clients lsp.Client[]
--- @param clients vim.lsp.Client[]
--- @param params table
--- @param buffer_id integer
--- @param is_visual boolean
Expand Down Expand Up @@ -216,10 +216,10 @@ end
-- execute a lsp command, either via client command function (if available)
-- or via workspace/executeCommand (if supported by the server)
-- this func is referred from https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp.lua#L1666-L1697C6
--- @param client lsp.Client
--- @param client vim.lsp.Client
--- @param command lsp.Command
--- @param buffer_id integer
--- @param handler? lsp-handler only called if a server command
--- @param handler ?lsp.Handler only called if a server command
local exec_command = function(client, command, buffer_id, handler)
local cmdname = command.command
local func = client.commands[cmdname] or lsp.commands[cmdname]
Expand Down Expand Up @@ -254,7 +254,7 @@ local exec_command = function(client, command, buffer_id, handler)
end

--- @param action lsp.CodeAction|lsp.Command
--- @param client lsp.Client
--- @param client vim.lsp.Client
--- @param buffer_id integer
local apply_action = function(action, client, buffer_id)
if action.edit then
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/declaration/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}

-- get all valid clients for definition
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = declaration_feature })
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/definition/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}

-- get all valid clients for definition
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = definition_feature })
Expand Down
8 changes: 4 additions & 4 deletions lua/LspUI/hover/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local lib_notify = require("LspUI.lib.notify")
local lib_util = require("LspUI.lib.util")
local lib_windows = require("LspUI.lib.windows")

--- @alias hover_tuple { client: lsp.Client, buffer_id: integer, contents: string[], width: integer, height: integer }
--- @alias hover_tuple { client: vim.lsp.Client, buffer_id: integer, contents: string[], width: integer, height: integer }

local M = {}

Expand All @@ -16,7 +16,7 @@ local hover_tuple_index

-- get all valid clients for hover
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = hover_feature })
Expand All @@ -27,7 +27,7 @@ M.get_clients = function(buffer_id)
end

-- get hovers from lsp
--- @param clients lsp.Client[]
--- @param clients vim.lsp.Client[]
--- @param buffer_id integer
--- @param callback function this callback has a param is hover_tuples[]
M.get_hovers = function(clients, buffer_id, callback)
Expand Down Expand Up @@ -70,7 +70,7 @@ M.get_hovers = function(clients, buffer_id, callback)
result.contents
)
markdown_lines =
lsp.util.trim_empty_lines(markdown_lines)
lib_util.trim_empty_lines(markdown_lines)

if vim.tbl_isempty(markdown_lines) then
if lsp_config.silent ~= true then
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/implementation/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}

-- get all valid clients for definition
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = implementation_feature })
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/lib/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end
M.diagnostic_vim_to_lsp = function(diagnostics)
---@diagnostic disable-next-line:no-unknown
return vim.tbl_map(function(diagnostic)
---@cast diagnostic Diagnostic
---@cast diagnostic vim.Diagnostic
return vim.tbl_extend("keep", {
-- "keep" the below fields over any duplicate fields
-- in diagnostic.user_data.lsp
Expand Down
20 changes: 20 additions & 0 deletions lua/LspUI/lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,25 @@ M.compare_uri = function(uri_1, uri_2)
end
return path_1 == path_2
end
--- Removes empty lines from the beginning and end.
---@param lines table list of lines to trim
---@return table trimmed list of lines
function M.trim_empty_lines(lines)
local start = 1
for i = 1, #lines do
if lines[i] ~= nil and #lines[i] > 0 then
start = i
break
end
end
local finish = 1
for i = #lines, 1, -1 do
if lines[i] ~= nil and #lines[i] > 0 then
finish = i
break
end
end
return vim.list_extend({}, lines, start, finish)
end

return M
2 changes: 1 addition & 1 deletion lua/LspUI/lib/windows.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local api, fn = vim.api, vim.fn

--- @alias window_wrap { buffer: integer, enter: boolean, config: vim.api.keyset.float_config } wrap for windows
--- @alias window_wrap { buffer: integer, enter: boolean, config: vim.api.keyset.win_config } wrap for windows

local M = {}

Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/lightbulb/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local autocmd_list = {}

-- get all valid clients for lightbulb
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = code_action_feature })
Expand Down
6 changes: 3 additions & 3 deletions lua/LspUI/pos_abstract.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local api, fn, lsp = vim.api, vim.fn, vim.lsp
local config = require("LspUI.config")
local lib_debug = require("LspUI.lib.debug")
local lib_notify = require("LspUI.lib.notify")
local lib_util = require("LspUI.lib.util")
local lib_windows = require("LspUI.lib.windows")
Expand Down Expand Up @@ -582,7 +581,7 @@ end
-- this function only can be called by `definition` or `declaration`
-- or `type definition` or `reference` or `implementation`
--- @param buffer_id integer which buffer do method
--- @param clients lsp.Client[]
--- @param clients vim.lsp.Client[]
--- @param params table
--- @param callback fun(datas: Lsp_position_wrap|nil)
M.lsp_clients_request = function(buffer_id, clients, params, callback)
Expand Down Expand Up @@ -947,6 +946,7 @@ end
local action_jump = function(cmd)
if current_item.range then
-- push tagstack must be called before close window
---@diagnostic disable-next-line: need-check-nil
push_tagstack()

lib_windows.close_window(M.secondary_view_window())
Expand Down Expand Up @@ -1208,7 +1208,7 @@ end

--- @param buffer_id integer which buffer do method
--- @param window_id integer? which window do method
--- @param clients lsp.Client[]
--- @param clients vim.lsp.Client[]
--- @param params table
--- @param new_method { method: string, name: string, fold: boolean }
M.go = function(new_method, buffer_id, window_id, clients, params)
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/reference/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}

-- get all valid clients for definition
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = reference_feature })
Expand Down
12 changes: 6 additions & 6 deletions lua/LspUI/rename/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local M = {}

-- get all valid clients of rename
--- @param buffer_id integer
--- @return lsp.Client[]? clients array or nil
--- @return vim.lsp.Client[]? clients array or nil
M.get_clients = function(buffer_id)
-- note: we need get lsp clients attached to current buffer
local clients =
Expand All @@ -23,7 +23,7 @@ M.get_clients = function(buffer_id)
end

-- rename
--- @param client lsp.Client lsp client instance, must be element of func `get_clients`
--- @param client vim.lsp.Client lsp client instance, must be element of func `get_clients`
--- @param buffer_id integer buffer id
--- @param position_param lsp.RenameParams this param must be generated by `vim.lsp.util.make_position_params`, has newname attribute
--- @param callback function
Expand All @@ -40,7 +40,7 @@ end

-- prepare rename, whether we can execute rename
-- if request return eroor, that mean we can't rename, and we should skip this
--- @param client lsp.Client lsp client instance, must be element of func `get_clients`
--- @param client vim.lsp.Client lsp client instance, must be element of func `get_clients`
--- @param buffer_id integer buffer id
--- @param position_param lsp.PrepareRenameParams this param must be generated by `vim.lsp.util.make_position_params`
--- @param callback function
Expand All @@ -63,7 +63,7 @@ end

-- do rename, a wrap function for prepare_rename and rename
--- @param id integer
--- @param clients lsp.Client[] lsp client instance, must be element of func `get_clients`
--- @param clients vim.lsp.Client[] lsp client instance, must be element of func `get_clients`
--- @param buffer_id integer buffer id
--- @param position_param lsp.PrepareRenameParams|lsp.RenameParams this param must be generated by `vim.lsp.util.make_position_params`, has newname attribute
M.do_rename = function(id, clients, buffer_id, position_param)
Expand Down Expand Up @@ -134,7 +134,7 @@ local calculate_length = function(str)
end

-- render the window
--- @param clients lsp.Client[]
--- @param clients vim.lsp.Client[]
--- @param buffer_id integer
--- @param current_win integer
--- @param old_name string
Expand Down Expand Up @@ -209,7 +209,7 @@ end
-- keybinding and autocommand
--- @param window_id integer rename float window's id
--- @param old_name string the word's old name
--- @param clients lsp.Client[] lsp clients
--- @param clients vim.lsp.Client[] lsp clients
--- @param old_buffer integer the buffer which word belongs to
--- @param new_buffer integer the buffer which attach to rename float window
--- @param position_param lsp.PrepareRenameParams|lsp.RenameParams this param must be generated by `vim.lsp.util.make_position_params`
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/signature/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ end

-- get all valid clients for lightbulb
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = signature_feature })
Expand Down
2 changes: 1 addition & 1 deletion lua/LspUI/type_definition/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}

-- get all valid clients for definition
--- @param buffer_id integer
--- @return lsp.Client[]|nil clients array or nil
--- @return vim.lsp.Client[]|nil clients array or nil
M.get_clients = function(buffer_id)
local clients =
lsp.get_clients({ bufnr = buffer_id, method = type_definition_feature })
Expand Down

0 comments on commit 7e560f4

Please sign in to comment.