{"action":"created","issue":{"url":"https://api.github.com/repos/justinmk/vim-dirvish/issues/119","repository_url":"https://api.github.com/repos/justinmk/vim-dirvish","labels_url":"https://api.github.com/repos/justinmk/vim-dirvish/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/justinmk/vim-dirvish/issues/119/comments","events_url":"https://api.github.com/repos/justinmk/vim-dirvish/issues/119/events","html_url":"https://github.com/justinmk/vim-dirvish/pull/119","id":320237835,"number":119,"title":"`x` and `q` don't work with `$ git ls-files | vim +'setf dirvish' -`","user":{"login":"lacygoill","id":8505073,"avatar_url":"https://avatars2.githubusercontent.com/u/8505073?v=4","gravatar_id":"","url":"https://api.github.com/users/lacygoill","html_url":"https://github.com/lacygoill","followers_url":"https://api.github.com/users/lacygoill/followers","following_url":"https://api.github.com/users/lacygoill/following{/other_user}","gists_url":"https://api.github.com/users/lacygoill/gists{/gist_id}","starred_url":"https://api.github.com/users/lacygoill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lacygoill/subscriptions","organizations_url":"https://api.github.com/users/lacygoill/orgs","repos_url":"https://api.github.com/users/lacygoill/repos","events_url":"https://api.github.com/users/lacygoill/events{/privacy}","received_events_url":"https://api.github.com/users/lacygoill/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-04T11:17:11Z","updated_at":"2018-05-05T05:11:58Z","closed_at":"2018-05-05T05:00:53Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/justinmk/vim-dirvish/pulls/119","html_url":"https://github.com/justinmk/vim-dirvish/pull/119","diff_url":"https://github.com/justinmk/vim-dirvish/pull/119.diff","patch_url":"https://github.com/justinmk/vim-dirvish/pull/119.patch"},"body":"Here's a neat example given in the README of the project:\r\n\r\n    git ls-files | vim +'setf dirvish' -\r\n\r\nIt works well, except for the `q` and `x` buffer-local mappings.\r\nThey don't work immediately because their `rhs` are `<plug>` mappings, which are are not defined in a `plugin/` directory, but in an `autoload/` one.\r\n\r\nConsider this minimal `vimrc` written in `/tmp/vimrc`:\r\n\r\n    set rtp^=~/.vim/plugged/vim-dirvish/\r\n    set rtp+=~/.vim/plugged/vim-dirvish/after\r\n    filetype plugin indent on\r\n\r\nFrom the directory of `vim-dirvish`, if I start Vim like this:\r\n\r\n    $ git ls-files | vim -Nu /tmp/vimrc +'setf dirvish' -\r\n\r\nVim opens a dirvish buffer listing the contents of the directory.\r\nBut if I press `x` on a filepath to add it to the arglist, nothing happens.\r\n\r\nThis PR tries to fix the issue by moving the `<plug>` mappings in the `plugin/` directory.\r\n\r\nI think you moved the `<plug>` mappings in `autoload/` on purpose, because doing so allows you to make the `set_args()` and `buf_close()` functions local to the script. Thus, you avoid polluting the function namespace with two additional public functions which are not intended to be invoked directly by the user.\r\n\r\nI value the reliability more than the reduced noise, but I understand your choice, because the mappings work correctly once you press another mapping whose `rhs` is defined in `plugin/` and which triggers the sourcing of the `autoload/` directory.\r\nStill, pressing a key which sometimes work, but sometimes don't, is a little distracting because when it doesn't and you forgot the issue, you may lose time in a useless debugging or wondering whether you did something wrong.\r\n\r\nFeel free to close the PR if you disagree.\r\n\r\n---\r\n\r\nEdit:\r\n\r\nBy the way, usually `dirvish` sets `'buftype'` to `nofile`, but not in the previous example.\r\nSo, when you press `Enter` on a file to edit it, you may get the error:\r\n\r\n    dirvish: E37: No write since last change\r\n\r\nMaybe it could be slightly improved by setting the option explicitly from the shell command-line:\r\n\r\n    $ git ls-files | vim +'setf dirvish' +'setl bt=nofile' -\r\n    #                                     ^^^^^^^^^^^^^^^^\r\n\r\n---\r\n\r\nEdit2:\r\n\r\nThere may be other settings which are not properly set in the previous example; namely `'swapfile'` and `'conceallevel'`.\r\n\r\nIt seems that usually, they are set by `s:buf_init()`, which is called by a chain of functions calls such as:\r\n\r\n    dirvish#open() → s:open_dir() → s:buf_init()\r\n\r\nMaybe `dirvish#open()` should be manually invoked from the shell (with a `+` argument) to handle the settings, but I don't know exactly how.\r\n\r\n---\r\n\r\nEdit3:\r\n\r\nThis shell command seems to fix all the issues:\r\n\r\n    $ git ls-files | vim +'call dirvish#open(\"\")' -\r\n\r\nSo, I close the PR."},"comment":{"url":"https://api.github.com/repos/justinmk/vim-dirvish/issues/comments/386780100","html_url":"https://github.com/justinmk/vim-dirvish/pull/119#issuecomment-386780100","issue_url":"https://api.github.com/repos/justinmk/vim-dirvish/issues/119","id":386780100,"user":{"login":"justinmk","id":1359421,"avatar_url":"https://avatars0.githubusercontent.com/u/1359421?v=4","gravatar_id":"","url":"https://api.github.com/users/justinmk","html_url":"https://github.com/justinmk","followers_url":"https://api.github.com/users/justinmk/followers","following_url":"https://api.github.com/users/justinmk/following{/other_user}","gists_url":"https://api.github.com/users/justinmk/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmk/subscriptions","organizations_url":"https://api.github.com/users/justinmk/orgs","repos_url":"https://api.github.com/users/justinmk/repos","events_url":"https://api.github.com/users/justinmk/events{/privacy}","received_events_url":"https://api.github.com/users/justinmk/received_events","type":"User","site_admin":false},"created_at":"2018-05-05T05:11:58Z","updated_at":"2018-05-05T05:11:58Z","author_association":"OWNER","body":"E37 goes away if you `:set nohidden`. I don't know exactly what causes it, but it's harmless.\r\n\r\n`q` won't work still, because Dirvish refuses to delete a buffer it doesn't own (`b:dirvish` is not defined). That's a safety feature.\r\n\r\n`x` works now."}}
{"actor":{"display_login":"justinmk"}}