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

Tram completion not working #1918

Closed
Ergus opened this issue Feb 1, 2019 · 4 comments
Closed

Tram completion not working #1918

Ergus opened this issue Feb 1, 2019 · 4 comments

Comments

@Ergus
Copy link
Contributor

@Ergus Ergus commented Feb 1, 2019

Hi:
I already wrote this but as it was in a very old issue, I preffer to open a new one because maybe it is not related.

When I try:

C-x C-f /ssh: 

It doesn't list anything most of the times. (I tried with ido and it is working fine). Maybe it has to do with the fact that I have TAB bind to ivy-partial, but when I try C-j or TAB I only get a message:

ivy--directory-done: Args out of range: "", 0, 3

My ivy config actually is:

(use-package ivy :ensure t
  :diminish
  :demand
  :bind (("C-c i r" . ivy-resume)
		 :map ivy-minibuffer-map
			  ("TAB" . ivy-partial))
  :config
  (setq ivy-use-virtual-buffers t
		ivy-count-format "(%d/%d) "
		ivy-display-style 'fancy
		enable-recursive-minibuffers t)
  (ivy-mode t)

  (use-package ivy-rich :ensure t
	:config
	(ivy-rich-mode 1))

  (use-package swiper :ensure t
	:bind (("C-s" . swiper)
		   ("C-r" . swiper)
		   :map minibuffer-local-map ("C-r" . counsel-minibuffer-history)
		   :map read-expression-map ("C-r" . counsel-expression-history))))

(use-package counsel :ensure t
  :diminish
  :bind (:map counsel-mode-map
			  ("C-c c a" . counsel-ag)
			  ("C-c c a" . 'counsel-ag)
			  ("C-c c i" . 'counsel-imenu)
			  ("C-c c g" . 'counsel-grep)
			  ("C-c c t" . 'counsel-git)
			  ("C-c c r" . 'counsel-git-grep)
			  ("C-c c l" . 'counsel-locate))
  :init
  (counsel-mode t)
  (which-key-add-key-based-replacements "C-c c" "counsel")

  :config
  (use-package counsel-tramp :ensure t
	:after exec-path-from-shell
	:commands counsel-tramp
	:config
	(setq tramp-default-method "ssh"))
  )

In some cases the completion works and not in others (specially in the beginning when emacs is just opened it doesnt even contain ssh as a possible completion).

Also when there are alias in the ~/.ssh/config that should connect using: /ssh:myserver:/var then the access there is only to the home directory and still no completion. Putting a (message ...) inside counsel--find-file shows that the variable ivy-text is empty there in those cases. So there is a previous command filtering. In other cases i tried something like /ssh:myserver:/var (not expecting for completion) and ivy-text in those cases was "/var" and it was completting with my local and not the remote /var content. So it looks like a filter problem again.

Related to this I see that the package counsel-tramp pretty much does the completion work and the function counsel-tramp--candidates does all the completion work there, so it can be used to fix this issue. But the point with this is to avoid the artificial call to counsel-tramp command (and/or require an extra keybind for it) instead of the default counsel-find-file to connect to tramp. Which fits better in the emacs workflow.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Feb 1, 2019

Please try to reproduce by cloing this repo and running make plain. List the sequence of keys that you press.

Loading

@Ergus
Copy link
Contributor Author

@Ergus Ergus commented Feb 1, 2019

Done! Yes, same issue.
C-x C-f DEL DEL ssh (there is not completion working and probably it should)
C-x C-f DEL DEL ssh RET (File not found and directory write-protected)
C-x C-f DEL DEL ssh TAB (No matches)
After this error if I try the same commands (or repeat the tab in the last), it completes. So it looks like an initialization problem. Because after the error once everything works more or less as expected.

Loading

@abo-abo abo-abo closed this in da85d1e Feb 5, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Feb 5, 2019

Thanks, please test.

Also note that you can get TRAMP completion with /ssh: RET from the current dir. There's no need to descend into the root directory. One advantage of doing it like this is that you can do /sudo:: RET to get sudo precisely in the current directory, and keep the completion session.

Of course you can still go to the root directory if you prefer.

Loading

@Ergus
Copy link
Contributor Author

@Ergus Ergus commented Feb 6, 2019

Yes everything works fine now. Very thanks! for the fix and the hint.

Loading

astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
To make sure we have TRAMP compleiton candidates when expected,
require TRAMP as soon as the collection function is
`read-file-name-internal'.

Fixes abo-abo#1918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants