Giter Club home page Giter Club logo

nnn.vim's Introduction

nnn.vim

File manager for vim/neovim powered by n³.

demo.mov

colorscheme yin

Requirements

  1. has('nvim') || has('terminal') i.e. terminal support
  2. Optional has('nvim-0.5') || has('popupwin') for floating window
  3. Optional n³ v4.3(+) needed for file-explorer mode

Install

Install n³. Instructions here.

Install the plugin using the built-in package manager:

Vim:

git clone --depth 1 https://github.com/mcchrish/nnn.vim\
 ~/.vim/pack/nnn/start/nnn.vim

Neovim:

git clone --depth 1 https://github.com/mcchrish/nnn.vim\
 "${XDG_DATA_HOME:-~/.local/share}"/nvim/site/pack/nnn/start/nnn.vim

Or install the plugin using other plugin manager:

" using vim-plug
Plug 'mcchrish/nnn.vim'

Usage

Picker

To open n³ as a file picker in vim/neovim, use the command :NnnPicker or the key-binding <leader>n. The command accepts an optional path to open e.g. :NnnPicker path/to/somewhere.

Run the plugin, select file(s) and press Enter to quit the n³ window. Now vim will open the first selected file and add the remaining files to the arg list/buffer list.

Pressing Enter on a file in n³ will pick any earlier selection (or the hovered file if no selection exists) and exit n³.

Explorer

To open n³ as a file-explorer use the command :NnnExplorer. The command accepts optional path similar to :NnnPicker. In explorer mode pressing Enter will pick a file but keep the n³ window open. Running :NnnExplorer while an explorer window is active on that tab will toggle/close it.

NOTE: In order to use explorer mode n³ version 4.3 (or above) must be installed.


NOTE: Pressing l or Right on a file would open it instead of picking. Use -o via nnn#command to disable this.

To discard selection and/or exit, press q.

cd on quit

Press c-g to quit n³ and cd into the last directory.

set hidden may be required for the floating windows to work.

For complete plugin documentation see :help nnn.

Configuration

Custom mappings

" Disable default mappings
let g:nnn#set_default_mappings = 0

" Set custom mappings
nnoremap <silent> <leader>nn :NnnPicker<CR>

" Start n³ in the current file's directory
nnoremap <leader>n :NnnPicker %:p:h<CR>

Layout

" Opens the n³ window in a split
let g:nnn#layout = 'new' " or vnew, tabnew etc.

" Or pass a dictionary with window size
let g:nnn#layout = { 'left': '~20%' } " or right, up, down

" Floating window. This is the default
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Comment' } }

g:nnn#explorer_layout is same as g:nnn#layout but for the explorer mode.

Action

It's possible to set extra key-bindings for opening files in various ways. No default is set so that n³'s key-bindings are not overridden.

let g:nnn#action = {
      \ '<c-t>': 'tab split',
      \ '<c-s>': 'split',
      \ '<c-v>': 'vsplit' }

With the above example, when inside an n³ window, pressing ^T will open the selected file in a tab instead of the current window. ^X will open in a split an so on. Multi-selected files will be loaded in the buffer list.

An example assigning a function to an action:

function! CdSelectedFile(lines)
    let dir = a:lines[-1]
    if filereadable(dir)
        let dir = fnamemodify(dir, ':h')
    endif
    execute 'cd' dir
endfunction

let g:nnn#action = { '<c-w>': function('CdSelectedFile') }

In this example, pressing c-w will select the file and cd into its directory.

Persistent session

n³ sessions can be used to remember the location when it is reopened.

" use the same n³ session within a vim session
let g:nnn#session = 'local'

" use the same n³ session everywhere (including outside vim)
let g:nnn#session = 'global'

NOTE: If desired, an n³ session can be disabled temporarily by passing session: 0 as an option to nnn#pick().

Command override

It's possible to override the default n³ command and add some extra program options.

" to start n³ in detail mode:
let g:nnn#command = 'nnn -d'

" OR, to pass env variables
let g:nnn#command = 'NNN_TRASH=1 nnn -d'

nnn#pick() and nnn#explorer()

The nnn#pick([<dir>][,<opts>]) and nnn#explorer([<dir>][,<opts>]) functions can be called with a custom directory and additional options such as opening file in splits or tabs. They are more configurable versions of the :NnnPicker and :NnnExplorer commands.

