daveyarwood / dotfiles

my version-controlled config files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use kotlin.ctags

wuseal opened this issue · comments

commented

Hello, After putting the content in kotlin.ctags into ~/.ctags file. I run this command:
ctags --list-languages
It doesn't contains Kotlin.

Ada
Ant
Asciidoc
Asm
Asp
Autoconf
AutoIt
Automake
Awk
Basic
BETA
BibTeX
C
C#
C++
Clojure
CMake
Cobol
CPreProcessor
CSS
Ctags
CUDA
D
DBusIntrospect
Diff
DosBatch
DTD
DTS
Eiffel
Elixir
Elm
EmacsLisp
Erlang
Falcon
Flex
Fortran
Fypp
Gdbinit
Glade
Go
HTML
Iniconf
Inko
ITcl
Java
JavaProperties
JavaScript
JSON
Kconfig
LdScript
Lisp
Lua
M4
Make
Man
Markdown
MatLab
Maven2
Moose
Myrddin
NSIS
ObjectiveC
OCaml
OldC [disabled]
OldC++ [disabled]
Pascal
Passwd
Perl
Perl6
PHP
PlistXML
Pod
PowerShell
Protobuf
PuppetManifest
Python
PythonLoggingConfig
QemuHX
QtMoc
R
RelaxNG
ReStructuredText
REXX
Robot
RpmSpec
RSpec
Ruby
Rust
Scheme
SCSS
Sh
SLang
SML
SQL
SVG
SystemdUnit
SystemTap
SystemVerilog
Tcl
TclOO
Tex
TeXBeamer
TTCN
TypeScript
Unknown [disabled]
Varlink
Vera
Verilog
VHDL
Vim
WindRes
XML
XSLT
YACC
YumRepo
Zephir

I am using Universal-ctags.

Hi, Bro, I need your help 😢

My file is located at ~/.ctags.d/kotlin.ctags. Give that a try and see if it fixes the issue.

commented

@daveyarwood Hi, Thanks for you reply.
After putting the content in ~/.ctags.d/kotlin.ctags as you said, It seems do work, but there is an error throw out when I run
ctags --list-languages

ctags: Non-alphanumeric char is used in kind name: 'data classes' in "--regex-kotlin" option

May something not compatible with current Universal-ctags?

commented

Hi, I follow the solution here:https://gist.github.com/kittinunf/25484de6294a0c4263c86dda3aa1580c#gistcomment-3171742

Because you can't have spaces in Kind names. Replacing line 6 with the line below fixes the problem.
--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy|open)[[:space:]]*)*(private[^ ]*|protected)?[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*data[[:space:]]+class[[:space:]]+([[:alnum:]_:]+)/\6/d,dataclasses/

It works for me.
Thank you for your help, best wishes to you 😄

commented

It seems do not work with TagbarToggle
image
No file tags could be found 😢

Are you generating the ctags? You can do it manually with ctags -R followed by the directory that your source code is in. For example, ctags -R . or ctags -R src

Having to do this manually every time your source code changes would be really annoying, so there are Vim plugins to automate it. I use https://github.com/ludovicchabant/vim-gutentags and it works well.

You will be interested in universal-ctags/ctags#2769.

Nice! Looks like I might be able to simplify my setup once that is released.

I've since deleted my Kotlin ctags config, as there now seems to be good built-in support for Kotlin (possibly related to the commit linked above).