dotfiles/.config/nvim/lua/core/utils.lua
hok7z 6e3706524e Update dotfiles
modified:   .config/bottom/bottom.toml
modified:   .config/fish/config.fish
modified:   .config/fish/fish_variables
deleted:    .config/ipython/profile_default/history.sqlite
deleted:    .config/ipython/profile_default/startup/README
modified:   .config/nvim/lua/core/options.lua
modified:   .config/nvim/lua/core/utils.lua
modified:   .config/nvim/lua/lsp/init.lua
modified:   .config/nvim/lua/lsp/servers/clangd.lua
modified:   .config/nvim/lua/lsp/servers/cssls.lua
modified:   .config/nvim/lua/lsp/servers/gopls.lua
modified:   .config/nvim/lua/lsp/servers/pyright.lua
deleted:    .config/qalculate/qalc.cfg
deleted:    .config/qalculate/qalc.history
deleted:    .config/qalculate/qalc.history-00938.tmp
deleted:    .config/qalculate/qalc.history-23524.tmp
deleted:    .config/ranger/plugins/__init__.py
deleted:    .config/ranger/rc.conf
deleted:    .config/ranger/rifle.conf
deleted:    .config/systemd/user/default.target.wants/pipewire-pulse.service
deleted:    .config/systemd/user/default.target.wants/pipewire.service
deleted:    .config/systemd/user/default.target.wants/ssh-agent.service
deleted:    .config/systemd/user/sockets.target.wants/pipewire-pulse.socket
deleted:    .config/systemd/user/sockets.target.wants/pipewire.socket
deleted:    .config/systemd/user/ssh-agent.service
2023-01-01 22:52:12 +02:00

45 lines
1.1 KiB
Lua

local M = {}
local fn, api = vim.fn, vim.api
function M.debounce(func, timeout)
local timer_id
return function(...)
if timer_id ~= nil then
fn.timer_stop(timer_id)
end
local args = {...}
local function cb()
func(args)
timer_id = nil
end
timer_id = fn.timer_start(timeout, cb)
end
end
-- Convert UTF-8 hex code to character
function M.u(code)
if type(code) == 'string' then
code = tonumber('0x' .. code)
end
local c = string.char
if code <= 0x7f then
return c(code)
end
local t = {}
if code <= 0x07ff then
t[1] = c(bit.bor(0xc0, bit.rshift(code, 6)))
t[2] = c(bit.bor(0x80, bit.band(code, 0x3f)))
elseif code <= 0xffff then
t[1] = c(bit.bor(0xe0, bit.rshift(code, 12)))
t[2] = c(bit.bor(0x80, bit.band(bit.rshift(code, 6), 0x3f)))
t[3] = c(bit.bor(0x80, bit.band(code, 0x3f)))
else
t[1] = c(bit.bor(0xf0, bit.rshift(code, 18)))
t[2] = c(bit.bor(0x80, bit.band(bit.rshift(code, 12), 0x3f)))
t[3] = c(bit.bor(0x80, bit.band(bit.rshift(code, 6), 0x3f)))
t[4] = c(bit.bor(0x80, bit.band(code, 0x3f)))
end
return table.concat(t)
end
return M