call nnn#pick('~/some-directory', { 'edit': 'vertical split' })
" Then add custom mappings

opts can be:

  • edit - type of window the select file will be open.
  • layout - same as g:nnn#layout and overrides it if specified.

Environment variables

n³ will detect env variables defined in vimrc.

let $NNN_TRASH=1

Explorer FAQ

  • How to auto start explorer when vim opens?
" Start NnnExplorer and leave the cursor in it.
autocmd VimEnter * call nnn#explorer()

" Start NnnExplorer and put the cursor back in the other window.
autocmd VimEnter * call nnn#explorer() | wincmd p | stopinsert

" If a file is specified, start NnnExplorer and move the cursor to the file window.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() > 0 || exists("s:std_in") | call nnn#explorer() | wincmd p | stopinsert | endif
  • How to auto close vim when explorer is the last window remaining?
" Exit Vim if NnnExplorer is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && &filetype ==# 'nnn' | quit! | endif

" Close the tab if NnnExplorer is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && &filetype ==# 'nnn' | quit! | endif

Setup for init.lua

Use the same option names as you would in Vim script, e.g.:

local function copy_to_clipboard(lines)
	local joined_lines = table.concat(lines, "\n")
	vim.fn.setreg("+", joined_lines)
end

require("nnn").setup({
	command = "nnn -o -C",
	set_default_mappings = 0,
	replace_netrw = 1,
	action = {
		["<c-t>"] = "tab split",
		["<c-s>"] = "split",
		["<c-v>"] = "vsplit",
		["<c-o>"] = copy_to_clipboard,
	},
})

Troubleshooting

These are some common problems that one might run into. Follow the instruction and add relevant code snippet into your vimrc or init.vim to fix them.

  • Files being renamed randomly: This can happen when using AutoComplPop plugin.
function! AutoCmpNNN()
    call acp#disable()
    autocmd BufLeave <buffer> call acp#enable()
    autocmd BufEnter <buffer> call acp#disable()
endfunction
autocmd FileType nnn call AutoCmpNNN()
  • Explorer buffer gets wiped when opening a file: This can happen when using miniBufExpl plugin. The workaround is to make sure miniBufExpl is open before calling :NnnExplorer.
let g:miniBufExplBuffersNeeded = 1
  • Can't execute wqa: This issue exists in both vim and neovim. When you try to quit using the command wqa you see the error: E948: Job still running. Crude workaround:
command Z w | qa
cabbrev wqa Z

Credits

Main n³ repository.

nnn.vim's People

Contributors

asgeo1 avatar chriszarate avatar deoxys314 avatar greenfoo avatar jarun avatar laggardkernel avatar lclrc avatar mcchrish avatar mizlan avatar mroavi avatar n-r-k avatar shwnchpl avatar sun617 avatar tombaxter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nnn.vim's Issues

Doesn't open in Vim

Describe the bug

Pressing Enter or L doesn't open the file in the current running Vim. It uses different applications depending on the file.

To Reproduce

  1. Open Vim
  2. Run command 'NnnPicker'
  3. Open file (using L or Enter)

Expected behavior

Open the file for editing in the currently running (Neo)Vim instance

Extra info

This is probably not a bug in the software but rather in my brain. Please help.

floating window layout error

Describe the bug

Pressing <leader>n with nnn.vim set in a floating window layout produces vim errors

Error detected while processing function nnn#pick:
line   19:
E948: Job still running (add ! to end the job)

and the following message in the floating window:

/bin/sh: -c option requires and argument

To Reproduce

Installed nnn 3.1, vim 8.2.534 Linux.
No NNN_* environment variables set.
In .vimrc (copied from README):

" Floating window (neovim latest and vim with patch 8.2.191)
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }
  1. Open vim
  2. Press <leader>n
  3. See error

Thank you.

Toggle Script

Is your feature request related to a problem? Please describe.

Couldnt figure out a good way to toggle nnn in vim.

Describe the solution you'd like

let g:nnn#set_default_mappings=0
if argc() == 0
  au VimEnter * call nnn#pick('%:p:h', { 'edit': 'edit' })
endif
nnoremap <silent> q :call nnn#pick('%:p:h', { 'edit': 'vsplit', 'layout': { 'left': '~13%' } })<CR>

