Neovim quick file switcher

Compare changes

Choose any two refs to compare.

Changed files
+21 -3
lua
javelin
+8 -1
lua/javelin/data.lua
···
---@param path string
local function add_path(root_path, path)
local list = Data.get_list(root_path)
-
table.insert(list, normalize_path(root_path, vim.fn.fnamemodify(path, ":~")))
+
path = normalize_path(root_path, vim.fn.fnamemodify(path, ":~"))
+
+
if vim.tbl_contains(list, path) then
+
log.warn("File already in list: " .. path)
+
return
+
end
+
+
table.insert(list, path)
write(root_path)
end
+13 -2
lua/javelin/ui.lua
···
local function open_buf(file)
-- nvim 0.11 only command
-
if vim.fn.exists("*isabsolutepath") then
-
if not vim.fn.isabsolutepath(file) then
+
if vim.fn.exists("*isabsolutepath") == 1 then
+
if vim.fn.isabsolutepath(file) == 0 then
file = data.get_root() .. "/" .. file
end
else
···
open_buf(file)
end,
},
+
on_buf = function(self)
+
vim.api.nvim_create_autocmd("BufLeave", {
+
buffer = self.buf,
+
callback = function()
+
if not self.closed then
+
self:close()
+
end
+
return true
+
end,
+
})
+
end,
on_close = function(self)
if self.buf then
local lines = self:lines()