Pārlūkot izejas kodu

vim plugin has a new project page

master
Arun Prakash Jana pirms 6 gadiem
vecāks
revīzija
0abe07f9bd
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: A75979F35C080412
2 mainītis faili ar 5 papildinājumiem un 71 dzēšanām
  1. +5
    -5
      README.md
  2. +0
    -66
      scripts/vim-plugin/nnn-picker.vim

+ 5
- 5
README.md Parādīt failu

@@ -23,7 +23,7 @@ Noice is Not Noice, a noicer fork...


`nnn` is probably the [fastest and most resource-sensitive](#performance) file manager you have ever used. It integrates seamlessly with your DE and favourite GUI utilities, has a unique [navigate-as-you-type](#navigate-as-you-type-mode) mode with auto-select, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, subshell spawning and much more. `nnn` is probably the [fastest and most resource-sensitive](#performance) file manager you have ever used. It integrates seamlessly with your DE and favourite GUI utilities, has a unique [navigate-as-you-type](#navigate-as-you-type-mode) mode with auto-select, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, subshell spawning and much more.


[Integrate utilities](https://github.com/jarun/nnn#sample-scripts) like sxiv or fzy easily, or use it as a [vim file picker](https://github.com/jarun/nnn#vim-plugin); `nnn` supports as many scripts as you need! [Integrate utilities](https://github.com/jarun/nnn#sample-scripts) like sxiv or fzy easily, or use it as a [vim file picker](https://github.com/jarun/nnn#neovim-plugin); `nnn` supports as many scripts as you need!


It runs on Linux, OS X, Raspberry Pi, Cygwin, Linux subsystem for Windows and Termux. It runs on Linux, OS X, Raspberry Pi, Cygwin, Linux subsystem for Windows and Termux.


@@ -63,7 +63,7 @@ It runs on Linux, OS X, Raspberry Pi, Cygwin, Linux subsystem for Windows and Te
- [quote paths](#quote-paths) - [quote paths](#quote-paths)
- [to clipboard](#to-clipboard) - [to clipboard](#to-clipboard)
- [cd on quit](#cd-on-quit) - [cd on quit](#cd-on-quit)
- [vim plugin](#vim-plugin) - [(neo)vim plugin](#neovim-plugin)
- [run custom scripts](#run-custom-scripts) - [run custom scripts](#run-custom-scripts)
- [sample scripts](#sample-scripts) - [sample scripts](#sample-scripts)
- [change dir color](#change-dir-color) - [change dir color](#change-dir-color)
@@ -81,7 +81,7 @@ It runs on Linux, OS X, Raspberry Pi, Cygwin, Linux subsystem for Windows and Te


- Modes - Modes
- Basic, detail (default), disk usage analyzer (du) - Basic, detail (default), disk usage analyzer (du)
- Vim file picker (as a vim plugin) - Vim (or neovim) file picker (as a plugin)
- Navigation - Navigation
- Familiar, easy shortcuts (arrows, `~`, `-`, `&`) - Familiar, easy shortcuts (arrows, `~`, `-`, `&`)
- *Navigate-as-you-type* with auto-select directory - *Navigate-as-you-type* with auto-select directory
@@ -441,9 +441,9 @@ Pick the appropriate file for your shell from [`scripts/quitcd`](scripts/quitcd)


As you might notice, `nnn` uses the environment variable `NNN_TMPFILE` to write the last visited directory path. You can change it. As you might notice, `nnn` uses the environment variable `NNN_TMPFILE` to write the last visited directory path. You can change it.


#### vim plugin #### (neo)vim plugin


`nnn` can be used as a file picker/chooser within vim. The instructions are available in the [nnn-picker.vim](https://github.com/jarun/nnn/blob/master/scripts/vim-plugin/nnn-picker.vim) plugin. `nnn` can be used as a file picker/chooser within vim or neovim. Find the plugin [here](https://github.com/mcchrish/nnn.vim).


#### run custom scripts #### run custom scripts




+ 0
- 66
scripts/vim-plugin/nnn-picker.vim Parādīt failu

@@ -1,66 +0,0 @@
" vim/neovim plugin to use nnn as a file picker
" Closely follows and inspired by the vim_file_chooser plugin for ranger.
"
" Author: Arun Prakash Jana
" Email: engineerarun@gmail.com
" Homepage: https://github.com/jarun/nnn
" Copyright © 2018 Arun Prakash Jana
"
" Usage:
" Copy this file to the vim/neovim plugin directory.
" To open nnn as a file picker in vim/neovim, use the command ":NnnPicker" or
" ":Np" or the key-binding "<leader>n". Once you select one or more files and
" quit nnn, vim/neovim will open the first selected file and add the remaining
" files to the arg list/buffer list. If no file is explicitly selected, the
" last selected entry is picked.

let s:temp = ""

fun! s:T_OnExit(job_id, code, event) dict
if a:code == 0
bd!
call s:evaluate_temp()
endif
endfun

fun! s:evaluate_temp()
if !filereadable(s:temp)
echoerr 'Temp file ' . s:temp . 'not readable!'
redraw!
" Nothing to read.
return
endif
let names = readfile(s:temp)
if empty(names)
redraw!
" Nothing to open.
return
endif
" Edit the first item.
exec 'edit ' . fnameescape(names[0])
" Add any remaining items to the arg list/buffer list.
for name in names[1:]
exec 'argadd ' . fnameescape(name)
endfor
redraw!
endfun

function! NnnPicker()
let s:temp = tempname()
let l:cmd = 'nnn -p ' . shellescape(s:temp)
if has("nvim")
enew
call termopen(l:cmd, {'on_exit': function('s:T_OnExit')}) | startinsert
elseif has("gui_running")
exec 'silent !xterm -e ' . l:cmd
call s:evaluate_temp()
else
exec 'silent !' . l:cmd
call s:evaluate_temp()
endif
endfunction

command! -bar NnnPicker call NnnPicker()
nnoremap <leader>n :<C-U>NnnPicker<CR>
command! -nargs=* -complete=file Np :call NnnPicker()

||||||
x
 
000:0
Notiek ielāde…
Atcelt
Saglabāt