Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

scala support #2

Closed
fommil opened this issue Jan 13, 2016 · 16 comments
Closed

scala support #2

fommil opened this issue Jan 13, 2016 · 16 comments

Comments

@fommil
Copy link

fommil commented Jan 13, 2016

We recommend these ctags for Scala support in Emacs

https://github.com/fommil/dotfiles/blob/master/.ctags

happy to contribute them!

@masatake
Copy link
Member

Great!
(I expect you will submit a pull request.)

You may want to integrate the scale parser to universal ctags.
This repository, ctags-xparsers, is for more minor languages. scala is too popular to put here.
Please, look at https://github.com/universal-ctags/ctags/blob/master/docs/optlib.rst
This document is a bit old. When I wrote the document I had a plan to ship .ctags libraries(optlib) as part of ctags package. However, now the optlibs are translated to C language by misc/optlib2c script and are linked to ctags executable. Therefore I have to update the document. I don't have time this week. I will work on this topic next week.

@fommil
Copy link
Author

fommil commented Jan 13, 2016

ok, great feedback! I'm actually super busy at the moment with conference preparations and various FLOSS obligations (I need another few days in the week, help!) but if somebody could raise the PR I'd happily advise, especially if it means that Scala support will be faster 😄

@masatake
Copy link
Member

O.k. Could you add copyright notice to https://github.com/fommil/dotfiles/blob/master/.ctags like https://github.com/universal-ctags/ctags/blob/master/optlib/gdbinit.ctags ?

I will submit a PR based on your .ctags when you add the copyright notice.

@fommil
Copy link
Author

fommil commented Jan 13, 2016

Are you sure exuberant ctags ignores the comments?

@masatake
Copy link
Member

No, exuberant-ctags doesn't have such comment syntax.

@fommil
Copy link
Author

fommil commented Jan 13, 2016

ok, I'll need to create a new file then because that's my live .ctags file for exhuberant ctags.

@fommil
Copy link
Author

fommil commented Jan 13, 2016

#  Copyright (c) 2015 Samuel Halliday
#
#  Author: Samuel Halliday <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
--langdef=scala
--langmap=scala:.scala
--regex-scala=/\bclass\s+(\w+)/\1/c,classes/
--regex-scala=/\bobject\s+(\w+)/\1/c,objects/
--regex-scala=/\btrait\s+(\w+)/\1/t,traits/
--regex-scala=/\btype\s+(\w+)/\1/T,types/
--regex-scala=/\bdef\s+(\w+)/\1/m,methods/
--regex-scala=/\bval\s+(\w+)/\1/l,constants/
--regex-scala=/\bvar\s+(\w+)/\1/l,variables/
--regex-scala=/\bpackage\s+((\w|[.])+)/\1/p,packages/

@masatake
Copy link
Member

Thank you. I'll make a PR based on this.

@fommil
Copy link
Author

fommil commented Jan 13, 2016

err, typo above in email address (double .com). I'll fix but you might have grabbed an old one.

@fommil
Copy link
Author

fommil commented Jan 13, 2016

also, can you rewrap the license. It's a bit funky.

@masatake
Copy link
Member

Could you show an example scala input in which all kinds are used?

@masatake
Copy link
Member

--regex-scala=/\bobject\s+(\w+)/\1/c,objects/

I guess this should be o.objects.
constants may be C.
How about variable? The variable here is local thing? So you choose l?
I think v is better for it.

BTW, Regex meta parser of u-ctags has a stack, so you can attach scope information.

@fommil
Copy link
Author

fommil commented Jan 14, 2016

I never really cared about the classifications, Emacs doesn't do anything smart with it and in Scala TAGS are a very rough approximation at best.

if you need a test project, and I hope integration tests are going to be part of the new CI (something that old-school GNU development seriously lacks), then I'd recommend ensime-server as a project.

@fommil
Copy link
Author

fommil commented Jan 14, 2016

  • class => traditional OOP concept
  • object => singleton classes (constants)
  • trait => a bit like OOP interface
  • type => an alias for a complex class / trait
  • def => methods / functions
  • val => immutable variables
  • var => mutable variables
  • package => traditional OOP concept of a namespace

@fommil
Copy link
Author

fommil commented Jan 14, 2016

btw, in scala, everything is modular so everything can be nested within everything else so you can't really say that anything is "local".

@masatake
Copy link
Member

I never really cared about the classifications, Emacs doesn't do anything
"classifications" is the critical advantage of ctags. If you are interested in hacking ctags, please take time to design classifications. Currently Emacs doesn't utilize the advantage. However, of course, it is not the limitation of Emacs. It just means none works on this area.

I'm working on spelunker.el which utilizes S expression based filter engine added to readtags.

universal-ctags/ctags#791

spelunker.el uses the classifications heavily.

@fommil fommil closed this as completed Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants