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

Document how to run ctags with custom settings #268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions doc/ctags.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

CTAGS
=====
# CTAGS

Ctags generates indices of symbol definitions in source files. It
started its life as part of the BSD Unix, but there are several more
Expand All @@ -21,9 +20,21 @@ compiled in. Zoekt expects the `universal-ctags` binary to be on
`$PATH`. Note: only Ubuntu names the binary `universal-ctags`, while
most distributions name it `ctags`.

Use the following invocation to compile and install universal-ctags:
## Setup

### Option 1: Install through package manager

It is possible to install `ctags` on Ubuntu via `apt`:

```
sudo apt install universal-ctags
```

### Option 2: Compile from source

Use the following invocation to compile and install universal-ctags:

```sh
sudo apt-get install
pkg-config autoconf \
libseccomp-dev libseccomp \
Expand All @@ -39,3 +50,34 @@ mkdir ${NAME}
cp ctags ${NAME}/universal-ctags
tar zcf ${NAME}.tar.gz ${NAME}/
```

## Indexing with ctags

Zoekt runs `ctags` with a hard coded list of languages by default.
However, it's possible to pass only the languages available on your system
by wrapping `ctags` in a script.

1. Create a file `custom-ctags.sh`:

```sh
#!/usr/bin/bash

set -o pipefail
set -eux

CTAGS_LANGUAGES=$(/usr/bin/universal-ctags --list-languages | grep -v 'disabled' | tr '\n' ',' | sed 's/.$//')
/usr/bin/universal-ctags --languages=$CTAGS_LANGUAGES $@
```

2. Make it executable:

```sh
chmod +x custom-ctags.sh
```

3. Set the environment variable when indexing with Zoekt:

```sh
export CTAGS_COMMAND=$PWD/custom-ctags.sh
go run cmd/zoekt-index/main.go -index /tmp/zoekt-index /path/to/repository
```