Skip to content

Commit f0d797f

Browse files
committed
feat(api)!: Added a dumb easter egg and improved code for user.distro.archlinux.
Signed-off-by: Guennadi Maximov C <[email protected]>
1 parent af48342 commit f0d797f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lua/user_api/distro/archlinux.lua

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ function Archlinux:validate()
2525
---@type string[]|table
2626
local new_rtpaths = {}
2727

28+
-- First check for each dir's existance
2829
for _, p in next, self.rtpaths do
2930
if vim.fn.isdirectory(p) then
3031
table.insert(new_rtpaths, p)
3132
end
3233
end
3334

35+
-- If no dirs...
3436
if not type_not_empty('table', new_rtpaths) then
3537
return false
3638
end
3739

3840
self.rtpaths = vim.tbl_deep_extend('force', {}, new_rtpaths)
41+
3942
return true
4043
end
4144

@@ -47,16 +50,13 @@ function Archlinux:setup()
4750
local Check = require('user_api.check')
4851
local Util = require('user_api.util')
4952

50-
local is_dir = Check.exists.vim_isdir
53+
local is_dir = vim.fn.isdirectory
5154
local type_not_empty = Check.value.type_not_empty
5255
local strip_values = Util.strip_values
5356

54-
---@type table
55-
---@diagnostic disable-next-line
56-
local rtp = vim.opt.rtp:get()
57-
58-
for _, path in next, vim.deepcopy(self.rtpaths) do
59-
if not (is_dir(path) or vim.tbl_contains(rtp, path)) then
57+
-- Check if path is in rtp already
58+
for _, path in next, self.rtpaths do
59+
if not (is_dir(path) ~= 1 or vim.tbl_contains(vim.opt.rtp:get(), path)) then ---@diagnostic disable-line
6060
self.rtpaths = strip_values(self.rtpaths, { path })
6161
end
6262
end
@@ -73,6 +73,10 @@ function Archlinux:setup()
7373
local ok, _ = pcall(vim.cmd, 'runtime! archlinux.vim')
7474

7575
assert(ok, 'BAD SETUP FOR Archlinux!')
76+
77+
if ok then
78+
_G.I_USE_ARCH = 'BTW'
79+
end
7680
end
7781

7882
---@param O? table

0 commit comments

Comments
 (0)