follow-up #18013 - inline syntax highlighting (#18166)

This commit is contained in:
Andrey Makarov 2021-06-04 17:16:51 +03:00 • committed by GitHub
commit 7e21218a07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 183 additions and 164 deletions

View file

@ -1,5 +1,3 @@
.. default-role:: code
================================
Nim IDE Integration Guide
================================
@ -7,14 +5,16 @@
:Author: Unknown
:Version: |nimversion|
.. default-role:: code
.. include:: rstcommon.rst
.. contents::
Nim differs from many other compilers in that it is really fast,
and being so fast makes it suited to provide external queries for
text editors about the source code being written. Through the
`nimsuggest` tool, any IDE
can query a `.nim` source file and obtain useful information like
`nimsuggest`:cmd: tool, any IDE
can query a ``.nim`` source file and obtain useful information like
definition of symbols or suggestions for completion.
This document will guide you through the available options. If you
@ -27,29 +27,30 @@ already available.
Installation
============
Nimsuggest is part of Nim's core. Build it via::
Nimsuggest is part of Nim's core. Build it via:
.. code:: cmd
koch nimsuggest
Nimsuggest invocation
=====================
Run it via `nimsuggest --stdin --debug myproject.nim`. Nimsuggest is a
Run it via `nimsuggest --stdin --debug myproject.nim`:cmd:. Nimsuggest is a
server that takes queries that are related to `myproject`. There is some
support so that you can throw random `.nim` files which are not part
support so that you can throw random ``.nim`` files which are not part
of `myproject` at Nimsuggest too, but usually the query refer to modules/files
that are part of `myproject`.
`--stdin` means that Nimsuggest reads the query from `stdin`. This is great
`--stdin`:option: means that Nimsuggest reads the query from `stdin`. This is great
for testing things out and playing with it but for an editor communication
via sockets is more reasonable so that is the default. It listens to port 6000
by default.
Nimsuggest is basically a frontend for the nim compiler so `--path` flags and
Nimsuggest is basically a frontend for the nim compiler so `--path`:option: flags and
`config files <https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files>`_
can be used to specify additional dependencies like
`nimsuggest --stdin --debug --path:"dependencies" myproject.nim`.
`nimsuggest --stdin --debug --path:"dependencies" myproject.nim`:cmd:.
Specifying the location of the query
@ -60,25 +61,25 @@ cryptic 3 letter "command" `def` or `con` or `sug` or `use` followed by
a location. A query location consists of:
`file.nim`
``file.nim``
This is the name of the module or include file the query refers to.
`dirtyfile.nim`
``dirtyfile.nim``
This is optional.
The `file` parameter is enough for static analysis, but IDEs
tend to have *unsaved buffers* where the user may still be in
the middle of typing a line. In such situations the IDE can
save the current contents to a temporary file and then use the
`dirtyfile.nim` option to tell Nimsuggest that `foobar.nim` should
be taken from `temporary/foobar.nim`.
``dirtyfile.nim`` option to tell Nimsuggest that ``foobar.nim`` should
be taken from ``temporary/foobar.nim``.
`line`
``line``
An integer with the line you are going to query. For the compiler
lines start at **1**.
`col`
``col``
An integer with the column you are going to query. For the
compiler columns start at **0**.
@ -149,9 +150,9 @@ tab characters (``\t``). The values of each column are:
1. Three characters indicating the type of returned answer (e.g.
`def` for definition, `sug` for suggestion, etc).
2. Type of the symbol. This can be `skProc`, `skLet`, and just
about any of the enums defined in the module `compiler/ast.nim`.
about any of the enums defined in the module ``compiler/ast.nim``.
3. Fully qualified path of the symbol. If you are querying a symbol
defined in the `proj.nim` file, this would have the form
defined in the ``proj.nim`` file, this would have the form
`proj.symbolName`.
4. Type/signature. For variables and enums this will contain the
type of the symbol, for procs, methods and templates this will