Giter Club home page Giter Club logo

Comments (18)

khuedoan avatar khuedoan commented on May 30, 2024 1

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>

from nnn.vim.

jarun avatar jarun commented on May 30, 2024 1

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.

from nnn.vim.

hujianxin avatar hujianxin commented on May 30, 2024

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

from nnn.vim.

jarun avatar jarun commented on May 30, 2024

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

from nnn.vim.

hujianxin avatar hujianxin commented on May 30, 2024

@jarun thanks for you replying, I got your meaning

from nnn.vim.

kyoz avatar kyoz commented on May 30, 2024

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

from nnn.vim.

jarun avatar jarun commented on May 30, 2024

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?

from nnn.vim.

mizlan avatar mizlan commented on May 30, 2024

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.

from nnn.vim.

mcchrish avatar mcchrish commented on May 30, 2024

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.

from nnn.vim.

mcchrish avatar mcchrish commented on May 30, 2024

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.

from nnn.vim.

mizlan avatar mizlan commented on May 30, 2024

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.

from nnn.vim.

mizlan avatar mizlan commented on May 30, 2024

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.

from nnn.vim.

mizlan avatar mizlan commented on May 30, 2024

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.

from nnn.vim.

mcchrish avatar mcchrish commented on May 30, 2024

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.

from nnn.vim.

mizlan avatar mizlan commented on May 30, 2024

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.

from nnn.vim.

mizlan avatar mizlan commented on May 30, 2024

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).

from nnn.vim.

jarun avatar jarun commented on May 30, 2024

Sure!

from nnn.vim.

jarun avatar jarun commented on May 30, 2024

Fixed at #96.

from nnn.vim.

Related Issues (20)

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.