Compare commits
No commits in common. "4d048aecd8306473bd3606c2cb9377755922de03" and "3c59ab0b6164a3ef7b18ca1927a976056d097c8a" have entirely different histories.
4d048aecd8
...
3c59ab0b61
2 changed files with 0 additions and 66 deletions
|
@ -130,9 +130,6 @@ map.n.nore['<leader>S'] =
|
|||
[[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
-- fuzzy find files in cwd
|
||||
map.n.nore['<leader>f'] = [[:lua require 'telescope.builtin'.find_files()<cr>]]
|
||||
-- fuzzy find hidden files in cwd
|
||||
map.n.nore['<leader><c-f>'] =
|
||||
[[:lua require 'telescope.builtin'.find_files({hidden=true})<cr>]]
|
||||
-- general full-text search in cwd with rg
|
||||
map.n.nore['<leader>F'] = [[:lua require 'telescope.builtin'.live_grep()<cr>]]
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
-- will open the pdf file for whatever file i am currently viewing.
|
||||
-- POC only and only useful in a ALMP context for now.
|
||||
local fn = vim.fn
|
||||
|
||||
local function isDirectory(ftype)
|
||||
if ftype == 'directory' then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
local function isFile(ftype)
|
||||
if ftype == 'file' then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
local function cleanPath(path)
|
||||
if path:match("^~") then path = os.getenv("HOME") .. path:sub(2) end
|
||||
return path
|
||||
end
|
||||
-- Returns a set of all files at the target directory, as well
|
||||
-- as subdirectories if the recursive argument is set to true.
|
||||
-- Set has the form { "full/path/name.md" = "name.md" }
|
||||
local function get_all_files(path, recursive)
|
||||
local f = {}
|
||||
path = cleanPath(path)
|
||||
|
||||
local handle = vim.loop.fs_scandir(path)
|
||||
while handle do
|
||||
local name, ftype = vim.loop.fs_scandir_next(handle)
|
||||
if not name then break end
|
||||
|
||||
if isDirectory(ftype) and recursive then
|
||||
local subdir = get_all_files(path .. "/" .. name, true)
|
||||
for k, v in pairs(subdir) do f[tostring(k)] = v end
|
||||
end
|
||||
|
||||
if isFile(ftype) then f[tostring(path .. "/" .. name)] = name end
|
||||
end
|
||||
|
||||
return f
|
||||
end
|
||||
|
||||
local function get_basename()
|
||||
local name = fn.expand("%:t")
|
||||
return string.gsub(name, ".md", "")
|
||||
end
|
||||
|
||||
local function find_pdf(dir, bibkey)
|
||||
local pdfs = get_all_files(dir)
|
||||
for k, v in pairs(pdfs) do if v:find(bibkey, 0, true) then return k end end
|
||||
end
|
||||
|
||||
local function open_pdf(name) fn.jobstart("zathura '" .. name .. "'") end
|
||||
|
||||
local function openCurrentPdf()
|
||||
local fname = get_basename()
|
||||
local pdf_path = find_pdf(
|
||||
"/home/marty/projects/jobs/almp/output/Literature",
|
||||
fname)
|
||||
print(pdf_path)
|
||||
open_pdf(pdf_path)
|
||||
end
|
||||
|
||||
return {open = openCurrentPdf}
|
Loading…
Reference in a new issue