Skip to content

Commit

Permalink
loop -> uv
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed Nov 7, 2023
1 parent f9b0833 commit 48f7cc1
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.workspace.library": [
"${3rd}/luassert/library"
]
}
332 changes: 332 additions & 0 deletions .tags

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ Nondefault configuration example:
```lua

require'navigator'.setup({
debug = false, -- log output, set to true and log path: ~/.cache/nvim/gh.log
debug = false, -- log output, set to true and log path: ~/.cache/nvim/gh.log
-- slowdownd startup and some actions
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
height = 0.3, -- max list window height, 0.3 by default
preview_height = 0.35, -- max height of preview windows
Expand Down
1 change: 1 addition & 0 deletions lua/navigator/cclshierarchy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local util = require('navigator.util')
local log = util.log
local partial = util.partial
local lsphelper = require('navigator.lspwrapper')
local uv = vim.uv or vim.loop
local cwd = vim.loop.cwd()

local path_sep = require('navigator.util').path_sep()
Expand Down
9 changes: 7 additions & 2 deletions lua/navigator/debounce.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
local M = {}
local uv = vim.uv or vim.loop

function M.debounce_trailing(ms, fn)
local timer = vim.loop.new_timer()
local timer = uv.new_timer()
return function(...)
local argv = {...}
if timer:is_active() then
timer:stop()
return
end
timer:start(ms, 0, function()
timer:stop()
fn(unpack(argv))
Expand All @@ -12,7 +17,7 @@ function M.debounce_trailing(ms, fn)
end

function M.throttle_leading(ms, fn)
local timer = vim.loop.new_timer()
local timer = uv.new_timer()
local running = false
return function(...)
if not running then
Expand Down
2 changes: 1 addition & 1 deletion lua/navigator/hierarchy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local lsphelper = require('navigator.lspwrapper')

local path_sep = require('navigator.util').path_sep()
local path_cur = require('navigator.util').path_cur()
local cwd = vim.loop.cwd()
local cwd = vim.uv.cwd()
local in_method = 'callHierarchy/incomingCalls'
local out_method = 'callHierarchy/outgoingCalls'

Expand Down
3 changes: 2 additions & 1 deletion lua/navigator/lspclient/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true

function M.reload_lsp()
vim.cmd("LspStop")
local timer = vim.loop.new_timer()
local uv = vim.uv or vim.loop
local timer = uv.new_timer()
local i = 0
timer:start(500, 100, function()
if i >= 5 then
Expand Down
3 changes: 2 additions & 1 deletion lua/navigator/lspclient/lua_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ local on_attach = require('navigator.lspclient.attach').on_attach
local library = {}
local function add(lib)
for _, p in pairs(vfn.expand(lib, false, true)) do
p = vim.loop.fs_realpath(p)
local uv = vim.uv or vim.loop
p = uv.fs_realpath(p)
if p then
library[p] = true
end
Expand Down
6 changes: 3 additions & 3 deletions lua/navigator/reference.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local lsp = require('navigator.lspwrapper')
local trace = require('navigator.util').trace
-- local partial = util.partial
-- local cwd = vim.loop.cwd()
local uv = vim.loop
-- local lsphelper = require "navigator.lspwrapper"
local locations_to_items = lsphelper.locations_to_items

Expand Down Expand Up @@ -140,7 +141,6 @@ local ref_view = function(err, locations, ctx, cfg)

-- trace("update items", listview.ctrl.class)
local nv_ref_async
local uv = vim.uv or vim.loop
nv_ref_async = uv.new_async(vim.schedule_wrap(function()
if vim.tbl_isempty(second_part) then
return
Expand Down Expand Up @@ -176,7 +176,7 @@ local ref_hdlr = function(err, locations, ctx, cfg)
if ctx.no_show then
return ref_view(err, locations, ctx, cfg)
end
M.async_hdlr = vim.loop.new_async(vim.schedule_wrap(function()
M.async_hdlr = uv.new_async(vim.schedule_wrap(function()
ref_view(err, locations, ctx, cfg)
if M.async_hdlr:is_active() then
M.async_hdlr:close()
Expand Down Expand Up @@ -275,7 +275,7 @@ local ref_req = function()

local warmup_ts
if _NgConfigValues.treesitter_analysis then
warmup_ts = vim.loop.new_async(function()
warmup_ts = uv.new_async(function()
warmup_treesitter(cfg)
if warmup_ts:is_active() then
warmup_ts:close()
Expand Down

0 comments on commit 48f7cc1

Please sign in to comment.