edit: better code ^^^

Error on opening nnn second time

Steps:

While testing the plugin I noticed another issue:

  1. opened a file in vim: vim src/nnn.c
  2. Navigated up and used multi-select (^Y-^Y) to select 3 files
  3. Pressed q (nnn opened a blank file here, probably the current issue we are discussing)
  4. Pressed \n again

Seeing an error message highlighted in red. Please check.

Opening blank file second time

Steps:

  • \n, select file
  • close file (:q)
  • \n - instead on nnn selection view a blank file is opened

Environment:

vim v8.1
OS: Ubuntu 18.04 amd64
shell: bash and fish
nnn: master
nnn.vim: master

NnnPicker file select not working inside splits

Describe the bug

Selecting a file from :NnnPicker inside of a split throws an error and then closes the split.

To Reproduce

  1. Open vim
  2. Run command :sp
  3. Navigate to new split (<C-w>j)
  4. Run :NnnPicker (in new split)
  5. In NnnPicker, press enter on file I want to edit
  6. Pressing enter on the error message closes the split
Error detected while processing function <SNR>26_callback[7]..<SNR>26_eval_temp:
line   23:
E16: Invalid range: 2wincmd w
Press ENTER or type command to continue

Expected behavior

File should open in the split.

Screenshots

If applicable, add screenshots/gifs/videos to help explain your problem.

Environment:

  • OS: Arch Linux
  • Terminal: st 0.8.1
  • Shell: bash 4.4
  • Vim version: Nvim v0.3.2, Vim 8.1
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 2.2

Additional context

I am looking to use NnnPicker as a split explorer rather than a project drawer, if that makes a difference. The idea is explained here.

feat: keep nnn open

Is your feature request related to a problem? Please describe.
Coming from more graphical editors and IDEs, I'm used to having a file explorer open all the time.

Describe the solution you'd like

Using netrw in nvim I can get roughly equivalent behavior:
asciicast
Is it possible to do this with nnn instead?

Describe alternatives you've considered
Seems feasible to pass the file list back to vimscript on some bindable keypress and then process it as usual. I dont have the familiarity with nnn or vimscript to implement it myself atm.

Current version breaks on vim 8.1 on Debian

I updated from v1.6 (5a5c992) to the most recent release and nnn.vim breaks when it's called with the following error:

Error detected while processing function nnn#pick[12]..<SNR>27_build_window[3]..<SNR>27_create_term_buf: line 9: E121: Undefined variable: # E116: Invalid arguments for function term_start([&shell, &shellcmdflag, a:opts.cmd], #{ curwin: l:curwin, hidden: l:hidden, exit_cb: l:Exit_cb }) line 17: E121: Undefined variable: l:tbuf

Switching to the previous release solves the problem. BugFix please?

Persistent nnn session for a vim session

Describe the solution you'd like
I would love to have a persistent nnn session for my vim session -- meaning when I open nnn in vim and change directories or open a file, the next time I open nnn I want to be in the directory I changed to, but when I quit vim and start it again, the nnn session should be reset.

Describe alternatives you've considered
As nnn already implemented persistent sessions based on my other feature request (there's a new flag -S which automatically saves sessions and continues them on next nnn start) I could use an autocmd which deletes the session file after quitting vim, though this obviously also removes my nnn session used outside of vim.

Error with vim version 8.2.579

Settings I have:

nnoremap <leader>n :NnnPicker '%:p:h'<CR>

" Floating window (neovim latest and vim with patch 8.2.191)
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }

Steps:

vim somefile
<leader>n

Messages I see:

Error detected while processing function <SNR>18_BufEnterHandler[15]..<SNR>18_AutoUpdate[44]..<SNR>18_Updat
eExplorer[27]..<SNR>18_SwitchWindow:
line   24:
E994: Not allowed in a popup window
E994: Not allowed in a popup window
E994: Not allowed in a popup window
E994: Not allowed in a popup window
E366: Not allowed to enter a popup window

~/.nnncp file not generated on copy

Describe the bug

Hitting <Space> or <C-k> within the nnn buffer does not create the DIR/.nnncp file as described in the docs for nnn:

File paths are copied to the temporary file DIR/.nnncp, where DIR (by priority) is:

$HOME or,
$TMPDIR or,
/tmp

To Reproduce

Configuration:

