hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
362 stars 68 forks source link

import symbol at point using CTAGS #145

Closed fommil closed 5 years ago

fommil commented 6 years ago

although this feature is provided by ensime, I often find myself doing some lightweight coding with just scala-mode and my point is on an object Foo and I can use ctags to jump to Foo to recall the package name so I can add it to the import section at point or at the top of my file. It seems like this is the sort of thing we could automate.

VlachJosef commented 6 years ago

I'm not using CTAGS, but for lightweight imports I'm using: https://github.com/VlachJosef/scala-quick-import

It works like this:

  1. With point on any symbol, it will run ag and search for all existing imports in the project which contains that symbol.
  2. It let user choose from available imports of that symbol (if only one occurrence is found it is imported immediately).

Drawback: When import for given symbol doesn't exist yet in the project, it won't import anything.

Under the hood it is using ensime's ensime-insert-import command

yyadavalli commented 6 years ago

@VlachJosef I think it will be nice if we can move ensime-insert-import and other related functions out of ensime into scala-quick-import and add the whole thing to scala-mode. ensime can reuse the functions from scala-mode as needed.

fommil commented 6 years ago

It sounds like this might be part of the whole "sub ensime" package where it has access to .ensime but not the server. But if it doesn't even need .ensime then yeah in scala-mode makes a lot of sense.

yyadavalli commented 6 years ago

If access to .ensime is needed may be we can update the functionality in ensime, to fallback to ctags when no server is available. With that we can simply use the same keybinding/function, with or without the server running.