[
  {
    "path": "README.md",
    "content": "lf.vim\n======\n\n[lf](https://github.com/gokcehan/lf) integration in vim and neovim\n\n![lf.vim](https://user-images.githubusercontent.com/56180050/100401445-70299b00-3094-11eb-945a-7caa04de696d.png)\n\nInstallation\n------------\n\nInstall it with your favorite plugin manager. Example with vim-plug:\n\n        Plug 'ptzz/lf.vim'\n\nThen, add the vim-floaterm dependency:\n\n        Plug 'voldikss/vim-floaterm'\n\n**Note:** lf.vim should be loaded before vim-floaterm to override vim-floaterm's lf wrapper.\n\nTo install with vim pack you would need to enforce the loading order, by making both packages optional:\n\n        ~$ ls .vim/pack/plugins/opt/\n        lf.vim\tvim-floaterm\n\nAnd adding them manually in `.vimrc`:\n\n        packadd! vim-floaterm\n        packadd! lf.vim\n\n**Note:** for [some](https://stackoverflow.com/questions/67930489/native-vim-plugin-load-order) [reason](https://github.com/vim/vim/issues/7056) the loading is reversed\n\nHow to use it\n-------------\n\nThe default shortcut for opening lf is `<leader>f` (\\f by default).\nTo disable the default key mapping, add this line in your .vimrc or init.vim: `let g:lf_map_keys = 0`.\nThen you can add a new mapping with this line: `map <leader>f :Lf<CR>`.\n\nTo set the floating window width and height, set `g:lf_width` and `g:lf_height` accordingly. If not found, it will default to `g:floaterm_width` and `g:floaterm_height`.\n\nThe command for opening lf in the current file's directory is `:Lf`.\nWhen opening (default 'l' and '\\<right\\>') a file from the lf window,\nvim will open the selected file in the current window. To open the selected\nfile in a new tab instead use `:LfNewTab`.\n\n(Note that the lf `open` command is required to return to the originating vim session.\nE.g. the `edit` command opens a new process of $EDITOR.)\n\nFor opening lf in the current workspace, run `:LfWorkingDirectory`.\nVim will open the selected file in the current window.\n`:LfWorkingDirectoryNewTab` will open the selected file in a new tab instead.\n\nFor changing the current directory via lf, run `:Lfcd`or run `:Lflcd` for the current window.\n\nList of commands:\n```vim\n\" Change directory with lf via cd or lcd\nLfcd\nLflcd\n\nLf \" Open current file by default\nLfCurrentFile \" Default Lf behaviour\nLfCurrentDirectory\nLfWorkingDirectory\n\n\" Always open in new tabs\nLfNewTab\nLfCurrentFileNewTab\nLfCurrentDirectoryNewTab\nLfWorkingDirectoryNewTab\n\n\" Open tab if it exists or in new tab if it does not\nLfCurrentFileExistingOrNewTab\nLfCurrentDirectoryExistingOrNewTab\nLfWorkingDirectoryExistingOrNewTab\n```\n\nThe old way to make vim open the selected file in a new tab was to add\n`let g:lf_open_new_tab = 1` in your .vimrc or init.vim. That way is still\nsupported but deprecated.\n\n### Opening lf instead of netrw when you open a directory\nIf you want to see vim opening lf when you open a directory (ex: nvim ./dir or :edit ./dir), please add this in your .(n)vimrc.\n```vim\nlet g:NERDTreeHijackNetrw = 0 \" Add this line if you use NERDTree\nlet g:lf_replace_netrw = 1 \" Open lf when vim opens a directory\n```\n\n### Setting a custom lf command\nBy default lf is opened with the command `lf` but you can set an other custom command by setting the `g:lf_command_override` variable in your .(n)vimrc.\n\nFor instance if you want to display the hidden files by default you can write:\n```vim\nlet g:lf_command_override = 'lf -command \"set hidden\"'\n```\n"
  },
  {
    "path": "autoload/floaterm/wrapper/lf.vim",
    "content": "function! floaterm#wrapper#lf#(cmd, jobopts, ...) abort\n  let lf_tmpfile = tempname()\n  let lastdir_tmpfile = tempname()\n  let original_dir = getcwd()\n  lcd %:p:h\n\n  let cmdlist = split(a:cmd)\n\n  if exists('g:lf_command_override')\n    let s:lf_command = g:lf_command_override\n  else\n    let s:lf_command = 'lf'\n  endif\n\n  let cmd = s:lf_command . ' ' . '-last-dir-path=' . fnameescape(lastdir_tmpfile) . ' -selection-path=' . fnameescape(lf_tmpfile)\n\n  if len(cmdlist) > 1\n    let cmd .= ' ' . join(cmdlist[1:], ' ')\n  else\n    let cmd .= ' \"' . getcwd() . '\"'\n  endif\n\n  exe \"lcd \" . original_dir\n  let cmd = [&shell, &shellcmdflag, cmd]\n  let a:jobopts.on_exit = funcref('LfCallback', [lf_tmpfile, lastdir_tmpfile])\n  return [v:false, cmd]\nendfunction\n"
  },
  {
    "path": "plugin/lf.vim",
    "content": "\" Copyright (c) 2015 François Cabrol\n\"\n\" MIT License\n\"\n\" Permission is hereby granted, free of charge, to any person obtaining\n\" a copy of this software and associated documentation files (the\n\" \"Software\"), to deal in the Software without restriction, including\n\" without limitation the rights to use, copy, modify, merge, publish,\n\" distribute, sublicense, and/or sell copies of the Software, and to\n\" permit persons to whom the Software is furnished to do so, subject to\n\" the following conditions:\n\"\n\" The above copyright notice and this permission notice shall be\n\" included in all copies or substantial portions of the Software.\n\"\n\" THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n\" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n\" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n\" ================ Lf =======================\nfunction! OpenLfIn(path, edit_cmd)\n  let currentPath = shellescape(isdirectory(a:path) ? fnamemodify(expand(a:path), \":p:h\") : expand(a:path))\n  let s:edit_cmd = a:edit_cmd\n  if exists(\":FloatermNew\")\n    exec 'FloatermNew' . ' --height=' . string(get(g:, 'lf_height', g:floaterm_height)) . \n        \\ ' --width=' . string(get(g:, 'lf_width', g:floaterm_width)) . \n        \\ ' --title=lf --titleposition=center lf -- ' . currentPath\n  else\n    echoerr \"Failed to open a floating terminal. Make sure `voldikss/vim-floaterm` is installed.\"\n  endif\nendfun\n\nfunction! LfCallback(lf_tmpfile, lastdir_tmpfile, ...) abort\n  let edit_cmd = get(s:, 'edit_cmd', 'default')\n  if (edit_cmd == 'cd' || edit_cmd == 'lcd') && filereadable(a:lastdir_tmpfile)\n    let lastdir = readfile(a:lastdir_tmpfile, '', 1)[0]\n    if lastdir != getcwd()\n      exec edit_cmd . ' ' . lastdir\n      return\n    endif\n  elseif filereadable(a:lf_tmpfile)\n    let filenames = readfile(a:lf_tmpfile)\n    if !empty(filenames)\n      if has('nvim')\n        call floaterm#window#hide(bufnr('%'))\n      endif\n      let locations = []\n      let floaterm_opener = edit_cmd != 'default' ? s:edit_cmd : g:floaterm_opener\n      for filename in filenames\n        let dict = {'filename': fnamemodify(fnameescape(filename), ':p')}\n        call add(locations, dict)\n      endfor\n      call floaterm#util#open(locations, floaterm_opener)\n      unlet! s:edit_cmd\n    endif\n  else\n    let lf_exit_code = a:2\n    if lf_exit_code != 0\n      echoerr 'lf returned non-zero exit code ' . lf_exit_code\n      return\n    endif\n  endif\nendfunction\n\n\" For backwards-compatibility (deprecated)\nif exists('g:lf_open_new_tab') && g:lf_open_new_tab\n  let s:default_edit_cmd='tabedit'\nelse\n  let s:default_edit_cmd='edit'\nendif\n\ncommand! Lfcd call OpenLfIn(\".\", 'cd')\ncommand! Lflcd call OpenLfIn(\".\", 'lcd')\ncommand! LfCurrentFile call OpenLfIn(\"%\", s:default_edit_cmd)\ncommand! LfCurrentDirectory call OpenLfIn(\"%:p:h\", s:default_edit_cmd)\ncommand! LfWorkingDirectory call OpenLfIn(\".\", s:default_edit_cmd)\ncommand! Lf LfCurrentFile\n\n\" To open the selected file in a new tab\ncommand! LfCurrentFileNewTab call OpenLfIn(\"%\", 'tabedit')\ncommand! LfCurrentFileExistingOrNewTab call OpenLfIn(\"%\", 'tab drop')\ncommand! LfCurrentDirectoryNewTab call OpenLfIn(\"%:p:h\", 'tabedit')\ncommand! LfCurrentDirectoryExistingOrNewTab call OpenLfIn(\"%:p:h\", 'tab drop')\ncommand! LfWorkingDirectoryNewTab call OpenLfIn(\".\", 'tabedit')\ncommand! LfWorkingDirectoryExistingOrNewTab call OpenLfIn(\".\", 'tab drop')\ncommand! LfNewTab LfCurrentDirectoryNewTab\n\n\" For retro-compatibility\nfunction! OpenLf()\n  Lf\nendfunction\n\n\" To open lf when vim load a directory\nif exists('g:lf_replace_netrw') && g:lf_replace_netrw\n  augroup ReplaceNetrwByLfVim\n    autocmd VimEnter * silent! autocmd! FileExplorer\n    autocmd BufEnter * let s:buf_path = expand(\"%\") | if isdirectory(s:buf_path) | bdelete! | call timer_start(100, {->OpenLfIn(s:buf_path, s:default_edit_cmd)}) | endif\n  augroup END\nendif\n\nif !exists('g:lf_map_keys') || g:lf_map_keys\n  map <leader>f :Lf<CR>\nendif\n"
  }
]