call plug#begin('~/.local/share/nvim/plugged')
Plug 'mcchrish/nnn.vim'
call plug#end()

Steps to reproduce:

  1. Open vim
  2. Open nnn buffer (\n)
  3. Press key <C-k> or <Space>
  4. Directory is echoed at the bottom of the nnn UI to signify it was copied
  5. Without exiting the nnn buffer, in another terminal run cat ~/.nnncp, cat $TMPDIR/.nnncp, cat /tmp/.nnncp
  6. Observe that the file is not found

Expected behavior

~/.nnncp file should be populated with the selected directory/file.
This works as expected if I perform the action in nnn outside of vim

Environment:

  • OS: macOS 10.14
  • Terminal: iterm2 3.2.6
  • Shell: zsh 5.5.1
  • Neovim version: neovim 0.3.1
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 2.2

Additional context

Alternatively, is there any way to interface with the selected entry in the NNN buffer? Such as to copy its name into a vim register?

opening up nested horizontal split overlaps other buffers

How to repeat:

Open 4 buffers with in this format

| 1 | 2 |


| 3 | 4 |

Now place your focus on on buffer 2. Open Nnn and use "ctrl-x" to open a horizontal split. This split will make 2, 5 (the new buffer) and 4 overtake 1 and 2.

I used the key mappings in the readme to get ctrl-x to work.

If I just play around with the opening in splits, the behavior is strange. Sometimes if I focus on area 2, and go to open a horizontal split, it simply just opens the file in buffer 2. Now if I go to vertical split a file, it removes buffers 2 and 4 all together.

Please confirm behaviour

Noticing the following in vim status with master nnn.vim:

~/GitHub/nnn/CHANGELOG                                                                   1,1            Top
[src/nnn.c] /home/vaio/GitHub/nnn/nnn.1 /home/vaio/GitHub/nnn/Makefile /home/vaio/GitHub/nnn/LICENSE

Steps:

  • I opened src/nnn.c
  • Pressed <leader> n
  • Selected the listed after src/nnn.c above
  • Pressed Enter on CHANGELOG

CHANGELOG is opened and I see the above listing in status line with :args

Confirm if the above behaviour is correct.

Also, when I am closing I see only 2 files opened: CHANGELOG and LICENSE (neither src/nnn.c nor the other 2 files are there)

In my .vimrc I have the following mapping settings:

let g:nnn#set_default_mappings = 0 
nnoremap <leader>n :NnnPicker '%:p:h'<CR>

NNN.vim throws error after renaming or deleting a file

Describe the bug
After using nnn.vim to rename or delete a file in the same buffer nnn throws an error when I try to open another file:

Error detected while processing function <SNR>275_callback[7]..<SNR>275_eval_temp_file[4]..<SNR>275_switch_back:
line    7:
E211: File "~/pathtofile/FileOne.txt" no longer available
Press ENTER or type command to continue

Expected result would be to open the next file without throwing an error.

To Reproduce

Steps to reproduce the behavior and with the most minimal configuration.
With only nnn.vim installed and additional configurations/plugins that helps reproduce the bug:

  1. Open vim with the following init.vim
" Bootstrap Plug
let autoload_plug_path = stdpath('data') . '/site/autoload/plug.vim'
if !filereadable(autoload_plug_path)
  silent execute '!curl -fLo ' . autoload_plug_path . '  --create-dirs
      \ "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"'
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
unlet autoload_plug_path

packadd! matchit

" Plugins
call plug#begin('~/.nvim/plugged')
Plug 'mcchrish/nnn.vim'
let $NNN_USE_EDITOR=1
call plug#end()

  1. Create a test folder with FileOne.txt and FileTwo.txt
  2. Open folder with nvim ~/pathtofolder/FileOne.txt
  3. Run command :NnnPicker '%:p:h'
  4. Select FileOne.txt in NNN
  5. Delete FileOne.txt in NNN by pressing and y to confirm
  6. Open the now selected FileTwo.txt by pressing enter
  7. NNN throws the error
Error detected while processing function <SNR>275_callback[7]..<SNR>275_eval_temp_file[4]..<SNR>275_switch_back:
line    7:
E211: File "~/pathtofile/FileOne.txt" no longer available
Press ENTER or type command to continue

Expected behavior

I expect NNN to open FileTwo.txt in the current buffer in nvim without throwing an error

