Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use one instance for nnn or remember nnn paths #43

Closed
kyoz opened this issue Mar 3, 2019 · 18 comments
Closed

Use one instance for nnn or remember nnn paths #43

kyoz opened this issue Mar 3, 2019 · 18 comments
Labels
enhancement New feature or request

Comments

@kyoz
Copy link

kyoz commented Mar 3, 2019

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

@kyoz kyoz added the enhancement New feature or request label Mar 3, 2019
@hujianxin
Copy link

it will be wonderful if there is a nnn buffer and it keeps everything I have entered

@jarun
Copy link
Collaborator

jarun commented Dec 30, 2019

If it's possible, it has to be done in the plugin. nnn itself doesn't track any user details.

@hujianxin
Copy link

@jarun thanks for you replying, I got your meaning

@khuedoan
Copy link

khuedoan commented Jan 7, 2021

I'm using this key binding which opens nnn in the current buffer's directory, not a replacement for remembering path but may fit your use case:

nnoremap <C-n> :NnnPicker %<CR>

@kyoz
Copy link
Author

kyoz commented Jan 13, 2021

@khuedoan ya. Sometime when i need to use nnn, i have call command with some args my self too 😄

@jarun
Copy link
Collaborator

jarun commented May 19, 2021

nnn now supports sessions. See options -s/-S. Option -s is probably better suited to have a specific session for the plugin.

@mcchrish @mizlan it this doable now, perhaps with an nnn.vim flag/setting that says enable session management?

@mizlan
Copy link
Contributor

mizlan commented May 19, 2021

Sure! I'll work on this. Also, this seems like an approach we can use to simulate a classic directory viewer. That would entail reopening an nnn process with the session every time a file is chosen. We can probably do better with some change in nnn later but that's a workaround for now I guess.

@mcchrish
Copy link
Owner

https://github.com/mcchrish/nnn.vim/blob/master/doc/nnn.txt#L149-L159 with this option, it should be possible to make use of sessions right away. They can pass any file they want for example:

" create a session that is tied to the current vim session
let g:nnn#command = 'nnn -s ' . tempname()

Another possibility is to tweak nnn#pick() to accept a command option, example:

call nnn#pick('~/some-files', { 'command': 'nnn -s '. tempname() })

Which is probably the most flexible direction.

@mcchrish
Copy link
Owner

Also, this seems like an approach we can use to simulate a classic directory viewer. That would entail reopening an nnn process with the session every time a file is chosen.

Seems like a possible direction if stdout option doesn't work out #43.

@mizlan
Copy link
Contributor

mizlan commented May 20, 2021

There are some annoying things with the way sessions currently work in upstream nnn. Namely, you cannot load a non-existent session name and have it created with nnn -s <new_session_name>. I am currently fixing this (was this behavior intentional?) and will push to nnn soon.

Please let me know if you do not happen to experience this issue. To be specific, you will see an open failed message in the nnn echo area for 1 second after opening nnn with a nonexistent session.

@mizlan
Copy link
Contributor

mizlan commented May 20, 2021

Actually, I am understanding sessions incorrectly. I think it would be less suitable to call them "sessions" since they are more like "snapshots" that can be arbitrarily loaded and saved. What we would need is an option for named sessions to be saved on quit. All that needs to be done is to take the existing code for auto-saving the @ default session and modify it for named sessions. However, we'd also have to either:

  1. introduce a new program option to specify whether sessions should be "replaced" on quit.
  2. make a breaking change that changes the meaning of sessions from "snapshots" to more like real "sessions".
  3. (this is the one I think makes the most sense) modify the behavior of -S so that if both -s <name> and -S are provided, then it will persist (auto-save on quit) to the named session. If only -s <name> is provided, then load session initially but do not save on quit. If only -S is provided then use the default @ session. Edit: However, the drawback of this approach is that you cannot load a session and then persist to @ session later on...

I am currently working on making the third choice here work.

@mizlan
Copy link
Contributor

mizlan commented May 20, 2021

https://github.com/mcchrish/nnn.vim/blob/master/doc/nnn.txt#L149-L159 with this option, it should be possible to make use of sessions right away. They can pass any file they want for example:

" create a session that is tied to the current vim session
let g:nnn#command = 'nnn -s ' . tempname()

