Skip to content

Commit

Permalink
refactor: remove unneeded util functions and refactor to match cursor…
Browse files Browse the repository at this point in the history
…less.nvim
  • Loading branch information
fidgetingbits committed Jun 13, 2024
1 parent 5e6a798 commit 596dda1
Showing 1 changed file with 3 additions and 36 deletions.
39 changes: 3 additions & 36 deletions lua/talon/utils.lua
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
local M = {}

function M.dump_table(o, depth, max_depth)
local seen_tables = {}
local function dump(o, depth, max_depth)
depth = depth or 1
if max_depth and depth > max_depth then
return '{ ... }'
end
if seen_tables[o] then
return '{ DUPLICATE }'
end
seen_tables[o] = true
if type(o) == 'table' then
local s = '{ \n'
for k, v in pairs(o) do
if type(k) ~= 'number' then
k = '"' .. k .. '"'
end
s = s
.. string.rep(' ', depth * 2)
.. '['
.. k
.. '] = '
.. dump(v, depth + 1, max_depth)
.. ',\n'
end
return s .. string.rep(' ', (depth - 1) * 2) .. '}'
else
return tostring(o)
end
end
return dump(o, depth, max_depth)
end

-- :lua print(require('talon.utils').is_win())
function M.is_win()
return package.config:sub(1, 1) == '\\'
function M.is_platform_windows()
return vim.uv.os_uname().version:find('Windows')
end

-- https://www.reddit.com/r/neovim/comments/tk1hby/get_the_path_to_the_current_lua_script_in_neovim/
Expand All @@ -51,7 +18,7 @@ function M.talon_nvim_path()
-- skip as the file name is prefixed by "@"
str = str:sub(2)
-- print(('source_file2=%s'):format(str))
if require('talon.utils').is_win() then
if require('talon.utils').is_platform_windows() then
str = str:gsub('/', '\\')
-- print('is_win')
end
Expand Down

0 comments on commit 596dda1

Please sign in to comment.