Environment:

  • OS: macOs 10.14.3
  • Terminal: iterm 3.2.7
  • Shell: zsh 5.7.1
  • Vim version: NVIM v0.4.0-dev
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 2.3

Not working! Screen flashes, nothing happens.

I'm using

  • terminal vim: version 8.1.72
  • plugin manager: vim plug
  • nnn: 2.1
  • macOs: 10.14.1

When I type :Np in vim, screen flashes a bit, then nothing happens. There's no message in :messages commands

Segmentation fault on run

I get this

Vim: Caught deadly signal SEGV
Vim: Finished.
zsh: segmentation fault  vim

when running :NnnPicker in vim.

Here's my system:

  • iTerm2 build 3.2.3
  • vim 8.1.350
  • macOS HighSierra 10.13.6
  • installed using vim plug
  • nnn.vim commit 2389259

error in switch_back function

Describe the bug

A clear and concise description of what the bug is.

When navigating to files in nnn-vim I receive an error in the switch_back method.

"src/libcrun/cgroup.c" line 52 of 2602 --1%-- col 1
Error detected while processing function <SNR>76_callback[6]..<SNR>76_eval_temp_file[4]..<SNR>76_switch_back[13]..<SNR>76_present:
line    2:
E896: Argument of get() must be a List, Dictionary or Blob

Seems like this method is receiving the wrong data type.

To Reproduce
I am using vimx from the default fedora repositories.

❯ vimx --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 18 2020 00:00:00)
Included patches: 1-789
Modified by <[email protected]>
Compiled by <[email protected]>

nnn-vim (master)
nnn v3.0

Steps to reproduce the behavior and with the most minimal configuration.
With only nnn.vim installed and additional configurations/plugins that helps reproduce the bug:

  1. Open vim
  2. Run command '....'
  3. Press key '....'
  4. See error

Expected behavior

Opening a file does not produce error.

Environment:

  • OS: Fedora 32
  • Terminal: tilix
  • Shell: zsh
  • Vim version: vimx 8 (fedora repos)
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 3.0

nnn window isn't closed after picking

A clear and concise description of what the bug is.
When I use floating layout:

let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }

Window floating view opens as expected, however after picking floating window stays up as empty buffer. Without window everything works as expected.

Steps to reproduce the behavior and with the most minimal configuration.
With only nnn.vim installed and additional configurations/plugins that helps reproduce the bug:

Use this layout:

let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }
  1. Open nnn as floating window
  2. Pick file
  3. Window stays open

Expected behavior

I pick a file and window closes.

Environment:

  • OS: FreeBSD nimble 12.1-RELEASE-p3 FreeBSD 12.1-RELEASE-p3 r359342 GENERIC amd64
  • Terminal: st
  • Shell: zsh 5.8 (amd64-portbld-freebsd12.1)
  • Vim version: 0.4.3
  • Plugin manager:Plug
  • Plugin version: master (today)
  • Nnn version: 3.0

Additional context

NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/libexec/ccache/cc -O2 -pipe -march=haswell -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -march=haswell -DLIBICONV_PLUG -fstack-protector-strong -fno-strict-aliasing -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wno-c11-extensions -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/wrkdirs/usr/ports/editors/neovim/work/.build/config -I/wrkdirs/usr/ports/editors/neovim/work/neovim-0.4.3/src -I/usr/local/include -I/usr/include -I/wrkdirs/usr/ports/editors/neovim/work/.build/src/nvim/auto -I/wrkdirs/usr/ports/editors/neovim/work/.build/include
Compiled by root@live-system-nimble-job-08

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info```

Allow custom nnn command

Useful when trying to pass env variables or adding some command flag.

let g:nnn#command = 'DISABLE_FILE_OPEN_ON_NAV=1 /usr/local/bin/nnn -l`

Pressing "L" at leaf file should open file in buffer

Is your feature request related to a problem? Please describe.
I am not sure this is a "problem" but more (I think) how nnn works outside of nnn.vim

A clear and concise description of what the problem is. Ex. I'm always
frustrated when [...]

When browsing through the filesystem using "H" and "L" when we reach a leaf file in the tree pressing "L" opens the system's default editor for the file type. I would assume most people are expecting the file to open in a (n)vim buffer.

Describe the solution you'd like
The file is opened in a vim buffer

