Skip to content

Commit

Permalink
add ctags command
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWitch committed Oct 25, 2021
1 parent f97543d commit 27feec4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
42 changes: 40 additions & 2 deletions doc/DEVELOPMENT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ In general, things like ``for`` loops should have no spaces between the ``for``
# correct
for(int i = 0; i < 10; i++) { log_debug(i); }
``ctags`` Support
'''''''''''''''''

A ``.ctagsdb`` file can assist certain code editors (like ``vim``) with jump-to-definition support and other useful features. To generate a ``taisei/.ctagsdb`` file.

.. code:: sh
ninja ctags -C build/
You then have to let your editor know that a ``.ctagsdb`` file exists.

Using ``.vimrc`` as an example:

.. code:: sh
# this will walk the project directory until it finds a .ctagsdb file
set tags=.ctagsdb;
Compiling Issues
----------------

Expand Down Expand Up @@ -86,14 +104,20 @@ Platform-Specific Tips
macOS
"""""

Tools
'''''

On macOS, you need to begin with installing the Xcode Command Line Tools:

.. code:: sh
xcode-select --install
There are additional command line tools that you'll need. You can acquire those
by using `Homebrew <https://brew.sh/>`__.
For other tools, such as ``meson``, you can acquire those by using
`Homebrew <https://brew.sh/>`__.

Libraries
'''''''''

As of 2021-08-05, you should **not** install the following packages via
Homebrew, as the versions available do not compile against Taisei correctly.
Expand Down Expand Up @@ -123,3 +147,17 @@ following option:
.. code:: sh
meson configure build/ --wrap-mode=forcefallback
``ctags`` Error
'''''''''''''''

You may run into an error when generating ``.ctagsdb`` file, such as ``illegal option -- L`` or something similar. This is because the version of ``ctags`` that ships with Xcode isn't directly supported by ``ninja``.

You can install and alias the Homebrew version of ``ctags`` by doing the following:

.. code:: sh
brew install ctags
# either run this in console, or add to your shell profile
alias ctags='/usr/local/bin/ctags'
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ foreach bindist_target : bindist_targets
)
endforeach

run_target('ctags',
command : ['ctags', '-R', '--exclude=.git', '-f', '.ctagsdb', join_paths(meson.source_root(), 'src')]
)

summary = '''

This comment has been minimized.

Copy link
@Akaricchi

Akaricchi Oct 27, 2021

Member

I've never used this, but Meson is supposed to auto-generate a ctags target if the tool is installed. https://mesonbuild.com/Release-notes-for-0-53-0.html#source-tags-targets

It does something like this in the source directory:

git ls-tree -r --name-only HEAD | ctags -L-

Which outputs to the tags file (ctags default; seems there's no way to override that without overriding the built-in target). Either way, the tags file needs to be added to .gitignore.

Summary:
Expand Down

0 comments on commit 27feec4

Please sign in to comment.