Did you happen to test this? Because to my knowledge this isn't actually possible yet, read my prior comments for details.

@mcchrish
Copy link
Owner

I have not. I assumed the behavior of nnn that it will automatically save the session on quit (or sync the session to the file every navigation). My bad.

@mizlan
Copy link
Contributor

mizlan commented May 20, 2021

However, the drawback of this approach is that you cannot load a session and then persist to @ session later on...

This isn't really an issue to be concerned with as this isn't the default behavior anyway. Take a look at jarun/nnn#1023 (comment) for more details.

@jarun
Copy link
Collaborator

jarun commented May 20, 2021

See jarun/nnn#1023.

However, the drawback of this approach is that you cannot load a session and then persist to @ session later on

Persistent session option is global. So any session which is active at quit will be persisted. I don;t want more complexity in that. The "auto session" (@) will be used to restore the last working state when a session is loaded at runtime temporarily. Also "auto session" will be used (as it is now) to persist the session if no other session is active at program quit.

@mizlan
Copy link
Contributor

mizlan commented May 20, 2021

May I assign myself this task? I think the interface should be kept simple. Maybe have a g:nnn#session variable which can have values 'none' (default), 'global' (the @ session which allows syncing in and out of vim), or 'vim' (a session named "vim" that only syncs within vim).

@jarun
Copy link
Collaborator

jarun commented May 20, 2021

Sure!

@jarun jarun mentioned this issue May 21, 2021
50 tasks
@jarun
Copy link
Collaborator

jarun commented May 21, 2021

Fixed at #96.

@jarun jarun closed this as completed May 21, 2021
@jarun jarun mentioned this issue Jun 2, 2021
10 tasks
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jul 26, 2021
nnn v4.2 Mojito
2021-07-21

- `NNN_PLUG` indicator symbol interpretation has **changed**:
  - `!` - _run-cmd-as-plugin_ (earlier `_`)
  - `&` - _run-gui-cmd-as-plugin_ (earlier `|`)
  - `|` (new) - page noninteractive _run-cmd-as-plugin_ output