layout configuration à la fzf

let g:fzf_layout = { 'down': '~40%' }

" ours would look like
let g:nnn#layout = { 'down': '~40%' }

edit: also add backwards compatibility

Search option request

Hello! Are you not planning option "search_on_open" (lusty file system explorer like). Navigation with arrows too loong... Thanks!

Use one instance for nnn or remember nnn paths

Is your feature request related to a problem? Please describe.

After select a file with Enter. nnn close and everything is reset when we reopen nnn again, everything is reset to default current path, see below gif:

ezgif com-video-to-gif

Describe the solution you'd like

It's more convenient if nnn.vim can use one instance for nnn. Or at least remember the current path of nnn.

Like i have 2 buffer which splited

| buffer 1 | buffer 2 |

When i was in buffer 1, open nnn and goes to folder test/buffer1/test1.js
And in buffer 2, open nnn and goes to folder test/buffer2/test2.js

When i reopen nnn in those buffers. It should open the current path of that buffer. If it can remember path of each context [1][2][3][4], it's the best.

That's just my idea. How do you guys thinks. I'v just a lots of files manager for vim. nnn is the fasted but it lack some convenient features.

Minimal vimrc

call plug#begin('~/.config/nvim/plugged') "---------------------- Start vim plug

Plug 'mcchrish/nnn.vim'

call plug#end() "---------------------------------------- End of Vim-Plug define```

Versions

OS: macOS Mojave 10.14.1
Terminal: Alacritty
Neovim: Latest
nnn: Latest
nnn.vim: Latest

NnnPicker command doesn't work

Hi.
When I run :NnnPicker something blink and nothing happening.
My vim config:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov 24 2018 19:11:56)
macOS version
Included patches: 1-500
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               +perl              +vartabs
+clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           -python            +viminfo
+conceal           +linebreak         +python3           +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       +lua               +ruby              +writebackup
+dialog_con        +menu              +scrollbind        -X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       -xim
-dnd               +mouse             +startuptime       -xpm
-ebcdic            -mouseshape        +statusline        -xsmp
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_clipboard
+eval              -mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.0/lib/perl5/5.28.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.5.3 -lobjc```

script errors on file open

Describe the bug
When opening a file, I receive the following error message in nvim

Error detected while processing function <SNR>48_callback[6]..<SNR>48_eval_temp_file[4]..<SNR>48_switch_back:                               
line   13:
E716: Key not present in Dictionary: window) == v:t_dict
Press ENTER or type command to continue
Error detected while processing function <SNR>48_callback[6]..<SNR>48_eval_temp_file[4]..<SNR>48_switch_back:
line   13:
E116: Invalid arguments for function type
Press ENTER or type command to continue
Error detected while processing function <SNR>48_callback[6]..<SNR>48_eval_temp_file[4]..<SNR>48_switch_back:
line   13:
E15: Invalid expression: type(l:layout) == v:t_dict && type(l:layout.window) == v:t_dict
Press ENTER or type command to continue

The file opens as expected and the nnn window closes once I've ENTERed my way through the errors. So it more or less works, it's just a bit inconvenient.

To Reproduce

minimal neovim config:

call plug#begin()
  " nnn filemanager integration
  Plug 'mcchrish/nnn.vim'
call plug#end()

" Or pass a dictionary with window size
let g:nnn#layout = { 'left': '~20%' }
  1. Open nvim
  2. open nnn as filepicker with <leader>n
  3. Locate a file and hit ENTER to open
  4. See error

Expected behavior

nnn is displayed in a vertical split to the left, 20% of screen width. The file opens, no errors displayed (specifically none occurring, not just suppressed :) ).

I'd personally rather have the filepicker window remain open afterward, but that's either a config i havent found or a separate feature request.

Screenshots

n/a

Environment:

  • OS: Ubuntu 18.04.4 LTS x86_64
    wm: i3
  • Terminal: gnome-terminal
  • Shell: bash 4.4.20
  • Vim version:
    NVIM v0.5.0-517-gf2894bffb
    Build type: RelWithDebInfo
    LuaJIT 2.1.0-beta3
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 2.7

Part of the left is trimmed after upgrading nnn to 2.7

Describe the bug

When set layout to 'right' or a floating window, part of the left content is trimmed, which doesn't happen with nnn 2.6 but only on 2.7.

To Reproduce

let g:nnn#set_default_mappings = 0

nnoremap <leader>n :NnnPicker '%:p:h'<CR>

let g:nnn#layout = { 'right': '~20%' } " or right, up, down

Set layout as "left". Open vim, trigger the nnn window with <leader>n.

Expected behavior

Content in the nnn window should be left-aligned, and only right of the content is trimmed when it's too long.

Screenshots

If applicable, add screenshots/gifs/videos to help explain your problem.

Environment:

  • OS: macOS 10.13.6
  • Terminal: kitty 0.14.6
  • Shell: zsh 5.7.1
  • Vim version: nvim 0.4.2
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 2.7

nnn.vim not loading

Describe the bug

Loading nnn.vim via vundle
nnn version 2.1
vim version 8.1.575
(Both latest from Fedora repos)

When running :Np I see a brief flash (so fast I cannot read it) but the picker does not appear. My vim does include terminal support (:term opens my terminal).

My terminal is urxvt and I can provide any additional details you need if you think that might be relevant.

To Reproduce

My minimal vim config for testing nnn.vim:

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'mcchrish/nnn.vim'
call vundle#end()
filetype plugin indent on

  1. Open vim
  2. Run command: :Np or :NnnPicker

Expected behavior

nnn picker should appear

Environment:

  • OS: Fedora 29
  • Terminal urxvt
  • Shell bash
  • Vim version vim 8.1.575
  • Plugin manager vundle
  • Nnn version 2.1

Closing out nnn popup window doesn't restore status bar

Describe the bug

If no file is selected when user presses Q to quit the pop up window, the status bar remains inactive.

To Reproduce

  1. Configure nnn.vim to use popup window as suggested by the doc
    let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }
  2. Launch Nvim to open whatever file and notice the status bar being active.
  3. Do :NnnPicker '%:p:h'
    The nnn popup window shows and notice the status bar becomes inactive (being grey)
  4. Hit Q directly without selecting any file
  5. The status bar remains inactive (being grey).

Expected behavior

The status bar should restore its active mode.

Screenshots

Please find attached screenshots.
maim-2020-07-28_175050
maim-2020-07-28_175054
maim-2020-07-28_175057
Environment:

  • OS: Arch Linux, Ubuntu 20.04
  • Terminal: xterm 358, alacritty 0.4.3
  • Shell: bash 5.0.17
  • Vim version: neovim 0.4.3
  • Plugin manager: minpac
  • Plugin version: master
  • Nnn version: 3.3

Additional context

None.

Command prompt crashed

Describe the bug

cfb524ea5e1ecaa7c0eb0ab2fbb6675e298eb31d in master branch changed ^S to ^P to show the command prompt. And after I type ^P and execute a command, nnn.vim crashed.

To Reproduce

most minimal configuration:

if has('nvim')
    set runtimepath^=~/.vim runtimepath+=~/.vim/after
    let &packpath = &runtimepath
endif
call plug#begin('~/.cache/vim/plugins')
Plug 'mcchrish/nnn.vim'
call plug#end()
  1. Compile and install nnn from master branch.
  2. Open vim (or nvim)
  3. Run command :NnnPicker
  4. Press key ^P, type ls
  5. See error

Expected behavior

After I execute ls, nnn.vim should continue to work.

Screenshots

peek 2019-02-08 11-17

Environment:

  • OS: Arch Linux
  • Terminal: GNOME Terminal 3.30.2 using VTE 0.54.3 +GNUTLS
  • Shell: zsh 5.7.1 (x86_64-pc-linux-gnu)
  • Vim version: neovim 0.3.4
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 2.2 (compile from master branch)

Additional context

none.

Environment variables within nnn#command doesn't work as expected

Describe the bug

Environment variables passed into nnn#command doesn't take effect.

let g:nnn#command = 'NNN_SHOW_HIDDEN=1 nnn -l' " light mode
nnoremap <leader>n :NnnPicker '%:p:h'<CR>

Hidden files are still not shown.

Environment:

  • OS: macOS 10.13
  • Shell: zsh 5.7.1
  • Vim version: neovim v0.3.4
  • Plugin manager: vim-plug
  • Nnn version: 2.4

Show git changes

Is your feature request related to a problem? Please describe.

When I change a file in vim, it would be nice if I could see which files were lastly modified since last commit.

Describe the solution you'd like

Basicly i'm looking for something like this for nnn.vim.

Describe alternatives you've considered

I'm not sure what else I can do besides asking nicely from the developers to implement this.

Thank you for considering this.

Popup Window does not scroll

Describe the bug

nnn-vim in popup-mode does not scroll the contents of the popup window

To Reproduce

" nnn configurations
let g:nnn#action = {
      \ '<C-h>': 'split',
      \ '<C-v>': 'vsplit' }
let $DISABLE_FILE_OPEN_ON_NAV=1
let $NNN_RESTRICT_NAV_OPEN=1
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }

Open a popup nnn with contents large enough to force the view to scroll, then try to scroll

Expected behavior

The popup window scrolls with the contents

Environment:

  • OS: Fedora 32
  • Terminal: Tilix
  • Shell: zsh 5.2.1
  • Vim version: vim8
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 3.0

Colors are hard to read with termguicolors set

Describe the bug
In order to use coc-highlight I am required to add set termguicolors in my vimrc/init.vim.

Unfortunately with this setting, nnn inside of vim uses colors that are very low contrast and difficuclt to read.

I realize that it is occurring because of this color setting I am adding, but it appears nnn inside of vim is the only thing being affected. Any advise would be appreciated.

To Reproduce

  1. Add set termguicolors
  2. Open Nnn picker in VIm

Expected behavior

Same colors as nnn outside of vim.

Screenshots

Screen Shot 2020-04-29 at 1 04 32 AM
Screen Shot 2020-04-29 at 1 04 46 AM

Environment:

  • OS: macOS 10.15.4
  • Terminal: iTerm2
  • Shell: zsh 5.8
  • Vim version: NVIM v0.4.3
  • Plugin manager: vim-plug
  • Plugin version: master
  • Nnn version: 3.0

How to pick new files and edit the picked file in current vim instance?

it seems when I press e on a file in nnn, it launches a new instance of vim. It's not editing the picked file in the current instance of vim.

So I cannot have multiple buffer editing in one VIM instance.
What I want is something like ranger,

  1. I open the file browser
  2. choose one file to edit
  3. the buffer for the file is added into current vim instance

Unknown function term_start

I just installed the latest nnn release and tried to get nnn.vim working but :NnnPicker failed with this message:
2018-11-30-10-19-06_scrot

Opening Buffer Once

Is your feature request related to a problem? Please describe.

Is it possible to open the nnn window once? So let's say, I have it open already, open a file and then start nnn again, I expect that it reuses the same window.

Support vim popup

As the title says. Neovim and soon Vim will support floating window. Would be nice that the plugin can support it.

cd on quit not working

Describe the bug

I cannot get the cd on quit functionality to work with the vim plugin.

I followed the steps described here: https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit

I made sure this works when starting nnn (via n) directly from the terminal.

In my init.vim I added the following configuration:

let g:nnn#command = 'n -o'

When I run :NnnPicker I get the following error:

zsh:1: command not found: n

[Process exited 127]

Apparently, the nnn vim-plugin doesn't like ZSH functions.

My next attempt was to move the contents of the n function into a separate bash file and placed it in my ~/.local/bin which is in my PATH env variable. This didn't work even when starting it from the terminal: whenever I quit (with or without ^G) the cd does not happen.

Any ideas on how to support cd on quit inside vim's nnn plugin?

Update 1: I kept googling and now I understand why the bash file approach doesn't work: you cannot change directory from a child process. One suggested solution to this problem is to source the script (. n) instead of executing it directly. Doing this now I can actually cd on quit from nnn using the n bash script. So then I went back to vim to modify the nnn command to:

let g:nnn#command = '. nn -o'

Now nnn starts successfully but the cd on quit functionality still does not work. I suspect that the reason why the cd on quit functionality does not work with the vim plugin has the same root as the problem described above: child processes not being able to make their parents to cd.

Update 2: I tried the following command to start nnn:

let g:nnn#command = 'NNN_TMPFILE=/home/mroavi/.config/nnn/.lastd nnn -o'

However, I noticed that the .lastd file is not being generated after exiting. Any idea why?

PD: I wasn't sure whether to mark this as an enhancement or a bug. Please feel free to modify it if you consider this an enhancement rather than a bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.