- persistent selection markers (#1086)
- option _extract to..._ for archives
- mount remote and mount/extract archive to a smart context
- confirm file trashing to avoid accidental press of <kbd>x</kbd> (#1101)
- insert the last command executed at prompt on <kbd>Up</kbd> or <kbd>Down</kbd>
- insert the current file name at empty prompt on <kbd>TAB</kbd>
- handle redraw issue on missed `KEY_RESIZE` (#1067)
- add force-tty capability to spawn and set pagers to it (#1064)
- clear selection mode on deselecting last selected file (#1098)
- remove selected hovered entry from selection on deletion
- disable filtering in empty directories
- ignore last pressed filter character when no matches
- fix broken screen on resize while paging (#1072)
- fix archive not hovered on creation
- remove libgit2 dependency in `gitstatus` patch (#1095)
- add `-G` flag for `gitstatus` patch
- option `-X` for explorer (persistent picker) mode
- option `-F` decommissioned in favour of config `NNN_HELP`
- `-F` redefined to multiplex `NNN_FIFO` to preview or explore
- support paging noninterative _run-cmd-as-plugin_ output
- `nuke` - add option to execute binaries (#1111)
- plugin `fzopen` - call `open` on macOS, add option to use `nuke`
- plugin `fzcd` will not modify selection
- plugin `suedit` - preserve environment
- several `preview-tui` fixes
- plugin `wall` renamed to `wallpaper`
- remove plugin `fzz` - merged into plugin `autojump`
- remove plugin `upgrade` - packaging is on OBS now
- remove plugin `treeview` - needs minor `preview-tui` tweak
- remove plugin `picker` - `nnn -p -` does the same
- remove plugin `pdfview` - needs simple change in `pdfread`
- remove plugin `uidgid` - use program option `-U`
- remove plugins `mediainf`, `hexview` - simple one-liners

-------------------------------------------------------------------------------

nnn v4.1.1 Sake
2021-06-03

- fix segfault on session save (#1041)
- remove redundant `_Atomic` usage
- move [`patches`](../tree/master/patches) directory to top-level
- fix and cleanup gitstatus patch
- plugin `imgview` improvements (#1049)
- restore source-code packing on CircleCI
- add Makefile target to compile with musl

-------------------------------------------------------------------------------

nnn v4.1
2021-06-02

- a patch management model for approved patches
- multi-threaded disk usage calculation using pthreads and FTS
- dynamic view update when calculating disk usage
- <kbd>Bksp</kbd>/<kbd>Del</kbd> at empty filter prompt to refresh dir
- Try to create new context with <kbd>Shift-TAB</kbd>, else reverse cycle
- <kbd>Alt+Esc</kbd> to quit context from filter prompt
- fix zombies left behind after running plugins (#999)
- named persistent sessions (mcchrish/nnn.vim#43)
- consider nanosecond resolution when sorting by time (#978)
- check external selection in `'c'urrent / 's'el` prompt (#976)
- show number of files selected in local selection buffer, if any
- `nnn` & picker plugin (e.g. `fzopen`) sync (mcchrish/nnn.vim#82)
- make batch rename interactive (#971)
- cached uid/gid for performance improvement
- fixes for `nnn` with `netbsd-curses`, `musl-fts`, `musl` (#998)
- script to statically compile `nnn` with `musl gcc` on Ubuntu
- restore hovered file when plugin is chosen from plugin dir
- support QuickLook on WSL in `preview-tui` (#959)
- toggle `preview-tui` with the same _custom_ plugin key
- smoother preview toggling in `preview-tui` (#966)
- `listen_on` should be set in kitty.conf for `preview-tui` (#970)
- minimal `bat` style in `preview-tui`, honors `$BAT_STYLE`
- plugin `preview-tui-ext` supersedes `preview-tui` (#1033)
- plugin `fzcd` can now fuzzy search multiple directories
- plugin `imgview` supersedes `imgthumb` and `vidthumb`
- plugin `umounttree`: unmount remote mntpoint from within
- plugin `xdgdefault`: set the default app for hovered file type
- plugin `fzplug`: fuzzy find, preview and run other plugins
- plugin `cmusq`: queue/play music in `cmus`
- plugin `mocplay` renamed to `mocq`
- plugin `cleanfilename` renamed to `fixname`
- go to last dir on <kbd>~</kbd> (HOME) or <kbd>`</kbd> (ROOT) key repeat
- ambiguous key <kbd>^Space</kbd> to select/clear range dropped (#998)
- user wiki page for [Themes](https://github.com/jarun/nnn/wiki/Themes)
- show selection mark (`+`) in reverse bold for improved visibility
- reverse block replaces `>` to mark hovered entry in detail mode
- make option `O_CKBOARD` removed
- make option `O_NOLOC` renamed to `O_NOLC`
- ignore `O_NOLC` if `O_ICONS` or `O_NERD` is specified (#1026)
- unicode arrow indicators if `O_ICONS` or `O_NERD` is specified
- make option `NOX11`: disable notis, sel-clipboard sync, xterm title
- retain filter in _nav-to-type_ mode after file open
- fix no files picked with `NNN_TMPFILE` exported and <kbd>q</kbd> to quit
- disable xterm title setting in picker mode (#974)

-------------------------------------------------------------------------------

nnn v4.0 Sushi
2021-04-13

- show xterm title on option `-x`

-------------------------------------------------------------------------------

nnn v3.7
2021-04-13

- allow plugins to clear selection (#884, #889, #917)
- do not clear selection on hovered file deletion
- resurrect `'c'urrent/'s'el` prompt and option `-u` (#889)
- show only file name in reverse in detail mode
- more file/mime types supported in `preview-tui-ext`
- plugin `mtpmount` - (un)mount MTP devices
- plugin `cleanfilename` - more shell-friendly file names
- plugin `rsynccp` - copy-paste with visual progress
- replace `$HOME` by `~` in address bar
- show current path in terminal title (#911)
- total links and inode number of hardlink in statusbar
- fix symlink to text file not opening in CLI editor (#890)
- fix symlink size shown as 0B in statusbar (#888)
- show symlink target in statusbar (#893)
- show correct disk free/total on macOS (#888)
- fix directory disk usage showing as 0 on macOS (#941)
- fix name col len with `-C` and icons compiled-in (#936)
- refactor printing entries in light/detail modes (#934)
- make option `O_CKBOARD` for checker board as indicator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants